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

Added choice for the color with which we want to play

parent 80462fe8
No related branches found
No related tags found
No related merge requests found
...@@ -5,11 +5,13 @@ import javafx.fxml.FXML; ...@@ -5,11 +5,13 @@ import javafx.fxml.FXML;
import javafx.fxml.Initializable; import javafx.fxml.Initializable;
import javafx.scene.control.Alert; import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType; import javafx.scene.control.ButtonType;
import javafx.scene.control.ChoiceDialog;
import javafx.scene.input.MouseEvent; import javafx.scene.input.MouseEvent;
import javafx.scene.layout.BorderPane; import javafx.scene.layout.BorderPane;
import javafx.scene.paint.Color; import javafx.scene.paint.Color;
import javafx.scene.shape.Polygon; import javafx.scene.shape.Polygon;
import model.GameState; import model.GameState;
import model.Player;
import model.Tile; import model.Tile;
import view.TileView; import view.TileView;
...@@ -27,6 +29,7 @@ public class Controller implements Initializable ...@@ -27,6 +29,7 @@ public class Controller implements Initializable
private PrintWriter gameInput; private PrintWriter gameInput;
private Tile[] board; private Tile[] board;
private TileView[] boardView; private TileView[] boardView;
private Player humanPlayer;
@FXML @FXML
private Polygon tile0, tile1, tile2, tile3, tile4, tile5, tile6, tile7, tile8, tile9, tile10, tile11, tile12, tile13, tile14, tile15, tile16, tile17, tile18, tile19, tile20, tile21, tile22, tile23, tile24, tile25, tile26, tile27, tile28, tile29, tile30, tile31, tile32, tile33, tile34, tile35, tile36, tile37, tile38, tile39, tile40, tile41, tile42, tile43, tile44, tile45, tile46, tile47, tile48, tile49, tile50, tile51, tile52, tile53, tile54, tile55, tile56, tile57, tile58, tile59; private Polygon tile0, tile1, tile2, tile3, tile4, tile5, tile6, tile7, tile8, tile9, tile10, tile11, tile12, tile13, tile14, tile15, tile16, tile17, tile18, tile19, tile20, tile21, tile22, tile23, tile24, tile25, tile26, tile27, tile28, tile29, tile30, tile31, tile32, tile33, tile34, tile35, tile36, tile37, tile38, tile39, tile40, tile41, tile42, tile43, tile44, tile45, tile46, tile47, tile48, tile49, tile50, tile51, tile52, tile53, tile54, tile55, tile56, tile57, tile58, tile59;
...@@ -69,8 +72,23 @@ public class Controller implements Initializable ...@@ -69,8 +72,23 @@ public class Controller implements Initializable
upT.setDaemon(true); upT.setDaemon(true);
upT.start(); upT.start();
//We tell the game that we will start //Choice: who will start?
gameInput.println("h"); ChoiceDialog<Player> playerChoice = new ChoiceDialog<>(Player.Red, Player.Red, Player.Blue);
playerChoice.setTitle("Penguin game!");
playerChoice.setHeaderText("Choose your color (red starts)");
playerChoice.showAndWait();
humanPlayer = playerChoice.getResult();
if (humanPlayer == null)
{
System.exit(0);
}
else
{
if (humanPlayer.equals(Player.Red))
gameInput.println("h");
else
gameInput.println("c");
}
} }
......
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