yatzy v1.0.0 Yatzy.Player View Source

Module for player interactions

Link to this section Summary

Functions

Creating a new player with an empty score sheet.

Rolling the dice for the player

Saving the current roll in the score sheet

Calculating a user's total score

Link to this section Types

Link to this type

t()

View Source
t() :: %Yatzy.Player{
  current_roll: Yatzy.Roll.t(),
  name: String.t(),
  sheet: Yatzy.Sheet.t()
}

Link to this section Functions

Link to this function

new(name)

View Source
new(name :: String.t()) :: t()

Creating a new player with an empty score sheet.

Example

iex> Yatzy.Player.new("Bob")
%Yatzy.Player{name: "Bob", sheet: %Yatzy.Sheet{}, current_roll: %Yatzy.Roll{}}
Link to this function

roll(player, opts \\ [])

View Source
roll(player :: t(), opts :: Yatzy.Roll.options()) :: t()

Rolling the dice for the player

Link to this function

save(player, rule)

View Source
save(player :: t(), rule :: atom()) :: t()

Saving the current roll in the score sheet

Link to this function

score(player)

View Source
score(player :: t()) :: integer()

Calculating a user's total score