Skip to content

Adversarian/bazaar-sim

Repository files navigation

bazaar-sim

Battle simulator for The Bazaar.

Project Shape

This repo keeps combat logic in a pure simulator core and treats live game integration as an adapter around public JSON contracts.

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.

Development

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 hooks

Equivalent 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 Release

To install the local pre-commit gate, run:

make hooks

CI runs Rust formatting, Clippy linting, tests, release build checks, and the exporter lifecycle regression.

Local Data Extraction

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.db
  • local-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.json

data combat-coverage is the board-readiness gate. data prepare writes local-data/datapacks/current.json; there is no separate pack command.

Snapshot Simulation

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 test

Live Exporter

tools/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 Release

Manual runtime smoke checklist:

  1. Install the release mod package into the game folder.
  2. Start the game and confirm the overlay does not report Worker unavailable.
  3. Confirm <The Bazaar>/bazaar-sim/datapacks/current.json is created or reused.
  4. Press the configured export hotkey and confirm bazaar-sim/exports/combatant-player-*.json.
  5. Enter one fight and confirm bazaar-sim/fights/live-fight-*.json.
  6. Confirm bazaar-sim/results/sim-result-*.json is written.
  7. Confirm the overlay shows either Win | Loss | Draw or a diagnostic-backed failure.

CI And Releases

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 --release

Example Snapshots

Committed 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.

About

Battle simulator for The Bazaar.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages