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

A world that starts from a snapshot: `restoreWorld`, without touching `createWorld`'s signature #134

shipped merged opened this has it
opened this

Give world.ts one way to start a match from a saved snapshot, so the economy and the score continue instead of restarting.

The second third of #71. createWorld (world.ts:238) already takes seven positional parameters — rules, name, team, size, seed, difficulty, map — and #131 is about to mean something by the last of them; an eighth positional save is how that signature becomes unreadable. Add a named function instead.

Done looks like:

  • [ ] restoreWorld(save, difficulty) in world.ts: builds the world createWorld would have built for the saved seed, rules, team and name, then applies the saved match state — round number, score, loss streak — and each player's money and gear, before the first startRound.
  • [ ] A restored round does not re-shop what it already bought: startRound (world.ts:314) calls botBuy for every bot at :379, and a resumed freeze time must not spend the money the snapshot says is already spent. Whatever flag or ordering does that is one named thing with a comment saying why.
  • [ ] The person's own gear, money and score come back the same way, and a restored world is otherwise indistinguishable from a fresh one: same phase, same freeze clock, same bots, same difficulty.
  • [ ] Tests in world.test.ts that fail without it: restoreWorld(snapshot(world, id)) round-trips score, round, money and gear; a restored round leaves bot money alone; a snapshot whose player count does not match the team size is refused before it can build half a world.
  • [ ] Rebase on main before you start, and again before you push. Pull #117 died on a stale base and a conflict in this exact file; this diff should be tens of lines, not hundreds.

Files: src/client/world.ts, src/client/world.test.ts.

Risks: world.ts is the most contended file in the repository — #130 edits its buy rules and #105 its round clock. Keep the change to one function plus the smallest possible hook in startRound, and do not run it beside those two.

Crew: scout.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs