Instead of doing this in the compute_scores function (for the current
round) as we may end up having that function called multiple times.
+
+ /* Before closing out the current round, we accumulate that score
+ * for each player into their runnning total. */
+ for (let score of this.state.scores.scores) {
+ const player = this.players.find(p => p.name === score.player);
+ if (player.score)
+ player.score += score.score;
+ else
+ player.score = score.score;
+
+ /* And broadcast that new score out. */
+ this.broadcast_event('player-update', player.info_json());
+ }
+
/* Now that we're done with the active prompt, we remove it from
* the list of prompts and also remove any prompts that received
* no votes. This keeps the list of prompts clean.
/* Now that we're done with the active prompt, we remove it from
* the list of prompts and also remove any prompts that received
* no votes. This keeps the list of prompts clean.
player: a.player.name,
score: score
});
player: a.player.name,
score: score
});
- /* Now that we've computed the score for a player for this
- * round, also accumulate that score into the players runnning
- * total. */
- if (a.player.score)
- a.player.score += score;
- else
- a.player.score = score;
-
- /* And broadcast that new score out. */
- this.broadcast_event('player-update', a.player.info_json());