knight finished

This commit is contained in:
hugomanipoud2 2025-05-21 19:25:22 +02:00
parent 6787c0eae2
commit a8c96922a5
1 changed files with 28 additions and 6 deletions

View File

@ -237,37 +237,59 @@ public class Move {
} }
if (selectX == x - 1 && selectY == y - 2) { if (selectX == x - 1 && selectY == y - 2) {
if(board.getPiece(x, y) != null) {
return color != board.getPiece(x, y).isWhite();
}
return true; return true;
} }
if (selectX == x - 1 && selectY == y + 2) { if (selectX == x - 1 && selectY == y + 2) {
return true; if(board.getPiece(x, y) != null) {
return color != board.getPiece(x, y).isWhite();
}
return true;
} }
if (selectX == x + 1 && selectY == y - 2) { if (selectX == x + 1 && selectY == y - 2) {
return true; if(board.getPiece(x, y) != null) {
return color != board.getPiece(x, y).isWhite();
}
return true;
} }
if (selectX == x + 2 && selectY == y + 1) { if (selectX == x + 2 && selectY == y + 1) {
return true; if(board.getPiece(x, y) != null) {
return color != board.getPiece(x, y).isWhite();
}
return true;
} }
if (selectX == x - 2 && selectY == y - 1) { if (selectX == x - 2 && selectY == y - 1) {
return true; if(board.getPiece(x, y) != null) {
return color != board.getPiece(x, y).isWhite();
}
return true;
} }
if (selectX == x - 2 && selectY == y + 1) { if (selectX == x - 2 && selectY == y + 1) {
return true; if(board.getPiece(x, y) != null) {
return color != board.getPiece(x, y).isWhite();
}
return true;
} }
if (selectX == x + 2 && selectY == y - 1) { if (selectX == x + 2 && selectY == y - 1) {
return true; if(board.getPiece(x, y) != null) {
return color != board.getPiece(x, y).isWhite();
}
return true;
} }
return false; return false;