From a6170e7728d87479f3f2f1193cb839f889a36291 Mon Sep 17 00:00:00 2001 From: tothe Date: Thu, 15 May 2025 22:31:56 +0200 Subject: [PATCH] playmove is done (in board class) --- src/backend/Board.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/backend/Board.java b/src/backend/Board.java index c0f233a..7aaf10b 100644 --- a/src/backend/Board.java +++ b/src/backend/Board.java @@ -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 + ")"); } + } \ No newline at end of file