]> git.cworth.org Git - empires-server/commitdiff
empathy: Tell clients how many players have responded
authorCarl Worth <cworth@cworth.org>
Wed, 10 Jun 2020 03:01:56 +0000 (20:01 -0700)
committerCarl Worth <cworth@cworth.org>
Wed, 10 Jun 2020 03:01:56 +0000 (20:01 -0700)
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.

empathy.js

index ca93b30f8be5343197a7877c002fa7181cfb2a02..9bc5740d1b9b6fab0bed5d47e3dcb99138bc5676 100644 (file)
@@ -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 };
   }
 }