Fix bug with constants after game completion

Migrate saves with bugged constants
This commit is contained in:
SpectralFlame 2023-07-23 21:56:34 -05:00 committed by cyip92
parent 2d4fddd1b0
commit 561c8cfc9c
3 changed files with 10 additions and 1 deletions

View File

@ -56,6 +56,7 @@ export const NG = {
// which could lead to some edge cases where it starts when it shouldn't (ie before it's unlocked)
// It's easier to do something like this to avoid it entirely.
const automatorConstants = JSON.stringify(player.reality.automator.constants);
const automatorConstantSort = JSON.stringify(player.reality.automator.constantSortOrder);
const automatorScripts = JSON.stringify(player.reality.automator.scripts);
const fullCompletions = player.records.fullGameCompletions;
const fullTimePlayed = player.records.previousRunRealTime + player.records.realTimePlayed;
@ -72,6 +73,7 @@ export const NG = {
player.secretUnlocks = secretUnlocks;
player.secretAchievementBits = JSON.parse(secretAchievements);
player.reality.automator.constants = JSON.parse(automatorConstants);
player.reality.automator.constantSortOrder = JSON.parse(automatorConstantSort);
player.reality.automator.scripts = JSON.parse(automatorScripts);
player.records.fullGameCompletions = fullCompletions;
player.records.previousRunRealTime = fullTimePlayed;

View File

@ -359,7 +359,7 @@ window.player = {
previousRuns: {}
},
IPMultPurchases: 0,
version: 23,
version: 24,
infinityPower: DC.D1,
postC4Tier: 0,
eternityPoints: DC.D0,

View File

@ -404,6 +404,13 @@ export const migrations = {
}
}
},
24: player => {
// Automator constants didn't copy over properly across new games - retroactively fix bugged saves as well
const definedConstants = Object.keys(player.reality.automator.constants);
if (definedConstants.length !== player.reality.automator.constantSortOrder.length) {
player.reality.automator.constantSortOrder = [...definedConstants];
}
},
},
normalizeTimespans(player) {