better undo
This commit is contained in:
@@ -57,19 +57,14 @@ public class ChessBoard {
|
||||
public void undoLastMove() {
|
||||
assert this.lastMove != null: "Can't undo at the beginning!";
|
||||
|
||||
Move move = this.lastMove;
|
||||
undoMove(this.lastMove, this.lastEjectedPiece);
|
||||
}
|
||||
|
||||
public void undoMove(Move move, Piece deadPiece) {
|
||||
Piece movingPiece = pieceAt(move.getFinish());
|
||||
pieceComes(movingPiece, move.getStart());
|
||||
pieceLeaves(move.getFinish());
|
||||
pieceComes(deadPiece, move.getFinish());
|
||||
movingPiece.unMove();
|
||||
|
||||
if (this.lastEjectedPiece == null)
|
||||
return;
|
||||
|
||||
Piece piece = this.lastEjectedPiece;
|
||||
|
||||
pieceComes(piece, move.getFinish());
|
||||
}
|
||||
|
||||
public boolean isCellEmpty(Coordinate coordinate) {
|
||||
|
||||
Reference in New Issue
Block a user