fix moves preview

This commit is contained in:
2025-04-10 11:07:44 +02:00
parent 19b45371bb
commit 7aa129bbc6
2 changed files with 3 additions and 14 deletions

View File

@@ -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;