Repository navigation
Import the game's save, and fix island loading races - #7
Merged
Merged
Conversation
The game's Export to Optimizer button writes an R2X1 code holding the player's whole save. Pasting it into Import code now loads it: every unlocked island's cleared obstacles and buildings onto our maps, the roster, Time Lab and anomaly, and research in progress either counted as done or turned into the upgrade plan. Islands still locked in the game are reset to their untouched maps. The format is in docs/game-export.md; three real exports are test fixtures. - encoding/gameExport.ts reads the code; data/gameImport.ts maps it onto our islands via IslandTemplate.game (area id and grid origin). - Island 5's template had a tree one tile from where the game has it. - Loading an island decodes before it paints and only the newest load lands, so the bare map no longer flashes and repeated taps settle on the saved board; tapping the open island does nothing. - Reset and a game import cancel a save still encoding, which could otherwise land afterwards and bring the replaced board back.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The game's Export to Optimizer button writes an
R2X1.code holding the player's whole save. Pasting it into Import code (renamed from "Import a layout") now loads it:Applying it takes two presses, because it replaces the player's boards. The dialog summarises the code first, and warns about any building it couldn't place or any anomaly this version doesn't know.
The format is specified in
docs/game-export.md. Three real exports from the game are test fixtures.How
packages/solver/src/encoding/gameExport.tsreads the code: raw deflate, base64url, a palette of the game's own ids, andBinaryWritertypes. It ignores stray characters around a pasted code.packages/solver/src/data/gameImport.tsmaps it onto our data. Each shipped template now carriesgame: { areaId, originX, originY }, linking it to its region of the game's single world grid. A board is built from our template, with cleared obstacles cleared and buildings placed, so shipped maps still change only by player moves.encoding/streams.tsholds the byte helpers both codecs share.Fixes found along the way
Testing
npm test: 941 passed, includinggameExport.test.ts(the real exports: alignment of every island, roster and Time Lab mapping, research in progress, refusals) and the app-sidegameImport.test.tsandtemplateLoad.test.ts.npm run checkandnpm run knipare clean.Open question for the game developer
One sample reports a research in progress with 0 seconds left. Either it had finished but wasn't collected, or the seconds aren't read from the running timer.