yatzy v1.0.0 Yatzy.Scoring View Source

Utility functions for calculating scores of a given roll.

Link to this section Summary

Functions

Checking what is the highest pair, trips, square, etc and the running total

Counting how many dice show a given number and summing the matching dice

Link to this section Types

Link to this type

t()

View Source
t() :: %Yatzy.Scoring{
  description: String.t(),
  name: String.t(),
  roll: Yatzy.Roll.t(),
  score: String.t() | nil
}

Link to this section Functions

Link to this function

chunk_by(roll, length)

View Source
chunk_by(roll :: [integer()], length :: integer()) :: integer()

Checking what is the highest pair, trips, square, etc and the running total

Examples

iex> Yatzy.Scoring.chunk_by([1, 1, 3, 3, 4], 2)
6
Link to this function

count(roll, value)

View Source
count(roll :: [integer()], value :: integer()) :: integer()

Counting how many dice show a given number and summing the matching dice

Examples

iex> Yatzy.Scoring.count([1, 2, 3, 3, 3], 3)
9