]> 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 a9911d760188ba0736a8f8fb1db15057ab97bbc5..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];