diff --git a/app/src/main/java/chess/controller/CommandExecutor.java b/app/src/main/java/chess/controller/CommandExecutor.java index bd2ad8a..c29d92d 100644 --- a/app/src/main/java/chess/controller/CommandExecutor.java +++ b/app/src/main/java/chess/controller/CommandExecutor.java @@ -1,6 +1,7 @@ package chess.controller; import chess.controller.Command.CommandResult; +import chess.controller.commands.UndoCommand; import chess.model.Game; import chess.model.Game.GameStatus; @@ -21,7 +22,7 @@ public class CommandExecutor { CommandResult result = command.execute(this.game, this.outputSystem); // non player commands are not supposed to return move result - assert result != CommandResult.Moved || command instanceof PlayerCommand; + assert result != CommandResult.Moved || command instanceof PlayerCommand || command instanceof UndoCommand; processResult(command, result); diff --git a/app/src/main/java/chess/view/simplerender/Window.java b/app/src/main/java/chess/view/simplerender/Window.java index fd7b93f..3aaa352 100644 --- a/app/src/main/java/chess/view/simplerender/Window.java +++ b/app/src/main/java/chess/view/simplerender/Window.java @@ -138,19 +138,7 @@ public class Window extends JFrame implements OutputSystem { } } - private void clearPreviews() { - for (int y = 0; y < 8; y++) { - for (int x = 0; x < 8; x++) { - JLabel cell = this.cells[x][y]; - cell.paintComponents(getGraphics()); - } - } - } - private boolean previewMoves(int x, int y) { - - clearPreviews(); - GetAllowedMovesCommand movesCommand = new GetAllowedMovesCommand(new Coordinate(x, y)); if (sendCommand(movesCommand) == CommandResult.NotAllowed) return false; @@ -180,13 +168,13 @@ public class Window extends JFrame implements OutputSystem { for (int x = 0; x < 8; x++) { JLabel cell = this.cells[x][y]; cell.setBackground(getCellColor(x, y)); + cell.paint(cell.getGraphics()); } } } private void onCellClicked(int x, int y) { clearMoves(); - clearPreviews(); if (this.lastClick == null) { if (isCellEmpty(x, y)) return;