this.broadcast_event_object('scores', this.state.scores);
}
+ serialize() {
+ const data = super.serialize();
+ data.next_prompt_id = this.next_prompt_id;
+ data.equivalencies = this.equivalencies;
+ data.answering_start_time_ms = this.answering_start_time_ms;
+ data.judging_start_time_ms = this.judging_start_time_ms;
+ data.answers = this.answers.map(a => ({
+ session_id: a.player.session_id,
+ answers: a.answers
+ }));
+ data.kudos = {};
+ for (const [name, k] of Object.entries(this.kudos)) {
+ data.kudos[name] = {
+ session_id: k.player.session_id,
+ words: k.words
+ };
+ }
+ return data;
+ }
+
restore(data) {
super.restore(data);
this.state.players_answering = new Set(this.state.players_answering);
this.state.players_judging = new Set(this.state.players_judging);
this.state.end_judging = new Set(this.state.end_judging);
this.state.new_game_votes = new Set(this.state.new_game_votes);
+
+ this.next_prompt_id = data.next_prompt_id || 1;
+ this.equivalencies = data.equivalencies || {};
+ this.answering_start_time_ms = data.answering_start_time_ms || 0;
+ this.judging_start_time_ms = data.judging_start_time_ms || 0;
+
+ if (data.answers) {
+ this.answers = data.answers
+ .filter(a => this.players_by_session[a.session_id])
+ .map(a => ({
+ player: this.players_by_session[a.session_id],
+ answers: a.answers
+ }));
+ }
+
+ if (data.kudos) {
+ for (const [name, k] of Object.entries(data.kudos)) {
+ const player = this.players_by_session[k.session_id];
+ if (player) {
+ this.kudos[name] = { player, words: k.words };
+ }
+ }
+ }
}
}