mundane.engine.serialize¶
Serialisation helpers: turn a GameState into plain, JSON-ready data.
This is deliberately one-way (state -> dict -> JSON): the export/download feature never reads the
file back. Round-trip loading is out of scope; if it is added later, decode with msgspec
(msgspec.json.decode(data, type=GameState), msgspec ships with Litestar) rather than a
hand-written decoder.
Attributes¶
Functions¶
|
Recursively convert dataclass-derived data to JSON-native values (any Enum -> its value). |
|
Return a plain, JSON-ready dict for |
|
Return a JSON-ready dict for |
|
Serialise |
|
Serialise |
Module Contents¶
- mundane.engine.serialize._jsonify(value: object) object[source]¶
Recursively convert dataclass-derived data to JSON-native values (any Enum -> its value).
- mundane.engine.serialize.state_to_dict(state: mundane.engine.state.GameState) dict[str, object][source]¶
Return a plain, JSON-ready dict for
state. After M1 it holds only ids and scalars.
- mundane.engine.serialize.action_to_dict(action: mundane.engine.actions.Action) dict[str, object][source]¶
Return a JSON-ready dict for
action: its discriminator tag plus its fields.