Complete overhaul of code structure and relevant files (#639)
This commit is contained in:
56
src/Cache/CPS/AverageQueue.js
Normal file
56
src/Cache/CPS/AverageQueue.js
Normal file
@@ -0,0 +1,56 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import { ClickTimes, CookieTimes } from '../../Disp/VariablesAndData';
|
||||
import {
|
||||
ChoEggDiff, ClicksDiff, CookiesDiff, WrinkDiff, WrinkFattestDiff,
|
||||
} from '../VariablesAndData';
|
||||
|
||||
/**
|
||||
* @class
|
||||
* @classdesc This is a class used to store values used to calculate average over time (mostly cps)
|
||||
* @var {number} maxLength The maximum length of the value-storage
|
||||
* @var {[]} queue The values stored
|
||||
* @method addLatest(newValue) Appends newValue to the value storage
|
||||
* @method calcAverage(timePeriod) Returns the average over the specified timeperiod
|
||||
*/
|
||||
export class CMAvgQueue {
|
||||
constructor(maxLength) {
|
||||
this.maxLength = maxLength;
|
||||
this.queue = [];
|
||||
}
|
||||
|
||||
addLatest(newValue) {
|
||||
if (this.queue.push(newValue) > this.maxLength) {
|
||||
this.queue.shift();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This functions returns the average of the values in the queue
|
||||
* @param {number} timePeriod The period in seconds to computer average over
|
||||
* @returns {number} ret The average
|
||||
*/
|
||||
calcAverage(timePeriod) {
|
||||
if (timePeriod > this.maxLength) timePeriod = this.maxLength;
|
||||
if (timePeriod > this.queue.length) timePeriod = this.queue.length;
|
||||
let ret = 0;
|
||||
for (let i = this.queue.length - 1; i >= 0 && i > this.queue.length - 1 - timePeriod; i--) {
|
||||
ret += this.queue[i];
|
||||
}
|
||||
if (ret === 0) {
|
||||
return 0;
|
||||
}
|
||||
return ret / timePeriod;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This functions caches creates the CMAvgQueue used by CM.Cache.CacheAvgCPS() to calculate CPS
|
||||
* Called by CM.Cache.InitCache()
|
||||
*/
|
||||
export function InitCookiesDiff() {
|
||||
CookiesDiff = new CMAvgQueue(CookieTimes[CookieTimes.length - 1]);
|
||||
WrinkDiff = new CMAvgQueue(CookieTimes[CookieTimes.length - 1]);
|
||||
WrinkFattestDiff = new CMAvgQueue(CookieTimes[CookieTimes.length - 1]);
|
||||
ChoEggDiff = new CMAvgQueue(CookieTimes[CookieTimes.length - 1]);
|
||||
ClicksDiff = new CMAvgQueue(ClickTimes[ClickTimes.length - 1]);
|
||||
}
|
||||
67
src/Cache/CPS/CPS.js
Normal file
67
src/Cache/CPS/CPS.js
Normal file
@@ -0,0 +1,67 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
|
||||
import { CMOptions } from '../../Config/VariablesAndData';
|
||||
import { ClickTimes, CookieTimes } from '../../Disp/VariablesAndData';
|
||||
import {
|
||||
CacheAverageClicks, CacheAverageCPS, CacheAverageGainBank, CacheAverageGainChoEgg, CacheAverageGainWrink, CacheAverageGainWrinkFattest, CacheAvgCPSWithChoEgg, CacheLastChoEgg, CacheLastClicks, CacheLastCookies, CacheLastCPSCheck, CacheLastWrinkCookies, CacheLastWrinkFattestCookies, CacheRealCookiesEarned, CacheSellForChoEgg, CacheWrinklersFattest, CacheWrinklersTotal, ChoEggDiff, ClicksDiff, CookiesDiff, WrinkDiff, WrinkFattestDiff,
|
||||
} from '../VariablesAndData';
|
||||
|
||||
/**
|
||||
* This functions caches two variables related average CPS and Clicks
|
||||
* It is called by CM.Cache.LoopCache()
|
||||
* @global {number} CM.Cache.RealCookiesEarned Cookies earned including the Chocolate Egg
|
||||
* @global {number} CM.Cache.AvgCPS Average cookies over time-period as defined by AvgCPSHist
|
||||
* @global {number} CM.Cache.AverageClicks Average cookies from clicking over time-period as defined by AvgClicksHist
|
||||
* @global {number} CM.Cache.AvgCPSChoEgg Average cookies from combination of normal CPS and average Chocolate Cookie CPS
|
||||
*/
|
||||
export default function CacheAvgCPS() {
|
||||
const currDate = Math.floor(Date.now() / 1000);
|
||||
// Only calculate every new second
|
||||
if ((Game.T / Game.fps) % 1 === 0) {
|
||||
let choEggTotal = Game.cookies + CacheSellForChoEgg;
|
||||
if (Game.cpsSucked > 0) choEggTotal += CacheWrinklersTotal;
|
||||
CacheRealCookiesEarned = Math.max(Game.cookiesEarned, choEggTotal);
|
||||
choEggTotal *= 0.05;
|
||||
|
||||
// Add recent gains to AvgQueue's
|
||||
const timeDiff = currDate - CacheLastCPSCheck;
|
||||
const bankDiffAvg = Math.max(0, (Game.cookies - CacheLastCookies)) / timeDiff;
|
||||
const wrinkDiffAvg = Math.max(0, (CacheWrinklersTotal - CacheLastWrinkCookies)) / timeDiff;
|
||||
const wrinkFattestDiffAvg = Math.max(0, (CacheWrinklersFattest[0] - CacheLastWrinkFattestCookies)) / timeDiff;
|
||||
const choEggDiffAvg = Math.max(0, (choEggTotal - CacheLastChoEgg)) / timeDiff;
|
||||
const clicksDiffAvg = (Game.cookieClicks - CacheLastClicks) / timeDiff;
|
||||
for (let i = 0; i < timeDiff; i++) {
|
||||
CookiesDiff.addLatest(bankDiffAvg);
|
||||
WrinkDiff.addLatest(wrinkDiffAvg);
|
||||
WrinkFattestDiff.addLatest(wrinkFattestDiffAvg);
|
||||
ChoEggDiff.addLatest(choEggDiffAvg);
|
||||
ClicksDiff.addLatest(clicksDiffAvg);
|
||||
}
|
||||
|
||||
// Store current data for next loop
|
||||
CacheLastCPSCheck = currDate;
|
||||
CacheLastCookies = Game.cookies;
|
||||
CacheLastWrinkCookies = CacheWrinklersTotal;
|
||||
CacheLastWrinkFattestCookies = CacheWrinklersFattest[0];
|
||||
CacheLastChoEgg = choEggTotal;
|
||||
CacheLastClicks = Game.cookieClicks;
|
||||
|
||||
// Get average gain over period of cpsLength seconds
|
||||
const cpsLength = CookieTimes[CMOptions.AvgCPSHist];
|
||||
CacheAverageGainBank = CookiesDiff.calcAverage(cpsLength);
|
||||
CacheAverageGainWrink = WrinkDiff.calcAverage(cpsLength);
|
||||
CacheAverageGainWrinkFattest = WrinkFattestDiff.calcAverage(cpsLength);
|
||||
CacheAverageGainChoEgg = ChoEggDiff.calcAverage(cpsLength);
|
||||
CacheAverageCPS = CacheAverageGainBank;
|
||||
if (CMOptions.CalcWrink === 1) CacheAverageCPS += CacheAverageGainWrink;
|
||||
if (CMOptions.CalcWrink === 2) CacheAverageCPS += CacheAverageGainWrinkFattest;
|
||||
|
||||
const choEgg = (Game.HasUnlocked('Chocolate egg') && !Game.Has('Chocolate egg'));
|
||||
|
||||
if (choEgg || CMOptions.CalcWrink === 0) {
|
||||
CacheAvgCPSWithChoEgg = CacheAverageGainBank + CacheAverageGainWrink + (choEgg ? CacheAverageGainChoEgg : 0);
|
||||
} else CacheAvgCPSWithChoEgg = CacheAverageCPS;
|
||||
|
||||
CacheAverageClicks = ClicksDiff.calcAverage(ClickTimes[CMOptions.AvgClicksHist]);
|
||||
}
|
||||
}
|
||||
25
src/Cache/CPS/CurrWrinklerCPS.js
Normal file
25
src/Cache/CPS/CurrWrinklerCPS.js
Normal file
@@ -0,0 +1,25 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import { SimObjects } from '../../Sim/VariablesAndData';
|
||||
import { CacheCurrWrinklerCount, CacheCurrWrinklerCPSMult } from '../VariablesAndData';
|
||||
|
||||
/**
|
||||
* This functions caches the current Wrinkler CPS multiplier
|
||||
* @global {number} CM.Cache.CurrWrinklerCount Current number of wrinklers
|
||||
* @global {number} CM.Cache.CurrWrinklerCPSMult Current multiplier of CPS because of wrinklers (excluding their negative sucking effect)
|
||||
*/
|
||||
export default function CacheCurrWrinklerCPS() {
|
||||
CacheCurrWrinklerCPSMult = 0;
|
||||
let count = 0;
|
||||
for (const i in Game.wrinklers) {
|
||||
if (Game.wrinklers[i].phase === 2) count++;
|
||||
}
|
||||
let godMult = 1;
|
||||
if (SimObjects.Temple.minigameLoaded) {
|
||||
const godLvl = Game.hasGod('scorn');
|
||||
if (godLvl === 1) godMult *= 1.15;
|
||||
else if (godLvl === 2) godMult *= 1.1;
|
||||
else if (godLvl === 3) godMult *= 1.05;
|
||||
}
|
||||
CacheCurrWrinklerCount = count;
|
||||
CacheCurrWrinklerCPSMult = count * (count * 0.05 * 1.1) * (Game.Has('Sacrilegious corruption') * 0.05 + 1) * (Game.Has('Wrinklerspawn') * 0.05 + 1) * godMult;
|
||||
}
|
||||
11
src/Cache/CPS/GetCPSBuffMult.js
Normal file
11
src/Cache/CPS/GetCPSBuffMult.js
Normal file
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* This function returns the current CPS buff
|
||||
* @returns {number} mult The multiplier
|
||||
*/
|
||||
export default function GetCPSBuffMult() {
|
||||
let mult = 1;
|
||||
for (const i of Object.keys(Game.buffs)) {
|
||||
if (typeof Game.buffs[i].multCpS !== 'undefined') mult *= Game.buffs[i].multCpS;
|
||||
}
|
||||
return mult;
|
||||
}
|
||||
14
src/Cache/CPS/NoGoldSwitchCPS.js
Normal file
14
src/Cache/CPS/NoGoldSwitchCPS.js
Normal file
@@ -0,0 +1,14 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import CalcNoGoldSwitchCPS from '../../Sim/Calculations/NoGoldenSwitchCalc';
|
||||
import { CacheNoGoldSwitchCookiesPS } from '../VariablesAndData';
|
||||
|
||||
/**
|
||||
* This function calculates CPS without the Golden Switch as it might be needed in other functions
|
||||
* If so it CM.Sim.Win()'s them and the caller function will know to recall CM.Sim.CalculateGains()
|
||||
* It is called at the end of any functions that simulates certain behaviour
|
||||
*/
|
||||
export default function CacheNoGoldSwitchCPS() {
|
||||
if (Game.Has('Golden switch [off]')) {
|
||||
CacheNoGoldSwitchCookiesPS = CalcNoGoldSwitchCPS();
|
||||
} else CacheNoGoldSwitchCookiesPS = Game.cookiesPs;
|
||||
}
|
||||
25
src/Cache/CPS/SellChoEgg.js
Normal file
25
src/Cache/CPS/SellChoEgg.js
Normal file
@@ -0,0 +1,25 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import SellBuildingsForChoEgg from '../../Sim/SimulationEvents/SellBuildingForChoEgg';
|
||||
import { CacheSellForChoEgg } from '../VariablesAndData';
|
||||
|
||||
/**
|
||||
* This functions caches the reward for selling the Chocolate egg
|
||||
* It is called by CM.Main.Loop()
|
||||
* @global {number} CM.Cache.SellForChoEgg Total cookies to be gained from selling Chocolate egg
|
||||
*/
|
||||
export default function CacheSellAllForChoEgg() {
|
||||
let sellTotal = 0;
|
||||
// Compute cookies earned by selling stock market goods
|
||||
if (Game.Objects.Bank.minigameLoaded) {
|
||||
const marketGoods = Game.Objects.Bank.minigame.goods;
|
||||
let goodsVal = 0;
|
||||
for (const i of Object.keys(marketGoods)) {
|
||||
const marketGood = marketGoods[i];
|
||||
goodsVal += marketGood.stock * marketGood.val;
|
||||
}
|
||||
sellTotal += goodsVal * Game.cookiesPsRawHighest;
|
||||
}
|
||||
// Compute cookies earned by selling all buildings with optimal auras (ES + RB)
|
||||
sellTotal += SellBuildingsForChoEgg();
|
||||
CacheSellForChoEgg = sellTotal;
|
||||
}
|
||||
@@ -1,798 +0,0 @@
|
||||
/**
|
||||
* Cache *
|
||||
*/
|
||||
|
||||
/**
|
||||
* Section: General Cache related functions */
|
||||
|
||||
/**
|
||||
* This functions runs all cache-functions to generate all "full" cache
|
||||
* The declaration follows the structure of the CM.Cache.js file
|
||||
* It is called by CM.Main.DelayInit
|
||||
*/
|
||||
CM.Cache.InitCache = function () {
|
||||
CM.Cache.CacheDragonAuras();
|
||||
CM.Cache.CacheWrinklers();
|
||||
CM.Cache.CacheStats();
|
||||
CM.Cache.CacheGoldenAndWrathCookiesMults();
|
||||
CM.Cache.CacheChain();
|
||||
CM.Cache.CacheMissingUpgrades();
|
||||
CM.Cache.CacheSeaSpec();
|
||||
CM.Cache.InitCookiesDiff();
|
||||
CM.Cache.HeavenlyChipsDiff = new CMAvgQueue(5); // Used by CM.Cache.CacheHeavenlyChipsPS()
|
||||
CM.Cache.CacheHeavenlyChipsPS();
|
||||
CM.Cache.CacheAvgCPS();
|
||||
CM.Cache.CacheIncome();
|
||||
CM.Cache.CacheBuildingsPrices();
|
||||
CM.Cache.CachePP();
|
||||
};
|
||||
|
||||
/**
|
||||
* This functions caches variables that are needed every loop
|
||||
* It is called by CM.Main.Loop()
|
||||
* @global {string} CM.Cache.TimeTillNextPrestige Time requried till next prestige level
|
||||
*/
|
||||
CM.Cache.LoopCache = function () {
|
||||
// Update Wrinkler Bank
|
||||
CM.Cache.CacheWrinklers();
|
||||
|
||||
CM.Cache.CachePP();
|
||||
CM.Cache.CacheCurrWrinklerCPS();
|
||||
CM.Cache.CacheAvgCPS();
|
||||
CM.Cache.CacheHeavenlyChipsPS();
|
||||
|
||||
const cookiesToNext = Game.HowManyCookiesReset(Math.floor(Game.HowMuchPrestige(Game.cookiesReset + Game.cookiesEarned)) + 1) - (Game.cookiesEarned + Game.cookiesReset);
|
||||
CM.Cache.TimeTillNextPrestige = CM.Disp.FormatTime(cookiesToNext / CM.Disp.GetCPS());
|
||||
};
|
||||
|
||||
/**
|
||||
* Section: Helper functions */
|
||||
|
||||
/**
|
||||
* @class
|
||||
* @classdesc This is a class used to store values used to calculate average over time (mostly cps)
|
||||
* @var {number} maxLength The maximum length of the value-storage
|
||||
* @var {[]} queue The values stored
|
||||
* @method addLatest(newValue) Appends newValue to the value storage
|
||||
* @method calcAverage(timePeriod) Returns the average over the specified timeperiod
|
||||
*/
|
||||
class CMAvgQueue {
|
||||
constructor(maxLength) {
|
||||
this.maxLength = maxLength;
|
||||
this.queue = [];
|
||||
}
|
||||
|
||||
addLatest(newValue) {
|
||||
if (this.queue.push(newValue) > this.maxLength) {
|
||||
this.queue.shift();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This functions returns the average of the values in the queue
|
||||
* @param {number} timePeriod The period in seconds to computer average over
|
||||
* @returns {number} ret The average
|
||||
*/
|
||||
calcAverage(timePeriod) {
|
||||
if (timePeriod > this.maxLength) timePeriod = this.maxLength;
|
||||
if (timePeriod > this.queue.length) timePeriod = this.queue.length;
|
||||
let ret = 0;
|
||||
for (let i = this.queue.length - 1; i >= 0 && i > this.queue.length - 1 - timePeriod; i--) {
|
||||
ret += this.queue[i];
|
||||
}
|
||||
if (ret === 0) {
|
||||
return 0;
|
||||
}
|
||||
return ret / timePeriod;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Section: Functions related to Dragon Auras */
|
||||
|
||||
/**
|
||||
* This functions caches the currently selected Dragon Auras
|
||||
* It is called by CM.Sim.CopyData() and CM.Cache.InitCache()
|
||||
* Uncapitalized dragon follows Game-naming
|
||||
* @global {number} CM.Cache.dragonAura The number of the first (right) Aura
|
||||
* @global {number} CM.Cache.dragonAura2 The number of the second (left) Aura
|
||||
*/
|
||||
CM.Cache.CacheDragonAuras = function () {
|
||||
CM.Cache.dragonAura = Game.dragonAura;
|
||||
CM.Cache.dragonAura2 = Game.dragonAura2;
|
||||
};
|
||||
|
||||
/**
|
||||
* Section: Functions related to Wrinklers */
|
||||
|
||||
/**
|
||||
* This functions caches data related to Wrinklers
|
||||
* It is called by CM.Cache.LoopCache() and CM.Cache.InitCache()
|
||||
* @global {number} CM.Cache.WrinklersTotal The cookies of all wrinklers
|
||||
* @global {number} CM.Cache.WrinklersNormal The cookies of all normal wrinklers
|
||||
* @global {[{number}, {number}]} CM.Cache.WrinklersFattest A list containing the cookies and the id of the fattest non-shiny wrinkler
|
||||
*/
|
||||
CM.Cache.CacheWrinklers = function () {
|
||||
CM.Cache.WrinklersTotal = 0;
|
||||
CM.Cache.WrinklersNormal = 0;
|
||||
CM.Cache.WrinklersFattest = [0, null];
|
||||
for (let i = 0; i < Game.wrinklers.length; i++) {
|
||||
let sucked = Game.wrinklers[i].sucked;
|
||||
let toSuck = 1.1;
|
||||
if (Game.Has('Sacrilegious corruption')) toSuck *= 1.05;
|
||||
if (Game.wrinklers[i].type === 1) toSuck *= 3; // Shiny wrinklers
|
||||
sucked *= toSuck;
|
||||
if (Game.Has('Wrinklerspawn')) sucked *= 1.05;
|
||||
if (CM.Sim.Objects.Temple.minigameLoaded) {
|
||||
const godLvl = Game.hasGod('scorn');
|
||||
if (godLvl === 1) sucked *= 1.15;
|
||||
else if (godLvl === 2) sucked *= 1.1;
|
||||
else if (godLvl === 3) sucked *= 1.05;
|
||||
}
|
||||
CM.Cache.WrinklersTotal += sucked;
|
||||
if (Game.wrinklers[i].type === 0) {
|
||||
CM.Cache.WrinklersNormal += sucked;
|
||||
if (sucked > CM.Cache.WrinklersFattest[0]) CM.Cache.WrinklersFattest = [sucked, i];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Section: Functions related to Caching stats */
|
||||
|
||||
/**
|
||||
* This functions caches variables related to the stats page
|
||||
* It is called by CM.Main.Loop() upon changes to cps and CM.Cache.InitCache()
|
||||
* @global {number} CM.Cache.Lucky Cookies required for max Lucky
|
||||
* @global {number} CM.Cache.LuckyReward Reward for max normal Lucky
|
||||
* @global {number} CM.Cache.LuckyWrathReward Reward for max normal Lucky from Wrath cookie
|
||||
* @global {number} CM.Cache.LuckyFrenzy Cookies required for max Lucky Frenzy
|
||||
* @global {number} CM.Cache.LuckyRewardFrenzy Reward for max Lucky Frenzy
|
||||
* @global {number} CM.Cache.LuckyWrathRewardFrenzy Reward for max Lucky Frenzy from Wrath cookie
|
||||
* @global {number} CM.Cache.Conjure Cookies required for max Conjure Baked Goods
|
||||
* @global {number} CM.Cache.ConjureReward Reward for max Conjure Baked Goods
|
||||
* @global {number} CM.Cache.Edifice Cookies required for most expensive building through Spontaneous Edifice
|
||||
* @global {string} CM.Cache.EdificeBuilding Name of most expensive building possible with Spontaneous Edifice
|
||||
*/
|
||||
CM.Cache.CacheStats = function () {
|
||||
CM.Cache.Lucky = (CM.Cache.NoGoldSwitchCookiesPS * 900) / 0.15;
|
||||
CM.Cache.Lucky *= CM.Cache.DragonsFortuneMultAdjustment;
|
||||
const cpsBuffMult = CM.Cache.getCPSBuffMult();
|
||||
if (cpsBuffMult > 0) CM.Cache.Lucky /= cpsBuffMult;
|
||||
else CM.Cache.Lucky = 0;
|
||||
CM.Cache.LuckyReward = CM.Cache.GoldenCookiesMult * (CM.Cache.Lucky * 0.15) + 13;
|
||||
CM.Cache.LuckyWrathReward = CM.Cache.WrathCookiesMult * (CM.Cache.Lucky * 0.15) + 13;
|
||||
CM.Cache.LuckyFrenzy = CM.Cache.Lucky * 7;
|
||||
CM.Cache.LuckyRewardFrenzy = CM.Cache.GoldenCookiesMult * (CM.Cache.LuckyFrenzy * 0.15) + 13;
|
||||
CM.Cache.LuckyWrathRewardFrenzy = CM.Cache.WrathCookiesMult * (CM.Cache.LuckyFrenzy * 0.15) + 13;
|
||||
CM.Cache.Conjure = CM.Cache.Lucky * 2;
|
||||
CM.Cache.ConjureReward = CM.Cache.Conjure * 0.15;
|
||||
|
||||
CM.Cache.Edifice = 0;
|
||||
let max = 0;
|
||||
let n = 0;
|
||||
for (const i of Object.keys(Game.Objects)) {
|
||||
if (Game.Objects[i].amount > max) max = Game.Objects[i].amount;
|
||||
if (Game.Objects[i].amount > 0) n++;
|
||||
}
|
||||
for (const i of Object.keys(Game.Objects)) {
|
||||
if ((Game.Objects[i].amount < max || n === 1)
|
||||
&& Game.Objects[i].amount < 400
|
||||
&& Game.Objects[i].price * 2 > CM.Cache.Edifice) {
|
||||
CM.Cache.Edifice = Game.Objects[i].price * 2;
|
||||
CM.Cache.EdificeBuilding = i;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* This functions calculates the multipliers of Golden and Wrath cookie rewards
|
||||
* It is mostly used by CM.Cache.MaxChainCookieReward() and CM.Cache.CacheChain()
|
||||
* It is called by CM.Disp.CreateStatsChainSection() and CM.Cache.CacheChain()
|
||||
* @param {number} CM.Cache.GoldenCookiesMult Multiplier for golden cookies
|
||||
* @param {number} CM.Cache.WrathCookiesMult Multiplier for wrath cookies
|
||||
* @param {number} CM.Cache.DragonsFortuneMultAdjustment Multiplier for dragon fortune + active golden cookie
|
||||
*/
|
||||
CM.Cache.CacheGoldenAndWrathCookiesMults = function () {
|
||||
if (CM.Footer.isInitzializing) {
|
||||
CM.Cache.GoldenCookiesMult = 1;
|
||||
CM.Cache.WrathCookiesMult = 1;
|
||||
CM.Cache.DragonsFortuneMultAdjustment = 1;
|
||||
} else {
|
||||
let goldenMult = 1;
|
||||
let wrathMult = 1;
|
||||
let mult = 1;
|
||||
|
||||
// Factor auras and upgrade in mults
|
||||
if (CM.Sim.Has('Green yeast digestives')) mult *= 1.01;
|
||||
if (CM.Sim.Has('Dragon fang')) mult *= 1.03;
|
||||
|
||||
goldenMult *= 1 + Game.auraMult('Ancestral Metamorphosis') * 0.1;
|
||||
goldenMult *= Game.eff('goldenCookieGain');
|
||||
wrathMult *= 1 + Game.auraMult('Unholy Dominion') * 0.1;
|
||||
wrathMult *= Game.eff('wrathCookieGain');
|
||||
|
||||
// Calculate final golden and wrath multipliers
|
||||
CM.Cache.GoldenCookiesMult = mult * goldenMult;
|
||||
CM.Cache.WrathCookiesMult = mult * wrathMult;
|
||||
|
||||
// Calculate Dragon's Fortune multiplier adjustment:
|
||||
// If Dragon's Fortune (or Reality Bending) aura is active and there are currently no golden cookies,
|
||||
// compute a multiplier adjustment to apply on the current CPS to simulate 1 golden cookie on screen.
|
||||
// Otherwise, the aura effect will be factored in the base CPS making the multiplier not requiring adjustment.
|
||||
CM.Cache.DragonsFortuneMultAdjustment = 1;
|
||||
if (Game.shimmerTypes.golden.n === 0) {
|
||||
CM.Cache.DragonsFortuneMultAdjustment *= 1 + Game.auraMult('Dragon\'s Fortune') * 1.23;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* This functions calculates the max possible payout given a set of variables
|
||||
* It is called by CM.Disp.CreateStatsChainSection() and CM.Cache.CacheChain()
|
||||
* @param {number} digit Number of Golden Cookies in chain
|
||||
* @param {number} maxPayout Maximum payout
|
||||
* @param {number} mult Multiplier
|
||||
* @returns [{number, number, number}] Total cookies earned, cookie needed for this and next level
|
||||
*/
|
||||
CM.Cache.MaxChainCookieReward = function (digit, maxPayout, mult) {
|
||||
let totalFromChain = 0;
|
||||
let moni = 0;
|
||||
let nextMoni = 0;
|
||||
let nextRequired = 0;
|
||||
let chain = 1 + Math.max(0, Math.ceil(Math.log(Game.cookies) / Math.LN10) - 10);
|
||||
while (nextMoni < maxPayout) {
|
||||
moni = Math.max(digit, Math.min(Math.floor(1 / 9 * 10 ** chain * digit * mult), maxPayout * mult));
|
||||
nextMoni = Math.max(digit, Math.min(Math.floor(1 / 9 * 10 ** (chain + 1) * digit * mult), maxPayout * mult));
|
||||
nextRequired = Math.floor(1 / 9 * 10 ** (chain + 1) * digit * mult);
|
||||
totalFromChain += moni;
|
||||
chain++;
|
||||
}
|
||||
return [totalFromChain, moni, nextRequired];
|
||||
};
|
||||
|
||||
/**
|
||||
* This functions caches data related to Chain Cookies reward from Golden Cookioes
|
||||
* It is called by CM.Main.Loop() upon changes to cps and CM.Cache.InitCache()
|
||||
* @global [{number, number}] CM.Cache.ChainMaxReward Total cookies earned, and cookies needed for next level for normal chain
|
||||
* @global {number} CM.Cache.ChainRequired Cookies needed for maximum reward for normal chain
|
||||
* @global {number} CM.Cache.ChainRequiredNext Total cookies needed for next level for normal chain
|
||||
* @global [{number, number}] CM.Cache.ChainMaxWrathReward Total cookies earned, and cookies needed for next level for wrath chain
|
||||
* @global {number} CM.Cache.ChainWrathRequired Cookies needed for maximum reward for wrath chain
|
||||
* @global {number} CM.Cache.ChainWrathRequiredNext Total cookies needed for next level for wrath chain
|
||||
* @global [{number, number}] CM.Cache.ChainFrenzyMaxReward Total cookies earned, and cookies needed for next level for normal frenzy chain
|
||||
* @global {number} CM.Cache.ChainFrenzyRequired Cookies needed for maximum reward for normal frenzy chain
|
||||
* @global {number} CM.Cache.ChainFrenzyRequiredNext Total cookies needed for next level for normal frenzy chain
|
||||
* @global [{number, number}] CM.Cache.ChainFrenzyWrathMaxReward Total cookies earned, and cookies needed for next level for wrath frenzy chain
|
||||
* @global {number} CM.Cache.ChainFrenzyWrathRequired Cookies needed for maximum reward for wrath frenzy chain
|
||||
* @global {number} CM.Cache.ChainFrenzyWrathRequiredNext Total cookies needed for next level for wrath frenzy chain
|
||||
*/
|
||||
CM.Cache.CacheChain = function () {
|
||||
let maxPayout = CM.Cache.NoGoldSwitchCookiesPS * 60 * 60 * 6 * CM.Cache.DragonsFortuneMultAdjustment;
|
||||
// Removes effect of Frenzy etc.
|
||||
const cpsBuffMult = CM.Cache.getCPSBuffMult();
|
||||
if (cpsBuffMult > 0) maxPayout /= cpsBuffMult;
|
||||
else maxPayout = 0;
|
||||
|
||||
CM.Cache.ChainMaxReward = CM.Cache.MaxChainCookieReward(7, maxPayout, CM.Cache.GoldenCookiesMult);
|
||||
CM.Cache.ChainRequired = CM.Cache.ChainMaxReward[1] * 2 / CM.Cache.GoldenCookiesMult;
|
||||
CM.Cache.ChainRequiredNext = CM.Cache.ChainMaxReward[2] / 60 / 60 / 6 / CM.Cache.DragonsFortuneMultAdjustment;
|
||||
|
||||
CM.Cache.ChainMaxWrathReward = CM.Cache.MaxChainCookieReward(6, maxPayout, CM.Cache.WrathCookiesMult);
|
||||
CM.Cache.ChainWrathRequired = CM.Cache.ChainMaxWrathReward[1] * 2 / CM.Cache.WrathCookiesMult;
|
||||
CM.Cache.ChainWrathRequiredNext = CM.Cache.ChainMaxWrathReward[2] / 60 / 60 / 6 / CM.Cache.DragonsFortuneMultAdjustment;
|
||||
|
||||
CM.Cache.ChainFrenzyMaxReward = CM.Cache.MaxChainCookieReward(7, maxPayout * 7, CM.Cache.GoldenCookiesMult);
|
||||
CM.Cache.ChainFrenzyRequired = CM.Cache.ChainFrenzyMaxReward[1] * 2 / CM.Cache.GoldenCookiesMult;
|
||||
CM.Cache.ChainFrenzyRequiredNext = CM.Cache.ChainFrenzyMaxReward[2] / 60 / 60 / 6 / CM.Cache.DragonsFortuneMultAdjustment;
|
||||
|
||||
CM.Cache.ChainFrenzyMaxWrathReward = CM.Cache.MaxChainCookieReward(6, maxPayout * 7, CM.Cache.WrathCookiesMult);
|
||||
CM.Cache.ChainFrenzyWrathRequired = CM.Cache.ChainFrenzyMaxWrathReward[1] * 2 / CM.Cache.WrathCookiesMult;
|
||||
CM.Cache.ChainFrenzyWrathRequiredNext = CM.Cache.ChainFrenzyMaxWrathReward[2] / 60 / 60 / 6 / CM.Cache.DragonsFortuneMultAdjustment;
|
||||
};
|
||||
|
||||
/**
|
||||
* This functions caches variables related to missing upgrades
|
||||
* It is called by CM.Main.Loop() and CM.Cache.InitCache()
|
||||
* @global {string} CM.Cache.MissingUpgrades String containig the HTML to create the "crates" for missing normal upgrades
|
||||
* @global {string} CM.Cache.MissingUpgradesCookies String containig the HTML to create the "crates" for missing cookie upgrades
|
||||
* @global {string} CM.Cache.MissingUpgradesPrestige String containig the HTML to create the "crates" for missing prestige upgrades
|
||||
*/
|
||||
CM.Cache.CacheMissingUpgrades = function () {
|
||||
CM.Cache.MissingUpgrades = '';
|
||||
CM.Cache.MissingUpgradesCookies = '';
|
||||
CM.Cache.MissingUpgradesPrestige = '';
|
||||
const list = [];
|
||||
// sort the upgrades
|
||||
for (const i of Object.keys(Game.Upgrades)) {
|
||||
list.push(Game.Upgrades[i]);
|
||||
}
|
||||
const sortMap = function (a, b) {
|
||||
if (a.order > b.order) return 1;
|
||||
else if (a.order < b.order) return -1;
|
||||
return 0;
|
||||
};
|
||||
list.sort(sortMap);
|
||||
|
||||
for (const i of Object.keys(list)) {
|
||||
const me = list[i];
|
||||
|
||||
if (me.bought === 0) {
|
||||
let str = '';
|
||||
|
||||
str += CM.Disp.crateMissing(me);
|
||||
if (me.pool === 'prestige') CM.Cache.MissingUpgradesPrestige += str;
|
||||
else if (me.pool === 'cookie') CM.Cache.MissingUpgradesCookies += str;
|
||||
else if (me.pool !== 'toggle' && me.pool !== 'unused' && me.pool !== 'debug') CM.Cache.MissingUpgrades += str;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* This functions caches the reward of popping a reindeer
|
||||
* It is called by CM.Main.Loop() and CM.Cache.InitCache()
|
||||
* @global {number} CM.Cache.SeaSpec The reward for popping a reindeer
|
||||
*/
|
||||
CM.Cache.CacheSeaSpec = function () {
|
||||
if (Game.season === 'christmas') {
|
||||
let val = Game.cookiesPs * 60;
|
||||
if (Game.hasBuff('Elder frenzy')) val *= 0.5;
|
||||
if (Game.hasBuff('Frenzy')) val *= 0.75;
|
||||
CM.Cache.SeaSpec = Math.max(25, val);
|
||||
if (Game.Has('Ho ho ho-flavored frosting')) CM.Cache.SeaSpec *= 2;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* This functions caches the heavenly chips per second in the last five seconds
|
||||
* It is called by CM.Cache.LoopCache()
|
||||
* @global {number} CM.Cache.HCPerSecond The Heavenly Chips per second in the last five seconds
|
||||
*/
|
||||
CM.Cache.CacheHeavenlyChipsPS = function () {
|
||||
const currDate = Math.floor(Date.now() / 1000);
|
||||
// Only calculate every new second
|
||||
if ((Game.T / Game.fps) % 1 === 0) {
|
||||
const chipsOwned = Game.HowMuchPrestige(Game.cookiesReset);
|
||||
const ascendNowToOwn = Math.floor(Game.HowMuchPrestige(Game.cookiesReset + Game.cookiesEarned));
|
||||
const ascendNowToGet = ascendNowToOwn - Math.floor(chipsOwned);
|
||||
|
||||
// Add recent gains to AvgQueue's
|
||||
const timeDiff = currDate - CM.Cache.lastHeavenlyCheck;
|
||||
const heavenlyChipsDiffAvg = Math.max(0, (ascendNowToGet - CM.Cache.lastHeavenlyChips)) / timeDiff;
|
||||
for (let i = 0; i < timeDiff; i++) {
|
||||
CM.Cache.HeavenlyChipsDiff.addLatest(heavenlyChipsDiffAvg);
|
||||
}
|
||||
|
||||
// Store current data for next loop
|
||||
CM.Cache.lastHeavenlyCheck = currDate;
|
||||
CM.Cache.lastHeavenlyChips = ascendNowToGet;
|
||||
|
||||
// Get average gain over period of 5 seconds
|
||||
CM.Cache.HCPerSecond = CM.Cache.HeavenlyChipsDiff.calcAverage(5);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Section: Functions related to caching CPS */
|
||||
|
||||
/**
|
||||
* This functions caches creates the CMAvgQueue used by CM.Cache.CacheAvgCPS() to calculate CPS
|
||||
* Called by CM.Cache.InitCache()
|
||||
*/
|
||||
CM.Cache.InitCookiesDiff = function () {
|
||||
CM.Cache.CookiesDiff = new CMAvgQueue(CM.Disp.cookieTimes[CM.Disp.cookieTimes.length - 1]);
|
||||
CM.Cache.WrinkDiff = new CMAvgQueue(CM.Disp.cookieTimes[CM.Disp.cookieTimes.length - 1]);
|
||||
CM.Cache.WrinkFattestDiff = new CMAvgQueue(CM.Disp.cookieTimes[CM.Disp.cookieTimes.length - 1]);
|
||||
CM.Cache.ChoEggDiff = new CMAvgQueue(CM.Disp.cookieTimes[CM.Disp.cookieTimes.length - 1]);
|
||||
CM.Cache.ClicksDiff = new CMAvgQueue(CM.Disp.clickTimes[CM.Disp.clickTimes.length - 1]);
|
||||
};
|
||||
|
||||
/**
|
||||
* This functions caches two variables related average CPS and Clicks
|
||||
* It is called by CM.Cache.LoopCache()
|
||||
* @global {number} CM.Cache.RealCookiesEarned Cookies earned including the Chocolate Egg
|
||||
* @global {number} CM.Cache.AvgCPS Average cookies over time-period as defined by AvgCPSHist
|
||||
* @global {number} CM.Cache.AverageClicks Average cookies from clicking over time-period as defined by AvgClicksHist
|
||||
* @global {number} CM.Cache.AvgCPSChoEgg Average cookies from combination of normal CPS and average Chocolate Cookie CPS
|
||||
*/
|
||||
CM.Cache.CacheAvgCPS = function () {
|
||||
const currDate = Math.floor(Date.now() / 1000);
|
||||
// Only calculate every new second
|
||||
if ((Game.T / Game.fps) % 1 === 0) {
|
||||
let choEggTotal = Game.cookies + CM.Cache.SellForChoEgg;
|
||||
if (Game.cpsSucked > 0) choEggTotal += CM.Cache.WrinklersTotal;
|
||||
CM.Cache.RealCookiesEarned = Math.max(Game.cookiesEarned, choEggTotal);
|
||||
choEggTotal *= 0.05;
|
||||
|
||||
// Add recent gains to AvgQueue's
|
||||
const timeDiff = currDate - CM.Cache.lastCPSCheck;
|
||||
const bankDiffAvg = Math.max(0, (Game.cookies - CM.Cache.lastCookies)) / timeDiff;
|
||||
const wrinkDiffAvg = Math.max(0, (CM.Cache.WrinklersTotal - CM.Cache.lastWrinkCookies)) / timeDiff;
|
||||
const wrinkFattestDiffAvg = Math.max(0, (CM.Cache.WrinklersFattest[0] - CM.Cache.lastWrinkFattestCookies)) / timeDiff;
|
||||
const choEggDiffAvg = Math.max(0, (choEggTotal - CM.Cache.lastChoEgg)) / timeDiff;
|
||||
const clicksDiffAvg = (Game.cookieClicks - CM.Cache.lastClicks) / timeDiff;
|
||||
for (let i = 0; i < timeDiff; i++) {
|
||||
CM.Cache.CookiesDiff.addLatest(bankDiffAvg);
|
||||
CM.Cache.WrinkDiff.addLatest(wrinkDiffAvg);
|
||||
CM.Cache.WrinkFattestDiff.addLatest(wrinkFattestDiffAvg);
|
||||
CM.Cache.ChoEggDiff.addLatest(choEggDiffAvg);
|
||||
CM.Cache.ClicksDiff.addLatest(clicksDiffAvg);
|
||||
}
|
||||
|
||||
// Store current data for next loop
|
||||
CM.Cache.lastCPSCheck = currDate;
|
||||
CM.Cache.lastCookies = Game.cookies;
|
||||
CM.Cache.lastWrinkCookies = CM.Cache.WrinklersTotal;
|
||||
CM.Cache.lastWrinkFattestCookies = CM.Cache.WrinklersFattest[0];
|
||||
CM.Cache.lastChoEgg = choEggTotal;
|
||||
CM.Cache.lastClicks = Game.cookieClicks;
|
||||
|
||||
// Get average gain over period of cpsLength seconds
|
||||
const cpsLength = CM.Disp.cookieTimes[CM.Options.AvgCPSHist];
|
||||
CM.Cache.AverageGainBank = CM.Cache.CookiesDiff.calcAverage(cpsLength);
|
||||
CM.Cache.AverageGainWrink = CM.Cache.WrinkDiff.calcAverage(cpsLength);
|
||||
CM.Cache.AverageGainWrinkFattest = CM.Cache.WrinkFattestDiff.calcAverage(cpsLength);
|
||||
CM.Cache.AverageGainChoEgg = CM.Cache.ChoEggDiff.calcAverage(cpsLength);
|
||||
CM.Cache.AvgCPS = CM.Cache.AverageGainBank;
|
||||
if (CM.Options.CalcWrink === 1) CM.Cache.AvgCPS += CM.Cache.AverageGainWrink;
|
||||
if (CM.Options.CalcWrink === 2) CM.Cache.AvgCPS += CM.Cache.AverageGainWrinkFattest;
|
||||
|
||||
const choEgg = (Game.HasUnlocked('Chocolate egg') && !Game.Has('Chocolate egg'));
|
||||
|
||||
if (choEgg || CM.Options.CalcWrink === 0) {
|
||||
CM.Cache.AvgCPSWithChoEgg = CM.Cache.AverageGainBank + CM.Cache.AverageGainWrink + (choEgg ? CM.Cache.AverageGainChoEgg : 0);
|
||||
} else CM.Cache.AvgCPSWithChoEgg = CM.Cache.AvgCPS;
|
||||
|
||||
CM.Cache.AverageClicks = CM.Cache.ClicksDiff.calcAverage(CM.Disp.clickTimes[CM.Options.AvgClicksHist]);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* This functions caches the reward for selling the Chocolate egg
|
||||
* It is called by CM.Main.Loop()
|
||||
* @global {number} CM.Cache.SellForChoEgg Total cookies to be gained from selling Chocolate egg
|
||||
*/
|
||||
CM.Cache.CacheSellForChoEgg = function () {
|
||||
let sellTotal = 0;
|
||||
// Compute cookies earned by selling stock market goods
|
||||
if (Game.Objects.Bank.minigameLoaded) {
|
||||
const marketGoods = Game.Objects.Bank.minigame.goods;
|
||||
let goodsVal = 0;
|
||||
for (const i of Object.keys(marketGoods)) {
|
||||
const marketGood = marketGoods[i];
|
||||
goodsVal += marketGood.stock * marketGood.val;
|
||||
}
|
||||
sellTotal += goodsVal * Game.cookiesPsRawHighest;
|
||||
}
|
||||
// Compute cookies earned by selling all buildings with optimal auras (ES + RB)
|
||||
sellTotal += CM.Sim.SellBuildingsForChoEgg();
|
||||
CM.Cache.SellForChoEgg = sellTotal;
|
||||
};
|
||||
|
||||
/**
|
||||
* This functions caches the current Wrinkler CPS multiplier
|
||||
* It is called by CM.Cache.LoopCache(). Variables are mostly used by CM.Disp.GetCPS().
|
||||
* @global {number} CM.Cache.CurrWrinklerCount Current number of wrinklers
|
||||
* @global {number} CM.Cache.CurrWrinklerCPSMult Current multiplier of CPS because of wrinklers (excluding their negative sucking effect)
|
||||
*/
|
||||
CM.Cache.CacheCurrWrinklerCPS = function () {
|
||||
CM.Cache.CurrWrinklerCPSMult = 0;
|
||||
let count = 0;
|
||||
for (const i in Game.wrinklers) {
|
||||
if (Game.wrinklers[i].phase === 2) count++;
|
||||
}
|
||||
let godMult = 1;
|
||||
if (CM.Sim.Objects.Temple.minigameLoaded) {
|
||||
const godLvl = Game.hasGod('scorn');
|
||||
if (godLvl === 1) godMult *= 1.15;
|
||||
else if (godLvl === 2) godMult *= 1.1;
|
||||
else if (godLvl === 3) godMult *= 1.05;
|
||||
}
|
||||
CM.Cache.CurrWrinklerCount = count;
|
||||
CM.Cache.CurrWrinklerCPSMult = count * (count * 0.05 * 1.1) * (Game.Has('Sacrilegious corruption') * 0.05 + 1) * (Game.Has('Wrinklerspawn') * 0.05 + 1) * godMult;
|
||||
};
|
||||
|
||||
/**
|
||||
* This function returns the current CPS buff
|
||||
* It is called by CM.Sim.CalculateGains(), CM.Disp.UpdateTooltipWarnings(), CM.Cache.CacheStats() and CM.Cache.CacheChain()
|
||||
* @returns {number} mult The multiplier
|
||||
*/
|
||||
CM.Cache.getCPSBuffMult = function () {
|
||||
let mult = 1;
|
||||
for (const i of Object.keys(Game.buffs)) {
|
||||
if (typeof Game.buffs[i].multCpS !== 'undefined') mult *= Game.buffs[i].multCpS;
|
||||
}
|
||||
return mult;
|
||||
};
|
||||
|
||||
/**
|
||||
* This function calculates CPS without the Golden Switch as it might be needed in other functions
|
||||
* If so it CM.Sim.Win()'s them and the caller function will know to recall CM.Sim.CalculateGains()
|
||||
* It is called at the end of any functions that simulates certain behaviour
|
||||
*/
|
||||
CM.Cache.NoGoldSwitchCPS = function () {
|
||||
if (Game.Has('Golden switch [off]')) {
|
||||
CM.Cache.NoGoldSwitchCookiesPS = CM.Sim.NoGoldSwitchCPS();
|
||||
} else CM.Cache.NoGoldSwitchCookiesPS = Game.cookiesPs;
|
||||
};
|
||||
|
||||
/**
|
||||
* Section: Functions related to "Specials" (Dragon and Santa) */
|
||||
|
||||
/**
|
||||
* This functions caches the current cost of upgrading the dragon level so it can be displayed in the tooltip
|
||||
* It is called by the relevan tooltip-code as a result of CM.Disp.AddDragonLevelUpTooltip() and by CM.Main.Loop()
|
||||
* @global {number} CM.Cache.lastDragonLevel The last cached dragon level
|
||||
* @global {string} CM.Cache.CostDragonUpgrade The Beautified cost of the next upgrade
|
||||
*/
|
||||
CM.Cache.CacheDragonCost = function () {
|
||||
if (CM.Cache.lastDragonLevel !== Game.dragonLevel || CM.Sim.DoSims) {
|
||||
if (Game.dragonLevel < 25 && Game.dragonLevels[Game.dragonLevel].buy.toString().includes('sacrifice')) {
|
||||
let target = Game.dragonLevels[Game.dragonLevel].buy.toString().match(/Objects\[(.*)\]/)[1];
|
||||
const amount = Game.dragonLevels[Game.dragonLevel].buy.toString().match(/sacrifice\((.*?)\)/)[1];
|
||||
if (target !== 'i') {
|
||||
target = target.replaceAll("'", '');
|
||||
if (Game.Objects[target].amount < amount) {
|
||||
CM.Cache.CostDragonUpgrade = 'Not enough buildings to sell';
|
||||
} else {
|
||||
let cost = 0;
|
||||
CM.Sim.CopyData();
|
||||
for (let i = 0; i < amount; i++) {
|
||||
let price = CM.Sim.Objects[target].basePrice * Game.priceIncrease ** Math.max(0, CM.Sim.Objects[target].amount - 1 - CM.Sim.Objects[target].free);
|
||||
price = Game.modifyBuildingPrice(CM.Sim.Objects[target], price);
|
||||
price = Math.ceil(price);
|
||||
cost += price;
|
||||
CM.Sim.Objects[target].amount--;
|
||||
}
|
||||
CM.Cache.CostDragonUpgrade = `Cost to rebuy: ${CM.Disp.Beautify(cost)}`;
|
||||
}
|
||||
} else {
|
||||
let cost = 0;
|
||||
CM.Sim.CopyData();
|
||||
for (const j of Object.keys(Game.Objects)) {
|
||||
target = j;
|
||||
if (Game.Objects[target].amount < amount) {
|
||||
CM.Cache.CostDragonUpgrade = 'Not enough buildings to sell';
|
||||
break;
|
||||
} else {
|
||||
for (let i = 0; i < amount; i++) {
|
||||
let price = CM.Sim.Objects[target].basePrice * Game.priceIncrease ** Math.max(0, CM.Sim.Objects[target].amount - 1 - CM.Sim.Objects[target].free);
|
||||
price = Game.modifyBuildingPrice(CM.Sim.Objects[target], price);
|
||||
price = Math.ceil(price);
|
||||
cost += price;
|
||||
CM.Sim.Objects[target].amount--;
|
||||
}
|
||||
}
|
||||
CM.Cache.CostDragonUpgrade = `Cost to rebuy: ${CM.Disp.Beautify(cost)}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
CM.Cache.lastDragonLevel = Game.dragonLevel;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Section: Functions related to caching income */
|
||||
|
||||
/**
|
||||
* This functions caches the income gain of each building and upgrade and stores it in the cache
|
||||
* It is called by CM.Main.Loop() and CM.Cache.InitCache()
|
||||
*/
|
||||
CM.Cache.CacheIncome = function () {
|
||||
// Simulate Building Buys for 1, 10 and 100 amount
|
||||
CM.Cache.CacheBuildingIncome(1, 'Objects1');
|
||||
CM.Cache.CacheBuildingIncome(10, 'Objects10');
|
||||
CM.Cache.CacheBuildingIncome(100, 'Objects100');
|
||||
|
||||
// Simulate Upgrade Buys
|
||||
CM.Cache.CacheUpgradeIncome();
|
||||
};
|
||||
|
||||
/**
|
||||
* This functions starts the calculation/simulation of the bonus income of buildings
|
||||
* It is called by CM.Cache.CacheIncome()
|
||||
* @param {amount} amount Amount to be bought
|
||||
* @parem {string} target The target Cache object ("Objects1", "Objects10" or "Objects100")
|
||||
*/
|
||||
CM.Cache.CacheBuildingIncome = function (amount, target) {
|
||||
CM.Cache[target] = [];
|
||||
for (const i of Object.keys(Game.Objects)) {
|
||||
CM.Cache[target][i] = {};
|
||||
CM.Cache[target][i].bonus = CM.Sim.BuyBuildingsBonusIncome(i, amount);
|
||||
if (amount !== 1) {
|
||||
CM.Cache.DoRemakeBuildPrices = 1;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* This functions starts the calculation/simulation of the bonus income of upgrades
|
||||
* It is called by CM.Cache.CacheIncome()
|
||||
*/
|
||||
CM.Cache.CacheUpgradeIncome = function () {
|
||||
CM.Cache.Upgrades = [];
|
||||
for (const i of Object.keys(Game.Upgrades)) {
|
||||
const bonusIncome = CM.Sim.BuyUpgradesBonusIncome(i);
|
||||
CM.Cache.Upgrades[i] = {};
|
||||
if (bonusIncome[0]) CM.Cache.Upgrades[i].bonus = bonusIncome[0];
|
||||
if (bonusIncome[1]) CM.Cache.Upgrades[i].bonusMouse = bonusIncome[1];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Section: Functions related to caching prices */
|
||||
|
||||
/**
|
||||
* This functions caches the price of each building and stores it in the cache
|
||||
* It is called by CM.Main.Loop() and CM.Cache.InitCache()
|
||||
*/
|
||||
CM.Cache.CacheBuildingsPrices = function () {
|
||||
for (const i of Object.keys(Game.Objects)) {
|
||||
CM.Cache.Objects1[i].price = CM.Sim.BuildingGetPrice(Game.Objects[i], Game.Objects[i].basePrice, Game.Objects[i].amount, Game.Objects[i].free, 1);
|
||||
CM.Cache.Objects10[i].price = CM.Sim.BuildingGetPrice(Game.Objects[i], Game.Objects[i].basePrice, Game.Objects[i].amount, Game.Objects[i].free, 10);
|
||||
CM.Cache.Objects100[i].price = CM.Sim.BuildingGetPrice(Game.Objects[i], Game.Objects[i].basePrice, Game.Objects[i].amount, Game.Objects[i].free, 100);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Section: Functions related to caching PP */
|
||||
|
||||
/**
|
||||
* This functions caches the PP of each building and upgrade and stores it in the cache
|
||||
* It is called by CM.Cache.LoopCache() and CM.Cache.InitCache()
|
||||
*/
|
||||
CM.Cache.CachePP = function () {
|
||||
CM.Cache.CacheBuildingsPP();
|
||||
CM.Cache.CacheUpgradePP();
|
||||
};
|
||||
|
||||
/**
|
||||
* This functions return the colour assosciated with the given pp value
|
||||
* It is called by CM.Cache.CacheBuildingsPP(), CM.Cache.CacheBuildingsBulkPP() and CM.Cache.CacheUpgradePP()
|
||||
* @params {object} obj The obj of which the pp value should be checked
|
||||
* @params {number} price The price of the object
|
||||
* @returns {string} color The colour assosciated with the pp value
|
||||
*/
|
||||
CM.Cache.ColourOfPP = function (me, price) {
|
||||
let color = '';
|
||||
// Colour based on PP
|
||||
if (me.pp <= 0 || me.pp === Infinity) color = CM.Disp.colorGray;
|
||||
else if (me.pp < CM.Cache.min) color = CM.Disp.colorBlue;
|
||||
else if (me.pp === CM.Cache.min) color = CM.Disp.colorGreen;
|
||||
else if (me.pp === CM.Cache.max) color = CM.Disp.colorRed;
|
||||
else if (me.pp > CM.Cache.max) color = CM.Disp.colorPurple;
|
||||
else if (me.pp > CM.Cache.mid) color = CM.Disp.colorOrange;
|
||||
else color = CM.Disp.colorYellow;
|
||||
|
||||
// Colour based on price in terms of CPS
|
||||
if (Number(CM.Options.PPSecondsLowerLimit) !== 0) {
|
||||
if (price / CM.Disp.GetCPS() < Number(CM.Options.PPSecondsLowerLimit)) color = CM.Disp.colorBlue;
|
||||
}
|
||||
// Colour based on being able to purchase
|
||||
if (CM.Options.PPOnlyConsiderBuyable) {
|
||||
if (price - Game.cookies > 0) color = CM.Disp.colorRed;
|
||||
}
|
||||
return color;
|
||||
};
|
||||
|
||||
/**
|
||||
* This functions caches the PP of each building it saves all date in CM.Cache.Objects...
|
||||
* It is called by CM.Cache.CachePP()
|
||||
*/
|
||||
CM.Cache.CacheBuildingsPP = function () {
|
||||
CM.Cache.min = Infinity;
|
||||
CM.Cache.max = 1;
|
||||
CM.Cache.ArrayOfPPs = [];
|
||||
if (typeof CM.Options.PPExcludeTop === 'undefined') CM.Options.PPExcludeTop = 0; // Otherwise breaks during initialization
|
||||
|
||||
// Calculate PP and colors when compared to purchase of optimal building in single-purchase mode
|
||||
if (CM.Options.ColorPPBulkMode === 0 && Game.buyMode > 0) {
|
||||
for (const i of Object.keys(CM.Cache.Objects1)) {
|
||||
if (Game.cookiesPs) {
|
||||
CM.Cache.Objects1[i].pp = (Math.max(Game.Objects[i].getPrice() - (Game.cookies + CM.Disp.GetWrinkConfigBank()), 0) / Game.cookiesPs) + (Game.Objects[i].getPrice() / CM.Cache.Objects1[i].bonus);
|
||||
} else CM.Cache.Objects1[i].pp = (Game.Objects[i].getPrice() / CM.Cache.Objects1[i].bonus);
|
||||
CM.Cache.ArrayOfPPs.push([CM.Cache.Objects1[i].pp, Game.Objects[i].getPrice()]);
|
||||
}
|
||||
// Set CM.Cache.min to best non-excluded buidliung
|
||||
CM.Cache.ArrayOfPPs.sort((a, b) => a[0] - b[0]);
|
||||
if (CM.Options.PPOnlyConsiderBuyable) {
|
||||
while (CM.Cache.ArrayOfPPs[0][1] > Game.cookies) {
|
||||
if (CM.Cache.ArrayOfPPs.length === 1) {
|
||||
break;
|
||||
}
|
||||
CM.Cache.ArrayOfPPs.shift();
|
||||
}
|
||||
}
|
||||
CM.Cache.min = CM.Cache.ArrayOfPPs[CM.Options.PPExcludeTop][0];
|
||||
CM.Cache.max = CM.Cache.ArrayOfPPs[CM.Cache.ArrayOfPPs.length - 1][0];
|
||||
CM.Cache.mid = ((CM.Cache.max - CM.Cache.min) / 2) + CM.Cache.min;
|
||||
for (const i of Object.keys(CM.Cache.Objects1)) {
|
||||
CM.Cache.Objects1[i].color = CM.Cache.ColourOfPP(CM.Cache.Objects1[i], Game.Objects[i].getPrice());
|
||||
// Colour based on excluding certain top-buildings
|
||||
for (let j = 0; j < CM.Options.PPExcludeTop; j++) {
|
||||
if (CM.Cache.Objects1[i].pp === CM.Cache.ArrayOfPPs[j][0]) CM.Cache.Objects1[i].color = CM.Disp.colorGray;
|
||||
}
|
||||
}
|
||||
// Calculate PP of bulk-buy modes
|
||||
CM.Cache.CacheBuildingsBulkPP('Objects10');
|
||||
CM.Cache.CacheBuildingsBulkPP('Objects100');
|
||||
} else if (Game.buyMode > 0) {
|
||||
// Calculate PP and colors when compared to purchase of selected bulk mode
|
||||
const target = `Objects${Game.buyBulk}`;
|
||||
for (const i of Object.keys(CM.Cache[target])) {
|
||||
if (Game.cookiesPs) {
|
||||
CM.Cache[target][i].pp = (Math.max(Game.Objects[i].bulkPrice - (Game.cookies + CM.Disp.GetWrinkConfigBank()), 0) / Game.cookiesPs) + (Game.Objects[i].bulkPrice / CM.Cache[target][i].bonus);
|
||||
} else CM.Cache[target][i].pp = (Game.Objects[i].bulkPrice / CM.Cache[target][i].bonus);
|
||||
CM.Cache.ArrayOfPPs.push([CM.Cache[target][i].pp, Game.Objects[i].bulkPrice]);
|
||||
}
|
||||
// Set CM.Cache.min to best non-excluded buidliung
|
||||
CM.Cache.ArrayOfPPs.sort((a, b) => a[0] - b[0]);
|
||||
if (CM.Options.PPOnlyConsiderBuyable) {
|
||||
while (CM.Cache.ArrayOfPPs[0][1] > Game.cookies) {
|
||||
if (CM.Cache.ArrayOfPPs.length === 1) {
|
||||
break;
|
||||
}
|
||||
CM.Cache.ArrayOfPPs.shift();
|
||||
}
|
||||
}
|
||||
CM.Cache.min = CM.Cache.ArrayOfPPs[CM.Options.PPExcludeTop][0];
|
||||
CM.Cache.max = CM.Cache.ArrayOfPPs[CM.Cache.ArrayOfPPs.length - 1][0];
|
||||
CM.Cache.mid = ((CM.Cache.max - CM.Cache.min) / 2) + CM.Cache.min;
|
||||
|
||||
for (const i of Object.keys(CM.Cache.Objects1)) {
|
||||
CM.Cache[target][i].color = CM.Cache.ColourOfPP(CM.Cache[target][i], Game.Objects[i].bulkPrice);
|
||||
// Colour based on excluding certain top-buildings
|
||||
for (let j = 0; j < CM.Options.PPExcludeTop; j++) {
|
||||
if (CM.Cache[target][i].pp === CM.Cache.ArrayOfPPs[j][0]) CM.Cache[target][i].color = CM.Disp.colorGray;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* This functions caches the buildings of bulk-buy mode when PP is compared against optimal single-purchase building
|
||||
* It saves all date in CM.Cache.Objects...
|
||||
* It is called by CM.Cache.CacheBuildingsPP()
|
||||
*/
|
||||
CM.Cache.CacheBuildingsBulkPP = function (target) {
|
||||
for (const i of Object.keys(CM.Cache[target])) {
|
||||
if (Game.cookiesPs) {
|
||||
CM.Cache[target][i].pp = (Math.max(CM.Cache[target][i].price - (Game.cookies + CM.Disp.GetWrinkConfigBank()), 0) / Game.cookiesPs) + (CM.Cache[target][i].price / CM.Cache[target][i].bonus);
|
||||
} else CM.Cache[target][i].pp = (CM.Cache[target][i].price / CM.Cache[target][i].bonus);
|
||||
|
||||
CM.Cache[target][i].color = CM.Cache.ColourOfPP(CM.Cache[target][i], CM.Cache[target][i].price);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* This functions caches the PP of each building it saves all date in CM.Cache.Upgrades
|
||||
* It is called by CM.Cache.CachePP()
|
||||
*/
|
||||
CM.Cache.CacheUpgradePP = function () {
|
||||
for (const i of Object.keys(CM.Cache.Upgrades)) {
|
||||
if (Game.cookiesPs) {
|
||||
CM.Cache.Upgrades[i].pp = (Math.max(Game.Upgrades[i].getPrice() - (Game.cookies + CM.Disp.GetWrinkConfigBank()), 0) / Game.cookiesPs) + (Game.Upgrades[i].getPrice() / CM.Cache.Upgrades[i].bonus);
|
||||
} else CM.Cache.Upgrades[i].pp = (Game.Upgrades[i].getPrice() / CM.Cache.Upgrades[i].bonus);
|
||||
if (Number.isNaN(CM.Cache.Upgrades[i].pp)) CM.Cache.Upgrades[i].pp = Infinity;
|
||||
|
||||
CM.Cache.Upgrades[i].color = CM.Cache.ColourOfPP(CM.Cache.Upgrades[i], Game.Upgrades[i].getPrice());
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Section: Cached variables */
|
||||
|
||||
/**
|
||||
* Used to store the multiplier of the Century Egg
|
||||
*/
|
||||
CM.Cache.CentEgg = 0;
|
||||
|
||||
/**
|
||||
* Used to store if there was a Build Aura (used in CM.Main)
|
||||
*/
|
||||
CM.Cache.HadBuildAura = false;
|
||||
|
||||
/**
|
||||
* Used to store CPS without Golden Cookie Switch
|
||||
*/
|
||||
CM.Cache.NoGoldSwitchCookiesPS = 0;
|
||||
33
src/Cache/CacheInit.js
Normal file
33
src/Cache/CacheInit.js
Normal file
@@ -0,0 +1,33 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import { CMAvgQueue, InitCookiesDiff } from './CPS/AverageQueue';
|
||||
import CacheAvgCPS from './CPS/CPS';
|
||||
import CacheDragonAuras from './Dragon/CacheDragonAuras';
|
||||
import CachePP from './PP/PP';
|
||||
import { CacheBuildingsPrices, CacheIncome } from './PriceAndIncome/PriceAndIncome';
|
||||
import { CacheChain } from './Stats/ChainCookies';
|
||||
import CacheHeavenlyChipsPS from './Stats/HeavenlyChips';
|
||||
import CacheAllMissingUpgrades from './Stats/MissingUpgrades';
|
||||
import CacheSeasonSpec from './Stats/Reindeer';
|
||||
import { CacheGoldenAndWrathCookiesMults, CacheStatsCookies } from './Stats/Stats';
|
||||
import { HeavenlyChipsDiff } from './VariablesAndData';
|
||||
import CacheWrinklers from './Wrinklers/Wrinklers';
|
||||
|
||||
/**
|
||||
* This functions runs all cache-functions to generate all "full" cache
|
||||
*/
|
||||
export default function InitCache() {
|
||||
CacheDragonAuras();
|
||||
CacheWrinklers();
|
||||
CacheStatsCookies();
|
||||
CacheGoldenAndWrathCookiesMults();
|
||||
CacheChain();
|
||||
CacheAllMissingUpgrades();
|
||||
CacheSeasonSpec();
|
||||
InitCookiesDiff();
|
||||
HeavenlyChipsDiff = new CMAvgQueue(5); // Used by CM.Cache.CacheHeavenlyChipsPS()
|
||||
CacheHeavenlyChipsPS();
|
||||
CacheAvgCPS();
|
||||
CacheIncome();
|
||||
CacheBuildingsPrices();
|
||||
CachePP();
|
||||
}
|
||||
26
src/Cache/CacheLoop.js
Normal file
26
src/Cache/CacheLoop.js
Normal file
@@ -0,0 +1,26 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import { FormatTime } from '../Disp/BeautifyAndFormatting/BeautifyFormatting';
|
||||
import GetCPS from '../Disp/HelperFunctions/GetCPS';
|
||||
import CacheAvgCPS from './CPS/CPS';
|
||||
import CacheCurrWrinklerCPS from './CPS/CurrWrinklerCPS';
|
||||
import CachePP from './PP/PP';
|
||||
import CacheHeavenlyChipsPS from './Stats/HeavenlyChips';
|
||||
import { CacheTimeTillNextPrestige } from './VariablesAndData';
|
||||
import CacheWrinklers from './Wrinklers/Wrinklers';
|
||||
|
||||
/**
|
||||
* This functions caches variables that are needed every loop
|
||||
* @global {string} CM.Cache.TimeTillNextPrestige Time requried till next prestige level
|
||||
*/
|
||||
export default function LoopCache() {
|
||||
// Update Wrinkler Bank
|
||||
CacheWrinklers();
|
||||
|
||||
CachePP();
|
||||
CacheCurrWrinklerCPS();
|
||||
CacheAvgCPS();
|
||||
CacheHeavenlyChipsPS();
|
||||
|
||||
const cookiesToNext = Game.HowManyCookiesReset(Math.floor(Game.HowMuchPrestige(Game.cookiesReset + Game.cookiesEarned)) + 1) - (Game.cookiesEarned + Game.cookiesReset);
|
||||
CacheTimeTillNextPrestige = FormatTime(cookiesToNext / GetCPS());
|
||||
}
|
||||
10
src/Cache/Dragon/CacheDragonAuras.js
Normal file
10
src/Cache/Dragon/CacheDragonAuras.js
Normal file
@@ -0,0 +1,10 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import { CacheDragonAura, CacheDragonAura2 } from '../VariablesAndData';
|
||||
|
||||
/**
|
||||
* This functions caches the currently selected Dragon Auras
|
||||
*/
|
||||
export default function CacheDragonAuras() {
|
||||
CacheDragonAura = Game.dragonAura;
|
||||
CacheDragonAura2 = Game.dragonAura2;
|
||||
}
|
||||
58
src/Cache/Dragon/Dragon.js
Normal file
58
src/Cache/Dragon/Dragon.js
Normal file
@@ -0,0 +1,58 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
/** Functions related to the Dragon */
|
||||
|
||||
import { Beautify } from '../../Disp/BeautifyAndFormatting/BeautifyFormatting';
|
||||
import CopyData from '../../Sim/SimulationData/CopyData';
|
||||
import { SimDoSims, SimObjects } from '../../Sim/VariablesAndData';
|
||||
import {
|
||||
CacheCostDragonUpgrade, CacheDragonAura, CacheDragonAura2, CacheLastDragonLevel,
|
||||
} from '../VariablesAndData';
|
||||
|
||||
/**
|
||||
* This functions caches the current cost of upgrading the dragon level so it can be displayed in the tooltip
|
||||
*/
|
||||
export default function CacheDragonCost() {
|
||||
if (CacheLastDragonLevel !== Game.dragonLevel || SimDoSims) {
|
||||
if (Game.dragonLevel < 25 && Game.dragonLevels[Game.dragonLevel].buy.toString().includes('sacrifice')) {
|
||||
let target = Game.dragonLevels[Game.dragonLevel].buy.toString().match(/Objects\[(.*)\]/)[1];
|
||||
const amount = Game.dragonLevels[Game.dragonLevel].buy.toString().match(/sacrifice\((.*?)\)/)[1];
|
||||
if (target !== 'i') {
|
||||
target = target.replaceAll("'", '');
|
||||
if (Game.Objects[target].amount < amount) {
|
||||
CacheCostDragonUpgrade = 'Not enough buildings to sell';
|
||||
} else {
|
||||
let cost = 0;
|
||||
CopyData();
|
||||
for (let i = 0; i < amount; i++) {
|
||||
let price = SimObjects[target].basePrice * Game.priceIncrease ** Math.max(0, SimObjects[target].amount - 1 - SimObjects[target].free);
|
||||
price = Game.modifyBuildingPrice(SimObjects[target], price);
|
||||
price = Math.ceil(price);
|
||||
cost += price;
|
||||
SimObjects[target].amount--;
|
||||
}
|
||||
CacheCostDragonUpgrade = `Cost to rebuy: ${(cost)}`;
|
||||
}
|
||||
} else {
|
||||
let cost = 0;
|
||||
CopyData();
|
||||
for (const j of Object.keys(Game.Objects)) {
|
||||
target = j;
|
||||
if (Game.Objects[target].amount < amount) {
|
||||
CacheCostDragonUpgrade = 'Not enough buildings to sell';
|
||||
break;
|
||||
} else {
|
||||
for (let i = 0; i < amount; i++) {
|
||||
let price = SimObjects[target].basePrice * Game.priceIncrease ** Math.max(0, SimObjects[target].amount - 1 - SimObjects[target].free);
|
||||
price = Game.modifyBuildingPrice(SimObjects[target], price);
|
||||
price = Math.ceil(price);
|
||||
cost += price;
|
||||
SimObjects[target].amount--;
|
||||
}
|
||||
}
|
||||
CacheCostDragonUpgrade = `Cost to rebuy: ${Beautify(cost)}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
CacheLastDragonLevel = Game.dragonLevel;
|
||||
}
|
||||
}
|
||||
101
src/Cache/PP/Building.js
Normal file
101
src/Cache/PP/Building.js
Normal file
@@ -0,0 +1,101 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import { CMOptions } from '../../Config/VariablesAndData';
|
||||
import GetWrinkConfigBank from '../../Disp/HelperFunctions/GetWrinkConfigBank';
|
||||
import { ColorGray } from '../../Disp/VariablesAndData';
|
||||
import {
|
||||
CacheArrayOfPPs,
|
||||
CacheMaxPP, CacheMidPP, CacheMinPP, CacheObjects1, CacheObjects10, CacheObjects100,
|
||||
} from '../VariablesAndData';
|
||||
import ColourOfPP from './ColourOfPP';
|
||||
|
||||
/**
|
||||
* This functions caches the buildings of bulk-buy mode when PP is compared against optimal single-purchase building
|
||||
* It saves all date in CM.Cache.Objects...
|
||||
* It is called by CM.Cache.CacheBuildingsPP()
|
||||
*/
|
||||
function CacheBuildingsBulkPP(target) {
|
||||
for (const i of Object.keys(target)) {
|
||||
if (Game.cookiesPs) {
|
||||
target[i].pp = (Math.max(target[i].price - (Game.cookies + GetWrinkConfigBank()), 0) / Game.cookiesPs) + (target[i].price / target[i].bonus);
|
||||
} else target[i].pp = (target[i].price / target[i].bonus);
|
||||
|
||||
target[i].color = ColourOfPP(target[i], target[i].price);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This functions caches the PP of each building it saves all date in CM.Cache.Objects...
|
||||
* It is called by CM.Cache.CachePP()
|
||||
*/
|
||||
export default function CacheBuildingsPP() {
|
||||
CacheMinPP = Infinity;
|
||||
CacheMaxPP = 1;
|
||||
CacheArrayOfPPs = [];
|
||||
if (typeof CMOptions.PPExcludeTop === 'undefined') CMOptions.PPExcludeTop = 0; // Otherwise breaks during initialization
|
||||
|
||||
// Calculate PP and colors when compared to purchase of optimal building in single-purchase mode
|
||||
if (CMOptions.ColorPPBulkMode === 0 && Game.buyMode > 0) {
|
||||
for (const i of Object.keys(CacheObjects1)) {
|
||||
if (Game.cookiesPs) {
|
||||
CacheObjects1[i].pp = (Math.max(Game.Objects[i].getPrice() - (Game.cookies + GetWrinkConfigBank()), 0) / Game.cookiesPs) + (Game.Objects[i].getPrice() / CacheObjects1[i].bonus);
|
||||
} else CacheObjects1[i].pp = (Game.Objects[i].getPrice() / CacheObjects1[i].bonus);
|
||||
CacheArrayOfPPs.push([CacheObjects1[i].pp, Game.Objects[i].getPrice()]);
|
||||
}
|
||||
// Set CM.Cache.min to best non-excluded buidliung
|
||||
CacheArrayOfPPs.sort((a, b) => a[0] - b[0]);
|
||||
if (CMOptions.PPOnlyConsiderBuyable) {
|
||||
while (CacheArrayOfPPs[0][1] > Game.cookies) {
|
||||
if (CacheArrayOfPPs.length === 1) {
|
||||
break;
|
||||
}
|
||||
CacheArrayOfPPs.shift();
|
||||
}
|
||||
}
|
||||
CacheMinPP = CacheArrayOfPPs[CMOptions.PPExcludeTop][0];
|
||||
CacheMaxPP = CacheArrayOfPPs[CacheArrayOfPPs.length - 1][0];
|
||||
CacheMidPP = ((CacheMaxPP - CacheMinPP) / 2) + CacheMinPP;
|
||||
for (const i of Object.keys(CacheObjects1)) {
|
||||
CacheObjects1[i].color = ColourOfPP(CacheObjects1[i], Game.Objects[i].getPrice());
|
||||
// Colour based on excluding certain top-buildings
|
||||
for (let j = 0; j < CMOptions.PPExcludeTop; j++) {
|
||||
if (CacheObjects1[i].pp === CacheArrayOfPPs[j][0]) CacheObjects1[i].color = ColorGray;
|
||||
}
|
||||
}
|
||||
// Calculate PP of bulk-buy modes
|
||||
CacheBuildingsBulkPP(CacheObjects10);
|
||||
CacheBuildingsBulkPP(CacheObjects100);
|
||||
} else if (Game.buyMode > 0) {
|
||||
// Calculate PP and colors when compared to purchase of selected bulk mode
|
||||
let target;
|
||||
if (Game.buyBulk === 1) target = CacheObjects1;
|
||||
else if (Game.buyBulk === 10) target = CacheObjects10;
|
||||
else if (Game.buyBulk === 100) target = CacheObjects100;
|
||||
for (const i of Object.keys(target)) {
|
||||
if (Game.cookiesPs) {
|
||||
target[i].pp = (Math.max(Game.Objects[i].bulkPrice - (Game.cookies + GetWrinkConfigBank()), 0) / Game.cookiesPs) + (Game.Objects[i].bulkPrice / target[i].bonus);
|
||||
} else target[i].pp = (Game.Objects[i].bulkPrice / target[i].bonus);
|
||||
CacheArrayOfPPs.push([target[i].pp, Game.Objects[i].bulkPrice]);
|
||||
}
|
||||
// Set CM.Cache.min to best non-excluded buidliung
|
||||
CacheArrayOfPPs.sort((a, b) => a[0] - b[0]);
|
||||
if (CMOptions.PPOnlyConsiderBuyable) {
|
||||
while (CacheArrayOfPPs[0][1] > Game.cookies) {
|
||||
if (CacheArrayOfPPs.length === 1) {
|
||||
break;
|
||||
}
|
||||
CacheArrayOfPPs.shift();
|
||||
}
|
||||
}
|
||||
CacheMinPP = CacheArrayOfPPs[CMOptions.PPExcludeTop][0];
|
||||
CacheMaxPP = CacheArrayOfPPs[CacheArrayOfPPs.length - 1][0];
|
||||
CacheMidPP = ((CacheMaxPP - CacheMinPP) / 2) + CacheMinPP;
|
||||
|
||||
for (const i of Object.keys(CacheObjects1)) {
|
||||
target[i].color = ColourOfPP(target[i], Game.Objects[i].bulkPrice);
|
||||
// Colour based on excluding certain top-buildings
|
||||
for (let j = 0; j < CMOptions.PPExcludeTop; j++) {
|
||||
if (target[i].pp === CacheArrayOfPPs[j][0]) target[i].color = ColorGray;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
35
src/Cache/PP/ColourOfPP.js
Normal file
35
src/Cache/PP/ColourOfPP.js
Normal file
@@ -0,0 +1,35 @@
|
||||
import { CMOptions } from '../../Config/VariablesAndData';
|
||||
import GetCPS from '../../Disp/HelperFunctions/GetCPS';
|
||||
import {
|
||||
ColorBlue, ColorGray, ColorGreen, ColorOrange, ColorPurple, ColorRed, ColorYellow,
|
||||
} from '../../Disp/VariablesAndData';
|
||||
import { CacheMaxPP, CacheMidPP, CacheMinPP } from '../VariablesAndData';
|
||||
|
||||
/**
|
||||
* This functions return the colour assosciated with the given pp value
|
||||
* It is called by CM.Cache.CacheBuildingsPP(), CM.Cache.CacheBuildingsBulkPP() and CM.Cache.CacheUpgradePP()
|
||||
* @params {object} obj The obj of which the pp value should be checked
|
||||
* @params {number} price The price of the object
|
||||
* @returns {string} color The colour assosciated with the pp value
|
||||
*/
|
||||
export default function ColourOfPP(me, price) {
|
||||
let color = '';
|
||||
// Colour based on PP
|
||||
if (me.pp <= 0 || me.pp === Infinity) color = ColorGray;
|
||||
else if (me.pp < CacheMinPP) color = ColorBlue;
|
||||
else if (me.pp === CacheMinPP) color = ColorGreen;
|
||||
else if (me.pp === CacheMaxPP) color = ColorRed;
|
||||
else if (me.pp > CacheMaxPP) color = ColorPurple;
|
||||
else if (me.pp > CacheMidPP) color = ColorOrange;
|
||||
else color = ColorYellow;
|
||||
|
||||
// Colour based on price in terms of CPS
|
||||
if (Number(CMOptions.PPSecondsLowerLimit) !== 0) {
|
||||
if (price / GetCPS() < Number(CMOptions.PPSecondsLowerLimit)) color = ColorBlue;
|
||||
}
|
||||
// Colour based on being able to purchase
|
||||
if (CMOptions.PPOnlyConsiderBuyable) {
|
||||
if (price - Game.cookies > 0) color = ColorRed;
|
||||
}
|
||||
return color;
|
||||
}
|
||||
14
src/Cache/PP/PP.js
Normal file
14
src/Cache/PP/PP.js
Normal file
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Section: Functions related to caching PP */
|
||||
|
||||
import CacheBuildingsPP from './Building';
|
||||
import CacheUpgradePP from './Upgrade';
|
||||
|
||||
/**
|
||||
* This functions caches the PP of each building and upgrade and stores it in the cache
|
||||
* It is called by CM.Cache.LoopCache() and CM.Cache.InitCache()
|
||||
*/
|
||||
export default function CachePP() {
|
||||
CacheBuildingsPP();
|
||||
CacheUpgradePP();
|
||||
}
|
||||
18
src/Cache/PP/Upgrade.js
Normal file
18
src/Cache/PP/Upgrade.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import GetWrinkConfigBank from '../../Disp/HelperFunctions/GetWrinkConfigBank';
|
||||
import { CacheUpgrades } from '../VariablesAndData';
|
||||
import ColourOfPP from './ColourOfPP';
|
||||
|
||||
/**
|
||||
* This functions caches the PP of each building it saves all date in CM.Cache.Upgrades
|
||||
* It is called by CM.Cache.CachePP()
|
||||
*/
|
||||
export default function CacheUpgradePP() {
|
||||
for (const i of Object.keys(CacheUpgrades)) {
|
||||
if (Game.cookiesPs) {
|
||||
CacheUpgrades[i].pp = (Math.max(Game.Upgrades[i].getPrice() - (Game.cookies + GetWrinkConfigBank()), 0) / Game.cookiesPs) + (Game.Upgrades[i].getPrice() / CacheUpgrades[i].bonus);
|
||||
} else CacheUpgrades[i].pp = (Game.Upgrades[i].getPrice() / CacheUpgrades[i].bonus);
|
||||
if (Number.isNaN(CacheUpgrades[i].pp)) CacheUpgrades[i].pp = Infinity;
|
||||
|
||||
CacheUpgrades[i].color = ColourOfPP(CacheUpgrades[i], Game.Upgrades[i].getPrice());
|
||||
}
|
||||
}
|
||||
66
src/Cache/PriceAndIncome/PriceAndIncome.js
Normal file
66
src/Cache/PriceAndIncome/PriceAndIncome.js
Normal file
@@ -0,0 +1,66 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
/** Section: Functions related to caching income */
|
||||
|
||||
import BuildingGetPrice from '../../Sim/SimulationEvents/BuyBuilding';
|
||||
import BuyBuildingsBonusIncome from '../../Sim/SimulationEvents/BuyBuildingBonusIncome';
|
||||
import BuyUpgradesBonusIncome from '../../Sim/SimulationEvents/BuyUpgrades';
|
||||
import {
|
||||
CacheDoRemakeBuildPrices, CacheObjects1, CacheObjects10, CacheObjects100, CacheUpgrades,
|
||||
} from '../VariablesAndData';
|
||||
|
||||
/**
|
||||
* This functions starts the calculation/simulation of the bonus income of buildings
|
||||
* It is called by CM.Cache.CacheIncome()
|
||||
* @param {amount} amount Amount to be bought
|
||||
* @parem {string} target The target Cache object ("Objects1", "Objects10" or "Objects100")
|
||||
*/
|
||||
function CacheBuildingIncome(amount, target) {
|
||||
const result = [];
|
||||
for (const i of Object.keys(Game.Objects)) {
|
||||
result[i] = {};
|
||||
result[i].bonus = BuyBuildingsBonusIncome(i, amount);
|
||||
if (amount !== 1) {
|
||||
CacheDoRemakeBuildPrices = 1;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This functions starts the calculation/simulation of the bonus income of upgrades
|
||||
* It is called by CM.Cache.CacheIncome()
|
||||
*/
|
||||
function CacheUpgradeIncome() {
|
||||
CacheUpgrades = [];
|
||||
for (const i of Object.keys(Game.Upgrades)) {
|
||||
const bonusIncome = BuyUpgradesBonusIncome(i);
|
||||
CacheUpgrades[i] = {};
|
||||
if (bonusIncome[0]) CacheUpgrades[i].bonus = bonusIncome[0];
|
||||
if (bonusIncome[1]) CacheUpgrades[i].bonusMouse = bonusIncome[1];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This functions caches the price of each building and stores it in the cache
|
||||
*/
|
||||
export function CacheBuildingsPrices() {
|
||||
for (const i of Object.keys(Game.Objects)) {
|
||||
CacheObjects1[i].price = BuildingGetPrice(Game.Objects[i], Game.Objects[i].basePrice, Game.Objects[i].amount, Game.Objects[i].free, 1);
|
||||
CacheObjects10[i].price = BuildingGetPrice(Game.Objects[i], Game.Objects[i].basePrice, Game.Objects[i].amount, Game.Objects[i].free, 10);
|
||||
CacheObjects100[i].price = BuildingGetPrice(Game.Objects[i], Game.Objects[i].basePrice, Game.Objects[i].amount, Game.Objects[i].free, 100);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This functions caches the income gain of each building and upgrade and stores it in the cache
|
||||
* It is called by CM.Main.Loop() and CM.Cache.InitCache()
|
||||
*/
|
||||
export function CacheIncome() {
|
||||
// Simulate Building Buys for 1, 10 and 100 amount
|
||||
CacheObjects1 = CacheBuildingIncome(1);
|
||||
CacheObjects10 = CacheBuildingIncome(10);
|
||||
CacheObjects100 = CacheBuildingIncome(100);
|
||||
|
||||
// Simulate Upgrade Buys
|
||||
CacheUpgradeIncome();
|
||||
}
|
||||
69
src/Cache/Stats/ChainCookies.js
Normal file
69
src/Cache/Stats/ChainCookies.js
Normal file
@@ -0,0 +1,69 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import GetCPSBuffMult from '../CPS/GetCPSBuffMult';
|
||||
import {
|
||||
CacheChainFrenzyMaxReward, CacheChainFrenzyRequired, CacheChainFrenzyRequiredNext, CacheChainFrenzyWrathMaxReward, CacheChainFrenzyWrathRequired, CacheChainFrenzyWrathRequiredNext, CacheChainMaxReward, CacheChainRequired, CacheChainRequiredNext, CacheChainWrathMaxReward, CacheChainWrathRequired, CacheChainWrathRequiredNext, CacheDragonsFortuneMultAdjustment, CacheGoldenCookiesMult, CacheNoGoldSwitchCookiesPS, CacheWrathCookiesMult,
|
||||
} from '../VariablesAndData';
|
||||
|
||||
/**
|
||||
* This functions calculates the max possible payout given a set of variables
|
||||
* It is called by CM.Disp.CreateStatsChainSection() and CM.Cache.CacheChain()
|
||||
* @param {number} digit Number of Golden Cookies in chain
|
||||
* @param {number} maxPayout Maximum payout
|
||||
* @param {number} mult Multiplier
|
||||
* @returns [{number, number, number}] Total cookies earned, cookie needed for this and next level
|
||||
*/
|
||||
export function MaxChainCookieReward(digit, maxPayout, mult) {
|
||||
let totalFromChain = 0;
|
||||
let moni = 0;
|
||||
let nextMoni = 0;
|
||||
let nextRequired = 0;
|
||||
let chain = 1 + Math.max(0, Math.ceil(Math.log(Game.cookies) / Math.LN10) - 10);
|
||||
while (nextMoni < maxPayout) {
|
||||
moni = Math.max(digit, Math.min(Math.floor(1 / 9 * 10 ** chain * digit * mult), maxPayout * mult));
|
||||
nextMoni = Math.max(digit, Math.min(Math.floor(1 / 9 * 10 ** (chain + 1) * digit * mult), maxPayout * mult));
|
||||
nextRequired = Math.floor(1 / 9 * 10 ** (chain + 1) * digit * mult);
|
||||
totalFromChain += moni;
|
||||
chain++;
|
||||
}
|
||||
return [totalFromChain, moni, nextRequired];
|
||||
}
|
||||
|
||||
/**
|
||||
* This functions caches data related to Chain Cookies reward from Golden Cookioes
|
||||
* It is called by CM.Main.Loop() upon changes to cps and CM.Cache.InitCache()
|
||||
* @global [{number, number}] CM.Cache.ChainMaxReward Total cookies earned, and cookies needed for next level for normal chain
|
||||
* @global {number} CM.Cache.ChainRequired Cookies needed for maximum reward for normal chain
|
||||
* @global {number} CM.Cache.ChainRequiredNext Total cookies needed for next level for normal chain
|
||||
* @global [{number, number}] CM.Cache.ChainMaxWrathReward Total cookies earned, and cookies needed for next level for wrath chain
|
||||
* @global {number} CM.Cache.ChainWrathRequired Cookies needed for maximum reward for wrath chain
|
||||
* @global {number} CM.Cache.ChainWrathRequiredNext Total cookies needed for next level for wrath chain
|
||||
* @global [{number, number}] CM.Cache.ChainFrenzyMaxReward Total cookies earned, and cookies needed for next level for normal frenzy chain
|
||||
* @global {number} CM.Cache.ChainFrenzyRequired Cookies needed for maximum reward for normal frenzy chain
|
||||
* @global {number} CM.Cache.ChainFrenzyRequiredNext Total cookies needed for next level for normal frenzy chain
|
||||
* @global [{number, number}] CM.Cache.ChainFrenzyWrathMaxReward Total cookies earned, and cookies needed for next level for wrath frenzy chain
|
||||
* @global {number} CM.Cache.ChainFrenzyWrathRequired Cookies needed for maximum reward for wrath frenzy chain
|
||||
* @global {number} CM.Cache.ChainFrenzyWrathRequiredNext Total cookies needed for next level for wrath frenzy chain
|
||||
*/
|
||||
export function CacheChain() {
|
||||
let maxPayout = CacheNoGoldSwitchCookiesPS * 60 * 60 * 6 * CacheDragonsFortuneMultAdjustment;
|
||||
// Removes effect of Frenzy etc.
|
||||
const cpsBuffMult = GetCPSBuffMult();
|
||||
if (cpsBuffMult > 0) maxPayout /= cpsBuffMult;
|
||||
else maxPayout = 0;
|
||||
|
||||
CacheChainMaxReward = MaxChainCookieReward(7, maxPayout, CacheGoldenCookiesMult);
|
||||
CacheChainRequired = CacheChainMaxReward[1] * 2 / CacheGoldenCookiesMult;
|
||||
CacheChainRequiredNext = CacheChainMaxReward[2] / 60 / 60 / 6 / CacheDragonsFortuneMultAdjustment;
|
||||
|
||||
CacheChainWrathMaxReward = MaxChainCookieReward(6, maxPayout, CacheWrathCookiesMult);
|
||||
CacheChainWrathRequired = CacheChainWrathMaxReward[1] * 2 / CacheWrathCookiesMult;
|
||||
CacheChainWrathRequiredNext = CacheChainWrathMaxReward[2] / 60 / 60 / 6 / CacheDragonsFortuneMultAdjustment;
|
||||
|
||||
CacheChainFrenzyMaxReward = MaxChainCookieReward(7, maxPayout * 7, CacheGoldenCookiesMult);
|
||||
CacheChainFrenzyRequired = CacheChainFrenzyMaxReward[1] * 2 / CacheGoldenCookiesMult;
|
||||
CacheChainFrenzyRequiredNext = CacheChainFrenzyMaxReward[2] / 60 / 60 / 6 / CacheDragonsFortuneMultAdjustment;
|
||||
|
||||
CacheChainFrenzyWrathMaxReward = MaxChainCookieReward(6, maxPayout * 7, CacheWrathCookiesMult);
|
||||
CacheChainFrenzyWrathRequired = CacheChainFrenzyWrathMaxReward[1] * 2 / CacheWrathCookiesMult;
|
||||
CacheChainFrenzyWrathRequiredNext = CacheChainFrenzyWrathMaxReward[2] / 60 / 60 / 6 / CacheDragonsFortuneMultAdjustment;
|
||||
}
|
||||
33
src/Cache/Stats/HeavenlyChips.js
Normal file
33
src/Cache/Stats/HeavenlyChips.js
Normal file
@@ -0,0 +1,33 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import {
|
||||
CacheHCPerSecond, CacheLastHeavenlyCheck, CacheLastHeavenlyChips, HeavenlyChipsDiff,
|
||||
} from '../VariablesAndData';
|
||||
|
||||
/**
|
||||
* This functions caches the heavenly chips per second in the last five seconds
|
||||
* It is called by CM.Cache.LoopCache()
|
||||
* @global {number} CM.Cache.HCPerSecond The Heavenly Chips per second in the last five seconds
|
||||
*/
|
||||
export default function CacheHeavenlyChipsPS() {
|
||||
const currDate = Math.floor(Date.now() / 1000);
|
||||
// Only calculate every new second
|
||||
if ((Game.T / Game.fps) % 1 === 0) {
|
||||
const chipsOwned = Game.HowMuchPrestige(Game.cookiesReset);
|
||||
const ascendNowToOwn = Math.floor(Game.HowMuchPrestige(Game.cookiesReset + Game.cookiesEarned));
|
||||
const ascendNowToGet = ascendNowToOwn - Math.floor(chipsOwned);
|
||||
|
||||
// Add recent gains to AvgQueue's
|
||||
const timeDiff = currDate - CacheLastHeavenlyCheck;
|
||||
const heavenlyChipsDiffAvg = Math.max(0, (ascendNowToGet - CacheLastHeavenlyChips)) / timeDiff;
|
||||
for (let i = 0; i < timeDiff; i++) {
|
||||
HeavenlyChipsDiff.addLatest(heavenlyChipsDiffAvg);
|
||||
}
|
||||
|
||||
// Store current data for next loop
|
||||
CacheLastHeavenlyCheck = currDate;
|
||||
CacheLastHeavenlyChips = ascendNowToGet;
|
||||
|
||||
// Get average gain over period of 5 seconds
|
||||
CacheHCPerSecond = HeavenlyChipsDiff.calcAverage(5);
|
||||
}
|
||||
}
|
||||
40
src/Cache/Stats/MissingUpgrades.js
Normal file
40
src/Cache/Stats/MissingUpgrades.js
Normal file
@@ -0,0 +1,40 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import { crateMissing } from '../../Disp/MenuSections/CreateMissingUpgrades';
|
||||
import { CacheMissingUpgrades, CacheMissingUpgradesCookies, CacheMissingUpgradesPrestige } from '../VariablesAndData';
|
||||
|
||||
/**
|
||||
* This functions caches variables related to missing upgrades
|
||||
* It is called by CM.Main.Loop() and CM.Cache.InitCache()
|
||||
* @global {string} CM.Cache.MissingUpgrades String containig the HTML to create the "crates" for missing normal upgrades
|
||||
* @global {string} CM.Cache.MissingUpgradesCookies String containig the HTML to create the "crates" for missing cookie upgrades
|
||||
* @global {string} CM.Cache.MissingUpgradesPrestige String containig the HTML to create the "crates" for missing prestige upgrades
|
||||
*/
|
||||
export default function CacheAllMissingUpgrades() {
|
||||
CacheMissingUpgrades = '';
|
||||
CacheMissingUpgradesCookies = '';
|
||||
CacheMissingUpgradesPrestige = '';
|
||||
const list = [];
|
||||
// sort the upgrades
|
||||
for (const i of Object.keys(Game.Upgrades)) {
|
||||
list.push(Game.Upgrades[i]);
|
||||
}
|
||||
const sortMap = function (a, b) {
|
||||
if (a.order > b.order) return 1;
|
||||
if (a.order < b.order) return -1;
|
||||
return 0;
|
||||
};
|
||||
list.sort(sortMap);
|
||||
|
||||
for (const i of Object.keys(list)) {
|
||||
const me = list[i];
|
||||
|
||||
if (me.bought === 0) {
|
||||
let str = '';
|
||||
|
||||
str += crateMissing(me);
|
||||
if (me.pool === 'prestige') CacheMissingUpgradesPrestige += str;
|
||||
else if (me.pool === 'cookie') CacheMissingUpgradesCookies += str;
|
||||
else if (me.pool !== 'toggle' && me.pool !== 'unused' && me.pool !== 'debug') CacheMissingUpgrades += str;
|
||||
}
|
||||
}
|
||||
}
|
||||
17
src/Cache/Stats/Reindeer.js
Normal file
17
src/Cache/Stats/Reindeer.js
Normal file
@@ -0,0 +1,17 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import { CacheSeaSpec } from '../VariablesAndData';
|
||||
|
||||
/**
|
||||
* This functions caches the reward of popping a reindeer
|
||||
* It is called by CM.Main.Loop() and CM.Cache.InitCache()
|
||||
* @global {number} CM.Cache.SeaSpec The reward for popping a reindeer
|
||||
*/
|
||||
export default function CacheSeasonSpec() {
|
||||
if (Game.season === 'christmas') {
|
||||
let val = Game.cookiesPs * 60;
|
||||
if (Game.hasBuff('Elder frenzy')) val *= 0.5;
|
||||
if (Game.hasBuff('Frenzy')) val *= 0.75;
|
||||
CacheSeaSpec = Math.max(25, val);
|
||||
if (Game.Has('Ho ho ho-flavored frosting')) CacheSeaSpec *= 2;
|
||||
}
|
||||
}
|
||||
73
src/Cache/Stats/Stats.js
Normal file
73
src/Cache/Stats/Stats.js
Normal file
@@ -0,0 +1,73 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
/** Functions related to Caching stats */
|
||||
|
||||
import SimHas from '../../Sim/ReplacedGameFunctions/SimHas';
|
||||
import GetCPSBuffMult from '../CPS/GetCPSBuffMult';
|
||||
import {
|
||||
CacheConjure, CacheConjureReward, CacheDragonsFortuneMultAdjustment, CacheEdifice, CacheEdificeBuilding, CacheGoldenCookiesMult, CacheLucky, CacheLuckyFrenzy, CacheLuckyReward, CacheLuckyRewardFrenzy, CacheLuckyWrathReward, CacheLuckyWrathRewardFrenzy, CacheNoGoldSwitchCookiesPS, CacheWrathCookiesMult,
|
||||
} from '../VariablesAndData';
|
||||
|
||||
/**
|
||||
* This functions caches variables related to the stats page
|
||||
*/
|
||||
export function CacheStatsCookies() {
|
||||
CacheLucky = (CacheNoGoldSwitchCookiesPS * 900) / 0.15;
|
||||
CacheLucky *= CacheDragonsFortuneMultAdjustment;
|
||||
const cpsBuffMult = GetCPSBuffMult();
|
||||
if (cpsBuffMult > 0) CacheLucky /= cpsBuffMult;
|
||||
else CacheLucky = 0;
|
||||
CacheLuckyReward = CacheGoldenCookiesMult * (CacheLucky * 0.15) + 13;
|
||||
CacheLuckyWrathReward = CacheWrathCookiesMult * (CacheLucky * 0.15) + 13;
|
||||
CacheLuckyFrenzy = CacheLucky * 7;
|
||||
CacheLuckyRewardFrenzy = CacheGoldenCookiesMult * (CacheLuckyFrenzy * 0.15) + 13;
|
||||
CacheLuckyWrathRewardFrenzy = CacheWrathCookiesMult * (CacheLuckyFrenzy * 0.15) + 13;
|
||||
CacheConjure = CacheLucky * 2;
|
||||
CacheConjureReward = CacheConjure * 0.15;
|
||||
|
||||
CacheEdifice = 0;
|
||||
let max = 0;
|
||||
let n = 0;
|
||||
for (const i of Object.keys(Game.Objects)) {
|
||||
if (Game.Objects[i].amount > max) max = Game.Objects[i].amount;
|
||||
if (Game.Objects[i].amount > 0) n++;
|
||||
}
|
||||
for (const i of Object.keys(Game.Objects)) {
|
||||
if ((Game.Objects[i].amount < max || n === 1)
|
||||
&& Game.Objects[i].amount < 400
|
||||
&& Game.Objects[i].price * 2 > CacheEdifice) {
|
||||
CacheEdifice = Game.Objects[i].price * 2;
|
||||
CacheEdificeBuilding = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This functions calculates the multipliers of Golden and Wrath cookie rewards
|
||||
*/
|
||||
export function CacheGoldenAndWrathCookiesMults() {
|
||||
let goldenMult = 1;
|
||||
let wrathMult = 1;
|
||||
let mult = 1;
|
||||
|
||||
// Factor auras and upgrade in mults
|
||||
if (SimHas('Green yeast digestives')) mult *= 1.01;
|
||||
if (SimHas('Dragon fang')) mult *= 1.03;
|
||||
|
||||
goldenMult *= 1 + Game.auraMult('Ancestral Metamorphosis') * 0.1;
|
||||
goldenMult *= Game.eff('goldenCookieGain');
|
||||
wrathMult *= 1 + Game.auraMult('Unholy Dominion') * 0.1;
|
||||
wrathMult *= Game.eff('wrathCookieGain');
|
||||
|
||||
// Calculate final golden and wrath multipliers
|
||||
CacheGoldenCookiesMult = mult * goldenMult;
|
||||
CacheWrathCookiesMult = mult * wrathMult;
|
||||
|
||||
// Calculate Dragon's Fortune multiplier adjustment:
|
||||
// If Dragon's Fortune (or Reality Bending) aura is active and there are currently no golden cookies,
|
||||
// compute a multiplier adjustment to apply on the current CPS to simulate 1 golden cookie on screen.
|
||||
// Otherwise, the aura effect will be factored in the base CPS making the multiplier not requiring adjustment.
|
||||
CacheDragonsFortuneMultAdjustment = 1;
|
||||
if (Game.shimmerTypes.golden.n === 0) {
|
||||
CacheDragonsFortuneMultAdjustment *= 1 + Game.auraMult('Dragon\'s Fortune') * 1.23;
|
||||
}
|
||||
}
|
||||
102
src/Cache/VariablesAndData.js
Normal file
102
src/Cache/VariablesAndData.js
Normal file
@@ -0,0 +1,102 @@
|
||||
/* eslint-disable prefer-const */
|
||||
|
||||
export let CacheDragonAura = 0;
|
||||
export let CacheDragonAura2 = 0;
|
||||
export let CacheLastDragonLevel = 0;
|
||||
export let CacheCostDragonUpgrade = 0;
|
||||
export let CacheLucky = 0;
|
||||
export let CacheLuckyReward = 0;
|
||||
export let CacheLuckyWrathReward = 0;
|
||||
export let CacheLuckyFrenzy = 0;
|
||||
export let CacheLuckyRewardFrenzy = 0;
|
||||
export let CacheLuckyWrathRewardFrenzy = 0;
|
||||
export let CacheConjure = 0;
|
||||
export let CacheConjureReward = 0;
|
||||
export let CacheEdifice = 0;
|
||||
export let CacheEdificeBuilding = 0;
|
||||
export let CacheNoGoldSwitchCookiesPS = 0;
|
||||
export let CacheDragonsFortuneMultAdjustment = 1;
|
||||
export let CacheGoldenCookiesMult = 1;
|
||||
export let CacheWrathCookiesMult = 1;
|
||||
|
||||
export let CacheHCPerSecond = 0;
|
||||
|
||||
export let CacheCentEgg = 0;
|
||||
export let CacheSeaSpec = 0;
|
||||
export let CacheLastChoEgg = 0;
|
||||
|
||||
export let CacheObjects1 = {};
|
||||
export let CacheObjects10 = {};
|
||||
export let CacheObjects100 = {};
|
||||
|
||||
export let CacheWrinklersTotal = 0;
|
||||
export let CacheWrinklersNormal = 0;
|
||||
export let CacheWrinklersFattest = [0, null];
|
||||
|
||||
export let CacheAvgCps = 0;
|
||||
export let CacheCurrWrinklerCPSMult = 0;
|
||||
export let CacheCurrWrinklerCount = 0;
|
||||
|
||||
export let CacheUpgrades = {};
|
||||
|
||||
export let CacheAverageClicks = {};
|
||||
|
||||
export let CacheMissingUpgrades = {};
|
||||
export let CacheMissingUpgradesPrestige = {};
|
||||
export let CacheMissingUpgradesCookies = {};
|
||||
|
||||
export let CacheChainRequired = 0;
|
||||
export let CacheChainRequiredNext = 0;
|
||||
export let CacheChainMaxReward = [];
|
||||
export let CacheChainWrathRequired = 0;
|
||||
export let CacheChainWrathRequiredNext = 0;
|
||||
export let CacheChainWrathMaxReward = [];
|
||||
export let CacheChainFrenzyRequired = 0;
|
||||
export let CacheChainFrenzyRequiredNext = 0;
|
||||
export let CacheChainFrenzyMaxReward = [];
|
||||
export let CacheChainFrenzyWrathRequired = 0;
|
||||
export let CacheChainFrenzyWrathRequiredNext = 0;
|
||||
export let CacheChainFrenzyWrathMaxReward = [];
|
||||
|
||||
export let CacheRealCookiesEarned = 0;
|
||||
export let CacheAvgCPSWithChoEgg = 0;
|
||||
|
||||
export let CacheSpawnedGoldenShimmer = {};
|
||||
export let CacheSeasonPopShimmer = {};
|
||||
|
||||
export let CacheTimeTillNextPrestige = 0;
|
||||
|
||||
export let CacheMinPP = 0;
|
||||
export let CacheMidPP = 0;
|
||||
export let CacheMaxPP = 0;
|
||||
export let CacheArrayOfPPs = [];
|
||||
|
||||
export let CacheGoldenShimmersByID = {};
|
||||
|
||||
export let CacheSellForChoEgg = 0;
|
||||
|
||||
export let CookiesDiff;
|
||||
export let WrinkDiff;
|
||||
export let WrinkFattestDiff;
|
||||
export let ChoEggDiff;
|
||||
export let ClicksDiff;
|
||||
export let HeavenlyChipsDiff;
|
||||
|
||||
export let CacheLastCPSCheck;
|
||||
export let CacheLastCookies;
|
||||
export let CacheLastWrinkCookies;
|
||||
export let CacheLastWrinkFattestCookies;
|
||||
export let CacheLastClicks;
|
||||
|
||||
export let CacheAverageGainBank;
|
||||
export let CacheAverageGainWrink;
|
||||
export let CacheAverageGainWrinkFattest;
|
||||
export let CacheAverageGainChoEgg;
|
||||
export let CacheAverageCPS;
|
||||
|
||||
export let CacheLastHeavenlyCheck;
|
||||
export let CacheLastHeavenlyChips;
|
||||
|
||||
export let CacheDoRemakeBuildPrices;
|
||||
|
||||
export let CacheHadBuildAura;
|
||||
36
src/Cache/Wrinklers/Wrinklers.js
Normal file
36
src/Cache/Wrinklers/Wrinklers.js
Normal file
@@ -0,0 +1,36 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
/** Caches data related to Wrinklers */
|
||||
|
||||
import { SimObjects } from '../../Sim/VariablesAndData';
|
||||
import {
|
||||
CacheWrinklersFattest, CacheWrinklersNormal, CacheWrinklersTotal,
|
||||
} from '../VariablesAndData';
|
||||
|
||||
/**
|
||||
* This functions caches data related to Wrinklers
|
||||
* It is called by CM.Cache.LoopCache() and CM.Cache.InitCache()
|
||||
* @global {number} CM.Cache.WrinklersTotal The cookies of all wrinklers
|
||||
* @global {number} CM.Cache.WrinklersNormal The cookies of all normal wrinklers
|
||||
* @global {[{number}, {number}]} CM.Cache.WrinklersFattest A list containing the cookies and the id of the fattest non-shiny wrinkler
|
||||
*/
|
||||
export default function CacheWrinklers() {
|
||||
for (let i = 0; i < Game.wrinklers.length; i++) {
|
||||
let sucked = Game.wrinklers[i].sucked;
|
||||
let toSuck = 1.1;
|
||||
if (Game.Has('Sacrilegious corruption')) toSuck *= 1.05;
|
||||
if (Game.wrinklers[i].type === 1) toSuck *= 3; // Shiny wrinklers
|
||||
sucked *= toSuck;
|
||||
if (Game.Has('Wrinklerspawn')) sucked *= 1.05;
|
||||
if (SimObjects.Temple.minigameLoaded) {
|
||||
const godLvl = Game.hasGod('scorn');
|
||||
if (godLvl === 1) sucked *= 1.15;
|
||||
else if (godLvl === 2) sucked *= 1.1;
|
||||
else if (godLvl === 3) sucked *= 1.05;
|
||||
}
|
||||
CacheWrinklersTotal += sucked;
|
||||
if (Game.wrinklers[i].type === 0) {
|
||||
CacheWrinklersNormal += sucked;
|
||||
if (sucked > CacheWrinklersFattest[0]) CacheWrinklersFattest = [sucked, i];
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user