Public: anyone can read this; the crew can change it.

forked from trevato/cs

The map you played has a name you can keep: the seed on the menu, in the URL, and a link that plays it again #213

Merged opened this

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

Merged

A generated map now has a name you can read before you play it, type back in, and hand to somebody else. `src/mapname.ts` is the one door a name goes through — `nameOf`, `seedOf`, `mapFrom` — and its test is a round trip rather than a regular expression, so `gen_0ya` (that is `gen_ya` written badly) and `gen_zzzzzzzz` (nobody's seed) are typos, not maps. The server validates `?map=` with it before…

shipped production is serving it deploy ae07c2d

opened this

A generated map now has a name you can read before you play it, type back in, and hand to somebody else. src/mapname.ts is the one door a name goes through — nameOf, seedOf, mapFrom — and its test is a round trip rather than a regular expression, so gen_0ya (that is gen_ya written badly) and gen_zzzzzzzz (nobody's seed) are typos, not maps. The server validates ?map= with it before rendering and src/client/main.ts validates the field with it again before anything reaches generateLevel; neither trusts the other, and a junk value is de_forge with a sentence, never an error page.

On the menu there is a Map name field beside the select, and above Play a line that names the map Play is about to give you — on generated the match id is drawn the moment the menu needs to name the map it carves, so the name on screen is the map you get rather than a guess, and the id the menu named is the id the match uses. Next to it, Copy this map's link: an <a href="/?map=gen_…"> first, 44px and keyboard-reachable, with the clipboard as the thing the click adds; a browser without one just follows the link. The played map's name under the stage is a link to that map too. The match id is untouched: a named map overrides it, ?match= still plays a match back, and ?map= stays the shooter's parameter — /range and /example are asserted to carry nothing of it.

src/client/generate.test.ts folds gen_14u5j6g's cells into a digest through the engine's digest door and pins it, which is the claim the name makes: same name, same forty-by-forty cells, every machine. The bundle grew 1,358 raw / 531 gzipped bytes and went 588 bytes past the raw ceiling, so the app's ceiling moves to 100,000 / 45,000 with the measurement written into src/games.ts beside every earlier raise — #135 had already noted its 770 bytes of headroom was the thinnest on the page. I left the terminal alone: it browses saved matches, and no map name is stored with a result, so there was nothing there to show. The branch is rebased on current main; bun run test passes (959 tests, typecheck included). In the preview, open /?map=gen_14u5j6g, then switch the select to generated and watch the name and its link change before you press Play.

🤖 Generated with Claude Code

Closes #148

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs