View Source FiveHundred.Game (Five Hundred v0.1.0)

Models a game of 500

TODO:

  • score

Link to this section Summary

Link to this section Types

@type game_code() :: String.t()
@type state() :: :bidding | :playing | :waiting_for_players | :finished
@type t() :: %FiveHundred.Game{
  bid_exclusion: [FiveHundred.Player.t()],
  game_code: nil | game_code(),
  last_round_winner: nil | integer(),
  max_players: integer(),
  players: [FiveHundred.Player.t()],
  state: state(),
  turn: nil | integer(),
  winning_bid: nil | FiveHundred.PlayerBid.t()
}

Link to this section Functions

@spec advance_turn(t()) :: {:ok, t()}
@spec bid(t(), FiveHundred.PlayerBid.t()) ::
  {:ok,
   %FiveHundred.Game{
     bid_exclusion: term(),
     game_code: term(),
     last_round_winner: term(),
     max_players: term(),
     players: term(),
     state: term(),
     turn: term(),
     winning_bid: term()
   }}
  | {:error,
     :last_round_winner_must_bid_first
     | :not_bidding
     | :bid_not_high_enough
     | :cannot_bid}
@spec bid_advance(t()) :: {:ok, t()} | {:error, :not_bidding}
Link to this function

ensure_bid_is_higher(game, playerBid)

View Source
@spec ensure_bid_is_higher(t(), FiveHundred.PlayerBid.t()) ::
  {:ok, t()} | {:error, :bid_not_high_enough}
@spec ensure_bidding(t()) :: {:ok, t()} | {:error, :not_bidding}
Link to this function

ensure_can_bid(game, player_index)

View Source
@spec ensure_can_bid(t(), integer()) :: {:ok, t()} | {:error, atom()}
Link to this function

ensure_last_winner_has_bid_first(game, player_bid)

View Source
@spec ensure_last_winner_has_bid_first(t(), %FiveHundred.PlayerBid{
  bid: term(),
  player_index: term()
}) ::
  {:ok, t()} | {:error, :last_round_winner_bid_first}
Link to this function

ensure_turn(game, player_index)

View Source
@spec ensure_turn(t(), integer()) :: {:ok, t()} | {:error, :not_your_turn}
Link to this function

exclude_from_bidding(game, player_index)

View Source
@spec exclude_from_bidding(t(), integer()) :: {:ok, t()} | {:error, atom()}
@spec game_code(integer()) :: String.t()
@spec get_player(t(), String.t()) :: {:ok, String.t()} | {:error, atom()}
@spec join_game(t(), FiveHundred.Player.t()) :: {:ok, t()} | {:error, :max_players}
Link to this function

new_game(player, game_code, max_players \\ 4)

View Source
Link to this function

pass(game, player_index)

View Source
@spec pass(t(), integer()) :: {:ok, t()} | {:error, :not_your_turn | :not_bidding}
@spec ready_for_bidding?({:ok, t()}) :: {:ok, t()}
Link to this function

set_winning_bid(game, playerBid)

View Source
@spec set_winning_bid(t(), FiveHundred.PlayerBid.t()) :: {:ok, t()} | {:error, atom()}