Merge branch 'master' of

https://gitarero.ecam.fr/valentine.giral/OOP_3B3_Project.git
This commit is contained in:
Lymeng LY 2025-05-09 10:42:59 +02:00
parent f331bd3e9a
commit 0a74a10e9b
1 changed files with 21 additions and 3 deletions

View File

@ -10,6 +10,7 @@ public class Board {
private int turnNumber=0; // Tracks the number of turns elapsed private int turnNumber=0; // Tracks the number of turns elapsed
private boolean turnWhite=true; // True if it's White's turn, False if it's Black's turn private boolean turnWhite=true; // True if it's White's turn, False if it's Black's turn
private ArrayList<int[]> highlightedPositions = new ArrayList<>();// List containing all board positions private ArrayList<int[]> highlightedPositions = new ArrayList<>();// List containing all board positions
private boolean isValidMove;
private boolean inBounds(int x, int y) { private boolean inBounds(int x, int y) {
// Verify the bounds of the board // Verify the bounds of the board
@ -190,8 +191,8 @@ public class Board {
else { else {
// Check if the move is valid by checking if it exists in highlightedPositions // Check if the move is valid by checking if it exists in highlightedPositions
boolean isValidMove = false; boolean isValidMove = false;
for (int[] pos : highlightedPositions) { for (int[] pos1 : highlightedPositions) {
if (pos[0] == x && pos[1] == y) { if (pos1[0] == x && pos1[1] == y) {
isValidMove = true; isValidMove = true;
break; break;
} }
@ -383,7 +384,24 @@ public class Board {
} }
public Board(Board board) { public Board(Board board) {
//TODO //copy the board size
this.col = board.col; //number of column
this.line = board.line; //number of row
this.turnNumber = board.turnNumber;
this.turnWhite = board.turnWhite;
//copy the selected positions
this.selectedPosition = board.selectedPosition == null ? null:
new int[] {board.selectedPosition[0], board.selectedPosition[1]};
//Deep copy highlighted positions
this.highlightedPositions = new ArrayList<>();
for (int[] pos : highlightedPositions) {
}
} }