yatzy v1.0.0 Yatzy.Sheet View Source

Operations on a sheets used to keep track of player's score

Link to this section Summary

Functions

Determine if the whole sheet has been filled out

Update the score sheet with a roll under a rule.

Calculate the total score for a given sheet

Link to this section Types

Link to this type

t()

View Source
t() :: %Yatzy.Sheet{
  chance: struct(),
  fives: struct(),
  four_of_a_kind: struct(),
  fours: struct(),
  large_straight: struct(),
  one_pair: struct(),
  ones: struct(),
  sixes: struct(),
  small_straight: struct(),
  three_of_a_kind: struct(),
  threes: struct(),
  two_pairs: struct(),
  twos: struct(),
  yatzy: struct()
}

Link to this section Functions

Link to this function

completed?(sheet)

View Source
completed?(sheet :: t()) :: boolean()

Determine if the whole sheet has been filled out

Example

iex> Yatzy.Sheet.completed?(%Yatzy.Sheet{})
false
Link to this function

record(sheet, roll, rule)

View Source
record(sheet :: t(), roll :: Yatzy.Roll.t(), rule :: atom()) :: t()

Update the score sheet with a roll under a rule.

Example

iex> Yatzy.Sheet.record(%Yatzy.Sheet{}, %Yatzy.Roll{dice: [1, 1, 1, 1, 1]}, :ones) |> Yatzy.Sheet.total()
5
Link to this function

total(sheet)

View Source
total(sheet :: t()) :: integer()

Calculate the total score for a given sheet

Examples

iex> Yatzy.Sheet.total(%Yatzy.Sheet{})
0