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