# Timestorm Baseball

A standalone browser-first Three.js baseball prototype for `NES_Timestorm_Baseball`.

## Play

Open `index.html` directly in a browser. No npm, Python, build step, or local web server is required for gameplay.

The game includes:

- Title, team select, lineup, match, half-inning summary, and game-over screens.
- Blue team: Founding Fathers.
- Red team: British Union.
- A full inning loop with outs, balls, strikes, base runners, scoring, side switches, regulation ending, and extra innings.
- A local Three.js field renderer that attempts to load `assets/models/wrigley_field_mcp.glb` and keeps a procedural Wrigley-style fallback for direct `file://` play.
- Card drop-in support using predictable filenames in `assets/cards/`.

## Controls

- `Space`: swing.
- `P`: power swing.
- `T`: take pitch.
- `B`: bunt.
- `Enter`: continue from half-inning summary.

## Card assets

The lineup first tries generated files in `assets/cards/` using these naming patterns:

- `blue-george-washington.webp`, `.png`, `.jpg`, `.svg`
- `george-washington.webp`, `.png`, `.jpg`, `.svg`

Equivalent names are used for every roster member. If no asset is present, the game uses a procedural SVG fallback.

## Local vision-model tooling

Open `tools/vision-test.html` to build and submit ComfyUI workflows against `/home/jetson/ComfyUI` running on `http://127.0.0.1:8188`.

The harness supports:

- Flux2 Klein split-model card workflows.
- Founding Father 9-card batch generation.
- BiRefNet background cleanup for uploaded image QA.
- ComfyUI `/object_info` capability probing.
- `POST /api/prompt` and `POST /prompt`.
- `GET /api/history_v2/{prompt_id}` and `GET /history/{prompt_id}`.

## ROM research

Open `tools/rom-research.html` and choose `research/source/BaseballUSAEurope.nes` to parse the ROM locally in the browser. The current local metadata and PRG/CHR split artifacts are stored under `research/`.

ROM binaries are ignored by `.gitignore` and should not be distributed unless the project has explicit rights.

## Wrigley field assets

The local GLB and texture source inventory were copied from `/home/jetson/blender-wrigley-field` into:

- `assets/models/wrigley_field_mcp.glb`
- `assets/textures/wrigley/source/`
- `assets/textures/wrigley/manifest.json`

## Coding model

This project follows Eric Rhea's coding model guide: smallest useful change, proof-first where possible, clear ownership boundaries, files kept under 1100 lines, bounded commands, and honest verification reporting.

## Browser gameplay self-test

Open `tools/game-selftest.html` directly in a browser and press **Run Self-Test**. It loads `index.html` in an iframe, clicks through title/team-select/lineup/match, drives deterministic pitch outcomes, and proves the browser runtime can reach game over without npm or Python.

## Standalone asset audit

Open `tools/asset-audit.html` directly in a browser and choose the `NES_Timestorm_Baseball` folder. It checks the local package for the runtime files, Three.js bundle, Wrigley GLB, Wrigley texture inventory, ROM research metadata, browser tools, and all 18 roster card placeholders without npm, Python, or a server.

## Generated local-AI cards

All 18 roster cards have local ComfyUI-generated PNG runtime assets in `assets/cards/`. Per-card provenance records are under `research/generated-ai-cards/`, and the reusable Flux2 workflows are under `research/generated-workflows/`. SVG fallback cards remain in place for review and rollback.

## Card QA and authenticity dashboard

Open `tools/card-qa.html` to review all 18 generated roster cards and export a JSON QA report. Open `tools/authenticity-dashboard.html` to compare current browser implementation evidence against the ROM research lanes and remaining screenshot/evidence gaps. Both pages run directly from local files.

## Evidence reports

Current browser evidence artifacts are stored under `research/evidence/browser/`. `evidence-runner-report.json` is the combined browser report; `game-selftest-report.json` and `asset-audit-report.json` are split summaries derived from the same passing run. Generated-card QA evidence is stored under `research/generated-ai-cards/card-qa-report.json` and `research/generated-ai-cards/card-qa-contact-sheet.png`.

## ROM deconstruction artifacts

ROM research artifacts are under `research/extracted/rom/`: `deconstruction-summary.json`, `chr-pattern-table.png`, `prg-strings.json`, and `prg-strings.txt`. These are generated from the local ignored ROM copy and support authenticity review without requiring the game runtime to load the ROM.

Direct file-open evidence is captured at `research/evidence/browser/index-file-open.png`. The full deterministic gameplay and asset evidence report is `research/evidence/browser/evidence-runner-report.json`.

## ROM capture evidence

The local browser NES capture runner is `tools/run-rom-capture.js`. It serves `tools/rom-emulator-capture.html`, loads the ignored local ROM, scripts controller input, and writes reference PNGs plus `research/evidence/screens/rom-capture-report.json`. Comparison notes are in `research/evidence/screens/comparison-notes.md`.
