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

refactor custom event handler

parent 3c451fa6
No related branches found
No related tags found
2 merge requests!6Add final version of the game to main branch,!5Add basic implementation
......@@ -22,18 +22,19 @@ public class TicTacToeFX extends Application {
EventHandler<GameEvent> gameEventHandler = gameEvent -> {
String currentPlayer = isXTurn ? "X" : "O";
final Stage dialog = new Stage();
dialog.initModality(Modality.APPLICATION_MODAL);
dialog.initOwner(primaryStage);
VBox dialogVbox = new VBox(20);
if(gameEvent.getEventType() == GameEvent.VICTORY_EVENT) {
dialogVbox.getChildren().add(new Text("This is a victory for player " + currentPlayer + "!"));
}
else if(gameEvent.getEventType() == GameEvent.DRAW_EVENT) {
dialogVbox.getChildren().add(new Text("This is a Draw!"));
}
Scene dialogScene = new Scene(dialogVbox, 150, 150);
Scene dialogScene = new Scene(dialogVbox, 200, 100);
dialog.setScene(dialogScene);
dialog.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