marche mieux
This commit is contained in:
parent
97e949bf2d
commit
697103f8f2
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue