]> git.cworth.org Git - empires-server/blobdiff - empathy.js
Include still-answering players when ruling on end-asnwering majority
[empires-server] / empathy.js
index 5c2bd18d2b86ff6dd11f29778f4aca7925a28f03..1cd120ee5e098870112f91c13025464fea079a40 100644 (file)
@@ -55,7 +55,7 @@ class Empathy extends Game {
     this.state.players_answering = new Set();
     this.state.answering_idle = false;
     this.state.end_answers = new Set();
-    this.state.ambiguities = 0;
+    this.state.ambiguities = null;
     this.state.players_judged = [];
     this.state.players_judging = new Set();
     this.state.end_judging = new Set();
@@ -506,7 +506,12 @@ router.post('/end-answers/:prompt_id([0-9]+)', (request, response) => {
   else
     response.sendStatus(404);
 
-  if (game.state.end_answers.size > (game.state.players_answered.length / 2))
+  /* The majority rule here includes all players that have answered as
+   * well as all that have started typing. */
+  const players_involved = (game.state.players_answered.length +
+                            game.state.players_answering.size);
+
+  if (game.state.end_answers.size > players_involved / 2)
     game.perform_judging();
 });