From: Carl Worth <cworth@cworth.org>
Date: Wed, 10 Jun 2020 03:01:56 +0000 (-0700)
Subject: empathy: Tell clients how many players have responded
X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=3b34788d2953573eb46291b17a7a5562a2cc0f47;p=lmno-server

empathy: Tell clients how many players have responded

That's probably not quite the information the client _really_ wants,
(since it probably wants to at least show the names of those who
haven't submitted yet), but it at least gives the client _some_
information that's not static.
---

diff --git a/empathy.js b/empathy.js
index ca93b30..9bc5740 100644
--- a/empathy.js
+++ b/empathy.js
@@ -6,7 +6,8 @@ class Empathy extends Game {
     super(id);
     this.state = {
       prompts: [],
-      active_prompt: null
+      active_prompt: null,
+      players_answered: 0
     };
     this.answers = [];
     this.next_prompt_id = 1;
@@ -74,6 +75,11 @@ class Empathy extends Game {
       answers: answers
     });
 
+    /* And notify players how many players have answered. */
+    this.state.players_answered++;
+
+    this.broadcast_event_object('answered', this.state.players_answered);
+
     return { valid: true };
   }
 }