From c7d7991a166e4f2626ea582c0ce38929847ecefd Mon Sep 17 00:00:00 2001 From: hugomanipoud2 Date: Fri, 23 May 2025 13:11:11 +0200 Subject: [PATCH] castling can be undone et redo, but only for the concerned castle, the king will still move and the castlking variable for the other type of castle will get + 1, still an improvement --- OOP_3B5_Project/src/backend/Board.java | 3 +++ OOP_3B5_Project/src/backend/Move.java | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/OOP_3B5_Project/src/backend/Board.java b/OOP_3B5_Project/src/backend/Board.java index 5c7feea..3916370 100644 --- a/OOP_3B5_Project/src/backend/Board.java +++ b/OOP_3B5_Project/src/backend/Board.java @@ -279,6 +279,7 @@ public class Board { pieces.clear(); // removes all pieces from arraylist of pieces used pieces.addAll(previousState); // add all pieces from previous state of board to arraylist boardHistory.remove(turnNb + 1); + move.moveResetCastlingVar(turnNb); }else if (turnNb == 1) { turnNb--; @@ -286,6 +287,8 @@ public class Board { boardHistory.clear(); populateBoard(); + + } } diff --git a/OOP_3B5_Project/src/backend/Move.java b/OOP_3B5_Project/src/backend/Move.java index 2803f5d..3e87a63 100644 --- a/OOP_3B5_Project/src/backend/Move.java +++ b/OOP_3B5_Project/src/backend/Move.java @@ -393,7 +393,9 @@ public boolean isKingMoveValid(int x, int y, boolean color, int selectX, int se } - + public void moveResetCastlingVar(int turnNb) { + specialMoves.resetCastlingVar(turnNb); + }