Merge pull request #994 from benblank/cmd-cache

Export caches via CookieMonsterData
This commit is contained in:
Daniël van Noord
2021-09-22 12:34:39 +02:00
committed by GitHub
19 changed files with 140 additions and 31 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,19 +1,20 @@
import { ClickTimes, CookieTimes } from '../../Disp/VariablesAndData'; import { ClickTimes, CookieTimes } from '../../Disp/VariablesAndData';
import FillCMDCache from '../FillCMDCache';
import { import {
CacheAverageClicks, // eslint-disable-line no-unused-vars CacheAverageClicks,
CacheAverageCPS, CacheAverageCPS,
CacheAverageGainBank, CacheAverageGainBank,
CacheAverageGainChoEgg, CacheAverageGainChoEgg,
CacheAverageGainWrink, CacheAverageGainWrink,
CacheAverageGainWrinkFattest, CacheAverageGainWrinkFattest,
CacheAvgCPSWithChoEgg, // eslint-disable-line no-unused-vars CacheAvgCPSWithChoEgg,
CacheLastChoEgg, CacheLastChoEgg,
CacheLastClicks, CacheLastClicks,
CacheLastCookies, CacheLastCookies,
CacheLastCPSCheck, CacheLastCPSCheck,
CacheLastWrinkCookies, CacheLastWrinkCookies,
CacheLastWrinkFattestCookies, CacheLastWrinkFattestCookies,
CacheRealCookiesEarned, // eslint-disable-line no-unused-vars CacheRealCookiesEarned,
CacheSellForChoEgg, CacheSellForChoEgg,
CacheWrinklersFattest, CacheWrinklersFattest,
CacheWrinklersTotal, CacheWrinklersTotal,
@@ -93,4 +94,21 @@ export default function CacheAvgCPS() {
ClickTimes[Game.mods.cookieMonsterFramework.saveData.cookieMonsterMod.settings.AvgClicksHist], ClickTimes[Game.mods.cookieMonsterFramework.saveData.cookieMonsterMod.settings.AvgClicksHist],
); );
} }
FillCMDCache({
CacheRealCookiesEarned,
CacheLastCPSCheck,
CacheLastCookies,
CacheLastWrinkCookies,
CacheLastWrinkFattestCookies,
CacheLastChoEgg,
CacheLastClicks,
CacheAverageGainBank,
CacheAverageGainWrink,
CacheAverageGainWrinkFattest,
CacheAverageGainChoEgg,
CacheAverageCPS,
CacheAvgCPSWithChoEgg,
CacheAverageClicks,
});
} }

View File

