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

EffectFactory

Takes a card's params and returns a bound Effect closure.

EFFECTS

name -> factory. The engine is the sole authority on what's valid.

Exceptions

UnknownEffectError

A JSON card names an effect that is not in the EFFECTS vocabulary.

InvalidEffectParamsError

A JSON card's params are missing or the wrong type for its named effect.

DuplicateCardError

Two cards resolved to the same composed id.

Functions

_require_int_param(→ int)

Return params[key] as an int, or reject the card with InvalidEffectParamsError.

damage_composure(→ mundane.engine.state.Effect)

Return an effect that deals params['amount'] chaos to the opponent's Composure.

counter_task(→ mundane.engine.state.Effect)

Return an effect that counters a task on the stack (the old Noise Complaint). No params.

none(→ mundane.engine.state.Effect)

Return a no-op effect. Permanents name this so that every JSON card names an effect.

build_card(→ mundane.engine.state.Card)

Build one Card from a (schema-validated) JSON card dict in set set_id.

build_pool(→ dict[str, mundane.engine.state.Card])

Build {composed_id: Card} from one parsed set dict (offline; used by tests and the demo).

Module Contents

exception mundane.engine.cards.UnknownEffectError[source]

Bases: Exception

A JSON card names an effect that is not in the EFFECTS vocabulary.

exception mundane.engine.cards.InvalidEffectParamsError[source]

Bases: Exception

A JSON card’s params are missing or the wrong type for its named effect.

exception mundane.engine.cards.DuplicateCardError[source]

Bases: Exception

Two cards resolved to the same composed id.

type mundane.engine.cards.EffectFactory = Callable[[Mapping[str, object]], Effect][source]

Takes a card’s params and returns a bound Effect closure.

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 with InvalidEffectParamsError.

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 Card from a (schema-validated) JSON card dict in set set_id.

Composes the namespaced id set_id:id, looks the effect name up in EFFECTS (raising UnknownEffectError if absent), and binds params into the effect closure (the factory raises InvalidEffectParamsError on 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_loader does the same across multiple fetched sets; this is the pure, no-I/O helper for a single already-parsed set. Raises DuplicateCardError on a repeated id.