mundane.engine.cards¶
The effect vocabulary (the fixed set of behaviours) and the JSON-card loader.
This is the ONLY place effect functions live. A JSON card names an effect from EFFECTS and
supplies params; it cannot define new behaviour. build_card() composes the namespaced id
set_id:id and binds the named effect’s params into a closure. The hardcoded CARD_LIBRARY
is gone: card content now lives in JSON sets (see mundane-cards), fetched and validated by the
API, while card behaviour stays here as code.
Attributes¶
Takes a card's |
|
name -> factory. The engine is the sole authority on what's valid. |
Exceptions¶
A JSON card names an effect that is not in the |
|
A JSON card's |
|
Two cards resolved to the same composed id. |
Functions¶
|
Return |
|
Return an effect that deals |
|
Return an effect that counters a task on the stack (the old Noise Complaint). No params. |
|
Return a no-op effect. Permanents name this so that every JSON card names an effect. |
|
Build one |
|
Build |
Module Contents¶
- exception mundane.engine.cards.UnknownEffectError[source]¶
Bases:
ExceptionA JSON card names an effect that is not in the
EFFECTSvocabulary.
- exception mundane.engine.cards.InvalidEffectParamsError[source]¶
Bases:
ExceptionA JSON card’s
paramsare missing or the wrong type for its named effect.
- exception mundane.engine.cards.DuplicateCardError[source]¶
Bases:
ExceptionTwo cards resolved to the same composed id.
- type mundane.engine.cards.EffectFactory = Callable[[Mapping[str, object]], Effect][source]¶
Takes a card’s
paramsand returns a boundEffectclosure.
- mundane.engine.cards._require_int_param(params: collections.abc.Mapping[str, object], key: str) int[source]¶
Return
params[key]as an int, or reject the card withInvalidEffectParamsError.
- mundane.engine.cards.damage_composure(params: collections.abc.Mapping[str, object]) mundane.engine.state.Effect[source]¶
Return an effect that deals
params['amount']chaos to the opponent’s Composure.
- mundane.engine.cards.counter_task(_params: collections.abc.Mapping[str, object]) mundane.engine.state.Effect[source]¶
Return an effect that counters a task on the stack (the old Noise Complaint). No params.
- mundane.engine.cards.none(_params: collections.abc.Mapping[str, object]) mundane.engine.state.Effect[source]¶
Return a no-op effect. Permanents name this so that every JSON card names an effect.
- mundane.engine.cards.EFFECTS: dict[str, EffectFactory][source]¶
name -> factory. The engine is the sole authority on what’s valid.
- Type:
The fixed effect vocabulary
- mundane.engine.cards.build_card(set_id: str, card_dict: collections.abc.Mapping[str, object]) mundane.engine.state.Card[source]¶
Build one
Cardfrom a (schema-validated) JSON card dict in setset_id.Composes the namespaced id
set_id:id, looks theeffectname up inEFFECTS(raisingUnknownEffectErrorif absent), and bindsparamsinto the effect closure (the factory raisesInvalidEffectParamsErroron bad params).
- mundane.engine.cards.build_pool(set_dict: collections.abc.Mapping[str, object]) dict[str, mundane.engine.state.Card][source]¶
Build
{composed_id: Card}from one parsed set dict (offline; used by tests and the demo).The API’s
set_loaderdoes the same across multiple fetched sets; this is the pure, no-I/O helper for a single already-parsed set. RaisesDuplicateCardErroron a repeated id.