From 3e64372220157e5e23005dde05e6eb6db74821e7 Mon Sep 17 00:00:00 2001 From: Pseudonian Date: Wed, 24 Feb 2021 22:56:54 -0500 Subject: [PATCH] Fix frozen production, improper reset on pre v2.0.0 savefiles. --- src/Calculate.ts | 1 - src/CheckVariables.ts | 22 ++++++++++++++++++++++ src/Synergism.ts | 15 --------------- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/Calculate.ts b/src/Calculate.ts index e006a1585..3ee37728e 100644 --- a/src/Calculate.ts +++ b/src/Calculate.ts @@ -937,7 +937,6 @@ export const calculateTimeAcceleration = () => { timeMult *= (1 + 0.10 * (player.talismanRarity[2-1] - 1)) // Chronos Talisman bonus timeMult *= G['challenge15Rewards'].globalSpeed // Challenge 15 reward timeMult *= G['lazinessMultiplier'][player.usedCorruptions[3]] - if (player.currentChallenge.ascension === 15 && player.platonicUpgrades[15] > 0) { timeMult *= 1000 } diff --git a/src/CheckVariables.ts b/src/CheckVariables.ts index 5a5b0e9dc..5ed2ed823 100644 --- a/src/CheckVariables.ts +++ b/src/CheckVariables.ts @@ -6,7 +6,28 @@ import { buyResearch } from './Research'; import { c15RewardUpdate } from './Statistics'; import { LegacyShopUpgrades } from './types/LegacySynergism'; +/** + * Given player data, it checks, on load if variables are undefined + * or set incorrectly, and corrects it. This should be where all new + * variable declarations for `player` should go! + * @param data + */ export const checkVariablesOnLoad = (data: Player) => { + if (player.currentChallenge.transcension === undefined) { + player.currentChallenge = { + transcension: 0, + reincarnation: 0, + ascension: 0, + } + } + if (!Array.isArray(data.challengecompletions)) { + player.challengecompletions = Object.values(data.challengecompletions); + player.challengecompletions[0] = 0; + player.challengecompletions[11] = 0; + player.challengecompletions[12] = 0; + player.challengecompletions[13] = 0; + player.challengecompletions[14] = 0; + } if (data.wowCubes === undefined) { player.wowCubes = 0; player.wowTesseracts = 0; @@ -223,6 +244,7 @@ export const checkVariablesOnLoad = (data: Player) => { } if (data.platonicBlessings === undefined) { const ascCount = player.ascensionCount + console.log(player.currentChallenge.ascension) if (player.currentChallenge.ascension !== 0 && player.currentChallenge.ascension !== 15) { resetCheck('ascensionChallenge', false, true); } diff --git a/src/Synergism.ts b/src/Synergism.ts index 2c20b9df3..3e6b092b8 100644 --- a/src/Synergism.ts +++ b/src/Synergism.ts @@ -1007,21 +1007,6 @@ export const loadSynergy = (): void => { player.historyShowPerSecond = false; player.historyCountMax = 10; } - if (player.currentChallenge.transcension === undefined) { - player.currentChallenge = { - transcension: 0, - reincarnation: 0, - ascension: 0, - } - /*let challengeCompletionArray = [0, player.challengecompletions.one, player.challengecompletions.two, player.challengecompletions.three, player.challengecompletions.four, player.challengecompletions.five, player.challengecompletions.six, player.challengecompletions.seven, player.challengecompletions.eight, player.challengecompletions.nine, player.challengecompletions.ten, 0, 0, 0, 0, 0] - let highestChallengeCompletionArray = [0, player.highestchallengecompletions.one, player.highestchallengecompletions.two, player.highestchallengecompletions.three, player.highestchallengecompletions.four, player.highestchallengecompletions.five, player.highestchallengecompletions.six, player.highestchallengecompletions.seven, player.highestchallengecompletions.eight, player.highestchallengecompletions.nine, player.highestchallengecompletions.ten, 0, 0, 0, 0, 0] - player.challengecompletions = [] - player.highestchallengecompletions = [] - for (let i = 0; i <= 15; i++) { - player.challengecompletions.push(challengeCompletionArray[i]) - player.highestchallengecompletions.push(highestChallengeCompletionArray[i]) - }*/ - } if (!Number.isInteger(player.ascendBuilding1.cost)) { player.ascendBuilding1.cost = 1;