yatzy v1.0.0 Yatzy.Game View Source

Game module responsible for :

  • starting a new game
  • delegating player interactions based on game's turn
  • finishing a game

Link to this section Summary

Functions

Finish the game and calculate the results

Create a new game with a list of players

(Re)Rolling the dice for a given player

Saving a player's current roll and ending that player's turn.

Link to this section Types

Link to this type

options()

View Source
options() :: [initial_player :: String.t()]
Link to this type

t()

View Source
t() :: %Yatzy.Game{
  current_player: String.t() | nil,
  players: %{required(String.t()) => Yatzy.Player.t()} | nil,
  result: :pending | Yatzy.Result.t()
}

Link to this section Functions

Link to this function

finish(game)

View Source
finish(game :: t()) :: t()

Finish the game and calculate the results

Link to this function

new(player_names, options \\ [])

View Source
new(player_names :: [String.t()], options :: options()) :: t()

Create a new game with a list of players

Link to this function

roll(game, player_name, opts \\ [])

View Source
roll(game :: t(), player_name :: String.t(), opts :: Yatzy.Roll.options()) ::
  t()

(Re)Rolling the dice for a given player

Link to this function

save(game, player_name, rule)

View Source
save(game :: t(), player_name :: String.t(), rule :: atom()) :: t()

Saving a player's current roll and ending that player's turn.