Skip to content

Fix infinite loop when less than 2 players#30

Closed
twt1978 wants to merge 1 commit intoMightyT-2:mainfrom
twt1978:main
Closed

Fix infinite loop when less than 2 players#30
twt1978 wants to merge 1 commit intoMightyT-2:mainfrom
twt1978:main

Conversation

@twt1978
Copy link

@twt1978 twt1978 commented Feb 14, 2026

This PR fixes the infinite loop issue described in #28.

Problem:
If the user enters "!" immediately when prompted for player names, the game will enter an infinite loop when prompted for an imposter count.

Solution:

  • Added validation to ensure at least 2 players before proceeding
  • Prevents infinite loop in imposter count selection
  • Maintains game flow while ensuring proper player count

Changes:

  • Added a while loop after player collection that ensures at least 2 players
  • User is prompted to add more players until minimum count is satisfied
  • Preserves existing game logic and user experience

Testing:

  • Tested with 0 initial players (prompts for at least 2)
  • Tested with 1 initial player (prompts for one more)
  • Tested with 2+ initial players (proceeds normally)

Fixes #28

- Added validation to ensure at least 2 players before proceeding
- Prevents infinite loop in imposter count selection
- Maintains game flow while ensuring proper player count

Fixes MightyT-2#28
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