Islands State v0.1.7 Islands.State View Source

Implements a state machine for the Game of Islands.

Inspired by the book Functional Web Development by Lance Halvorsen.

Link to this section Summary

Link to this section Types

Link to this type

game_state()

View Source
game_state() ::
  :initialized | :players_set | :player1_turn | :player2_turn | :game_over
Link to this type

player_state()

View Source
player_state() :: :islands_not_set | :islands_set
Link to this type

request()

View Source
request() ::
  :add_player
  | {:position_island, Islands.PlayerID.t()}
  | {:position_all_islands, Islands.PlayerID.t()}
  | {:set_islands, Islands.PlayerID.t()}
  | {:guess_coord, Islands.PlayerID.t()}
  | {:stop, Islands.PlayerID.t()}
  | {:win_check, :no_win | :win}
Link to this type

t()

View Source
t() :: %Islands.State{
  game_state: game_state(),
  player1_state: player_state(),
  player2_state: player_state()
}

Link to this section Functions

Link to this function

check(state, arg2)

View Source
check(t(), request()) :: {:ok, t()} | :error

Callback implementation for Access.fetch/2.

Link to this function

get(state, key, default)

View Source
Link to this function

get_and_update(state, key, fun)

View Source

Callback implementation for Access.get_and_update/3.

Callback implementation for Access.pop/2.