Send game end message and fix timing bug
This commit is contained in:
parent
fd7637230b
commit
32c6c194ce
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue