removed useless line in castling

This commit is contained in:
Louise BERTELOOT 2025-05-19 19:45:51 +02:00
parent 1e13672235
commit d3dbd9fdb7
1 changed files with 1 additions and 3 deletions

View File

@ -193,7 +193,7 @@ public class Board {
//store for castling
int originalX = selectedPiece.getX();
// detects castling
// detects castling (piece is castling only if piecetype is king and distance between king and its move is of 2)
boolean isCastling = selectedPiece.getType() == PieceType.King && Math.abs(x - originalX) == 2;
@ -213,14 +213,12 @@ public class Board {
Piece rook = getPieceAt(7, row);//selects the correct rook to be castled depending on weither the king went right or left (here selects right rook)
if (rook != null) {//if the rook is there
rook.setX(5);//moves the rook to the square to the left of the king
rook.setY(row);//same row
rook.setMoved(true);//the rook has been moved once so wont be used for castling anymore
}
} else {//king moves to the left this time (queen side castling)
Piece rook = getPieceAt(0, row);//selects the rook on the left
if (rook != null) {
rook.setX(3);//moves rook to the right of the king
rook.setY(row);
rook.setMoved(true);
}
}