From cead168a18a4fca8240bc7d922aecff831b9fe9a Mon Sep 17 00:00:00 2001 From: Stef Date: Thu, 18 Sep 2025 15:56:25 +0200 Subject: [PATCH] Stops running the gamethread when win or draw --- src/main/java/org/toop/game/tictactoe/TicTacToe.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/toop/game/tictactoe/TicTacToe.java b/src/main/java/org/toop/game/tictactoe/TicTacToe.java index 7b3500d..6ef249e 100644 --- a/src/main/java/org/toop/game/tictactoe/TicTacToe.java +++ b/src/main/java/org/toop/game/tictactoe/TicTacToe.java @@ -67,7 +67,9 @@ public class TicTacToe extends GameBase implements Runnable { } private void gameThread() { - while (true) { + boolean running = true; + + while (running) { ParsedCommand cmd = takeFromCommandQueue(); // Get next command if there was no command @@ -98,9 +100,11 @@ public class TicTacToe extends GameBase implements Runnable { switch (state){ case State.WIN:{ // Win + running = false; } case State.DRAW:{ // Draw + running = false; } case State.NORMAL:{ // Nothing wrong? @@ -109,7 +113,6 @@ public class TicTacToe extends GameBase implements Runnable { // Invalid move } } - } } }