Send game end message and fix timing bug

This commit is contained in:
Les De Ridder 2017-07-21 07:59:34 +02:00
parent fd7637230b
commit 32c6c194ce
1 changed files with 9 additions and 6 deletions

View File

@ -198,6 +198,8 @@ void wsGame(scope WebSocket socket)
continue;
}
game.currentRound.randomWordTimer.stop();
game.currentRound.currentWord = word;
game.currentRound.timer = setTimer(1.seconds, &game.currentRound.tick, true);
@ -257,6 +259,11 @@ class Game
if(roundsLeft == 0)
{
ended = true;
foreach(p; players)
{
sendGameState(p, this);
}
return;
}
@ -281,6 +288,7 @@ class Round
int secondsLeft;
Timer timer;
Timer randomWordTimer;
this(int number, Game game, Player[] players)
{
@ -342,12 +350,7 @@ class Round
drawer.sendMessage("setWordOptions", wordOptions.serializeToJson);
setTimer(10.seconds, delegate() {
if(!currentWord.empty)
{
return;
}
randomWordTimer = setTimer(10.seconds, delegate() {
game.currentRound.currentWord = choice(wordOptions);
game.currentRound.timer = setTimer(1.seconds, &game.currentRound.tick, true);