Islands.Game (Islands Game v0.1.29) View Source

Models a game in the Game of Islands.

Based on the book Functional Web Development by Lance Halvorsen.

Link to this section Summary

Link to this section Types

Specs

name() :: String.t()

Specs

overview() :: %{
  game_name: name(),
  player1: overview_player(),
  player2: overview_player()
}

Specs

overview_player() :: %{
  name: Islands.Player.name(),
  gender: Islands.Player.gender()
}

Specs

t() :: %Islands.Game{
  name: name(),
  player1: Islands.Player.t(),
  player2: Islands.Player.t(),
  request: Islands.Request.t(),
  response: Islands.Response.t(),
  state: Islands.State.t()
}

Link to this section Functions

Callback implementation for Access.fetch/2.

Link to this function

get_and_update(game, key, fun)

View Source

Callback implementation for Access.get_and_update/3.

Specs

haiku_name() :: name()

Generates a unique, URL-friendly name such as "bold-frog-8249".

Link to this function

new(name, player1_name, gender, pid)

View Source

Specs

new(name(), Islands.Player.name(), Islands.Player.gender(), pid()) ::
  t() | {:error, atom()}
Link to this function

notify_player(game, player_id)

View Source

Specs

notify_player(t(), Islands.PlayerID.t()) :: t()

Specs

Specs

overview(t()) :: overview()
Link to this function

player_board(game, player_id)

View Source

Specs

player_board(t(), Islands.PlayerID.t()) :: Islands.Board.t()

Callback implementation for Access.pop/2.

Specs

random_name() :: name()

Generates a random name.

Link to this function

update_board(game, player_id, board)

View Source

Specs

update_board(t(), Islands.PlayerID.t(), Islands.Board.t()) :: t()
Link to this function

update_guesses(game, player_id, hit_or_miss, guess)

View Source

Specs

update_guesses(
  t(),
  Islands.PlayerID.t(),
  Islands.Guesses.type(),
  Islands.Coord.t()
) :: t()
Link to this function

update_player(game, player_id, name, gender, pid)

View Source

Specs

update_player(
  t(),
  Islands.PlayerID.t(),
  Islands.Player.name(),
  Islands.Player.gender(),
  pid()
) :: t()
Link to this function

update_request(game, request)

View Source

Specs

update_request(t(), Islands.Request.t()) :: t()
Link to this function

update_response(game, response)

View Source

Specs

update_response(t(), Islands.Response.t()) :: t()
Link to this function

update_state(game, state)

View Source

Specs

update_state(t(), Islands.State.t()) :: t()