Pokex v0.2.0 Poker View Source

A foony module.

This implements the Five Card Draw poker game and its respective rules.

Link to this section Summary

Functions

Deals the cards of the deck to the players of the game

Exchanges card_list cards in hand for Player in spot_name with the top available in deck

Creates a new game session. It is actually the state of the game

Returns the Player at the requested spot

Initiates the table of the game with the given player list

Finds the winning spot amongst the players hands

Link to this section Functions

Deals the cards of the deck to the players of the game.

Fills the hands of the players. Also fills the Game.deck property with the rest of the cards.

Returns {:ok, game} containing the new state of the game ot {:error, reason} on error.

Link to this function exchange(game, spot_name, card_list) View Source

Exchanges card_list cards in hand for Player in spot_name with the top available in deck

Returns a new game {:ok, game} or {:error, reason} on failure

Creates a new game session. It is actually the state of the game.

Examples

iex> Poker.game()
{:ok,
%Game{
  deck: [],
  players: %Table{
    spot_five: nil,
    spot_four: nil,
    spot_one: nil,
    spot_six: nil,
    spot_three: nil,
    spot_two: nil
  },
  pot: nil
}}

Returns the Player at the requested spot.

Returns a %Player{} struct.

Link to this function players(player_list, game, mode \\ :add_players_soft) View Source

Initiates the table of the game with the given player list.

The player list is a list of tuples in the format {player_name, money_in_wallet}.

If any players where added before will be ignored. This is an initialization.

Returns {:ok, game} containing the new state of the game ot {:error, reason} on error.

Finds the winning spot amongst the players hands.

Returns {:winner, spot} when there is a definite winner, or {:tie, [spots]} with a list of spots that tie.