Skip to main content

Module save

Module save 

Source
Expand description

Save/load for dotzuki run: GameSave, a versioned JSON snapshot.

The save lives at <project>/.dotzuki-save.json (a dotfile in the project dir; override with --save-file). It captures only stable overworld state — current map, player tile + facing, persistent story flags, language — never a suspended scene engine, so it is written at stable points (see crate::game::RunnerGame) and resumes into a fresh overworld.

A plain versioned serde JSON file was chosen over the engine’s binary slot/CRC16 framework (dotzuki_engine::save): one file, human-readable, trivially debuggable, and corruption tolerance is handled by the load-then-validate path below. Loading never fails hard: a missing, unreadable, corrupt or version-mismatched file logs a warning and returns None, and the game boots fresh.

Structs§

GameSave
A dotzuki run save file.
PartyMemberSave
One party member’s persistent battle state (v2): current HP/MP and the non-volatile status (a kind: Status record id) carried between battles. Base stats are NOT saved — they are rebuilt from the records each battle. With a battle.levels block, level/exp ride along as OPTIONAL fields (the version stays 3: a save without them simply defaults to level 1 / 0 EXP, and older tooling ignores unknown keys).
PlayerSave
Saved player state (tile coordinates + facing + elevation level).

Constants§

DEFAULT_SAVE_FILE
Default save file name in the project directory.
SAVE_VERSION
Current save format version. Saves from a NEWER version are ignored (fresh boot); older saves load with per-field defaults (v1 has no party or inventory — both start fresh; v1/v2 have no money — the manifest’s shop.startMoney default applies; party members without level/exp default to level 1 / 0 EXP — the levels fields are optional, so the version stays 3).