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
check(match_id)
@spec check(binary()) :: :exist | :not_found
child_spec(init_arg)
Returns a specification to start this module under a supervisor.
See Supervisor
.
create_example_match()
@spec create_example_match() :: :ok
create_match(owner_username, match_id)
get(match_id)
Check whether a game exist.
get_last_match_id()
@spec get_last_match_id() :: term()
init(init_arg)
Callback implementation for GenServer.init/1
.
relay(match_id, payload)
relay/3 can be called by clients that associated with this game.
set(key, value)
set a game, distributed to all nodes.
set_authoritative(match_id, key, value)
set_authoritative/3 can only be called by server.