X-Git-Url: https://git.cworth.org/git?p=lmno.games;a=blobdiff_plain;f=empathy%2Fempathy.jsx;h=0c1fccfe0b60e1a399c2d2bf2c27082c46c1c5eb;hp=e67bbc87afbc91941c7460bb52aeb865aeac0d5b;hb=13c7633c804d5d1e51f2af1083f96e20b784ecfb;hpb=c94f971a08bd2e26c0b81dc0b029b2ca59941d96 diff --git a/empathy/empathy.jsx b/empathy/empathy.jsx index e67bbc8..0c1fccf 100644 --- a/empathy/empathy.jsx +++ b/empathy/empathy.jsx @@ -205,18 +205,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 (
Players: - {props.player.name} - {props.player.score > 0 ? ` (${props.player.score})` : ""} - {props.other_players.map(other => ( - - {", "} - {other.name} - {other.score > 0 ? ` (${other.score})` : ""} - - ))} + {names_and_scores}
); });