diff --git a/src/backend/Board.java b/src/backend/Board.java index 39d48f7..5f14069 100644 --- a/src/backend/Board.java +++ b/src/backend/Board.java @@ -411,14 +411,41 @@ public class Board { //Deep copy highlighted positions this.highlightedPositions = new ArrayList<>(); for (int[] pos : highlightedPositions) { - -//TO BE DONE + this.highlightedPositions.add(new int[]{pos[0], pos[1]}); + } + //Deep copy of board and pieces + this.board = new Piece[col][line]; + for (int y = 0; y < line; y++) { + for (int x = 0; x < col; x++) { + Piece p = board.board[y][x]; + if (p != null) { + this.board[y][x] = new Piece(p.isWhite(), p.getType(), p.getX(), p.getY()); + } + } } } public void playMove(Move move) { - //TODO + //get current piece coordinate + int fromX = move.piece.getX(); + int fromY = move.piece.getY(); + //Remove the piece from the original position + board[fromX][fromY] = null; + //Update the internal position of the piece + move.piece.setX(move.toX); + move.piece.setY(move.toY); + //place the piece at the new position + board[move.toY][move.toX] = move.piece; + + //end turn logic + this.turnWhite = !this.turnWhite; + this.turnNumber++; + + //Clear selection/highlight + this.selectedPosition = null; + this.highlightedPositions.clear(); + }