Skip to content

fix: require minimum 2 players to prevent infinite loop#29

Merged
MightyT-2 merged 1 commit intoMightyT-2:mainfrom
LakshmiSravya123:fix/28-minimum-player-count
Feb 15, 2026
Merged

fix: require minimum 2 players to prevent infinite loop#29
MightyT-2 merged 1 commit intoMightyT-2:mainfrom
LakshmiSravya123:fix/28-minimum-player-count

Conversation

@LakshmiSravya123
Copy link

@LakshmiSravya123 LakshmiSravya123 commented Feb 14, 2026

Summary

  • Fixed infinite loop when user enters "!" immediately with fewer than 2 players
  • Root cause: With 0 players, len(Player.playerList) / 2 = 0, making the while condition imposterCount <= 0 or imposterCount > 0 always true
  • Fix: The player entry loop now validates that at least 2 players exist before allowing exit. If the user types "!" too early, they see a message showing the current count and minimum requirement

Closes #28

Test plan

  • Typing "!" with 0 players now shows "You need at least 2 players! Currently have 0."
  • Typing "!" with 1 player shows the same warning
  • With 2+ players, "!" exits the loop as before
  • Duplicate name and empty input validation still works

When a user typed "!" immediately with fewer than 2 players,
the imposter count prompt entered an infinite loop because
`imposterCount > len(Player.playerList) / 2` with 0 players
evaluates to `imposterCount > 0`, which combined with
`imposterCount <= 0` is always true.

The fix validates that at least 2 players exist before allowing
the user to exit the player entry loop.
@LakshmiSravya123 LakshmiSravya123 force-pushed the fix/28-minimum-player-count branch from e4ac0c8 to eeb0da7 Compare February 15, 2026 05:12
@MightyT-2 MightyT-2 merged commit 5723f5c into MightyT-2:main Feb 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Infinite Loop Entered If There Are Less Than Two Imposters.

2 participants