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) => {
return b.players.length - a.players.length;
});
+ /* Put this round's scores into the game state object so it will
+ * be sent to any new clients that join. */
this.state.scores = {
scores: scores,
words: word_submitters_arr
};
+ /* And broadcast the scores to all connected clients. */
this.broadcast_event_object('scores', this.state.scores);
}
}
return JSON.stringify({
id: this.id,
name: this.name,
- team: this.team.name
+ team: this.team.name,
+ score: this.score
});
}
}
/* After adding the player to the list, and if we are already past
* the first move, assign this player to the first team that
- * doesn't already have a player aissgned (if any). */
+ * doesn't already have a player assigned (if any). */
if (! this.first_move) {
const have_players = Array(this.teams.length).fill(false);
this.players.forEach(p => {