just added isQueenMoveValid as a separate method just in case i need it

for the future, king and knight can be simplified via a helper function,
working on that
This commit is contained in:
hugomanipoud2 2025-05-21 19:35:21 +02:00
parent 1dd328c408
commit 87aaad73e0
2 changed files with 5 additions and 1 deletions

View File

@ -252,7 +252,7 @@ public class Board {
isAPieceHere = move.isRookMoveValid(x, y, color, selectX, selectY);
} else if (type == PieceType.Queen) {
isAPieceHere = (move.isBishopMoveValid(x, y, color, selectX, selectY) || move.isRookMoveValid(x, y, color, selectX, selectY)); // a queen is a Bishop and a rook, the move of both with an "Or" does the job !
isAPieceHere = move.isQueenMoveValid(x, y, color, selectX, selectY);
} else if (type == PieceType.Knight) {
isAPieceHere = move.isKnightMoveValid(x, y, color, selectX, selectY);

View File

@ -225,6 +225,10 @@ public class Move {
return false;
}
public boolean isQueenMoveValid(int x, int y, boolean color, int selectX, int selectY) {
return isBishopMoveValid(x, y, color, selectX, selectY) || isRookMoveValid(x, y, color, selectX, selectY); // a queen is a Bishop and a rook, the move of both with an "Or" does the job !;
}
public boolean isKnightMoveValid(int x, int y, boolean color, int selectX, int selectY) {