CardShark.Compare (CardShark v0.1.0) View Source
Module for comparing various cards and determining a 'winner'
Link to this section Summary
Functions
Return the high card from the given set, along with it's index.
Link to this section Functions
Specs
Return the high card from the given set, along with it's index.
Accepts an optional trump suit atom
The list of cards given should be in the order played, and it is assumed that the first card played determines the suit other cards need to be to be the high card (or be a trump card)
Examples
iex> cards = [%Card{face: "3", suit: :spades, value: 3}]
iex> Compare.high_card(cards)
{%Card{face: "3", suit: :spades, value: 3}, 0}
iex> cards = [
...> %Card{face: "3", suit: :spades, value: 3},
...> %Card{face: "6", suit: :diamonds, value: 6}
...> ]
iex> Compare.high_card(cards)
{%Card{face: "3", suit: :spades, value: 3}, 0}
iex> cards = [
...> %Card{face: "3", suit: :clubs, value: 3},
...> %Card{face: "8", suit: :clubs, value: 8}
...> ]
iex> Compare.high_card(cards)
{%Card{face: "8", suit: :clubs, value: 8}, 1}
iex> cards = [
...> %Card{face: "3", suit: :clubs, value: 3},
...> %Card{face: "ace", suit: :spades, value: 14},
...> %Card{face: "king", suit: :clubs, value: 13}
...> ]
iex> Compare.high_card(cards)
{%Card{face: "king", suit: :clubs, value: 13}, 2}
iex> cards = [
...> %Card{face: "3", suit: :clubs, value: 3},
...> %Card{face: "2", suit: :spades, value: 2},
...> %Card{face: "king", suit: :clubs, value: 13}
...> ]
iex> Compare.high_card(cards, :spades)
{%Card{face: "2", suit: :spades, value: 2}, 1}
iex> cards = [
...> %Card{face: "2", suit: :spades, value: 2},
...> %Card{face: "3", suit: :clubs, value: 3},
...> %Card{face: "king", suit: :clubs, value: 13}
...> ]
iex> Compare.high_card(cards, :spades)
{%Card{face: "2", suit: :spades, value: 2}, 0}
iex> cards = [
...> %Card{face: "2", suit: :spades, value: 2},
...> %Card{face: "3", suit: :clubs, value: 3},
...> %Card{face: "king", suit: :spades, value: 13}
...> ]
iex> Compare.high_card(cards, :diamonds)
{%Card{face: "king", suit: :spades, value: 13}, 2}