Export caches via CookieMonsterData.

This commit is contained in:
Ben Blank
2021-09-13 18:15:21 -07:00
parent 809bd4d35d
commit 74e7c64ca2
19 changed files with 136 additions and 31 deletions

View File

@@ -1,19 +1,20 @@
import { ClickTimes, CookieTimes } from '../../Disp/VariablesAndData';
import FillCMDCache from '../FillCMDCache';
import {
CacheAverageClicks, // eslint-disable-line no-unused-vars
CacheAverageClicks,
CacheAverageCPS,
CacheAverageGainBank,
CacheAverageGainChoEgg,
CacheAverageGainWrink,
CacheAverageGainWrinkFattest,
CacheAvgCPSWithChoEgg, // eslint-disable-line no-unused-vars
CacheAvgCPSWithChoEgg,
CacheLastChoEgg,
CacheLastClicks,
CacheLastCookies,
CacheLastCPSCheck,
CacheLastWrinkCookies,
CacheLastWrinkFattestCookies,
CacheRealCookiesEarned, // eslint-disable-line no-unused-vars
CacheRealCookiesEarned,
CacheSellForChoEgg,
CacheWrinklersFattest,
CacheWrinklersTotal,
@@ -93,4 +94,21 @@ export default function CacheAvgCPS() {
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 { 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
@@ -26,4 +27,6 @@ export default function CacheCurrWrinklerCPS() {
(Game.Has('Sacrilegious corruption') * 0.05 + 1) *
(Game.Has('Wrinklerspawn') * 0.05 + 1) *
godMult;
FillCMDCache({ CacheCurrWrinklerCount, CacheCurrWrinklerCPSMult });
}

View File

@@ -1,5 +1,6 @@
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
@@ -10,4 +11,6 @@ export default function CacheNoGoldSwitchCPS() {
if (Game.Has('Golden switch [off]')) {
CacheNoGoldSwitchCookiesPS = CalcNoGoldSwitchCPS();
} else CacheNoGoldSwitchCookiesPS = Game.cookiesPs;
FillCMDCache({ CacheNoGoldSwitchCookiesPS });
}

View File

@@ -1,5 +1,6 @@
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
@@ -21,4 +22,6 @@ export default function CacheSellAllForChoEgg() {
// Compute cookies earned by selling all buildings with optimal auras (ES + RB)
sellTotal += SellBuildingsForChoEgg();
CacheSellForChoEgg = sellTotal;
FillCMDCache({ CacheSellForChoEgg });
}

View File

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

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

@@ -0,0 +1,18 @@
/**
* 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/, '');
// 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 { ColourGray } from '../../Disp/VariablesAndData';
import BuildingGetPrice from '../../Sim/SimulationEvents/BuyBuilding';
import FillCMDCache from '../FillCMDCache';
import {
CacheMinPP, // eslint-disable-line no-unused-vars
CacheMinPPBulk, // eslint-disable-line no-unused-vars
CacheMinPP,
CacheMinPPBulk,
CacheObjects1,
CacheObjects10,
CacheObjects100,
@@ -106,4 +107,6 @@ export default function CacheBuildingsPP() {
CacheColour(CacheObjects1, 1);
CacheColour(CacheObjects10, 10);
CacheColour(CacheObjects100, 100);
FillCMDCache({ CacheMinPP, CacheMinPPBulk, CachePPArray });
}

View File

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

View File

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

View File

@@ -1,17 +1,18 @@
import GetCPSBuffMult from '../CPS/GetCPSBuffMult';
import FillCMDCache from '../FillCMDCache';
import {
CacheChainFrenzyMaxReward,
CacheChainFrenzyRequired, // eslint-disable-line no-unused-vars
CacheChainFrenzyRequiredNext, // eslint-disable-line no-unused-vars
CacheChainFrenzyRequired,
CacheChainFrenzyRequiredNext,
CacheChainFrenzyWrathMaxReward,
CacheChainFrenzyWrathRequired, // eslint-disable-line no-unused-vars
CacheChainFrenzyWrathRequiredNext, // eslint-disable-line no-unused-vars
CacheChainFrenzyWrathRequired,
CacheChainFrenzyWrathRequiredNext,
CacheChainMaxReward,
CacheChainRequired, // eslint-disable-line no-unused-vars
CacheChainRequiredNext, // eslint-disable-line no-unused-vars
CacheChainRequired,
CacheChainRequiredNext,
CacheChainWrathMaxReward,
CacheChainWrathRequired, // eslint-disable-line no-unused-vars
CacheChainWrathRequiredNext, // eslint-disable-line no-unused-vars
CacheChainWrathRequired,
CacheChainWrathRequiredNext,
CacheDragonsFortuneMultAdjustment,
CacheGoldenCookiesMult,
CacheNoGoldSwitchCookiesPS,
@@ -89,4 +90,19 @@ export function CacheChain() {
CacheChainFrenzyWrathRequired = (CacheChainFrenzyWrathMaxReward[1] * 2) / CacheWrathCookiesMult;
CacheChainFrenzyWrathRequiredNext =
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 {
CacheHCPerSecond, // eslint-disable-line no-unused-vars
CacheHCPerSecond,
CacheLastHeavenlyCheck,
CacheLastHeavenlyChips,
HeavenlyChipsDiff,
@@ -32,4 +33,6 @@ export default function CacheHeavenlyChipsPS() {
// Get average gain over period of 5 seconds
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
@@ -13,4 +14,6 @@ export default function CacheSeasonSpec() {
CacheSeaSpec = Math.max(25, val);
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 GetCPSBuffMult from '../CPS/GetCPSBuffMult';
import FillCMDCache from '../FillCMDCache';
import {
CacheConjure,
CacheConjureReward, // eslint-disable-line no-unused-vars
CacheConjureReward,
CacheDragonsFortuneMultAdjustment,
CacheEdifice,
CacheEdificeBuilding, // eslint-disable-line no-unused-vars
CacheEdificeBuilding,
CacheGoldenCookiesMult,
CacheLucky,
CacheLuckyFrenzy,
CacheLuckyReward, // eslint-disable-line no-unused-vars
CacheLuckyRewardFrenzy, // eslint-disable-line no-unused-vars
CacheLuckyWrathReward, // eslint-disable-line no-unused-vars
CacheLuckyWrathRewardFrenzy, // eslint-disable-line no-unused-vars
CacheLuckyReward,
CacheLuckyRewardFrenzy,
CacheLuckyWrathReward,
CacheLuckyWrathRewardFrenzy,
CacheNoGoldSwitchCookiesPS,
CacheWrathCookiesMult,
} from '../VariablesAndData';
@@ -53,6 +54,19 @@ export function CacheStatsCookies() {
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) {
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 FillCMDCache from '../FillCMDCache';
import { CacheObjectsNextAchievement } from '../VariablesAndData';
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 */
import { SimObjects } from '../../Sim/VariablesAndData';
import FillCMDCache from '../FillCMDCache';
import {
CacheWrinklersFattest,
CacheWrinklersNormal, // eslint-disable-line no-unused-vars
CacheWrinklersTotal, // eslint-disable-line no-unused-vars
CacheWrinklersNormal,
CacheWrinklersTotal,
} from '../VariablesAndData';
/**
@@ -37,4 +38,6 @@ export default function CacheWrinklers() {
if (sucked > CacheWrinklersFattest[0]) CacheWrinklersFattest = [sucked, i];
}
}
FillCMDCache({ CacheWrinklersTotal, CacheWrinklersNormal, CacheWrinklersFattest });
}