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

Models the Game of Islands.

Based on the book Functional Web Development by Lance Halvorsen.

Link to this section 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 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 square (row, col).

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.

Link to this section Functions

Link to this function

add_player(game_name, player2_name, gender, pid)

View Source

Specs

Adds the second player of a game.

Specs

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

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

Specs

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

Returns a sorted list of registered game names.

Specs

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

Specs

Lets the specified player guess square (row, col).

Link to this function

new_game(game_name, player1_name, gender, pid)

View Source

Specs

Starts a new game server process and supervises it.

Link to this function

position_all_islands(game_name, player_id)

View Source

Specs

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

Specs

Positions an island on the specified player's board.

Link to this function

set_islands(game_name, player_id)

View Source

Specs

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

Specs

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

Specs

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

Returns the tally of a game for the specified player.