]> git.cworth.org Git - lmno-server/commitdiff
Set judging_start_time_ms before anyone actually does any judging
authorCarl Worth <cworth@cworth.org>
Thu, 18 Jun 2020 16:04:29 +0000 (09:04 -0700)
committerCarl Worth <cworth@cworth.org>
Fri, 26 Jun 2020 14:37:59 +0000 (07:37 -0700)
The judging phase is different than answering in that judging is
optional. So we can't rely on clients actually sending a "judging"
notification, (since they might just submit without having clicked on
any of the words). So instead, we set the start time for the judging
phase as soon as we enter that phase.

empathy.js

index 3728a0e5dc318904c488f264773e41abe8263213..46d7f79ff876c3f1de89f75cb76b2ec9a22f3eac 100644 (file)
@@ -261,6 +261,10 @@ class Empathy extends Game {
       return a.toLowerCase().localeCompare(b.toLowerCase());
     });
 
+    if (this.judging_start_time_ms === 0) {
+      this.judging_start_time_ms = Date.now();
+    }
+
     this.broadcast_event_object('ambiguities', this.state.ambiguities);
   }
 
@@ -336,6 +340,7 @@ class Empathy extends Game {
   }
 
   receive_judging(prompt_id, session_id) {
+
     const player = this.players_by_session[session_id];
     if (! player)
       return { valid: false, message: "Player not found" };
@@ -358,9 +363,6 @@ class Empathy extends Game {
       }, PHASE_IDLE_TIMEOUT * 1000);
     }
 
-    if (this.judging_start_time_ms === 0)
-      this.judging_start_time_ms = Date.now();
-
     /* Notify all players this this player is actively judging. */
     this.state.players_judging.add(player.name);
     this.broadcast_event_object('player-judging', player.name);