I'm creating a single function called progress()
that is called after a player acts.
I think there are only 3 possible ways to end a poker game:
- Game ends normally, there are 2 or more players until last round ends, do the "showdown" phase, and determine winners
- Game ends abruptly, there is only one player remaining (all other players folded), that player wins, and his/her cards are not shown
- Game ends fast-forward, there are no players who can act (e.g.: all players act "all-in"), the remaining community cards are drawn, do showdown and determine winners.
Here's the current pseudocode:
Determine 'players in game' (i.e. players who hasn't folded)
If there are two or more players in game
If there are players who hasn't acted
Start next player turn
Else (all players has acted)
If all players all-in, OR all players ALL-IN except one player
(If there are less than one player who can act)
Ends game fast-forward: showdown and determine winners
Else (two or more players who didn't act ALL-IN)
If this round is last round ('River')
Ends game normally: showdown and determine winners
Else
Begin next round
Else (there is only one player in game)
Ends game abruptly: that one remaining player wins
Is there anything I missed?