@@ -1,5 +1,6 @@
import { SimObjects } from '../../Sim/VariablesAndData'; import { SimObjects } from '../../Sim/VariablesAndData';
import { CacheCurrWrinklerCount, CacheCurrWrinklerCPSMult } from '../VariablesAndData'; // eslint-disable-line no-unused-vars import FillCMDCache from '../FillCMDCache';
import { CacheCurrWrinklerCount, CacheCurrWrinklerCPSMult } from '../VariablesAndData';
/** /**
* This functions caches the current Wrinkler CPS multiplier * This functions caches the current Wrinkler CPS multiplier
@@ -26,4 +27,6 @@ export default function CacheCurrWrinklerCPS() {
(Game.Has('Sacrilegious corruption') * 0.05 + 1) * (Game.Has('Sacrilegious corruption') * 0.05 + 1) *
(Game.Has('Wrinklerspawn') * 0.05 + 1) * (Game.Has('Wrinklerspawn') * 0.05 + 1) *
godMult; godMult;
FillCMDCache({ CacheCurrWrinklerCount, CacheCurrWrinklerCPSMult });
} }

View File

@@ -1,5 +1,6 @@
import CalcNoGoldSwitchCPS from '../../Sim/Calculations/NoGoldenSwitchCalc'; import CalcNoGoldSwitchCPS from '../../Sim/Calculations/NoGoldenSwitchCalc';
import { CacheNoGoldSwitchCookiesPS } from '../VariablesAndData'; // eslint-disable-line no-unused-vars import FillCMDCache from '../FillCMDCache';
import { CacheNoGoldSwitchCookiesPS } from '../VariablesAndData';
/** /**
* This function calculates CPS without the Golden Switch as it might be needed in other functions * This function calculates CPS without the Golden Switch as it might be needed in other functions
@@ -10,4 +11,6 @@ export default function CacheNoGoldSwitchCPS() {
if (Game.Has('Golden switch [off]')) { if (Game.Has('Golden switch [off]')) {
CacheNoGoldSwitchCookiesPS = CalcNoGoldSwitchCPS(); CacheNoGoldSwitchCookiesPS = CalcNoGoldSwitchCPS();
} else CacheNoGoldSwitchCookiesPS = Game.cookiesPs; } else CacheNoGoldSwitchCookiesPS = Game.cookiesPs;
FillCMDCache({ CacheNoGoldSwitchCookiesPS });
} }

View File

@@ -1,5 +1,6 @@
import SellBuildingsForChoEgg from '../../Sim/SimulationEvents/SellBuildingForChoEgg'; import SellBuildingsForChoEgg from '../../Sim/SimulationEvents/SellBuildingForChoEgg';
import { CacheSellForChoEgg } from '../VariablesAndData'; // eslint-disable-line no-unused-vars import FillCMDCache from '../FillCMDCache';
import { CacheSellForChoEgg } from '../VariablesAndData';
/** /**
* This functions caches the reward for selling the Chocolate egg * This functions caches the reward for selling the Chocolate egg
@@ -21,4 +22,6 @@ export default function CacheSellAllForChoEgg() {
// Compute cookies earned by selling all buildings with optimal auras (ES + RB) // Compute cookies earned by selling all buildings with optimal auras (ES + RB)
sellTotal += SellBuildingsForChoEgg(); sellTotal += SellBuildingsForChoEgg();
CacheSellForChoEgg = sellTotal; CacheSellForChoEgg = sellTotal;
FillCMDCache({ CacheSellForChoEgg });
} }

View File

@@ -3,6 +3,7 @@
import Beautify from '../../Disp/BeautifyAndFormatting/Beautify'; import Beautify from '../../Disp/BeautifyAndFormatting/Beautify';
import CopyData from '../../Sim/SimulationData/CopyData'; import CopyData from '../../Sim/SimulationData/CopyData';
import { SimDoSims, SimObjects } from '../../Sim/VariablesAndData'; import { SimDoSims, SimObjects } from '../../Sim/VariablesAndData';
import FillCMDCache from '../FillCMDCache';
import { CacheCostDragonUpgrade, CacheLastDragonLevel } from '../VariablesAndData'; // eslint-disable-line no-unused-vars import { CacheCostDragonUpgrade, CacheLastDragonLevel } from '../VariablesAndData'; // eslint-disable-line no-unused-vars
/** /**
@@ -63,4 +64,6 @@ export default function CacheDragonCost() {
} }
CacheLastDragonLevel = Game.dragonLevel; CacheLastDragonLevel = Game.dragonLevel;
} }
FillCMDCache({ CacheLastDragonLevel });
} }

22
src/Cache/FillCMDCache.js Normal file
View File

@@ -0,0 +1,22 @@
/**
* Insert the provided values into `window.CookieMonsterData.Cache`.
*
* The initial 'Cache' is dropped from the name, so e.g. `CacheWrinklersTotal`
* becomes `window.CookieMonsterData.Cache.WrinklersTotal`.
*/
export default function FillCMDCache(caches) {
if (!('Cache' in window.CookieMonsterData)) {
window.CookieMonsterData.Cache = {};
}
Object.keys(caches).forEach((name) => {
const exportName = name.replace(/^Cache/, '');
if (typeof caches[name] === 'undefined') {
window.CookieMonsterData.Cache[exportName] = undefined;
} else {
// Passing through JSON ensures that no references are retained.
window.CookieMonsterData.Cache[exportName] = JSON.parse(JSON.stringify(caches[name]));
}
});
}

View File

