Islands Engine v0.2.35 Islands.Engine 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.

Ends a game.

Returns a sorted list of registered game names.

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

Allows the specified player to guess a coordinate.

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.

Returns the tally of the game for the specified player.

Allows to update the specified player.

Link to this section Functions

Link to this function

add_player(game_name, player2_name, gender, pid)

View Source
add_player(String.t(), String.t(), Islands.Player.gender(), pid()) ::
  Islands.Tally.t() | :ok

Adds the second player of a game.

Link to this function

end_game(game_name)

View Source
end_game(String.t()) :: :ok

Ends a game.

Link to this function

game_names()

View Source
game_names() :: [String.t()]

Returns a sorted list of registered game names.

Link to this function

game_pid(game_name)

View Source
game_pid(String.t()) :: pid() | nil

Returns the pid of the game server process registered under 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

Allows the specified player to guess a coordinate.

Link to this function

new_game(game_name, player1_name, gender, pid)

View Source

Starts a new game.

Link to this function

position_all_islands(game_name, player_id)

View Source
position_all_islands(String.t(), Islands.PlayerID.t()) ::
  Islands.Tally.t() | :ok

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
set_islands(String.t(), Islands.PlayerID.t()) :: Islands.Tally.t() | :ok

Declares all islands set for the specified player.

Link to this function

stop_game(game_name, player_id)

View Source
stop_game(String.t(), Islands.PlayerID.t()) :: Islands.Tally.t() | :ok

Stops a game.

Link to this function

tally(game_name, player_id)

View Source

Returns the tally of the game for the specified player.

Link to this function

update_player(game_name, player_id, player_name, gender, pid)

View Source
update_player(
  String.t(),
  Islands.PlayerID.t(),
  String.t(),
  Islands.Player.gender(),
  pid()
) :: Islands.Tally.t() | :ok

Allows to update the specified player.