fix moves preview
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user