]> git.cworth.org Git - empires-server/commitdiff
Empathy: Eliminate delay when there's nobody to wait for
authorCarl Worth <cworth@cworth.org>
Thu, 18 Jun 2020 14:31:32 +0000 (07:31 -0700)
committerCarl Worth <cworth@cworth.org>
Thu, 25 Jun 2020 16:16:04 +0000 (09:16 -0700)
We don't even need to see the "Move On" button appear if every single
registered player has completed the answering or judging task.

empathy.js

index 04b4c6d4bd3f33bb6ce62817af9088843b554c64..4b7b5a9d3b9ee1f25c921240790e7608a2d282bc 100644 (file)
@@ -481,6 +481,11 @@ router.post('/answer/:prompt_id([0-9]+)', (request, response) => {
                                      request.session.id,
                                      request.body.answers);
   response.json(result);
+
+  /* If every registered player has answered, then there's no need to
+   * wait for anything else. */
+  if (game.state.players_answered.length >= game.players.length)
+    game.perform_judging();
 });
 
 router.post('/answering/:prompt_id([0-9]+)', (request, response) => {
@@ -513,6 +518,11 @@ router.post('/judged/:prompt_id([0-9]+)', (request, response) => {
                                      request.session.id,
                                      request.body.word_groups);
   response.json(result);
+
+  /* If every registered player has judged, then there's no need to
+   * wait for anything else. */
+  if (game.state.players_judged.length >= game.players.length)
+    game.compute_scores();
 });
 
 router.post('/judging/:prompt_id([0-9]+)', (request, response) => {