Commit bc3d1743 authored by Anna Maria Eilertsen's avatar Anna Maria Eilertsen
Browse files

added label text for end of game with no winner

parent 8eb0d71f
......@@ -90,14 +90,20 @@ s * Initializes a JFrame in which we place the game
this.updateUI();
}
/**
* Children panels can call this method after being clicked.
*/
private void registerClick() {
updateGameUI();
endOfTurn();
if(!multiplayer) {
AIPlayerTurn();
}
}
public void updateGameUI() {
/**
* Should be called after a click to update the UI to reflect the current game state
*/
private void endOfTurn() {
clickablePanels.forEach(item -> item.updateToGame());
updateMessage();
MNKGameGUI.super.updateUI();
......@@ -107,12 +113,14 @@ s * Initializes a JFrame in which we place the game
}
}
private void AIPlayerTurn() {
ai.makeMove(game);
updateGameUI();
endOfTurn();
}
/**
* Should be called once a game stops
*/
private void stop() {
updateMessage();
clickablePanels.forEach(item -> item.removeMouseListeners());
......@@ -265,8 +273,11 @@ s * Initializes a JFrame in which we place the game
private void updateMessage() {
if (game.hasWinner())
statusMessage.setText("The game is over! The winner is " + getPlayerName(game.getWinner()));
else
else if(game.hasPossibleMoves()) {
statusMessage.setText("Next move from " + getPlayerName(game.getCurrent()));
}else{
statusMessage.setText("The game is over! No one won.");
}
}
public void collectPlayerInfo() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment