fix: always merge evolutionTree/generators with defaults on load
All checks were successful
CI/CD — Build & Deploy / Build & Deploy (push) Successful in 21s
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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user