X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;ds=sidebyside;f=empathy.js;h=b12c3e75553f596b7cc2108cc9e1c21f0bd97444;hb=9aa7407eda90493c1004258e705ef0fa4afa6a48;hp=f9bf7410d4da8e77f3208b6608005dc770dabbbd;hpb=02c84b85c58b60f48bb0baf37cacdd037e84d28d;p=lmno-server diff --git a/empathy.js b/empathy.js index f9bf741..b12c3e7 100644 --- a/empathy.js +++ b/empathy.js @@ -15,6 +15,20 @@ class Empathy extends Game { } reset() { + + /* 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. @@ -125,16 +139,6 @@ class Empathy extends Game { 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()); } scores.sort((a,b) => {