From: Carl Worth Date: Sun, 14 Jun 2020 23:43:49 +0000 (-0700) Subject: Don't display the answering "Move On" button until the server reports idle X-Git-Url: https://git.cworth.org/git?p=lmno.games;a=commitdiff_plain;h=1896a4e7c03026eb1ef2aa084b55e1434265fd9d Don't display the answering "Move On" button until the server reports idle By waiting until the server reports that things are idle, it's safer to display this button. (Displaying it early might result in a a user being considered a majority of just the group of that player alone, which is not what is desired.) --- diff --git a/empathy/empathy.jsx b/empathy/empathy.jsx index 8006942..683f92d 100644 --- a/empathy/empathy.jsx +++ b/empathy/empathy.jsx @@ -67,6 +67,8 @@ events.addEventListener("game-state", event => { window.game.set_players_answering(state.players_answering); + window.game.set_answering_idle(state.answering_idle); + window.game.set_end_answers(state.end_answers); window.game.set_ambiguities(state.ambiguities); @@ -104,6 +106,12 @@ events.addEventListener("player-answering", event => { window.game.set_player_answering(player); }); +events.addEventListener("answering-idle", event => { + const value = JSON.parse(event.data); + + window.game.set_answering_idle(value); +}); + events.addEventListener("vote-end-answers", event => { const player = JSON.parse(event.data); @@ -656,6 +664,30 @@ class ActivePrompt extends React.PureComponent { } render() { + let move_on_button = null; + if (this.props.idle) { + move_on_button =( + + ); + } + if (this.props.players_answered.has(this.props.player.name)) { return (
@@ -680,24 +712,7 @@ class ActivePrompt extends React.PureComponent { ); })} - + {move_on_button}
); @@ -755,6 +770,7 @@ class Game extends React.PureComponent { active_prompt: null, players_answered: new Set(), players_answering: {}, + answering_idle: false, end_answers_votes: new Set(), ambiguities: null, players_judged: new Set(), @@ -795,6 +811,7 @@ class Game extends React.PureComponent { active_prompt: null, players_answered: new Set(), players_answering: {}, + answering_idle: false, end_answers_votes: new Set(), ambiguities: null, players_judged: new Set(), @@ -864,6 +881,12 @@ class Game extends React.PureComponent { }); } + set_answering_idle(value) { + this.setState({ + answering_idle: value + }); + } + set_end_answers(players) { this.setState({ end_answers_votes: new Set(players) @@ -1001,6 +1024,7 @@ class Game extends React.PureComponent { player={state.player_info} players_answered={state.players_answered} players_answering={state.players_answering} + idle={state.answering_idle} votes={state.end_answers_votes} />; }