fix: always merge evolutionTree/generators with defaults on load
All checks were successful
CI/CD — Build & Deploy / Build & Deploy (push) Successful in 21s

Server saves don't store all node fields (branch, cost, effect, etc.).
migrateSave now always rebuilds tree from DEFAULT_EVOLUTION_TREE,
preserving unlocked state from the save. Fixes empty evolution tree.
This commit is contained in:
2026-03-28 20:44:26 +01:00
parent 1488962537
commit 39921aa8fc
2 changed files with 10 additions and 7 deletions

View File

@@ -23,6 +23,15 @@ export function migrateSave(raw: Record<string, unknown>): GameState {
// Futures migrations :
// if (version < 3) state = migrateV2toV3(state);
// Always rebuild tree & generators from defaults — the server/localStorage
// may not store all fields (branch, cost, effect, baseProduction, etc.)
state.evolutionTree = mergeEvolutionTree(
state.evolutionTree as Array<Record<string, unknown>> | undefined
);
state.generators = mergeGenerators(
state.generators as Array<Record<string, unknown>> | undefined
);
return state as unknown as GameState;
}