@@ -1,9 +1,10 @@
import GetWrinkConfigBank from '../../Disp/HelperFunctions/GetWrinkConfigBank'; import GetWrinkConfigBank from '../../Disp/HelperFunctions/GetWrinkConfigBank';
import { ColourGray } from '../../Disp/VariablesAndData'; import { ColourGray } from '../../Disp/VariablesAndData';
import BuildingGetPrice from '../../Sim/SimulationEvents/BuyBuilding'; import BuildingGetPrice from '../../Sim/SimulationEvents/BuyBuilding';
import FillCMDCache from '../FillCMDCache';
import { import {
CacheMinPP, // eslint-disable-line no-unused-vars CacheMinPP,
CacheMinPPBulk, // eslint-disable-line no-unused-vars CacheMinPPBulk,
CacheObjects1, CacheObjects1,
CacheObjects10, CacheObjects10,
CacheObjects100, CacheObjects100,
@@ -106,4 +107,6 @@ export default function CacheBuildingsPP() {
CacheColour(CacheObjects1, 1); CacheColour(CacheObjects1, 1);
CacheColour(CacheObjects10, 10); CacheColour(CacheObjects10, 10);
CacheColour(CacheObjects100, 100); CacheColour(CacheObjects100, 100);
FillCMDCache({ CacheMinPP, CacheMinPPBulk, CachePPArray });
} }

View File

@@ -1,4 +1,5 @@
import CalculateChangeGod from '../../Sim/SimulationEvents/GodChange'; import CalculateChangeGod from '../../Sim/SimulationEvents/GodChange';
import FillCMDCache from '../FillCMDCache';
import { CacheGods } from '../VariablesAndData'; import { CacheGods } from '../VariablesAndData';
/** /**
@@ -10,4 +11,6 @@ export default function CachePantheonGods() {
CacheGods[god][slot] = CalculateChangeGod(god, slot); CacheGods[god][slot] = CalculateChangeGod(god, slot);
} }
} }
FillCMDCache({ CacheGods });
} }

View File

@@ -3,6 +3,7 @@
import BuildingGetPrice from '../../Sim/SimulationEvents/BuyBuilding'; import BuildingGetPrice from '../../Sim/SimulationEvents/BuyBuilding';
import BuyBuildingsBonusIncome from '../../Sim/SimulationEvents/BuyBuildingBonusIncome'; import BuyBuildingsBonusIncome from '../../Sim/SimulationEvents/BuyBuildingBonusIncome';
import BuyUpgradesBonusIncome from '../../Sim/SimulationEvents/BuyUpgrades'; import BuyUpgradesBonusIncome from '../../Sim/SimulationEvents/BuyUpgrades';
import FillCMDCache from '../FillCMDCache';
import { import {
CacheAverageGainBank, CacheAverageGainBank,
CacheAverageGainWrink, CacheAverageGainWrink,
@@ -93,6 +94,8 @@ export function CacheBuildingsPrices() {
CacheObjectsNextAchievement[i].AmountNeeded, CacheObjectsNextAchievement[i].AmountNeeded,
); );
}); });
FillCMDCache({ CacheObjectsNextAchievement });
} }
/** /**

View File

@@ -1,17 +1,18 @@
import GetCPSBuffMult from '../CPS/GetCPSBuffMult'; import GetCPSBuffMult from '../CPS/GetCPSBuffMult';
import FillCMDCache from '../FillCMDCache';
import { import {
CacheChainFrenzyMaxReward, CacheChainFrenzyMaxReward,
CacheChainFrenzyRequired, // eslint-disable-line no-unused-vars CacheChainFrenzyRequired,
CacheChainFrenzyRequiredNext, // eslint-disable-line no-unused-vars CacheChainFrenzyRequiredNext,
CacheChainFrenzyWrathMaxReward, CacheChainFrenzyWrathMaxReward,
CacheChainFrenzyWrathRequired, // eslint-disable-line no-unused-vars CacheChainFrenzyWrathRequired,
CacheChainFrenzyWrathRequiredNext, // eslint-disable-line no-unused-vars CacheChainFrenzyWrathRequiredNext,
CacheChainMaxReward, CacheChainMaxReward,
CacheChainRequired, // eslint-disable-line no-unused-vars CacheChainRequired,
CacheChainRequiredNext, // eslint-disable-line no-unused-vars CacheChainRequiredNext,
CacheChainWrathMaxReward, CacheChainWrathMaxReward,
CacheChainWrathRequired, // eslint-disable-line no-unused-vars CacheChainWrathRequired,
CacheChainWrathRequiredNext, // eslint-disable-line no-unused-vars CacheChainWrathRequiredNext,
CacheDragonsFortuneMultAdjustment, CacheDragonsFortuneMultAdjustment,
CacheGoldenCookiesMult, CacheGoldenCookiesMult,
CacheNoGoldSwitchCookiesPS, CacheNoGoldSwitchCookiesPS,
@@ -89,4 +90,19 @@ export function CacheChain() {
CacheChainFrenzyWrathRequired = (CacheChainFrenzyWrathMaxReward[1] * 2) / CacheWrathCookiesMult; CacheChainFrenzyWrathRequired = (CacheChainFrenzyWrathMaxReward[1] * 2) / CacheWrathCookiesMult;
CacheChainFrenzyWrathRequiredNext = CacheChainFrenzyWrathRequiredNext =
CacheChainFrenzyWrathMaxReward[2] / 60 / 60 / 6 / CacheDragonsFortuneMultAdjustment; CacheChainFrenzyWrathMaxReward[2] / 60 / 60 / 6 / CacheDragonsFortuneMultAdjustment;
FillCMDCache({
CacheChainMaxReward,
CacheChainRequired,
CacheChainRequiredNext,
CacheChainWrathMaxReward,
CacheChainWrathRequired,
CacheChainWrathRequiredNext,
CacheChainFrenzyMaxReward,
CacheChainFrenzyRequired,
CacheChainFrenzyRequiredNext,
CacheChainFrenzyWrathMaxReward,
CacheChainFrenzyWrathRequired,
CacheChainFrenzyWrathRequiredNext,
});
} }

View File

@@ -1,5 +1,6 @@
import FillCMDCache from '../FillCMDCache';
import { import {
CacheHCPerSecond, // eslint-disable-line no-unused-vars CacheHCPerSecond,
CacheLastHeavenlyCheck, CacheLastHeavenlyCheck,
CacheLastHeavenlyChips, CacheLastHeavenlyChips,
HeavenlyChipsDiff, HeavenlyChipsDiff,
@@ -32,4 +33,6 @@ export default function CacheHeavenlyChipsPS() {
// Get average gain over period of 5 seconds // Get average gain over period of 5 seconds
CacheHCPerSecond = HeavenlyChipsDiff.calcAverage(5); CacheHCPerSecond = HeavenlyChipsDiff.calcAverage(5);
} }
FillCMDCache({ CacheLastHeavenlyCheck, CacheLastHeavenlyChips, CacheHCPerSecond });
} }

View File

@@ -1,4 +1,5 @@
import { CacheSeaSpec } from '../VariablesAndData'; // eslint-disable-line no-unused-vars import FillCMDCache from '../FillCMDCache';
import { CacheSeaSpec } from '../VariablesAndData';
/** /**
* This functions caches the reward of popping a reindeer * This functions caches the reward of popping a reindeer
@@ -13,4 +14,6 @@ export default function CacheSeasonSpec() {
CacheSeaSpec = Math.max(25, val); CacheSeaSpec = Math.max(25, val);
if (Game.Has('Ho ho ho-flavored frosting')) CacheSeaSpec *= 2; if (Game.Has('Ho ho ho-flavored frosting')) CacheSeaSpec *= 2;
} }
FillCMDCache({ CacheSeaSpec });
} }

View File

@@ -2,19 +2,20 @@
import SimHas from '../../Sim/ReplacedGameFunctions/SimHas'; import SimHas from '../../Sim/ReplacedGameFunctions/SimHas';
import GetCPSBuffMult from '../CPS/GetCPSBuffMult'; import GetCPSBuffMult from '../CPS/GetCPSBuffMult';
import FillCMDCache from '../FillCMDCache';
import { import {
CacheConjure, CacheConjure,
CacheConjureReward, // eslint-disable-line no-unused-vars CacheConjureReward,
CacheDragonsFortuneMultAdjustment, CacheDragonsFortuneMultAdjustment,
CacheEdifice, CacheEdifice,
CacheEdificeBuilding, // eslint-disable-line no-unused-vars CacheEdificeBuilding,
CacheGoldenCookiesMult, CacheGoldenCookiesMult,
CacheLucky, CacheLucky,
CacheLuckyFrenzy, CacheLuckyFrenzy,
CacheLuckyReward, // eslint-disable-line no-unused-vars CacheLuckyReward,
CacheLuckyRewardFrenzy, // eslint-disable-line no-unused-vars CacheLuckyRewardFrenzy,
CacheLuckyWrathReward, // eslint-disable-line no-unused-vars CacheLuckyWrathReward,
CacheLuckyWrathRewardFrenzy, // eslint-disable-line no-unused-vars CacheLuckyWrathRewardFrenzy,
CacheNoGoldSwitchCookiesPS, CacheNoGoldSwitchCookiesPS,
CacheWrathCookiesMult, CacheWrathCookiesMult,
} from '../VariablesAndData'; } from '../VariablesAndData';
@@ -53,6 +54,19 @@ export function CacheStatsCookies() {
CacheEdificeBuilding = i; CacheEdificeBuilding = i;
} }
}); });
FillCMDCache({
CacheLucky,
CacheLuckyReward,
CacheLuckyWrathReward,
CacheLuckyFrenzy,
CacheLuckyRewardFrenzy,
CacheLuckyWrathRewardFrenzy,
CacheConjure,
CacheConjureReward,
CacheEdifice,
CacheEdificeBuilding,
});
} }
/** /**
@@ -84,4 +98,10 @@ export function CacheGoldenAndWrathCookiesMults() {
if (Game.shimmerTypes.golden.n === 0) { if (Game.shimmerTypes.golden.n === 0) {
CacheDragonsFortuneMultAdjustment *= 1 + Game.auraMult("Dragon's Fortune") * 1.23; CacheDragonsFortuneMultAdjustment *= 1 + Game.auraMult("Dragon's Fortune") * 1.23;
} }
FillCMDCache({
CacheGoldenCookiesMult,
CacheWrathCookiesMult,
CacheDragonsFortuneMultAdjustment,
});
} }

View File

@@ -1,4 +1,5 @@
import BuildingGetPrice from '../../Sim/SimulationEvents/BuyBuilding'; import BuildingGetPrice from '../../Sim/SimulationEvents/BuyBuilding';
import FillCMDCache from '../FillCMDCache';
import { CacheObjectsNextAchievement } from '../VariablesAndData'; import { CacheObjectsNextAchievement } from '../VariablesAndData';
import IndividualAmountTillNextAchievement from './IndividualAmountTillNextAchievement'; import IndividualAmountTillNextAchievement from './IndividualAmountTillNextAchievement';
@@ -41,5 +42,7 @@ export default function AllAmountTillNextAchievement(forceRecalc) {
}; };
} }
}); });
CacheObjectsNextAchievement = result; // eslint-disable-line no-unused-vars CacheObjectsNextAchievement = result;
FillCMDCache({ CacheObjectsNextAchievement });
} }

View File

@@ -1,10 +1,11 @@
/** Caches data related to Wrinklers */ /** Caches data related to Wrinklers */
import { SimObjects } from '../../Sim/VariablesAndData'; import { SimObjects } from '../../Sim/VariablesAndData';
import FillCMDCache from '../FillCMDCache';
import { import {
CacheWrinklersFattest, CacheWrinklersFattest,
CacheWrinklersNormal, // eslint-disable-line no-unused-vars CacheWrinklersNormal,
CacheWrinklersTotal, // eslint-disable-line no-unused-vars CacheWrinklersTotal,
} from '../VariablesAndData'; } from '../VariablesAndData';
/** /**
@@ -37,4 +38,6 @@ export default function CacheWrinklers() {
if (sucked > CacheWrinklersFattest[0]) CacheWrinklersFattest = [sucked, i]; if (sucked > CacheWrinklersFattest[0]) CacheWrinklersFattest = [sucked, i];
} }
} }
FillCMDCache({ CacheWrinklersTotal, CacheWrinklersNormal, CacheWrinklersFattest });
} }