Skip to content

Commit dfed03c

Browse files
Merge pull request #5 from Tanner-Scadden/feat/coop-room-plumbing
feat(coop): co-op room plumbing on preview stages (Phases 2 and 3)
2 parents ec36b9a + 7beed14 commit dfed03c

51 files changed

Lines changed: 11095 additions & 86 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎AGENTS.md‎

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,29 @@ A pixel-art zombie shooter. It runs on desktop and on phones. The vision, the de
1414

1515
### Commands
1616

17-
| Command | What it does |
18-
| -------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
19-
| `bun install`, `bun dev` | Install dependencies; start the dev server |
20-
| `bun run typecheck` | Typecheck with `tsrs`, including the Effect rules. It covers `tools/audit`, so run `bun install` there once too |
21-
| `bun run lint` | Lint with oxlint and the Effect rules |
22-
| `bun run test` | The fast tier: Story, Scene, and unit tests and the packages, about 6 s. `-- <files>` or `-- --changed` narrows it |
23-
| `bun run test:full` | The full tier, as CI runs it: the fast tier plus the sim tier (`*.sim.test.ts`), whole wave replays and seed sweeps |
24-
| `bun run build` | Build for production |
25-
| `bun run perf:check` | Compare frame time to `tools/audit/frame-baseline.json` in headless Chrome |
26-
| `cd infra && bun alchemy plan --stage prod` | Show what a production deploy would change. `deploy` in place of `plan` deploys by hand (see `infra/README.md`) |
27-
| `cd tools/audit && bun live-check.ts [url]` | Load a deployed copy in headless Chrome and check that it boots |
28-
| `cd infra && bun run test` | Test the analytics Worker: the size cap, rate limits, decoding, and D1 rows |
29-
| `bun tools/analytics/report.ts --stage <s>` | Print a stage's analytics. `smoke.ts <api url>` posts one fake run summary and checks the API Worker |
30-
| `bun run heavy -- bun tools/audit/sqlite.ts` | Check the SQLite save on OPFS in headless Chrome. `sync.ts <url>` checks player sync on a deployed copy. `offline.ts` checks offline play and updates with the service worker |
31-
| `bun run balance [runs]` | The balance bot through the guard. `-- --wave 4 --runs 100` plays one wave from snapshots (`--wave all` for every wave). Env vars such as `MODE=endless` and `VIEW=portrait` pass through |
32-
| `bun run balance:model` | The analytical balance model: every wave and level from the tables, in under a second |
33-
| `bun run balance:nightly` | The nightly balance suite through the guard, reported in `tools/balance/reports/<date>.md` |
34-
| `bun run heavy -- <command...>` | Run any CPU-heavy command through the guard: timing jobs alone, the rest within a load budget of about 70% of the cores |
35-
| `bun run determinism` | One scripted run in Bun, Node, headless Chrome, and workerd, through the guard: where engines first differ |
36-
| `bun run determinism:diff -- [ref]` | Whether the working tree plays exactly like `ref` (`origin/main`), through the guard, for no-change refactors |
17+
| Command | What it does |
18+
| ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
19+
| `bun install`, `bun dev` | Install dependencies; start the dev server |
20+
| `bun run typecheck` | Typecheck with `tsrs`, including the Effect rules. It covers `tools/audit`, so run `bun install` there once too |
21+
| `bun run lint` | Lint with oxlint and the Effect rules |
22+
| `bun run test` | The fast tier: Story, Scene, and unit tests and the packages, about 6 s. `-- <files>` or `-- --changed` narrows it |
23+
| `bun run test:full` | The full tier, as CI runs it: the fast tier plus the sim tier (`*.sim.test.ts`), whole wave replays and seed sweeps |
24+
| `bun run build` | Build for production |
25+
| `bun run perf:check` | Compare frame time to `tools/audit/frame-baseline.json` in headless Chrome |
26+
| `cd infra && bun alchemy plan --stage prod` | Show what a production deploy would change. `deploy` in place of `plan` deploys by hand (see `infra/README.md`) |
27+
| `cd tools/audit && bun live-check.ts [url]` | Load a deployed copy in headless Chrome and check that it boots |
28+
| `cd infra && bun run test` | Test the analytics Worker: the size cap, rate limits, decoding, and D1 rows |
29+
| `bun tools/analytics/report.ts --stage <s>` | Print a stage's analytics. `smoke.ts <api url>` posts one fake run summary and checks the API Worker |
30+
| `bun run heavy -- bun tools/audit/sqlite.ts` | Check the SQLite save on OPFS in headless Chrome. `sync.ts <url>` checks player sync on a deployed copy. `offline.ts` checks offline play and updates with the service worker |
31+
| `bun run balance [runs]` | The balance bot through the guard. `-- --wave 4 --runs 100` plays one wave from snapshots (`--wave all` for every wave). Env vars such as `MODE=endless` and `VIEW=portrait` pass through |
32+
| `bun run balance:model` | The analytical balance model: every wave and level from the tables, in under a second |
33+
| `bun run balance:nightly` | The nightly balance suite through the guard, reported in `tools/balance/reports/<date>.md` |
34+
| `bun run heavy -- <command...>` | Run any CPU-heavy command through the guard: timing jobs alone, the rest within a load budget of about 70% of the cores |
35+
| `bun run determinism` | One scripted run in Bun, Node, headless Chrome, and workerd, through the guard: where engines first differ |
36+
| `bun run determinism:diff -- [ref]` | Whether the working tree plays exactly like `ref` (`origin/main`), through the guard, for no-change refactors |
37+
| `bun run mp:e2e` | Co-op rooms end to end in a local workerd: three players by code, then a QUICK PLAY group (a Shared heavy job) |
38+
| `bun tools/mp-dev/serve.ts <api origin>` | The co-op dev page at `http://localhost:4180/`; `bun tools/mp-dev/local.ts` runs a local API at `:8798` for it |
39+
| `bun run heavy -- --shared bun tools/audit/mp.ts <url> [n]` | Co-op in headless Chrome on a deploy's dev page: 2 to 4 pages join, play, rejoin, end, then QUICK PLAY |
3740

