diff --git a/OOP_3B5_Project/src/backend/Move.java b/OOP_3B5_Project/src/backend/Move.java index 2d0d6f0..50c8895 100644 --- a/OOP_3B5_Project/src/backend/Move.java +++ b/OOP_3B5_Project/src/backend/Move.java @@ -228,15 +228,11 @@ public class Move { public boolean isKnightMoveValid(int x, int y, boolean color, int selectX, int selectY) { - if (selectX == x + 1 && selectY == y + 2) { + if (selectX == x + 1 && selectY == y + 2) { // check one of the 8 possible cases - if(board.getPiece(selectX + 1, selectY + 2) != null) { - - if(color != board.getPiece(selectX+ 1, selectY + 2).isWhite()) { - return true; - } - - } + if(board.getPiece(x, y) != null) { // check at the exact tox and ToY coordinates if there is a piece + return color != board.getPiece(x, y).isWhite(); // no need for additional if statement compared to previous move methods, its a comparator in between the color of the played piece and the color of the piece at the destination, if different, it will return true (possibility to eat the piecebc ishighlighted will be true) , if the same it will return false + } return true; }