Annotated Cache.js and solved issues #555

This commit is contained in:
Daniël van Noord committed 2021-02-18 23:53:51 +01:00
1 parent ca46c10c55
commit 67535eaa4c
4 files changed
+188 -197

No files matched your search

+1 -1
View File
@@ -1 +1 @@
const CM={Backup:{},Cache:{},Config:{},ConfigData:{},Data:{},Disp:{},Footer:{},Main:{},Options:{},Sim:{},VersionMajor:"2.031",VersionMinor:"3"};CM.Cache.InitCache=function(){CM.Cache.CacheDragonAuras();CM.Cache.CacheWrinklers();CM.Cache.CacheStats();CM.Cache.RemakeChain();CM.Cache.CacheMissingUpgrades()};CM.Cache.CacheDragonAuras=function(){CM.Cache.dragonAura=Game.dragonAura;CM.Cache.dragonAura2=Game.dragonAura2};CM.Cache.CacheWrinklers=function(){CM.Cache.WrinklersTotal=0;CM.Cache.WrinklersNormal=0;CM.Cache.WrinklersFattest=[0,null];for(let i;i<Game.wrinklers.length;i++){var sucked=Game.wrinklers[i].sucked;var toSuck=1.1;if(Game.Has("Sacrilegious corruption"))toSuck*=1.05;if(Game.wrinklers[i].type==1)toSuck*=3;sucked*=toSuck;if(Game.Has("Wrinklerspawn"))sucked*=1.05;if(CM.Sim.Objects.Temple.minigameLoaded){var godLvl=CM.Sim.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]}}};CM.Cache.CacheStats=function(){CM.Cache.Lucky=CM.Cache.NoGoldSwitchCookiesPS*900/.15;CM.Cache.Lucky*=CM.Cache.DragonsFortuneMultAdjustment;let cpsBuffMult=CM.Sim.getCPSBuffMult();if(cpsBuffMult>0)CM.Cache.Lucky/=cpsBuffMult;else CM.Cache.Lucky=0;CM.Cache.LuckyReward=CM.Cache.GoldenCookiesMult*(CM.Cache.Lucky*.15)+13;CM.Cache.LuckyWrathReward=CM.Cache.WrathCookiesMult*(CM.Cache.Lucky*.15)+13;CM.Cache.LuckyFrenzy=CM.Cache.Lucky*7;CM.Cache.LuckyRewardFrenzy=CM.Cache.GoldenCookiesMult*(CM.Cache.LuckyFrenzy*.15)+13;CM.Cache.LuckyWrathRewardFrenzy=CM.Cache.WrathCookiesMult*(CM.Cache.LuckyFrenzy*.15)+13;CM.Cache.Conjure=CM.Cache.Lucky*2;CM.Cache.ConjureReward=CM.Cache.Conjure*.15;CM.Cache.Edifice=0;let max=0;let n=0;for(let 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(let 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}}};CM.Cache.MaxChainMoni=function(digit,maxPayout,mult){let totalFromChain=0;let moni=0;let nextMoni=0;var 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));nextMoni=Math.max(digit,Math.min(Math.floor(1/9*Math.pow(10,chain+1)*digit*mult),maxPayout));totalFromChain+=moni;chain++}return[totalFromChain,nextMoni]};CM.Cache.RemakeChain=function(){let maxPayout=CM.Cache.NoGoldSwitchCookiesPS*60*60*6*CM.Cache.DragonsFortuneMultAdjustment;let cpsBuffMult=CM.Sim.getCPSBuffMult();if(cpsBuffMult>0)maxPayout/=cpsBuffMult;else maxPayout=0;CM.Cache.ChainReward=CM.Cache.MaxChainMoni(7,maxPayout*CM.Cache.GoldenCookiesMult,CM.Cache.GoldenCookiesMult);CM.Cache.ChainRequired=CM.Cache.ChainReward[0]*2;CM.Cache.ChainRequiredNext=CM.Cache.ChainReward[1]/60/60/6/CM.Cache.DragonsFortuneMultAdjustment;CM.Cache.ChainWrathReward=CM.Cache.MaxChainMoni(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.ChainFrenzyReward=CM.Cache.MaxChainMoni(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.ChainFrenzyWrathReward=CM.Cache.MaxChainMoni(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.CacheMissingUpgrades=function(){CM.Cache.MissingUpgrades="";CM.Cache.MissingUpgradesCookies="";CM.Cache.MissingUpgradesPrestige="";var list=[];for(let i of Object.keys(Game.Upgrades)){list.push(Game.Upgrades[i])}var sortMap=function(a,b){if(a.order>b.order)return 1;else if(a.order<b.order)return-1;else return 0};list.sort(sortMap);for(let i of Object.keys(list)){var me=list[i];if(me.bought===0){var 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}}};class CMAvgQueue{constructor(maxLength){this.maxLength=maxLength;this.queue=[]}addLatest(newValue){if(this.queue.push(newValue)>this.maxLength){this.queue.shift()}}calcAverage(timePeriod){if(timePeriod>this.maxLength)timePeriod=this.maxLength;if(timePeriod>this.queue.length)timePeriod=this.queue.length;var ret=0;for(let i=this.queue.length-1;i>=0&&i>this.Line truncated
const CM={Backup:{},Cache:{},Config:{},ConfigData:{},Data:{},Disp:{},Footer:{},Main:{},Options:{},Sim:{},VersionMajor:"2.031",VersionMinor:"3"};CM.Cache.InitCache=function(){CM.Cache.CacheDragonAuras();CM.Cache.CacheWrinklers();CM.Cache.CacheStats();CM.Cache.RemakeGoldenAndWrathCookiesMults();CM.Cache.RemakeChain();CM.Cache.CacheMissingUpgrades();CM.Cache.RemakeSeaSpec();CM.Cache.RemakeIncome();CM.Cache.RemakeBuildingsPrices();CM.Cache.RemakePP()};CM.Cache.CacheDragonAuras=function(){CM.Cache.dragonAura=Game.dragonAura;CM.Cache.dragonAura2=Game.dragonAura2};CM.Cache.CacheWrinklers=function(){CM.Cache.WrinklersTotal=0;CM.Cache.WrinklersNormal=0;CM.Cache.WrinklersFattest=[0,null];for(let i;i<Game.wrinklers.length;i++){var sucked=Game.wrinklers[i].sucked;var toSuck=1.1;if(Game.Has("Sacrilegious corruption"))toSuck*=1.05;if(Game.wrinklers[i].type==1)toSuck*=3;sucked*=toSuck;if(Game.Has("Wrinklerspawn"))sucked*=1.05;if(CM.Sim.Objects.Temple.minigameLoaded){var godLvl=CM.Sim.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]}}};CM.Cache.CacheStats=function(){CM.Cache.Lucky=CM.Cache.NoGoldSwitchCookiesPS*900/.15;CM.Cache.Lucky*=CM.Cache.DragonsFortuneMultAdjustment;let cpsBuffMult=CM.Sim.getCPSBuffMult();if(cpsBuffMult>0)CM.Cache.Lucky/=cpsBuffMult;else CM.Cache.Lucky=0;CM.Cache.LuckyReward=CM.Cache.GoldenCookiesMult*(CM.Cache.Lucky*.15)+13;CM.Cache.LuckyWrathReward=CM.Cache.WrathCookiesMult*(CM.Cache.Lucky*.15)+13;CM.Cache.LuckyFrenzy=CM.Cache.Lucky*7;CM.Cache.LuckyRewardFrenzy=CM.Cache.GoldenCookiesMult*(CM.Cache.LuckyFrenzy*.15)+13;CM.Cache.LuckyWrathRewardFrenzy=CM.Cache.WrathCookiesMult*(CM.Cache.LuckyFrenzy*.15)+13;CM.Cache.Conjure=CM.Cache.Lucky*2;CM.Cache.ConjureReward=CM.Cache.Conjure*.15;CM.Cache.Edifice=0;let max=0;let n=0;for(let 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(let 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}}};CM.Cache.RemakeGoldenAndWrathCookiesMults=function(){if(CM.Footer.isInitzializing){CM.Cache.GoldenCookiesMult=1;CM.Cache.WrathCookiesMult=1;CM.Cache.DragonsFortuneMultAdjustment=1}else{var goldenMult=1;var wrathMult=1;var mult=1;if(CM.Sim.Has("Green yeast digestives"))mult*=1.01;if(CM.Sim.Has("Dragon fang"))mult*=1.03;goldenMult*=1+CM.Sim.auraMult("Ancestral Metamorphosis")*.1;goldenMult*=CM.Sim.eff("goldenCookieGain");wrathMult*=1+CM.Sim.auraMult("Unholy Dominion")*.1;wrathMult*=CM.Sim.eff("wrathCookieGain");CM.Cache.GoldenCookiesMult=mult*goldenMult;CM.Cache.WrathCookiesMult=mult*wrathMult;CM.Cache.DragonsFortuneMultAdjustment=1;if(Game.shimmerTypes.golden.n===0){CM.Cache.DragonsFortuneMultAdjustment*=1+CM.Sim.auraMult("Dragon's Fortune")*1.23}}};CM.Cache.MaxChainMoni=function(digit,maxPayout,mult){let totalFromChain=0;let moni=0;let nextMoni=0;var 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));nextMoni=Math.max(digit,Math.min(Math.floor(1/9*Math.pow(10,chain+1)*digit*mult),maxPayout));totalFromChain+=moni;chain++}return[totalFromChain,nextMoni]};CM.Cache.RemakeChain=function(){let maxPayout=CM.Cache.NoGoldSwitchCookiesPS*60*60*6*CM.Cache.DragonsFortuneMultAdjustment;let cpsBuffMult=CM.Sim.getCPSBuffMult();if(cpsBuffMult>0)maxPayout/=cpsBuffMult;else maxPayout=0;CM.Cache.ChainReward=CM.Cache.MaxChainMoni(7,maxPayout*CM.Cache.GoldenCookiesMult,CM.Cache.GoldenCookiesMult);CM.Cache.ChainRequired=CM.Cache.ChainReward[0]*2;CM.Cache.ChainRequiredNext=CM.Cache.ChainReward[1]/60/60/6/CM.Cache.DragonsFortuneMultAdjustment;CM.Cache.ChainWrathReward=CM.Cache.MaxChainMoni(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.ChainFrenzyReward=CM.Cache.MaxChainMoni(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.ChainFrenzyWrathReward=CM.Cache.MaxChainMoni(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.CacheMissingUpgrades=function(){CM.Cache.MissingUpgrades="";CM.Cache.MissingUpgradesCookies="";CM.Cache.MissingUpLine truncated
+176 -192
View File
@@ -15,8 +15,13 @@ CM.Cache.InitCache = function() {
CM.Cache.CacheDragonAuras();
CM.Cache.CacheWrinklers();
CM.Cache.CacheStats();
CM.Cache.RemakeGoldenAndWrathCookiesMults();
CM.Cache.RemakeChain();
CM.Cache.CacheMissingUpgrades();
CM.Cache.RemakeSeaSpec();
CM.Cache.RemakeIncome();
CM.Cache.RemakeBuildingsPrices();
CM.Cache.RemakePP();
};
/********
@@ -117,6 +122,48 @@ CM.Cache.CacheStats = function() {
}
};
/**
* This functions calculates the multipliers of Golden and Wrath cookie rewards
* It is mostly used by CM.Cache.MaxChainMoni() and CM.Cache.RemakeChain()
* It is called by CM.Disp.CreateStatsChainSection() and CM.Cache.RemakeChain()
* @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.RemakeGoldenAndWrathCookiesMults = function() {
if (CM.Footer.isInitzializing) {
CM.Cache.GoldenCookiesMult = 1;
CM.Cache.WrathCookiesMult = 1;
CM.Cache.DragonsFortuneMultAdjustment = 1;
} else {
var goldenMult = 1;
var wrathMult = 1;
var 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 + CM.Sim.auraMult('Ancestral Metamorphosis') * 0.1;
goldenMult *= CM.Sim.eff('goldenCookieGain');
wrathMult *= 1 + CM.Sim.auraMult('Unholy Dominion') * 0.1;
wrathMult *= CM.Sim.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 + CM.Sim.auraMult('Dragon\'s Fortune') * 1.23;
}
}
};
/**
* This functions calculates the max possible payout
* It is called by CM.Disp.CreateStatsChainSection() and CM.Cache.RemakeChain()
@@ -134,7 +181,6 @@ CM.Cache.MaxChainMoni = function(digit, maxPayout, mult) {
moni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain) * digit * mult), maxPayout));
// TODO: Calculate Cookies or cps needed for next level of chain
nextMoni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain + 1) * digit * mult), maxPayout));
lastMoni = moni
totalFromChain += moni;
chain++;
}
@@ -219,6 +265,21 @@ CM.Cache.CacheMissingUpgrades = function() {
}
};
/**
* This functions caches the reward of popping a reindeer
* It is called by CM.Loop() and CM.Cache.InitCache()
* @global {number} CM.Cache.SeaSpec The reward for popping a reindeer
*/
CM.Cache.RemakeSeaSpec = function() {
if (Game.season === 'christmas') {
var 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;
}
};
/********
* Section: Functions related to Caching CPS */
@@ -268,8 +329,9 @@ CM.Cache.InitCookiesDiff = function() {
/**
* This functions caches two variables related average CPS and Clicks
* * It is called by CM.Loop()
* It is called by CM.Loop()
* TODO: Check if this can be made more concise
* @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
@@ -329,6 +391,28 @@ CM.Cache.UpdateAvgCPS = function() {
}
};
/**
* This functions caches the reward for selling the Chocolate egg
* It is called by CM.Loop()
* @global {number} CM.Cache.SellForChoEgg Total cookies to be gained from selling Chocolate egg
*/
CM.Cache.RemakeSellForChoEgg = function() {
var sellTotal = 0;
// Compute cookies earned by selling stock market goods
if (Game.Objects.Bank.minigameLoaded) {
var marketGoods = Game.Objects.Bank.minigame.goods;
var goodsVal = 0;
for (let i of Object.keys(marketGoods)) {
var 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.Loop(). Variables are mostly used by CM.Disp.GetCPS().
@@ -411,11 +495,29 @@ CM.Cache.CacheDragonCost = function() {
};
/********
* Section: ? */
* 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.Loop() and CM.Cache.InitCache()
*/
CM.Cache.RemakeIncome = function() {
// Simulate Building Buys for 1, 10 and 100 amount
CM.Sim.BuyBuildings(1, 'Objects1');
CM.Sim.BuyBuildings(10, 'Objects10');
CM.Sim.BuyBuildings(100, 'Objects100');
// Simulate Upgrade Buys
CM.Sim.BuyUpgrades();
};
/********
* Section: UNSORTED */
* 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.Loop() and CM.Cache.InitCache()
*/
CM.Cache.RemakeBuildingsPrices = function() {
for (let 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);
@@ -424,33 +526,32 @@ CM.Cache.RemakeBuildingsPrices = function() {
}
};
CM.Cache.RemakeIncome = function() {
// Simulate Building Buys for 1 amount
CM.Sim.BuyBuildings(1, 'Objects1');
/********
* Section: Functions related to caching PP */
// Simulate Upgrade Buys
CM.Sim.BuyUpgrades();
// Simulate Building Buys for 10 amount
CM.Sim.BuyBuildings(10, 'Objects10');
// Simulate Building Buys for 100 amount
CM.Sim.BuyBuildings(100, 'Objects100');
/**
* This functions caches the PP of each building and upgrade and stores it in the cache
* It is called by CM.Loop() and CM.Cache.InitCache()
*/
CM.Cache.RemakePP = function() {
CM.Cache.RemakeBuildingsPP();
CM.Cache.RemakeUpgradePP();
};
/**
* This functions caches the PP of each building it saves all date in CM.Cache.Objects...
* It is called by CM.Cache.RemakePP()
*/
CM.Cache.RemakeBuildingsPP = function() {
CM.Cache.min = -1;
CM.Cache.max = -1;
CM.Cache.mid = -1;
// Calculate PP and colors when compared to purchase of single optimal building
// Calculate PP and colors when compared to purchase of optimal building in single-purchase mode
if (CM.Options.ColorPPBulkMode === 0) {
for (let i of Object.keys(CM.Cache.Objects1)) {
//CM.Cache.Objects1[i].pp = Game.Objects[i].getPrice() / CM.Cache.Objects1[i].bonus;
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);
}
} else CM.Cache.Objects1[i].pp = (Game.Objects[i].getPrice() / CM.Cache.Objects1[i].bonus);
if (CM.Cache.min === -1 || CM.Cache.Objects1[i].pp < CM.Cache.min) CM.Cache.min = CM.Cache.Objects1[i].pp;
if (CM.Cache.max === -1 || CM.Cache.Objects1[i].pp > CM.Cache.max) CM.Cache.max = CM.Cache.Objects1[i].pp;
}
@@ -463,92 +564,64 @@ CM.Cache.RemakeBuildingsPP = function() {
else color = CM.Disp.colorYellow;
CM.Cache.Objects1[i].color = color;
}
// Buildings for 10 amount
CM.Cache.RemakeBuildingsOtherPP(10, 'Objects10');
// Buildings for 100 amount
CM.Cache.RemakeBuildingsOtherPP(100, 'Objects100');
// Calculate PP of bulk-buy modes
CM.Cache.RemakeBuildingsBulkPP('Objects10');
CM.Cache.RemakeBuildingsBulkPP('Objects100');
}
// Calculate PP and colors when compared to purchase of selected bulk mode
else {
if (Game.buyBulk === 1) {
for (let i of Object.keys(CM.Cache.Objects1)) {
//CM.Cache.Objects1[i].pp = Game.Objects[i].getPrice() / CM.Cache.Objects1[i].bonus;
let target = `Objects${Game.buyBulk}`
for (let i of Object.keys(CM.Cache[target])) {
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);
}
if (CM.Cache.min === -1 || CM.Cache.Objects1[i].pp < CM.Cache.min) CM.Cache.min = CM.Cache.Objects1[i].pp;
if (CM.Cache.max === -1 || CM.Cache.Objects1[i].pp > CM.Cache.max) CM.Cache.max = CM.Cache.Objects1[i].pp;
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.CM.Cache[target][i].pp = (Game.Objects[i].bulkPrice / CM.Cache[target][i].bonus);
if (CM.Cache.min === -1 || CM.Cache[target][i].pp < CM.Cache.min) CM.Cache.min = CM.Cache[target][i].pp;
if (CM.Cache.max === -1 || CM.Cache[target][i].pp > CM.Cache.max) CM.Cache.max = CM.Cache[target][i].pp;
}
CM.Cache.mid = ((CM.Cache.max - CM.Cache.min) / 2) + CM.Cache.min;
for (let i of Object.keys(CM.Cache.Objects1)) {
let color = '';
if (CM.Cache.Objects1[i].pp === CM.Cache.min) color = CM.Disp.colorGreen;
else if (CM.Cache.Objects1[i].pp === CM.Cache.max) color = CM.Disp.colorRed;
else if (CM.Cache.Objects1[i].pp > CM.Cache.mid) color = CM.Disp.colorOrange;
if (CM.Cache[target][i].pp === CM.Cache.min) color = CM.Disp.colorGreen;
else if (CM.Cache[target][i].pp === CM.Cache.max) color = CM.Disp.colorRed;
else if (CM.Cache[target][i].pp > CM.Cache.mid) color = CM.Disp.colorOrange;
else color = CM.Disp.colorYellow;
CM.Cache.Objects1[i].color = color;
}
CM.Cache.RemakeBuildingsOtherPP(10, 'Objects10');
CM.Cache.RemakeBuildingsOtherPP(100, 'Objects100');
}
else if (Game.buyBulk === 10) {
for (let i of Object.keys(CM.Cache.Objects1)) {
if (Game.cookiesPs) {
CM.Cache.Objects10[i].pp = (Math.max(Game.Objects[i].bulkPrice - (Game.cookies + CM.Disp.GetWrinkConfigBank()), 0) / Game.cookiesPs) + (Game.Objects[i].bulkPrice / CM.Cache.Objects10[i].bonus);
} else {
CM.Cache.Objects10[i].pp = (Game.Objects[i].bulkPrice / CM.Cache.Objects10[i].bonus);
}
if (CM.Cache.min === -1 || CM.Cache.Objects10[i].pp < CM.Cache.min) CM.Cache.min = CM.Cache.Objects10[i].pp;
if (CM.Cache.max === -1 || CM.Cache.Objects10[i].pp > CM.Cache.max) CM.Cache.max = CM.Cache.Objects10[i].pp;
}
CM.Cache.mid = ((CM.Cache.max - CM.Cache.min) / 2) + CM.Cache.min;
for (let i of Object.keys(CM.Cache.Objects1)) {
let color = '';
if (CM.Cache.Objects10[i].pp === CM.Cache.min) color = CM.Disp.colorGreen;
else if (CM.Cache.Objects10[i].pp === CM.Cache.max) color = CM.Disp.colorRed;
else if (CM.Cache.Objects10[i].pp > CM.Cache.mid) color = CM.Disp.colorOrange;
else color = CM.Disp.colorYellow;
CM.Cache.Objects10[i].color = color;
}
CM.Cache.RemakeBuildingsOtherPP(1, 'Objects');
CM.Cache.RemakeBuildingsOtherPP(100, 'Objects100');
}
else if (Game.buyBulk === 100) {
for (let i of Object.keys(CM.Cache.Objects1)) {
if (Game.cookiesPs) {
CM.Cache.Objects100[i].pp = (Math.max(Game.Objects[i].bulkPrice - (Game.cookies + CM.Disp.GetWrinkConfigBank()), 0) / Game.cookiesPs) + (Game.Objects[i].bulkPrice / CM.Cache.Objects100[i].bonus);
} else {
CM.Cache.Objects100[i].pp = (Game.Objects[i].bulkPrice / CM.Cache.Objects100[i].bonus);
}
if (CM.Cache.min === -1 || CM.Cache.Objects100[i].pp < CM.Cache.min) CM.Cache.min = CM.Cache.Objects100[i].pp;
if (CM.Cache.max === -1 || CM.Cache.Objects100[i].pp > CM.Cache.max) CM.Cache.max = CM.Cache.Objects100[i].pp;
}
CM.Cache.mid = ((CM.Cache.max - CM.Cache.min) / 2) + CM.Cache.min;
for (let i of Object.keys(CM.Cache.Objects1)) {
let color = '';
if (CM.Cache.Objects100[i].pp === CM.Cache.min) color = CM.Disp.colorGreen;
else if (CM.Cache.Objects100[i].pp === CM.Cache.max) color = CM.Disp.colorRed;
else if (CM.Cache.Objects100[i].pp > CM.Cache.mid) color = CM.Disp.colorOrange;
else color = CM.Disp.colorYellow;
CM.Cache.Objects100[i].color = color;
}
CM.Cache.RemakeBuildingsOtherPP(1, 'Objects');
CM.Cache.RemakeBuildingsOtherPP(10, 'Objects10');
CM.Cache[target][i].color = color;
}
}
};
/**
* 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.RemakeBuildingsPP()
*/
CM.Cache.RemakeBuildingsBulkPP = function(target) {
for (let 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);
let color = '';
if (CM.Cache[target][i].pp <= 0 || CM.Cache[target][i].pp === Infinity) color = CM.Disp.colorGray;
else if (CM.Cache[target][i].pp < CM.Cache.min) color = CM.Disp.colorBlue;
else if (CM.Cache[target][i].pp === CM.Cache.min) color = CM.Disp.colorGreen;
else if (CM.Cache[target][i].pp === CM.Cache.max) color = CM.Disp.colorRed;
else if (CM.Cache[target][i].pp > CM.Cache.max) color = CM.Disp.colorPurple;
else if (CM.Cache[target][i].pp > CM.Cache.mid) color = CM.Disp.colorOrange;
else color = CM.Disp.colorYellow;
CM.Cache[target][i].color = color;
}
};
/**
* This functions caches the PP of each building it saves all date in CM.Cache.Upgrades
* It is called by CM.Cache.RemakePP()
*/
CM.Cache.RemakeUpgradePP = function() {
for (let i of Object.keys(CM.Cache.Upgrades)) {
//CM.Cache.Upgrades[i].pp = Game.Upgrades[i].getPrice() / CM.Cache.Upgrades[i].bonus;
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);
}
} else CM.Cache.Upgrades[i].pp = (Game.Upgrades[i].getPrice() / CM.Cache.Upgrades[i].bonus);
if (isNaN(CM.Cache.Upgrades[i].pp)) CM.Cache.Upgrades[i].pp = Infinity;
let color = '';
if (CM.Cache.Upgrades[i].pp <= 0 || CM.Cache.Upgrades[i].pp === Infinity) color = CM.Disp.colorGray;
@@ -562,109 +635,20 @@ CM.Cache.RemakeUpgradePP = function() {
}
};
CM.Cache.RemakeBuildingsOtherPP = function(amount, target) {
for (let i of Object.keys(CM.Cache[target])) {
//CM.Cache[target][i].pp = CM.Cache[target][i].price / CM.Cache[target][i].bonus;
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);
}
let color = '';
if (CM.Cache[target][i].pp <= 0 || CM.Cache[target][i].pp === Infinity) color = CM.Disp.colorGray;
else if (CM.Cache[target][i].pp < CM.Cache.min) color = CM.Disp.colorBlue;
else if (CM.Cache[target][i].pp === CM.Cache.min) color = CM.Disp.colorGreen;
else if (CM.Cache[target][i].pp === CM.Cache.max) color = CM.Disp.colorRed;
else if (CM.Cache[target][i].pp > CM.Cache.max) color = CM.Disp.colorPurple;
else if (CM.Cache[target][i].pp > CM.Cache.mid) color = CM.Disp.colorOrange;
else color = CM.Disp.colorYellow;
CM.Cache[target][i].color = color;
}
};
/********
* Section: Cached variables */
CM.Cache.RemakePP = function() {
// Buildings
CM.Cache.RemakeBuildingsPP();
// Upgrades
CM.Cache.RemakeUpgradePP();
};
CM.Cache.RemakeGoldenAndWrathCookiesMults = function() {
var goldenMult = 1;
var wrathMult = 1;
var 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 + CM.Sim.auraMult('Ancestral Metamorphosis') * 0.1;
goldenMult *= CM.Sim.eff('goldenCookieGain');
wrathMult *= 1 + CM.Sim.auraMult('Unholy Dominion') * 0.1;
wrathMult *= CM.Sim.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 + CM.Sim.auraMult('Dragon\'s Fortune') * 1.23;
}
};
CM.Cache.RemakeSeaSpec = function() {
if (Game.season === 'christmas') {
var val = Game.cookiesPs * 60;
if (Game.hasBuff('Elder frenzy')) val *= 0.5; // very sorry
if (Game.hasBuff('Frenzy')) val *= 0.75; // I sincerely apologize
CM.Cache.SeaSpec = Math.max(25, val);
if (Game.Has('Ho ho ho-flavored frosting')) CM.Cache.SeaSpec *= 2;
}
};
CM.Cache.RemakeSellForChoEgg = function() {
var sellTotal = 0;
// Compute cookies earned by selling stock market goods
if (Game.Objects.Bank.minigameLoaded) {
var marketGoods = Game.Objects.Bank.minigame.goods;
var goodsVal = 0;
for (let i of Object.keys(marketGoods)) {
var 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;
};
CM.Cache.min = -1;
CM.Cache.max = -1;
CM.Cache.mid = -1;
CM.Cache.GoldenCookiesMult = 1;
CM.Cache.WrathCookiesMult = 1;
CM.Cache.DragonsFortuneMultAdjustment = 1;
CM.Cache.NoGoldSwitchCookiesPS = 0;
CM.Cache.SeaSpec = 0;
CM.Cache.Chain = 0;
CM.Cache.ChainWrath = 0;
CM.Cache.ChainReward = 0;
CM.Cache.ChainWrathReward = 0;
CM.Cache.ChainFrenzy = 0;
CM.Cache.ChainFrenzyWrath = 0;
CM.Cache.ChainFrenzyReward = 0;
CM.Cache.ChainFrenzyWrathReward = 0;
/**
* Used to store the multiplier of the Century Egg
*/
CM.Cache.CentEgg = 0;
CM.Cache.SellForChoEgg = 0;
CM.Cache.Title = '';
/**
* Used to store if there was a Build Aura (used in CM.Main)
*/
CM.Cache.HadBuildAura = false;
CM.Cache.RealCookiesEarned = -1;
CM.Cache.goldenShimmersByID = {};
CM.Cache.spawnedGoldenShimmer = 0;
/**
* Used to store CPS without Golden Cookie Switch
*/
CM.Cache.NoGoldSwitchCookiesPS = 0;
+10 -3
View File
@@ -341,8 +341,10 @@ CM.Disp.Draw = function () {
CM.Disp.ToggleBotBar = function() {
if (CM.Options.BotBar === 1) {
CM.Disp.BotBar.style.display = '';
if (!CM.Footer.isInitzializing) {
CM.Disp.UpdateBotBar();
}
}
else {
CM.Disp.BotBar.style.display = 'none';
}
@@ -1070,11 +1072,11 @@ CM.Disp.UpdateFavicon = function() {
/**
* This function updates the tab title
* It is called on every loop by Game.Logic() which also sets CM.Cache.Title to Game.cookies
* It is called on every loop by Game.Logic() which also sets CM.Disp.Title to Game.cookies
*/
CM.Disp.UpdateTitle = function() {
if (Game.OnAscend || CM.Options.Title === 0) {
document.title = CM.Cache.Title;
document.title = CM.Disp.Title;
}
else if (CM.Options.Title === 1) {
let addFC = false;
@@ -1106,7 +1108,7 @@ CM.Disp.UpdateTitle = function() {
}
// Remove previous timers and add current cookies
let str = CM.Cache.Title;
let str = CM.Disp.Title;
if (str.charAt(0) === '[') {
str = str.substring(str.lastIndexOf(']') + 1);
}
@@ -2920,6 +2922,11 @@ CM.Disp.clickTimes = [1, 5, 10, 15, 30];
*/
CM.Disp.TooltipWrinklerBeingShown = [];
/**
* Used to store the number of cookies to be displayed in the tab-title
*/
CM.Disp.Title = '';
/**
* These are variables with base-values that get initalized when initliazing CookieMonster
* TODO: See if these can be removed or moved
+1 -1
View File
@@ -94,7 +94,7 @@ CM.ReplaceNative = function() {
};
CM.Backup.Logic = Game.Logic;
eval('CM.Backup.LogicMod = ' + Game.Logic.toString().split('document.title').join('CM.Cache.Title'));
eval('CM.Backup.LogicMod = ' + Game.Logic.toString().split('document.title').join('CM.Disp.Title'));
Game.Logic = function() {
CM.Backup.LogicMod();