X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;ds=sidebyside;f=empathy%2Fempathy.jsx;h=feff7775a99f782188474bab923da9e1580b8327;hb=d7cc3b52d47ed3836cea1d82951ea4db6e8c591d;hp=0c1fccfe0b60e1a399c2d2bf2c27082c46c1c5eb;hpb=13c7633c804d5d1e51f2af1083f96e20b784ecfb;p=lmno.games diff --git a/empathy/empathy.jsx b/empathy/empathy.jsx index 0c1fccf..feff777 100644 --- a/empathy/empathy.jsx +++ b/empathy/empathy.jsx @@ -45,6 +45,12 @@ events.addEventListener("player-enter", event => { window.game.set_other_player_info(info); }); +events.addEventListener("player-exit", event => { + const info = JSON.parse(event.data); + + window.game.remove_player(info); +}); + events.addEventListener("player-update", event => { const info = JSON.parse(event.data); @@ -82,6 +88,10 @@ events.addEventListener("game-state", event => { window.game.set_end_judging(state.end_judging); window.game.set_scores(state.scores); + + window.game.set_new_game_votes(state.new_game_votes); + + window.game.state_ready(); }); events.addEventListener("prompt", event => { @@ -168,6 +178,18 @@ events.addEventListener("scores", event => { 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 * *********************************************************/ @@ -341,6 +363,45 @@ class CategoryRequest extends React.PureComponent { } } +const PromptOption = React.memo(props => { + + const prompt = props.prompt; + + if (prompt.votes_against.find(v => v === props.player.name)) + return false; + + return ( + + ); +}); + const PromptOptions = React.memo(props => { if (props.prompts.length === 0) @@ -353,29 +414,13 @@ const PromptOptions = React.memo(props => { Select any categories below that you'd like to play. You can choose as many as you'd like.
- {props.prompts.map(p => { - return ( - - ); - })} + {props.prompts.map( + prompt =>- The following players have completed judging: - {[...this.props.players_judged].join(', ')} -
+ let still_waiting = null; + const judging_players = Object.keys(this.props.players_judging); + if (judging_players.length) { + still_waiting = ( +- Still waiting for the following players: + Still waiting for the following player + {judging_players.length > 1 ? 's' : '' } + :
+ The following players have completed judging:{' '} + {[...this.props.players_judged].join(', ')} +
+ {still_waiting} {move_on_button}- The following players have submitted their answers: - {[...this.props.players_answered].join(', ')} -
+ let still_waiting = null; + const answering_players = Object.keys(this.props.players_answering);; + if (answering_players.length) { + still_waiting = ( +- Still waiting for the following players: + Still waiting for the following player + {answering_players.length > 1 ? 's' : ''} + :
+ The following players have submitted their answers:{' '} + {[...this.props.players_answered].join(', ')} +
+ {still_waiting} {move_on_button}Remember, you're trying to match your answers with what the other players submit. - Give {this.props.prompt.items} answers for the following prompt: + Give {this.props.prompt.items} answer + {this.props.prompt.items > 1 ? 's' : ''} for the following prompt: