Changed updateBoard method for board flip feature

Quicksave
Justin 2025-06-19 21:26:13 +02:00
parent 1167b54260
commit d577d6843f
1 changed files with 18 additions and 12 deletions

View File

@ -145,18 +145,24 @@ public class GameGui {
}
public void updateBoard(BoardDTO boardDTO) {
PieceDTO[][] board = boardDTO.getBoard();
for (int row = 0; row < 8; row++) {
for (int col = 0; col < 8; col++) {
PieceDTO piece = board[row][col];
if (piece != null) {
fields[row][col].setText(piece.getUnicodeSymbol());
} else {
fields[row][col].setText("");
}
}
}
}
PieceDTO[][] board = boardDTO.getBoard();
if (!isFlipped) {
for (int row = 0; row < 8; row++) {
for (int col = 0; col < 8; col++) {
PieceDTO piece = board[row][col];
fields[row][col].setText(piece != null ? piece.getUnicodeSymbol() : "");
}
}
} else {
// Invertiere Zeilen und Spalten!
for (int row = 0; row < 8; row++) {
for (int col = 0; col < 8; col++) {
PieceDTO piece = board[7 - row][7 - col];
fields[row][col].setText(piece != null ? piece.getUnicodeSymbol() : "");
}
}
}
}
public void displayMessage(String msg) {