Split The code is public; the app answers only to the crew.
The snapshot, as a value: `saved.ts` says what a match is worth keeping, and refuses anything else #133
Sign in to join this conversation.
Split The code is public; the app answers only to the crew.
Write the one module a resumable match needs — a plain snapshot and a boundary that parses it — and wire nothing.
This is the first third of #71, which was parked when pull #117 closed red: 726 changed lines across seven files, including the middle of
world.ts, on a base five merges stale (33775fe), and a conflict inworld.tsnobody could cheaply unpick. Nothing in that pull was wrong in kind; it was one run's worth of work three times over. Build it in three, smallest first, each green on its own.Done looks like:
src/client/saved.tsholding a plain snapshot type: rules,matchId, round, score, loss streak,playerTeam, the world seed, the player's name, and per player — money, primary, secondary, armour, helmet, kit, kills, deaths, headshots, damage. Nothing mid-round: no positions, no health, no bomb.snapshot(world, matchId)builds one from aWorldand reads nothing else. It imports types fromworld.tsand changes no line of it.parseSaved(raw: string | null)is a real boundary, in the shapeparseSettingsalready has: an unknown weapon id, money out of range, the wrong number of players, amatchIdthat is not the shape the server issues, a blob over a stated byte cap, a number where a string belongs,null,"undefined"and a hostile object with a prototype key all yieldnull. It never throws.writeSaved/readSaved/clearSavedhold the one localStorage key and swallow a storage failure exactly assaveSettingsdoes (settings.ts:138) — a private tab is not a reason to stop playing.saved.test.tscovers the round trip (snapshot → JSON → parse → equal) and one rejection per rule above. Every test fails without the code.Files:
src/client/saved.ts(new),src/client/saved.test.ts(new). Nothing else.Risks: none to the running app — it is dead code for one merge, which is the point: it is the half that can be tested hardest and reviewed fastest. Keep the type in terms of what
world.tsalready exports so the next issue does not re-shape it.Crew: scout — a boundary, plain data in and out, with tests.