Changed updateBoard method for board flip feature
parent
1167b54260
commit
d577d6843f
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue