From 23ab0d1f2fe34ae413a3a37dc6c01855148f16b9 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Sat, 27 Jun 2020 17:52:06 -0700 Subject: [PATCH] Use set difference (ANSWERED - JUDGED) to determine whether to advance This is a bug fix for the bug described and tested in the previous commit. Previously we were simply comparing the count of players who had judged with the count of those who had answered. Here, instead, we compute an actual set difference and only auto-advance from the judging phase when every player who answered has also completed judging. This fix causes the test added in the previous comit to start passing, so now the entire test suite is passing once again. --- empathy.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/empathy.js b/empathy.js index 7b27ee4..ba25cc4 100644 --- a/empathy.js +++ b/empathy.js @@ -663,7 +663,8 @@ router.post('/judged/:prompt_id([0-9]+)', (request, response) => { /* If every player who answered has also judged, then there's no * need to wait for anything else. */ - if (game.state.players_judged.length >= game.state.players_answered.length) + const judged_set = new Set(game.state.players_judged); + if ([...game.state.players_answered].filter(x => !judged_set.has(x)).length === 0) game.compute_scores(); }); -- 2.43.0