diff --git a/src/main/java/com/example/tictactoe_game/TicTacToeFX.java b/src/main/java/com/example/tictactoe_game/TicTacToeFX.java index 6d9a08ea616a5ca439be43aaddf302726a48765f..bd22bc3e514704d57c6dbd82a8828f03c6b016f8 100644 --- a/src/main/java/com/example/tictactoe_game/TicTacToeFX.java +++ b/src/main/java/com/example/tictactoe_game/TicTacToeFX.java @@ -16,6 +16,8 @@ public class TicTacToeFX extends Application { private boolean isXTurn = true; + private boolean isGameOver = false; + @Override public void start(Stage primaryStage) { @@ -64,16 +66,18 @@ public class TicTacToeFX extends Application { } private void handleButtonClick(Button button) { - if(button.getText().isEmpty()) { + if(button.getText().isEmpty() && !this.isGameOver) { if (this.isXTurn) { button.setText("X"); } else { button.setText("O"); } if (checkForWin()) { + this.isGameOver = true; button.fireEvent(new GameEvent(GameEvent.VICTORY_EVENT)); } else if(checkForDraw()){ + this.isGameOver = true; button.fireEvent(new GameEvent(GameEvent.DRAW_EVENT)); }