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
@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.
@spec guess_coord( Islands.Game.name(), Islands.PlayerID.t(), Islands.Coord.row(), Islands.Coord.col() ) :: Islands.Tally.t() | {:error, term()}
Lets the specified player guess a square on the opponent's board.
@spec new_game( Islands.Game.name(), Islands.Player.name(), Islands.Player.gender(), pid() ) :: Supervisor.on_start_child()
Starts a new game server process and supervises it.
@spec position_all_islands(Islands.Game.name(), Islands.PlayerID.t()) :: Islands.Tally.t() | {:error, term()}
Positions all islands on the specified player's board.
@spec position_island( Islands.Game.name(), Islands.PlayerID.t(), Islands.Island.type(), Islands.Coord.row(), Islands.Coord.col() ) :: Islands.Tally.t() | {:error, term()}
Positions an island on the specified player's board.
@spec set_islands(Islands.Game.name(), Islands.PlayerID.t()) :: Islands.Tally.t() | {:error, term()}
Declares all islands set for the specified player.
@spec stop_game(Islands.Game.name(), Islands.PlayerID.t()) :: Islands.Tally.t() | {:error, term()}
Stops a game at a player's request.
@spec tally(Islands.Game.name(), Islands.PlayerID.t()) :: Islands.Tally.t() | {:error, term()}
Returns the tally of a game for the specified player.