Pokex v0.2.0 Deck View Source
Creating a Deck of cards and working with lists of cards.
Link to this section Summary
Functions
Adds a card
to the corresponding pair list in pair_list
Adds a card
to the corrsponding sequence in sequence_list
Returns a list of list of pairs included in card_list
.
A lonely card (one that does not match with any other)
will not be included in the pair_list
returned
Returns a list of same-suit card lists
Returns a list of sequences of card values found in the card_list
if any. Else returns empty list
Checks if the first card is next* to the value of the second
- if desc: next is one step smaller
- if asc: next is one step bigger
Returns true if all cards in card_list are of the same suit or false if they aren’t
Orders a list of cards
Regular deck creation
Returns a list of 52 regularly orderd tuples representing the Standard 52-card deck.
Tuples are of the following format {value, suit}
Returns a shuffled 52-card deck. For deck description see @regular
Link to this section Functions
Adds a card
to the corresponding pair list in pair_list
Returns a list of lists.
If the card does not belong to any pair it is added to a new empty list
at the pair_list
.
Adds a card
to the corrsponding sequence in sequence_list
.
Returns a list of lists.
If the card does not belong to any sequence it is added to a new empty list
at the sequence_list
.
Returns a list of list of pairs included in card_list
.
A lonely card (one that does not match with any other)
will not be included in the pair_list
returned
Returns a list of same-suit card lists.
Cards that are not paired in suit with any other are in one-element lists.
Returns a list of sequences of card values found in the card_list
if any. Else returns empty list.
If given an empty list it returns an empty list.
Attention: this returns Descending order (High to Low)
Checks if the first card is next* to the value of the second
- if desc: next is one step smaller
- if asc: next is one step bigger
Returns true if all cards in card_list are of the same suit or false if they aren’t
Orders a list of cards.
Regular deck creation
Returns a list of 52 regularly orderd tuples representing the Standard 52-card deck.
Tuples are of the following format {value, suit}
.
Examples
iex> Enum.take( Deck.regular(), 8)
[
{:ace, :clubs},
{:ace, :diamonds},
{:ace, :hearts},
{:ace, :spades},
{:king, :clubs},
{:king, :diamonds},
{:king, :hearts},
{:king, :spades}
]
iex> Enum.count( Deck.regular())
52
Returns a shuffled 52-card deck. For deck description see @regular