mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 10:54:51 +00:00
Stops running the gamethread when win or draw
This commit is contained in:
@@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user