pormotion added
This commit is contained in:
parent
ebdfedd0a6
commit
ad01fdd17b
|
|
@ -415,6 +415,12 @@ public class Board {
|
||||||
board[move.getFromX()][move.getFromY()] = null;
|
board[move.getFromX()][move.getFromY()] = null;
|
||||||
piece.x = move.getToX();
|
piece.x = move.getToX();
|
||||||
piece.y = move.getToY();
|
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++;
|
turn++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -469,6 +475,10 @@ public class Board {
|
||||||
return false; // King is not in check
|
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() {
|
private void highlightKingInCheck() {
|
||||||
// Check if white king is in check
|
// Check if white king is in check
|
||||||
Piece whiteKing = findKing(true);
|
Piece whiteKing = findKing(true);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue