X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;ds=inline;f=empathy%2Fempathy.jsx;h=dc13edf5063ad403d4ffca275fedb86b7b39ccca;hb=48039abb322ac4aaaf489b1de2eec88086a8e2dd;hp=c4aafde512166824ab87651015b2dd8fccc5e01e;hpb=84dc7d67e5ce98090b7790faab5543e2cf60653e;p=lmno.games diff --git a/empathy/empathy.jsx b/empathy/empathy.jsx index c4aafde..dc13edf 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); @@ -63,9 +69,29 @@ events.addEventListener("game-state", event => { window.game.set_active_prompt(state.active_prompt); - window.game.set_scores(state.scores); + window.game.set_players_answered(state.players_answered); + + 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); + + window.game.set_players_judged(state.players_judged); + + window.game.set_players_judging(state.players_judging); + + window.game.set_judging_idle(state.judging_idle); + + 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 => { @@ -92,6 +118,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); @@ -122,6 +154,12 @@ events.addEventListener("player-judging", event => { window.game.set_player_judging(player); }); +events.addEventListener("judging-idle", event => { + const value = JSON.parse(event.data); + + window.game.set_judging_idle(value); +}); + events.addEventListener("vote-end-judging", event => { const player = JSON.parse(event.data); @@ -140,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 * *********************************************************/ @@ -177,18 +227,23 @@ const PlayerInfo = React.memo(props => { if (! props.player.id) return null; + const all_players = [props.player, ...props.other_players]; + + const sorted_players = all_players.sort((a,b) => { + return b.score - a.score; + }); + + const names_and_scores = sorted_players.map(player => { + if (player.score) + return `${player.name} (${player.score})`; + else + return player.name; + }).join(', '); + return (
+ {text} +
+- The following players have completed judging: - {[...this.props.players_judged].join(', ')} -
+ let move_on_button = null; + + if (this.props.idle) { + move_on_button = ( + + ); + } + + 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}- Click on each pair of answers that should be scored as equivalent, - (and click any word twice to split it out from a group). Remember, + Click/tap on each pair of answers that should be scored as equivalent, + (or click a word twice to split it out from a group). Remember, what goes around comes around, so it's best to be generous when judging.
++ Also, for an especially fun or witty answer, you can give kudos + by clicking the star on the right. You may only do this for one + word/group. +
+- 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: