FIxed #580 and started at #29

This commit is contained in:
Daniël van Noord
2021-02-23 00:35:06 +01:00
parent e6596713b9
commit 2fcb7c0f66
3 changed files with 33 additions and 30 deletions

View File

@@ -228,39 +228,41 @@ CM.Cache.CacheGoldenAndWrathCookiesMults = function() {
/**
* 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}] Total cookies earned, and cookies needed for next level
* @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 * Math.pow(10, chain) * digit * mult), maxPayout));
moni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain) * digit * mult), maxPayout * mult));
// TODO: Calculate Cookies or cps needed for next level of chain. See issue #29
nextMoni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain + 1) * digit * mult), maxPayout));
nextMoni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain + 1) * digit * mult), maxPayout * mult));
nextRequired = Math.floor(1 / 9 * Math.pow(10, chain + 1) * digit * mult);
totalFromChain += moni;
chain++;
}
return [totalFromChain, nextMoni];
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.ChainReward Total cookies earned, and cookies needed for next level for normal chain
* @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.ChainWrathReward Total cookies earned, and cookies needed for next level for wrath 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.ChainFrenzyReward Total cookies earned, and cookies needed for next level for normal frenzy 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.ChainFrenzyWrathReward Total cookies earned, and cookies needed for next level for wrath 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
*/
@@ -271,23 +273,21 @@ CM.Cache.CacheChain = function() {
if (cpsBuffMult > 0) maxPayout /= cpsBuffMult;
else maxPayout = 0;
CM.Cache.ChainReward = CM.Cache.MaxChainCookieReward(7, maxPayout * CM.Cache.GoldenCookiesMult, CM.Cache.GoldenCookiesMult);
// TODO: All "required" variables are incorrect. Perhaps something to do with going over the required amount during the chain.
// See issue #580 on the Github
CM.Cache.ChainRequired = CM.Cache.ChainReward[0] * 2;
CM.Cache.ChainRequiredNext = CM.Cache.ChainReward[1] / 60 / 60 / 6 / CM.Cache.DragonsFortuneMultAdjustment;
CM.Cache.ChainMaxReward = CM.Cache.MaxChainCookieReward(7, maxPayout, CM.Cache.GoldenCookiesMult);
CM.Cache.ChainRequired = CM.Cache.ChainMaxReward[1] * 2;
CM.Cache.ChainRequiredNext = CM.Cache.ChainMaxReward[2] * 2;
CM.Cache.ChainWrathReward = CM.Cache.MaxChainCookieReward(6, maxPayout * CM.Cache.WrathCookiesMult, CM.Cache.WrathCookiesMult);
CM.Cache.ChainWrathRequired = CM.Cache.ChainWrathReward[0] * 2;
CM.Cache.ChainWrathRequiredNext = CM.Cache.ChainWrathReward[1] / 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.ChainWrathRequiredNext = CM.Cache.ChainMaxWrathReward[2] * 2;
CM.Cache.ChainFrenzyReward = CM.Cache.MaxChainCookieReward(7, maxPayout * 7 * CM.Cache.GoldenCookiesMult, CM.Cache.GoldenCookiesMult);
CM.Cache.ChainFrenzyRequired = CM.Cache.ChainFrenzyReward[0] * 2;
CM.Cache.ChainFrenzyRequiredNext = CM.Cache.ChainFrenzyReward[1] / 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.ChainFrenzyRequiredNext = CM.Cache.ChainFrenzyMaxReward[2] / 60 / 60 / 6 / CM.Cache.DragonsFortuneMultAdjustment;
CM.Cache.ChainFrenzyWrathReward = CM.Cache.MaxChainCookieReward(6, maxPayout * 7 * CM.Cache.WrathCookiesMult, CM.Cache.WrathCookiesMult);
CM.Cache.ChainFrenzyWrathRequired = CM.Cache.ChainFrenzyReward[0] * 2;
CM.Cache.ChainFrenzyWrathRequiredNext = CM.Cache.ChainFrenzyReward[1] / 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.ChainFrenzyWrathRequiredNext = CM.Cache.ChainFrenzyMaxWrathReward[2] / 60 / 60 / 6 / CM.Cache.DragonsFortuneMultAdjustment;
};
/**

View File

@@ -2382,7 +2382,7 @@ CM.Disp.AddMenuStats = function(title) {
CM.Disp.CreateStatsHeader = function(text, config) {
let div = document.createElement('div');
div.className = 'title';
div.style.padding = '5px 16px';
div.style.padding = '0px 16px';
div.style.opacity = '0.7';
div.style.fontSize = '17px';
div.style.fontFamily = '"Kavoon", Georgia, serif';
@@ -2624,14 +2624,17 @@ CM.Disp.CreateStatsChainSection = function() {
}
section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '"Chain" Cookies Required (Frenzy) (Wrath)', chainWrathReqFrenFrag, goldCookTooltip));
section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '"Chain" Reward (MAX) (Golden / Wrath)', document.createTextNode(Beautify(CM.Cache.ChainReward[0]) + ' / ' + Beautify(CM.Cache.ChainWrathReward[0])), goldCookTooltip));
section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '"Chain" Reward (MAX) (Golden / Wrath)', document.createTextNode(Beautify(CM.Cache.ChainMaxReward[0]) + ' / ' + Beautify(CM.Cache.ChainMaxWrathReward[0])), goldCookTooltip));
section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '"Chain" Reward (MAX) (Frenzy) (Golden / Wrath)', document.createTextNode((Beautify(CM.Cache.ChainFrenzyReward[0]) + ' / ' + Beautify(CM.Cache.ChainFrenzyWrathReward[0]))), goldCookTooltip));
section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '"Chain" Reward (MAX) (Frenzy) (Golden / Wrath)', document.createTextNode((Beautify(CM.Cache.ChainFrenzyMaxReward[0]) + ' / ' + Beautify(CM.Cache.ChainFrenzyMaxWrathReward[0]))), goldCookTooltip));
let chainCurMax = Math.min(CM.Cache.NoGoldSwitchCookiesPS * CM.Cache.DragonsFortuneMultAdjustment * 60 * 60 * 6, (Game.cookies + CM.Disp.GetWrinkConfigBank()) * 0.5);
let chainCurMax = Math.min(Game.cookiesPs * 60 * 60 * 6 * CM.Cache.DragonsFortuneMultAdjustment, Game.cookies * 0.5);
let chainCur = CM.Cache.MaxChainCookieReward(7, chainCurMax, CM.Cache.GoldenCookiesMult)[0];
let chainCurWrath = CM.Cache.MaxChainCookieReward(6, chainCurMax, CM.Cache.WrathCookiesMult)[0];
section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '"Chain" Reward (CUR) (Golden / Wrath)', document.createTextNode((Beautify(chainCur) + ' / ' + Beautify(chainCurWrath))), goldCookTooltip));
section.appendChild(CM.Disp.CreateStatsListing("withTooltip", 'CPS Needed For Next Level (G / W)', document.createTextNode((Beautify(CM.Cache.ChainRequiredNext) + ' / ' + Beautify(CM.Cache.ChainWrathRequiredNext))), goldCookTooltip));
section.appendChild(CM.Disp.CreateStatsListing("withTooltip", 'CPS Needed For Next Level (Frenzy) (G / W)', document.createTextNode((Beautify(CM.Cache.ChainFrenzyRequiredNext) + ' / ' + Beautify(CM.Cache.ChainFrenzyWrathRequiredNext))), goldCookTooltip));
return section;
};