]> git.cworth.org Git - lmno-server/commitdiff
anagrams: Restart any necessary timers when restoring a game
authorCarl Worth <cworth@cworth.org>
Sun, 8 Mar 2026 23:13:53 +0000 (19:13 -0400)
committerCarl Worth <cworth@cworth.org>
Sun, 8 Mar 2026 23:13:53 +0000 (19:13 -0400)
This could give some extra time to the current in-progress claim/vote,
but that's fine, (and better than leaving the timer un-started which
could result in a hung game if a player has been disconnected).

anagrams.js

index c0e3be87ebfe0f92eb65c272debd74b871e738c8..1ec3cb4ca15e511d70af0b7ae9aa268cf261f20e 100644 (file)
@@ -853,6 +853,13 @@ class Anagrams extends Game {
   restore(data) {
     super.restore(data);
     this.state.done_players = new Set(this.state.done_players);
+
+    /* Restart timers that were active at save time. */
+    if (this.state.vote_pending) {
+      this._vote_timer = setTimeout(() => this._resolve_vote(), VOTE_TIMEOUT_MS);
+    } else if (this.state.claim_queue.length > 0) {
+      this._activate_claimer();
+    }
   }
 }