Skip to content
Snippets Groups Projects
Commit 222eb3f8 authored by jan-schw's avatar jan-schw
Browse files

small cleanup

parent 83916419
No related branches found
No related tags found
2 merge requests!6Add final version of the game to main branch,!5Add basic implementation
...@@ -29,7 +29,7 @@ public class TicTacToeFX extends Application { ...@@ -29,7 +29,7 @@ public class TicTacToeFX extends Application {
public void start(Stage primaryStage) { public void start(Stage primaryStage) {
EventHandler<GameEvent> gameEventHandler = gameEvent -> { EventHandler<GameEvent> gameEventHandler = gameEvent -> {
String winner = this.isXTurn ? "X" : "O"; String currentPlayer = this.isXTurn ? "X" : "O";
// Dialogfenster erstellen // Dialogfenster erstellen
final Stage dialog = new Stage(); final Stage dialog = new Stage();
...@@ -41,7 +41,7 @@ public class TicTacToeFX extends Application { ...@@ -41,7 +41,7 @@ public class TicTacToeFX extends Application {
// Dialogtexte // Dialogtexte
if (gameEvent.getEventType() == GameEvent.VICTORY_EVENT) { if (gameEvent.getEventType() == GameEvent.VICTORY_EVENT) {
dialogVbox.getChildren().add(new Text("This is a victory for player " + winner + " in turn " + this.currentTurn + "!")); dialogVbox.getChildren().add(new Text("This is a victory for player " + currentPlayer + " in turn " + this.currentTurn + "!"));
} else if (gameEvent.getEventType() == GameEvent.DRAW_EVENT) { } else if (gameEvent.getEventType() == GameEvent.DRAW_EVENT) {
dialogVbox.getChildren().add(new Text("This is a Draw!")); dialogVbox.getChildren().add(new Text("This is a Draw!"));
} }
...@@ -88,9 +88,6 @@ public class TicTacToeFX extends Application { ...@@ -88,9 +88,6 @@ public class TicTacToeFX extends Application {
turnCounter = new Text("Current Turn: " + currentTurn); turnCounter = new Text("Current Turn: " + currentTurn);
// Elemente dem Spielfeld hinzufügen // Elemente dem Spielfeld hinzufügen
grid.add(currentPlayer, 3, 0);
grid.add(turnCounter, 3, 1);
Button restartButton = new Button("Restart"); Button restartButton = new Button("Restart");
restartButton.setOnAction(event -> restartGame()); restartButton.setOnAction(event -> restartGame());
...@@ -99,7 +96,7 @@ public class TicTacToeFX extends Application { ...@@ -99,7 +96,7 @@ public class TicTacToeFX extends Application {
vbox.getChildren().addAll(grid, currentPlayer, turnCounter, restartButton); vbox.getChildren().addAll(grid, currentPlayer, turnCounter, restartButton);
// Szene und Stage erstellen // Szene und Stage erstellen
Scene scene1 = new Scene(vbox, 400, 400); Scene scene1 = new Scene(vbox, 300, 400);
primaryStage.setTitle("Tic-Tac-Toe"); primaryStage.setTitle("Tic-Tac-Toe");
primaryStage.setScene(scene1); primaryStage.setScene(scene1);
primaryStage.show(); primaryStage.show();
......
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