3841
Before you finish a change, run `typecheck`, `lint`, `test`, and `build`. All four must pass. Also run `test:full` when the change touches gameplay (`simulation.ts`, `waves.ts`, `pacing.ts`, `combat.ts`, the zombie, boss, or trap modules), since CI runs it and blocks the deploy on it.
3942

@@ -113,6 +116,7 @@ Paths are under `src/`. The API Worker is in `infra/worker/` (analytics, and syn
113116
- **The Foldkit patch.** Every fixed sprite is a `Canvas.Image`, which Foldkit 0.169.0 has only through the Bun patch `patches/foldkit@0.169.0.patch`. Read [`patches/README.md`](./patches/README.md) before changing it, dropping it, or upgrading Foldkit.
114117
- **Deploying.** A push to `main` deploys production through `.github/workflows/deploy.yml` once `typecheck`, `lint`, `test`, and `build` pass, and a pull request gets a preview. Stages, local deploys, itch.io, and credentials are in [`infra/README.md`](./infra/README.md). The workflow is the only deploy path: never connect Cloudflare Workers Builds, and never put a token in the repo or in a `VITE_` variable.
115118
- **How updates reach installed apps, and offline play.** Each build is stamped into `version.json`, and a "New version ready" chip waits on the home menu. A service worker (`src/sw/`) precaches the build so the game cold starts with no network; it never decides which build runs, `version.json` does. Its kill switch is `IS_SERVICE_WORKER_KILLED` in `src/sw/precache.ts`. Check it with `bun run heavy -- bun tools/audit/offline.ts`. See "How updates reach installed apps" in [`PLATFORM.md`](./PLATFORM.md).
119+
- **Co-op.** The room protocol, the room's tick, the `room:<code>` lobby scope, QUICK PLAY, and the browser client are in `packages/netcode`; the `GameRoom` and `Matchmaker` Durable Objects in `infra/worker/`; the dev page and the local workerd in `tools/mp-dev`. They run a stand-in world until the World split; the dev page deploys on preview stages only. See "What Phases 2 and 3 built" in [`MULTIPLAYER.md`](./MULTIPLAYER.md).
116120

117121
### Rules
118122

0 commit comments

Comments
 (0)