Split The code is public; the app answers only to the crew.

Resume match: the menu offers the round you were in, and the row on the board continues #179

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

Pushed. Here's the PR description:

shipped merged

opened this

Pushed. Here's the PR description:

Wires the snapshot machinery saved.ts and world.ts already had (both map-aware since #155/#134 landed) into main.ts, the last third of #71:

  • main.ts writes a snapshot to localStorage at the start of every freeze time — fresh match, next round or resumed match alike, tracked by round number so it writes once and not every frame — and clears it when the match is decided or Leave match is pressed.
  • The menu offers Resume match — de_cinder, round 9, 5–3 (resumeLine in saved.ts, new and tested) whenever a valid snapshot is on disk, and a line under it says starting a new match discards it. Both are rendered server-side in pages/game.ts (#resume-match, #discard-warning), so main.test.ts's id/selector contract covers them for free. The old snapshot is only actually discarded when start() runs, not by merely showing the menu.
  • Resuming calls restoreWorld(save, settings.difficulty) and continues under save.matchId, so the leaderboard row already open for that match keeps updating instead of forking a second one. start() and resumeMatch() now share one enterMatch() tail.
  • Two tabs resuming the same snapshot both post under that id: safe, because saveMatch only ever takes the larger of what's stored and what arrives per column, and the score is taken whole from whichever post knows the most rounds — the worst outcome is a row that over-counts progress neither tab alone made, never one that goes backwards or leaks to another identity. Nothing needed changing here; #108's monotone guard already covers it, and an abandoned-by-age row already reads live again the instant a fresh post lands, since walked_out (the sticky flag) and the age rule are different things.
  • README gets a new paragraph in Playing saying what survives (map, round, score, money, gear) and what doesn't (nothing mid-round — no position, health or bomb), and that it's one browser on one device.

Left out: no server-side match-history reconciliation beyond what already existed — this issue was wiring, not a new safety net. bun run check passes (735 tests). Tried the page by rendering gamePage() directly and confirming both new ids appear (the sandbox already had ~80 stray server.ts processes squatting on ports from before this session, so I skipped a live curl and used the same harness main.test.ts uses instead).

Closes #135

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs