mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 10:54:51 +00:00
player info weer teruggestopt
This commit is contained in:
@@ -27,6 +27,9 @@ public class GenericGameController<T extends TurnBasedGame<T>> implements GameCo
|
|||||||
// Reference to gameView view
|
// Reference to gameView view
|
||||||
protected final GameView gameView;
|
protected final GameView gameView;
|
||||||
|
|
||||||
|
// Reference to String gametype
|
||||||
|
protected final String gameType;
|
||||||
|
|
||||||
// Reference to game canvas
|
// Reference to game canvas
|
||||||
protected final GameCanvas<T> canvas;
|
protected final GameCanvas<T> canvas;
|
||||||
|
|
||||||
@@ -39,6 +42,7 @@ public class GenericGameController<T extends TurnBasedGame<T>> implements GameCo
|
|||||||
|
|
||||||
this.canvas = canvas;
|
this.canvas = canvas;
|
||||||
this.game = game;
|
this.game = game;
|
||||||
|
this.gameType = gameType;
|
||||||
this.gameThreadBehaviour = gameThreadBehaviour;
|
this.gameThreadBehaviour = gameThreadBehaviour;
|
||||||
|
|
||||||
// Tell thread how to send moves
|
// Tell thread how to send moves
|
||||||
@@ -136,5 +140,12 @@ public class GenericGameController<T extends TurnBasedGame<T>> implements GameCo
|
|||||||
@Override
|
@Override
|
||||||
public void updateUI() {
|
public void updateUI() {
|
||||||
canvas.redraw(game.deepCopy());
|
canvas.redraw(game.deepCopy());
|
||||||
|
gameView.updatePlayerInfo(
|
||||||
|
true,
|
||||||
|
getCurrentPlayer().getName(),
|
||||||
|
game.getCurrentTurn() == 0 ? "X" : "O",
|
||||||
|
getPlayer((game.getCurrentTurn() + 1 ) % 2).getName(),
|
||||||
|
this.gameType
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ public final class GameView extends ViewWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void nextPlayer(boolean isMe, String currentPlayer, String currentMove, String nextPlayer, char GameType) {
|
public void updatePlayerInfo(boolean isMe, String currentPlayer, String currentMove, String nextPlayer, String GameType) {
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
if (!(hasSet)) {
|
if (!(hasSet)) {
|
||||||
playerHeader.setText(currentPlayer + " vs. " + nextPlayer);
|
playerHeader.setText(currentPlayer + " vs. " + nextPlayer);
|
||||||
@@ -112,8 +112,8 @@ public final class GameView extends ViewWidget {
|
|||||||
new GameOverPopup(iWon, winner).show(Pos.CENTER);
|
new GameOverPopup(iWon, winner).show(Pos.CENTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setPlayerHeaders(boolean isMe, String currentPlayer, String nextPlayer, char GameType) {
|
private void setPlayerHeaders(boolean isMe, String currentPlayer, String nextPlayer, String GameType) {
|
||||||
if (GameType == 'T') {
|
if (GameType.equals("TicTacToe")) {
|
||||||
if (isMe) {
|
if (isMe) {
|
||||||
player1Header.setText("X: " + currentPlayer);
|
player1Header.setText("X: " + currentPlayer);
|
||||||
player2Header.setText("O: " + nextPlayer);
|
player2Header.setText("O: " + nextPlayer);
|
||||||
@@ -124,7 +124,7 @@ public final class GameView extends ViewWidget {
|
|||||||
}
|
}
|
||||||
setPlayerInfoTTT();
|
setPlayerInfoTTT();
|
||||||
}
|
}
|
||||||
else if (GameType == 'R') {
|
else if (GameType.equals("Reversi")) {
|
||||||
if (isMe) {
|
if (isMe) {
|
||||||
player1Header.setText(currentPlayer);
|
player1Header.setText(currentPlayer);
|
||||||
player2Header.setText(nextPlayer);
|
player2Header.setText(nextPlayer);
|
||||||
|
|||||||
Reference in New Issue
Block a user