playmove is done (in board class)

This commit is contained in:
tothe 2025-05-15 22:31:56 +02:00
parent 08f48df26b
commit a6170e7728
1 changed files with 16 additions and 1 deletions

View File

@ -293,8 +293,23 @@ public class Board {
public void playMove(Move move) {
//TODO
int fromX = move.getFromX();
int fromY = move.getFromY();
int toX = move.getToX();
int toY = move.getToY();
Piece movingPiece = cells[fromX][fromY];
if (movingPiece == null) {
System.err.println("No piece at source position.");
return;
}
cells[toX][toY] = new Piece(movingPiece.getType(), movingPiece.isWhite(), toX, toY);
cells[fromX][fromY] = null;
System.out.println("Moved " + movingPiece.getType() + " from (" + fromX + "," + fromY + ") to (" + toX + "," + toY + ")");
}
}