GenGame.Game.Gameplay (gen_game v0.1.1)

Core module to manage a game state.

Example create game, and then try to relay: iex > GenGame.Game.Gameplay.create_match("p1", "game_100") iex > :ok = GenGame.Game.Gameplay.relay("game_100", %{"enemy_1": %{hp: 100}}) iex > GenGame.Game.Gameplay.get(match_id)

Summary

Functions

Returns a specification to start this module under a supervisor.

Check whether a game exist.

Callback implementation for GenServer.init/1.

relay/3 can be called by clients that associated with this game.

set a game, distributed to all nodes.

set_authoritative/3 can only be called by server.

Functions

Link to this function

check(match_id)

@spec check(binary()) :: :exist | :not_found
Link to this function

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

create_example_match()

@spec create_example_match() :: :ok
Link to this function

create_match(owner_username, match_id)

@spec create_match(binary(), binary()) :: :ok
@spec get(binary()) :: term()

Check whether a game exist.

Link to this function

get_last_match_id()

@spec get_last_match_id() :: term()

Callback implementation for GenServer.init/1.

Link to this function

relay(match_id, payload)

@spec relay(binary(), map()) :: :ok | {:error, :not_found}

relay/3 can be called by clients that associated with this game.

Link to this function

set(key, value)

@spec set(binary(), term()) :: term()

set a game, distributed to all nodes.

Link to this function

set_authoritative(match_id, key, value)

@spec set_authoritative(binary(), binary(), term()) :: :ok | {:error, :not_found}

set_authoritative/3 can only be called by server.

Link to this function

start_link(default)