marche mieux

This commit is contained in:
Romain MURPHY 2025-04-12 14:04:13 +02:00
parent 97e949bf2d
commit 697103f8f2
1 changed files with 9 additions and 7 deletions

View File

@ -83,7 +83,6 @@ public class Board {
}
}
}
boardHistory.add(new BoardHistory(board,turnNumber,turnColor));
}
public void cleanBoard() {
@ -96,6 +95,7 @@ public class Board {
}
this.turnNumber = 0;
this.turnColor = true;
boardHistory.clear();
}
@Override
@ -122,10 +122,10 @@ public class Board {
public void movePiece(int x, int y) {
if (select) {
boardHistory.add(new BoardHistory(board,turnNumber,turnColor));
Piece pieceToMove = this.board.get(this.ym).get(this.xm);
this.setPiece(x,y,pieceToMove.getType(),pieceToMove.isWhite());
board.get(this.ym).set(this.xm,null);
boardHistory.add(new BoardHistory(board,turnNumber,turnColor));
}
}
@ -181,11 +181,13 @@ public class Board {
}
public void undoLastMove() {
ArrayList<ArrayList<Piece>> boardToSet = boardHistory.get(boardHistory.size() - 2).getBoard();
this.turnNumber = boardHistory.getLast().getTurnNumber();
this.turnColor = boardHistory.getLast().isTurnColor();
boardHistory.removeLast();
board = boardToSet;
if (boardHistory.size()>=1) {
board = boardHistory.get(boardHistory.size() - 1).getBoard();
this.turnNumber = boardHistory.getLast().getTurnNumber();
this.turnColor = boardHistory.getLast().isTurnColor();
boardHistory.removeLast();
// System.out.println(boardHistory); // Debug
}
}
public Board(Board board) {