View Source Islands.Engine (Islands Engine v0.2.63)

Models the Game of Islands.

Based on the book Functional Web Development by Lance Halvorsen.

Summary

Functions

Adds the second player of a game.

Stops a game server process normally. It won't be restarted.

Returns a sorted list of registered game names.

Returns all the game overviews.

Returns the pid of the game server process registered via the given game_name, or nil if no such process is registered.

Lets the specified player guess a square on the opponent's board.

Starts a new game server process and supervises it.

Positions all islands on the specified player's board.

Positions an island on the specified player's board.

Declares all islands set for the specified player.

Stops a game at a player's request.

Returns the tally of a game for the specified player.

Functions

Link to this function

add_player(game_name, player2_name, gender, pid)

View Source
@spec add_player(
  Islands.Game.name(),
  Islands.Player.name(),
  Islands.Player.gender(),
  pid()
) ::
  Islands.Tally.t() | {:error, term()}

Adds the second player of a game.

@spec end_game(Islands.Game.name()) :: :ok | {:error, term()}

Stops a game server process normally. It won't be restarted.

@spec game_names() :: [Islands.Game.name()]

Returns a sorted list of registered game names.

@spec game_overviews() :: [Islands.Game.overview()]

Returns all the game overviews.

@spec game_pid(Islands.Game.name()) :: pid() | nil

Returns the pid of the game server process registered via the given game_name, or nil if no such process is registered.

Link to this function

guess_coord(game_name, player_id, row, col)

View Source

Lets the specified player guess a square on the opponent's board.

Link to this function

new_game(game_name, player1_name, gender, pid)

View Source

Starts a new game server process and supervises it.

Link to this function

position_all_islands(game_name, player_id)

View Source
@spec position_all_islands(Islands.Game.name(), Islands.PlayerID.t()) ::
  Islands.Tally.t() | {:error, term()}

Positions all islands on the specified player's board.

Link to this function

position_island(game_name, player_id, island_type, row, col)

View Source

Positions an island on the specified player's board.

Link to this function

set_islands(game_name, player_id)

View Source
@spec set_islands(Islands.Game.name(), Islands.PlayerID.t()) ::
  Islands.Tally.t() | {:error, term()}

Declares all islands set for the specified player.

Link to this function

stop_game(game_name, player_id)

View Source
@spec stop_game(Islands.Game.name(), Islands.PlayerID.t()) ::
  Islands.Tally.t() | {:error, term()}

Stops a game at a player's request.

Link to this function

tally(game_name, player_id)

View Source
@spec tally(Islands.Game.name(), Islands.PlayerID.t()) ::
  Islands.Tally.t() | {:error, term()}

Returns the tally of a game for the specified player.