v0.1.0 GameApp.Server

GameApp.Server provides a stateful process that maintains an internal game state and provides a public API for interacting with the game.

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

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

Generates a 4-letter code used as the identifier for a game server.

Joins a player to the game with the given shortcode.

Removes a player from the game with the given shortcode.

Selects a prompt to set for the current round.

Selects a reaction for the given player in the current round.

Selects a winner for the current round.

Starts the game with the given shortcode.

Starts the next round for the game with the given shortcode.

Returns a summary of the game state for a game with the given shortcode.

Returns a tuple used to register and lookup a game server process by name.

Link to this section Functions

Link to this function

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

game_pid(shortcode)

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

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

Link to this function

generate_shortcode()

generate_shortcode() :: String.t()

Generates a 4-letter code used as the identifier for a game server.

Link to this function

join(shortcode, player)

join(String.t(), GameApp.Player.t()) :: :ok

Joins a player to the game with the given shortcode.

Link to this function

leave(shortcode, player)

leave(String.t(), GameApp.Player.t()) :: :ok

Removes a player from the game with the given shortcode.

Link to this function

select_prompt(shortcode, prompt, channel_pid)

select_prompt(String.t(), String.t(), pid()) :: :ok

Selects a prompt to set for the current round.

Link to this function

select_reaction(shortcode, player, reaction, channel_pid)

select_reaction(String.t(), GameApp.Player.t(), String.t(), pid()) :: :ok

Selects a reaction for the given player in the current round.

Link to this function

select_winner(shortcode, winner, channel_pid)

select_winner(String.t(), GameApp.Player.t() | nil, pid()) :: :ok

Selects a winner for the current round.

Link to this function

start_game(shortcode)

start_game(String.t()) :: :ok

Starts the game with the given shortcode.

Link to this function

start_link(shortcode, player, config \\ %GameConfig{})

start_link(String.t(), GameApp.Player.t(), GameApp.Config.t()) ::
  {:ok, pid()} | :ignore | {:error, {:already_started, pid()} | term()}
Link to this function

start_round(shortcode, channel_pid)

start_round(String.t(), pid()) :: :ok

Starts the next round for the game with the given shortcode.

Link to this function

summary(shortcode)

summary(String.t()) :: GameApp.Game.t()

Returns a summary of the game state for a game with the given shortcode.

Link to this function

via_tuple(shortcode)

via_tuple(String.t()) :: {:via, Registry, {GameApp.Registry, String.t()}}

Returns a tuple used to register and lookup a game server process by name.