Stops running the gamethread when win or draw

This commit is contained in:
2025-09-18 15:56:25 +02:00
committed by Bas Antonius de Jong
parent f42831ea78
commit cead168a18

View File

@@ -67,7 +67,9 @@ public class TicTacToe extends GameBase implements Runnable {
} }
private void gameThread() { private void gameThread() {
while (true) { boolean running = true;
while (running) {
ParsedCommand cmd = takeFromCommandQueue(); ParsedCommand cmd = takeFromCommandQueue();
// Get next command if there was no command // Get next command if there was no command
@@ -98,9 +100,11 @@ public class TicTacToe extends GameBase implements Runnable {
switch (state){ switch (state){
case State.WIN:{ case State.WIN:{
// Win // Win
running = false;
} }
case State.DRAW:{ case State.DRAW:{
// Draw // Draw
running = false;
} }
case State.NORMAL:{ case State.NORMAL:{
// Nothing wrong? // Nothing wrong?
@@ -109,7 +113,6 @@ public class TicTacToe extends GameBase implements Runnable {
// Invalid move // Invalid move
} }
} }
} }
} }
} }