Making this phase advance much like the other phases, and dependent on
a majority of the players rather than just letting one player stomp
all over things.
Beyond this, we still do want to allow players to inspect the state of
past rounds, but the UI for that that will have to come later.
window.game.set_scores(state.scores);
window.game.set_scores(state.scores);
+ window.game.set_new_game_votes(state.new_game_votes);
+
window.game.state_ready();
});
window.game.state_ready();
});
window.game.set_scores(scores);
});
window.game.set_scores(scores);
});
+events.addEventListener("vote-new-game", event => {
+ const player = JSON.parse(event.data);
+
+ window.game.set_player_vote_new_game(player);
+});
+
+events.addEventListener("unvote-new-game", event => {
+ const player = JSON.parse(event.data);
+
+ window.game.set_player_unvote_new_game(player);
+});
+
/*********************************************************
* Game and supporting classes *
*********************************************************/
/*********************************************************
* Game and supporting classes *
*********************************************************/
judging_idle: false,
end_judging_votes: new Set(),
scores: null,
judging_idle: false,
end_judging_votes: new Set(),
scores: null,
+ new_game_votes: new Set(),
judging_idle: false,
end_judging_votes: new Set(),
scores: null,
judging_idle: false,
end_judging_votes: new Set(),
scores: null,
+ new_game_votes: new Set(),
+ set_new_game_votes(players) {
+ this.setState({
+ new_game_votes: new Set(players)
+ });
+ }
+
+ set_player_vote_new_game(player) {
+ this.setState({
+ new_game_votes: new Set([...this.state.new_game_votes, player])
+ });
+ }
+
+ set_player_unvote_new_game(player) {
+ this.setState({
+ new_game_votes: new Set([...this.state.new_game_votes].filter(p => p !== player))
+ });
+ }
+
state_ready() {
this.setState({
ready: true
state_ready() {
this.setState({
ready: true
- className="new-game"
- onClick={() => fetch_post_json('reset') }
+ className="vote-button"
+ onClick={() => fetch_post_json(`new-game/${state.active_prompt.id}`) }
+ <div className="vote-choices">
+ {[...state.new_game_votes].map(v => {
+ return (
+ <div
+ key={v}
+ className="vote-choice"
+ >
+ {v}
+ </div>
+ );
+ })}
+ </div>