v0.1.0 GameApp.Round
GameApp.Round
defines a struct that encapsulates Round state as well as
functions that update the round state.
Link to this section Summary
Functions
Creates a round for the given round number.
Removes the reaction for a player in a round.
Sets the prompt for a round.
Sets the reaction for a player in a round.
Sets the winner for a round.
Link to this section Types
Link to this type
t()
t() :: %GameApp.Round{ number: integer(), prompt: String.t() | nil, reactions: map(), winner: GameApp.Player.t() | nil }
Link to this section Functions
Creates a round for the given round number.
Examples
iex> Round.create(number: 1)
%Round{
number: 1,
winner: nil,
reactions: %{}
}
Link to this function
remove_reaction(round, player)
remove_reaction(GameApp.Round.t(), GameApp.Player.t()) :: GameApp.Round.t()
Removes the reaction for a player in a round.
Examples
iex> r = Round.create(number: 1)
iex> p = Player.create(id: "1", name: "Gamer")
iex> r = Round.set_reaction(r, p, "OMG!")
iex> Round.remove_reaction(r, p)
%Round{
number: 1,
winner: nil,
reactions: %{}
}
Link to this function
set_prompt(round, prompt)
set_prompt(GameApp.Round.t(), String.t()) :: GameApp.Round.t()
Sets the prompt for a round.
Examples
iex> r = Round.create(number: 1)
iex> Round.set_prompt(r, "Wat")
%Round{
number: 1,
prompt: "Wat",
winner: nil,
reactions: %{}
}
Link to this function
set_reaction(round, player, reaction)
set_reaction(GameApp.Round.t(), GameApp.Player.t(), String.t()) :: GameApp.Round.t()
Sets the reaction for a player in a round.
Examples
iex> r = Round.create(number: 1)
iex> Round.set_reaction(r, Player.create(id: "1", name: "Gamer"), "OMG!")
%Round{
number: 1,
winner: nil,
reactions: %{
"1" => "OMG!"
}
}
Link to this function
set_winner(round, winner)
set_winner(GameApp.Round.t(), GameApp.Player.t() | nil) :: GameApp.Round.t()
Sets the winner for a round.
Examples
iex> r = Round.create(number: 1)
iex> Round.set_winner(r, Player.create(id: "1", name: "Gamer"))
%Round{
number: 1,
winner: %Player{id: "1", name: "Gamer"},
reactions: %{}
}