Skip to content
Snippets Groups Projects
Commit 5411f947 authored by Bariatti Francesco's avatar Bariatti Francesco
Browse files

Modified GUI end of game function

parent 1e7b9ee7
No related branches found
No related tags found
No related merge requests found
......@@ -41,18 +41,21 @@ public class UpdateThread extends Thread
System.out.println(line);
if (line == null)
{
Platform.runLater(() ->
{
Player computer = Player.Red;
if (humanPlayer.equals(Player.Red))
computer = Player.Blue;
Alert alert = new Alert(Alert.AlertType.INFORMATION);
if (gameState.getScore(humanPlayer) > gameState.getScore(computer))
alert.setHeaderText("You won!!!!");
else if (gameState.getScore(humanPlayer) == gameState.getScore(computer))
alert.setHeaderText("That's a draw. Not bad!");
gameRunning = false;
}
else if(line.startsWith(Player.Red+" won") || line.startsWith(Player.Blue+" won") || line.startsWith("draw"))
{
//System.out.println("======= END OF GAME=======");
Platform.runLater(() -> {
Player computer = humanPlayer.equals(Player.Red) ? Player.Blue : Player.Red;
String message = "";
if (line.startsWith(humanPlayer.toString())) //Human won
message = "You won!!! I can't believe it!";
else if (line.startsWith(computer.toString()))
message = "You just lost the penguin game.";
else
alert.setHeaderText("You just lost the penguin game.");
message = "That's a draw. Not bad!";
Alert alert = new Alert(Alert.AlertType.INFORMATION, message, ButtonType.OK);
alert.showAndWait();
});
gameRunning = false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment