Compare commits

...

2 Commits

Author SHA1 Message Date
Jérôme BEDIER 4b260b4866 test to pull again 2025-05-21 19:40:58 +02:00
Jérôme BEDIER ad01fdd17b pormotion added 2025-05-21 19:39:47 +02:00
1 changed files with 11 additions and 1 deletions

View File

@ -403,7 +403,7 @@ public class Board {
public Board(Board board) {
//TODO
}
}// test
public void playMove(Move move) {
// Save current state before move for undo
@ -415,6 +415,12 @@ public class Board {
board[move.getFromX()][move.getFromY()] = null;
piece.x = move.getToX();
piece.y = move.getToY();
if (piece.getType() == PieceType.Pawn &&
(piece.getY() == 0 || piece.getY() == height - 1)) {
board[piece.getX()][piece.getY()] = promotePawn(piece.isWhite(), piece.getX(), piece.getY());
}
turn++;
}
@ -469,6 +475,10 @@ public class Board {
return false; // King is not in check
}
public static Piece promotePawn(boolean isWhite, int x, int y) {
return new Piece(isWhite, PieceType.Queen, x, y);
}
private void highlightKingInCheck() {
// Check if white king is in check
Piece whiteKing = findKing(true);