Skip to main content

dotzuki_runner/
lib.rs

1//! Generic runtime for **zero-Rust game projects**.
2//!
3//! A game project is a directory with a `.dotzuki-editor.json` manifest, a
4//! `dataRoot` holding `maps/<MapId>/` directories (Tiled `map.tmx.json` +
5//! `tileset.png` + `objects.json` sidecar + per-map `script.scene`), and a
6//! scenes directory with story `.scene` files. See
7//! `docs/reference/project-manifest.md` for the full contract.
8//!
9//! This crate boots such a project without any game-specific Rust:
10//!
11//! - [`manifest`] — serde model of `.dotzuki-editor.json`;
12//! - [`project`] — [`project::LoadedProject`]: manifest → DSL compile →
13//!   script registry + storyline routes + entry scene/map resolution;
14//! - [`map`] — [`map::RuntimeMap`]: TMX layers, collision grid, objects
15//!   sidecar (NPCs/warps/signs);
16//! - [`tileset`] — [`tileset::PngTileset`]: a `tileset.png` atlas sliced into
17//!   per-tile RGBA pixels, addressable by 1-based Tiled GID;
18//! - [`game`] — [`game::RunnerGame`]: the playable runtime (overworld +
19//!   scene VM + dialogue/choice UI), implementing `dotzuki_app::GameLoop` for
20//!   window mode and exposing windowless `update`/`draw` for headless use;
21//! - [`headless`] — [`headless::run_headless`]: a windowless frame driver
22//!   with auto-A input and PNG screenshots (native only);
23//! - [`watch`] — [`watch::ProjectWatcher`]: notify-based file watching for
24//!   `dotzuki run --watch` hot reload (feature `watch`);
25//! - [`vfs`] — [`vfs::ProjectFiles`]: the virtual file system every project
26//!   read goes through ([`vfs::DiskFiles`] native, [`vfs::MemoryFiles`] for
27//!   the WASM shell);
28//! - [`audio`] — [`audio::RunnerAudio`]: optional music/SFX playback for
29//!   scene audio commands (dotzuki-audio APU + cpal; silent when a project has
30//!   no `data/audio/` tracks or no output device is available);
31//! - [`battle`] — the generic, data-driven battle system (manifest `battle`
32//!   section → record-driven combatants, party switching, battle-usable
33//!   items, the standard damage formula, a menu/narration turn loop,
34//!   `startBattle` scene integration);
35//! - [`save`] — [`save::GameSave`]: versioned JSON save/load at
36//!   `<project>/.dotzuki-save.json`, written at stable overworld points.
37
38pub mod audio;
39pub mod battle;
40pub mod game;
41#[cfg(not(target_arch = "wasm32"))]
42pub mod headless;
43pub mod manifest;
44pub mod map;
45pub mod project;
46pub mod save;
47pub mod tileset;
48pub mod vfs;
49#[cfg(all(feature = "watch", not(target_arch = "wasm32")))]
50pub mod watch;
51
52pub use audio::RunnerAudio;
53pub use battle::hooks::validate_ruleset;
54pub use battle::{Battle, BattleOutcome};
55pub use game::{RunnerGame, RunnerOptions, SCREEN_H, SCREEN_W};
56#[cfg(not(target_arch = "wasm32"))]
57pub use headless::{run_headless, HeadlessOptions};
58pub use map::{EncounterConfig, EncounterTableEntry, EncounterZone, MapObjects, NpcDef, RuntimeMap, SignDef, WarpDef};
59pub use project::LoadedProject;
60pub use save::{GameSave, PlayerSave, DEFAULT_SAVE_FILE, SAVE_VERSION};
61pub use tileset::PngTileset;
62pub use vfs::{DiskFiles, MemoryFiles, ProjectFiles};
63#[cfg(all(feature = "watch", not(target_arch = "wasm32")))]
64pub use watch::ProjectWatcher;