/* Send a comment to every connected client every 15 seconds. */
setInterval(() => {this.broadcast_string(":");}, 15000);
/* Send a comment to every connected client every 15 seconds. */
setInterval(() => {this.broadcast_string(":");}, 15000);
this.broadcast_event("spectators", "{}");
this.broadcast_event("players", "{}");
}
reveal_next() {
this.broadcast_event("spectators", "{}");
this.broadcast_event("players", "{}");
}
reveal_next() {
- /* Don't try to reveal anything if we aren't in the reveal state. */
- if (this.state != GameState.REVEAL) {
+ /* Don't try to reveal anything if we aren't in the reveal phase. */
+ if (this.phase != GamePhase.REVEAL) {
- game_state_event_data(old_state, new_state) {
- var old_state_name;
- if (old_state)
- old_state_name = GameState.properties[old_state].name;
+ game_phase_event_data(old_phase, new_phase) {
+ var old_phase_name;
+ if (old_phase)
+ old_phase_name = GamePhase.properties[old_phase].name;
- /* Inform clients about a state change. */
- broadcast_state_change() {
- const event_data = this.game_state_event_data(this.old_state, this.state);
- this.broadcast_event("game-state", event_data);
+ /* Inform clients about a phase change. */
+ broadcast_phase_change() {
+ const event_data = this.game_phase_event_data(this.old_phase, this.phase);
+ this.broadcast_event("game-phase", event_data);
- var old_state = null;
- for (var state = GameState.JOIN; state <= this.state; state++) {
- var event_data = this.game_state_event_data(old_state, state);
- response.write("event: game-state\n" + "data: " + event_data + "\n\n");
- old_state = state;
+ var old_phase = null;
+ for (var phase = GamePhase.JOIN; phase <= this.phase; phase++) {
+ var event_data = this.game_phase_event_data(old_phase, phase);
+ response.write("event: game-phase\n" + "data: " + event_data + "\n\n");
+ old_phase = phase;