/** * Test/dev helpers for LANE-SIM. Not part of the game loop — nothing in src/main.ts, * src/render, src/ui or src/screen imports this, and it tree-shakes out of the bundle. * * Why it exists: contracts v4 gates every id named by a tech's `unlocks`, and that * includes the mosh reactor, the software decoder and the subsampler. So the reference * factory — the endgame demo — is no longer buildable from a fresh sim by design. It * represents a save where the research has already happened, and this is how a test says * so honestly, through the public save/load API rather than a back door into the sim. * * There is currently no legitimate in-sim path to this state: DATA ships no `kind:'lab'` * machine, and every science pack is made on the artifact-bottler, which is itself locked * behind a tech costing 10 analog-packs. See NOTES round 4. */ import type { GameData, Sim } from '../contracts'; /** * Rewrites a sim's research state to treat `techIds` as completed, via a save/load * round-trip. Call it on a fresh sim before enqueueing anything — load() replaces the * whole world, so any entities placed first would be discarded. */ export function grantResearch(sim: Sim, techIds: string[]): void { const blob = JSON.parse(sim.save()); blob.research = { active: null, progress: {}, unlocked: [...techIds] }; sim.load(JSON.stringify(blob)); } /** The late-game save: everything DATA's tech tree gates is open. */ export function grantAllResearch(sim: Sim, data: GameData): void { grantResearch(sim, data.tech.map((t) => t.id)); }