asobi_quest (asobi_quests v0.2.2)

View Source

A quest definition: what to count, how far, over which window, for what.

A definition is data, not code. A game declares one from Lua (game.quests.define) or an operator posts one over RPC, and it lives in quests until it is deactivated. Nothing here is per-player; that is asobi_quest_progress.

counter is the name a quest listens for. game.quests.progress(player, "kills", 1) advances every active quest whose counter is kills, so one call from a game script can move a daily, a weekly and a lifetime quest at once without the script knowing any of them exist.

Summary

Functions

changeset(Data, Params)

-spec changeset(map(), map()) ->
                   #kura_changeset{valid :: boolean(),
                                   schema :: module() | undefined,
                                   data :: map(),
                                   params :: map(),
                                   changes :: map(),
                                   errors :: [{atom(), binary()}],
                                   types :: #{atom() => kura_types:kura_type()},
                                   required :: [atom()],
                                   action :: atom() | undefined,
                                   constraints ::
                                       [#kura_constraint{type ::
                                                             unique | foreign_key | check | exclusion,
                                                         constraint :: binary(),
                                                         field :: atom(),
                                                         message :: binary()}],
                                   assoc_changes :: #{atom() => #kura_changeset{} | [#kura_changeset{}]},
                                   prepare :: [fun((#kura_changeset{}) -> #kura_changeset{})],
                                   optimistic_lock :: atom() | undefined}.

Cast and validate a definition.

reward_amount > 0 without a reward_currency is rejected: it reads as a reward and pays nothing, and the claim path would have no currency to grant.

fields()

-spec fields() ->
                [#kura_field{name :: atom(),
                             type :: kura_types:kura_type(),
                             column :: binary() | undefined,
                             default :: term(),
                             primary_key :: boolean(),
                             nullable :: boolean(),
                             virtual :: boolean()}].

generate_id()

-spec generate_id() -> binary().

indexes()

-spec indexes() -> [{[atom()], map()}].

table()

-spec table() -> binary().