mundane.api.schemas¶
Translate action JSON (a tagged union) into engine action dataclasses.
Every action body carries a type discriminator, e.g.
{"type": "play_card", "player": 0, "hand_index": 0}. The tags are exactly the keys of the
engine’s canonical ACTION_TYPES registry, so the HTTP surface mirrors the engine and the
round-trip action_to_dict -> parse_action() is the identity (covered by a test).
A body that does not describe a valid action — unknown type, missing field, wrong field type —
is rejected with IllegalAction, which the app maps to HTTP 422. No legality lives here; this
is pure translation.
Functions¶
|
Return |
|
Return |
|
Parse a tagged-union action body into the matching action dataclass. |
Module Contents¶
- mundane.api.schemas._require_int(body: dict[str, object], key: str) int[source]¶
Return
body[key]as an int, or reject the action if it is missing or not an integer.