From 87aaad73e072f30cfebfebbde61e374888a0896e Mon Sep 17 00:00:00 2001 From: hugomanipoud2 Date: Wed, 21 May 2025 19:35:21 +0200 Subject: [PATCH] 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 --- OOP_3B5_Project/src/backend/Board.java | 2 +- OOP_3B5_Project/src/backend/Move.java | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/OOP_3B5_Project/src/backend/Board.java b/OOP_3B5_Project/src/backend/Board.java index 5bb2bac..2672c9d 100644 --- a/OOP_3B5_Project/src/backend/Board.java +++ b/OOP_3B5_Project/src/backend/Board.java @@ -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); diff --git a/OOP_3B5_Project/src/backend/Move.java b/OOP_3B5_Project/src/backend/Move.java index beafb31..4c9167f 100644 --- a/OOP_3B5_Project/src/backend/Move.java +++ b/OOP_3B5_Project/src/backend/Move.java @@ -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) {