Good one
This commit is contained in:
parent
0bf99a6157
commit
9d64fad05f
|
|
@ -330,6 +330,27 @@ public void undoLastMove() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void playMove(Move move) {
|
||||||
|
Piece piece = move.getPieceMoved();
|
||||||
|
|
||||||
|
// If a piece is captured, remove it from the board
|
||||||
|
if (move.getPieceCaptured() != null) {
|
||||||
|
pieces.remove(move.getPieceCaptured());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the moved piece's position
|
||||||
|
piece.setPosition(move.getToX(), move.getToY());
|
||||||
|
|
||||||
|
// Save move in history for undo
|
||||||
|
moveHistory.add(move);
|
||||||
|
|
||||||
|
// Switch turn
|
||||||
|
turnWhite = !turnWhite;
|
||||||
|
turnNumber++;
|
||||||
|
|
||||||
|
// Clear selection/highlight
|
||||||
|
selected = null;
|
||||||
|
highlighted.clear();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue