X-Git-Url: https://git.cworth.org/git?p=lmno.games;a=blobdiff_plain;f=empathy%2Fempathy.jsx;h=2aec434654cf26d7bc5078298ab89f5d3739ce9d;hp=39461898cf5efd9d7478a2acd68a333c791be74c;hb=a3d68ced6e2f65187e4fc076a488715a777b8a62;hpb=ff43730d806faf03b488ee59c49d576686696d6c diff --git a/empathy/empathy.jsx b/empathy/empathy.jsx index 3946189..2aec434 100644 --- a/empathy/empathy.jsx +++ b/empathy/empathy.jsx @@ -74,6 +74,12 @@ events.addEventListener("start", event => { window.game.set_active_prompt(prompt); }); +events.addEventListener("answered", event => { + const players_answered = JSON.parse(event.data); + + window.game.set_players_answered(players_answered); +}); + /********************************************************* * Game and supporting classes * *********************************************************/ @@ -336,7 +342,8 @@ class ActivePrompt extends React.PureComponent { if (this.state.submitted) return (
-

Answers submitted

+

{this.props.players_answered}/ + {this.props.players_total} players have responded

Please wait for the rest of the players to submit their answers.

@@ -390,7 +397,9 @@ class Game extends React.PureComponent { game_info: {}, player_info: {}, other_players: [], - prompts: [] + prompts: [], + active_prompt: null, + players_answered: 0 }; } @@ -438,12 +447,21 @@ class Game extends React.PureComponent { }); } + set_players_answered(players_answered) { + this.setState({ + players_answered: players_answered + }); + } + render() { const state = this.state; + const players_total = 1 + state.other_players.length; if (state.active_prompt) { return ; }