cardgames.games.poker_game.PokerGame
- class cardgames.games.poker_game.PokerGame(loadout, players, instructions)
Bases:
cardgames.components.game.GameA class to simulate a game of poker.
- __init__(loadout, players, instructions)
Initialises attributes, and sets up a loop that starts a new game until there is a winner, or the game is exited.
- Parameters
loadout (str) – name of saved game to load (not yet functioning)
players (list(str)) –
instructions (bool) – show instructions
Methods
__init__(loadout, players, instructions)Initialises attributes, and sets up a loop that starts a new game until there is a winner, or the game is exited.
assess(p)Assess the cards of a player to find the best hand given the community cards.
Simulates one game of poker, consisting of five rounds (Preflop, Flop, Turn, River and Showdown).
Prints the player's options and asks each user for input to either: check, call, raise or fold.
Iterates through list of player names, and checks each player's status to see if player has previously folded or gone all in before presenting the player with a choice of actions.
reveal()Assesses the players cards to reveal the winner.
Attributes
List of player names :type: list
- assess(p: cardgames.components.player.Player)
Assess the cards of a player to find the best hand given the community cards.
Lists all pairwise combinations of the 5 community and 2 player cards, and uses the combinations to find all pairs, triples, and four-of-a-kinds, and sets the players best_cards attribute to the best hand the player has. TODO (Flushes and full houses not calculated yet.)
- Parameters
p (player.Player) – player
- next_game()
Simulates one game of poker, consisting of five rounds (Preflop, Flop, Turn, River and Showdown).
- player_choice(p)
Prints the player’s options and asks each user for input to either: check, call, raise or fold. Adjusts the player’s attributes and the game’s attributes accordingly.
- Parameters
p (
player.Player) – player- Returns
player
- Return type
player.Player
- player_names
List of player names :type: list
- player_turns()
Iterates through list of player names, and checks each player’s status to see if player has previously folded or gone all in before presenting the player with a choice of actions.