X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=empathy%2Fempathy.jsx;h=90bf0fd360829299facce85a1e3593c3a82db63a;hb=3259884cd8389a4467d8abc160b2eb64eb215323;hp=0c1fccfe0b60e1a399c2d2bf2c27082c46c1c5eb;hpb=13c7633c804d5d1e51f2af1083f96e20b784ecfb;p=lmno.games diff --git a/empathy/empathy.jsx b/empathy/empathy.jsx index 0c1fccf..90bf0fd 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.disable_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 * *********************************************************/ @@ -205,23 +227,43 @@ const PlayerInfo = React.memo(props => { if (! props.player.id) return null; - const all_players = [props.player, ...props.other_players]; + const all_players = [{...props.player, active:true}, ...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 a new array with the separator interspersed between + * each element of the array passed in as the argument. + */ + function intersperse(arr, sep) { + return arr.reduce((acc, val) => [...acc, sep, val], []).slice(1); + } + + let names_and_scores = sorted_players.map(player => { + if (player.score) { + return ( + + {player.name} ({player.score}) + + ); + } else { + if (player.active) + return player.name; + else + return null; + } + }).filter(component => component != null); + + names_and_scores = intersperse(names_and_scores, ", "); return (
+ {text} +
+- 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}- 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. +
++ Still waiting for the following player + {answering_players.length > 1 ? 's' : ''} + : +
+- The following players have submitted their answers: + The following players have submitted their answers:{' '} {[...this.props.players_answered].join(', ')}
-- Still waiting for the following players: -
-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: