Battle simulator for The Bazaar.
This repo keeps combat logic in a pure simulator core and treats live game integration as an adapter around public JSON contracts.
- Agent instructions: AGENTS.md
- Claude wrapper: CLAUDE.md
- Architecture: docs/ARCHITECTURE.md
- Contracts: docs/SPEC.md
Local game cache inspection data belongs in local-data/, which is gitignored.
The packaged production worker/CLI is the Rust native bazaar-sim binary. Rust is also the local simulator and data-tooling source of truth.
The root Makefile is a thin convenience layer around Cargo and dotnet:
make check
make fmt-fix
make lint-fix
make data-prepare SOURCE="/path/to/The Bazaar/or/GameData.db.zip"
make hooksEquivalent underlying commands:
cargo fmt --all --check
cargo fmt --all
cargo clippy --all-targets --all-features -- -D warnings
cargo clippy --fix --all-targets --all-features --allow-dirty -- -D warnings
cargo test
cargo build -p bazaar-sim --release
cargo run -p bazaar-sim -- data prepare --source "/path/to/The Bazaar/or/GameData.db.zip"
dotnet run --project tests/exporter-lifecycle/BazaarSimExporter.LifecycleTests.csproj -c ReleaseTo install the local pre-commit gate, run:
make hooksCI runs Rust formatting, Clippy linting, tests, release build checks, and the exporter lifecycle regression.
Generated reports and data packs belong under ignored local-data/.
From a clean clone, prepare local data from a GameData.db, a GameData.db.zip, or a folder containing either file:
cargo run -p bazaar-sim -- data prepare --source "/path/to/The Bazaar/or/GameData.db.zip"This writes:
local-data/GameData/GameData.dblocal-data/datapacks/current.json
Both files are local artifacts and must not be committed.
cargo run -p bazaar-sim -- data inventory --db local-data/GameData/GameData.db --out local-data/reports/inventory.json
cargo run -p bazaar-sim -- data coverage --db local-data/GameData/GameData.db --out local-data/reports/coverage.json
cargo run -p bazaar-sim -- data combat-coverage --db local-data/GameData/GameData.db --out local-data/reports/combat-coverage.jsondata combat-coverage is the board-readiness gate. data prepare writes local-data/datapacks/current.json; there is no separate pack command.
Manual/custom board sim:
cargo run -p bazaar-sim -- sim --data-pack local-data/datapacks/current.json --player local-data/live/player.json --opponent monster:<monster-id> --iterations 1000 --seed testtools/bazaar-sim-exporter contains the BepInEx plugin for live player board export and the first in-game post-lock overlay. It loads, listens for the configured hotkey, and attempts to write a CombatantSnapshot under <The Bazaar>/bazaar-sim/exports.
The exporter maps TheBazaar.Data.Run.Player into the public snapshot contract by reflection. If required runtime state is unavailable, it writes an explicit export-error-*.json diagnostic instead of a valid-looking partial snapshot. It does not implement combat semantics in the game process; it delegates data-pack preparation and simulation to the bundled hidden worker executable.
Local build from the repo root:
dotnet build tools/bazaar-sim-exporter/BazaarSimExporter.csproj -c ReleaseManual runtime smoke checklist:
- Install the release mod package into the game folder.
- Start the game and confirm the overlay does not report
Worker unavailable. - Confirm
<The Bazaar>/bazaar-sim/datapacks/current.jsonis created or reused. - Press the configured export hotkey and confirm
bazaar-sim/exports/combatant-player-*.json. - Enter one fight and confirm
bazaar-sim/fights/live-fight-*.json. - Confirm
bazaar-sim/results/sim-result-*.jsonis written. - Confirm the overlay shows either
Win | Loss | Drawor a diagnostic-backed failure.
GitHub Actions runs Rust format, Clippy, tests, release build checks, and the exporter lifecycle test on pushes and pull requests.
Pushing a v* tag runs the release workflow. It validates the repo, builds the Rust worker/CLI with cargo build -p bazaar-sim --release, publishes an installable mod package with BazaarSimExporter.dll plus the bundled hidden Windows worker executable, publishes standalone Linux and Windows bazaar-sim CLI packages, and creates or updates the matching GitHub release.
Local production CLI executable build from the repo root:
cargo build -p bazaar-sim --releaseCommitted examples use fake card ids and do not contain game data:
examples/combatants/player.json: user-facing board export shape.examples/live-fights/fight-locked.json: debug post-lock overlay replay shape.