Pokex v0.2.0 Hand View Source

Summoning poker specific rules for comparing hands.

‘Deuce-to-seven low’ rules apply which means Ace is the highest card.

Link to this section Summary

Functions

Analyses the poker hand and returns a map with the sequences, pairs and suit information

Returns the rank the hand belongs to

Resolves the rank of a hand from a hand analysis map

Returns a high level score based on the rank and relevant cards to the card

Sorts a list of hands by it’s rank

Link to this section Types

Link to this type analysis() View Source
analysis() :: %{
  sequences: [Card.t()],
  pairs: [Card.t()],
  is_same_suit: boolean(),
  the_hand: [Card.t()]
}

Link to this section Functions

Link to this function analyze(hand) View Source
analyze(hand :: hand()) :: analysis()

Analyses the poker hand and returns a map with the sequences, pairs and suit information.

Sequences is a list, pairs is a list and is_same_suit is a boolean noting whether all cards are of the same suit or not.

Link to this function rank(hand) View Source
rank(hand :: hand()) :: rank()

Returns the rank the hand belongs to.

Returns an int from 1 to 9.

1 is the highest rank and 9 is the lowest.

Link to this function rank_from_analysis(hand_analysis) View Source
rank_from_analysis(hand_analysis :: analysis()) :: rank()

Resolves the rank of a hand from a hand analysis map.

Returns an int from 1 to 9.

1 is the highest rank and 9 is the lowest.

Link to this function score(hand) View Source
score(hand :: hand()) :: number()

Returns a high level score based on the rank and relevant cards to the card.

For example, for Two pairs it takes into consideration the high cards of each of the pairs.

Link to this function sort_hands(hand_list) View Source
sort_hands(hand_list :: [hand()]) :: [hand()]

Sorts a list of hands by it’s rank.

Highest ranking cards appear at the head of the list.