]> git.cworth.org Git - lmno.games/blobdiff - empathy/empathy.jsx
Fix category voting to select among only those with the most votes
[lmno.games] / empathy / empathy.jsx
index 570e585b3076bda4117842acc009a209a357215b..001dcd5eeeb5ac3f943d368f971f8a78d19981d3 100644 (file)
@@ -433,14 +433,14 @@ const PromptOptions = React.memo(props => {
 
 const LetsPlay = React.memo(props => {
 
-  const quorum = Math.round((props.num_players + 1) / 2);
+  const quorum = Math.max(0, props.num_players - props.prompts.length);
   const max_votes = props.prompts.reduce(
     (max_so_far, v) => Math.max(max_so_far, v.votes.length), 0);
 
   if (max_votes < quorum)
     return null;
 
-  const candidates = props.prompts.filter(p => p.votes.length >= quorum);
+  const candidates = props.prompts.filter(p => p.votes.length >= max_votes);
   const index = Math.floor(Math.random() * candidates.length);
   const winner = candidates[index];
 
@@ -1227,7 +1227,9 @@ class Game extends React.PureComponent {
               }
               return (
                 <li key={score.players[0]}>
-                {score.players.join("/")}: {score.score} {perfect} {quirkster}
+                  {score.players.join("/")}: {score.score}
+                  {score.kudos ? `, ${'★'.repeat(score.kudos)}` : ""}
+                  {perfect} {quirkster}
                 </li>
               );
             })}
@@ -1237,7 +1239,9 @@ class Game extends React.PureComponent {
             {state.scores.words.map(word => {
               return (
                 <li key={word.word}>
-                  {word.word} ({word.players.length}): {word.players.join(', ')}
+                  {word.word} ({word.players.length}
+                  {word.kudos.length ? `, ${'★'.repeat(word.kudos.length)}` : ""}
+                  ): {word.players.join(', ')}
                 </li>
               );
             })}
@@ -1306,15 +1310,15 @@ class Game extends React.PureComponent {
       <CategoryRequest
         key="category-request"
       />,
-      <PromptOptions
-        key="prompts"
-        prompts={state.prompts}
-        player={state.player_info}
-      />,
       <LetsPlay
         key="lets-play"
         num_players={1+state.other_players.length}
         prompts={state.prompts}
+      />,
+      <PromptOptions
+        key="prompts"
+        prompts={state.prompts}
+        player={state.player_info}
       />
     ];
   }