Skip to content

Commit

Permalink
improve voting start logic
Browse files Browse the repository at this point in the history
  • Loading branch information
probablyjassin committed Nov 18, 2024
1 parent c9433ef commit c1ac69b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions utils/command_helpers/vote_btn_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,14 @@ async def button_callback(
)

# check if vote is decided
if not (len(mogi.voters) >= len(mogi.players)) or not (
mogi.votes[max(mogi.votes, key=mogi.votes.get)]
>= math.floor(len(mogi.players) / 2) + 1
):
all_vote_counts = sorted(mogi.votes.values(), reverse=True)
second_highest_votes = all_vote_counts[1] if len(all_vote_counts) > 1 else 0

isDecided = len(mogi.voters) >= len(mogi.players) or max(
mogi.votes.values()
) > (second_highest_votes + (len(mogi.players) - len(mogi.voters)))

if not isDecided:
return

# get winning format
Expand Down

0 comments on commit c1ac69b

Please sign in to comment.