View Source Perudex.Hand (Perudex v0.6.0)
Provides functions to manipulate a hand of dice in Perudex.
Link to this section Summary
Functions
Add a die to the hand if the maximum defined by game rules is not busted.
Initialize a new hand for a player given his allowed dice holding count.
Remove a die from the hand if it is not empty.
Link to this section Types
@type die() :: 1..6
Link to this section Functions
Add a die to the hand if the maximum defined by game rules is not busted.
examples
Examples:
iex> Perudex.Hand.add(%Perudex.Hand{remaining_dice: 4})
%Perudex.Hand{remaining_dice: 5, dice: nil}
Initialize a new hand for a player given his allowed dice holding count.
examples
Examples:
iex> hand = Perudex.Hand.new(%Perudex.Hand{remaining_dice: 5})
iex> %{remaining_dice: 5} = hand
iex> length(hand.dice) == hand.remaining_dice
Remove a die from the hand if it is not empty.
examples
Examples:
iex> Perudex.Hand.take(%Perudex.Hand{remaining_dice: 5})
%Perudex.Hand{remaining_dice: 4, dice: nil}
iex> Perudex.Hand.take(%Perudex.Hand{remaining_dice: 0})
%Perudex.Hand{remaining_dice: 0, dice: nil}