Fixed crash on selecting sell all #620
This commit is contained in:
3 files changed
+29
-7
No files matched your search
+1
-1
@@ -1 +1 @@
|
|||||||
const CM={Backup:{},Cache:{},Config:{},Data:{Config:{}},Disp:{},Footer:{},Main:{},Options:{},Sim:{},VersionMajor:"2.031",VersionMinor:"4"};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);CM.Cache.CacheHeavenlyChipsPS();CM.Cache.CacheAvgCPS();CM.Cache.CacheIncome();CM.Cache.CacheBuildingsPrices();CM.Cache.CachePP()};CM.Cache.LoopCache=function(){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())};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;let ret=0;for(let i=this.queue.length-1;i>=0&&i>this.queue.length-1-timePeriod;i--){ret+=this.queue[i]}return ret/timePeriod}}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=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;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]}}};CM.Cache.CacheStats=function(){CM.Cache.Lucky=CM.Cache.NoGoldSwitchCookiesPS*900/.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*.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(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}}};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;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")*.1;goldenMult*=Game.eff("goldenCookieGain");wrathMult*=1+Game.auraMult("Unholy Dominion")*.1;wrathMult*=Game.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+Game.auraMult("Dragon's Fortune")*1.23}}};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]};CM.Cache.CacheChain=function(){let maxPayout=CM.Cache.NoGoldSwitchCookiesPS*60*60*6*CM.Cache.DragonsFortuneMultAdjustment;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.ChaLine truncated
|
const CM={Backup:{},Cache:{},Config:{},Data:{Config:{}},Disp:{},Footer:{},Main:{},Options:{},Sim:{},VersionMajor:"2.031",VersionMinor:"4"};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);CM.Cache.CacheHeavenlyChipsPS();CM.Cache.CacheAvgCPS();CM.Cache.CacheIncome();CM.Cache.CacheBuildingsPrices();CM.Cache.CachePP()};CM.Cache.LoopCache=function(){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())};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;let ret=0;for(let i=this.queue.length-1;i>=0&&i>this.queue.length-1-timePeriod;i--){ret+=this.queue[i]}return ret/timePeriod}}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=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;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]}}};CM.Cache.CacheStats=function(){CM.Cache.Lucky=CM.Cache.NoGoldSwitchCookiesPS*900/.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*.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(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}}};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;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")*.1;goldenMult*=Game.eff("goldenCookieGain");wrathMult*=1+Game.auraMult("Unholy Dominion")*.1;wrathMult*=Game.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+Game.auraMult("Dragon's Fortune")*1.23}}};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]};CM.Cache.CacheChain=function(){let maxPayout=CM.Cache.NoGoldSwitchCookiesPS*60*60*6*CM.Cache.DragonsFortuneMultAdjustment;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.ChaLine truncated
|
||||||
+2
-2
@@ -684,7 +684,7 @@ CM.Cache.CacheBuildingsPP = function () {
|
|||||||
if (typeof CM.Options.PPExcludeTop === 'undefined') CM.Options.PPExcludeTop = 0; // Otherwise breaks during initialization
|
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
|
// Calculate PP and colors when compared to purchase of optimal building in single-purchase mode
|
||||||
if (CM.Options.ColorPPBulkMode === 0) {
|
if (CM.Options.ColorPPBulkMode === 0 && Game.buyMode > 0) {
|
||||||
for (const i of Object.keys(CM.Cache.Objects1)) {
|
for (const i of Object.keys(CM.Cache.Objects1)) {
|
||||||
if (Game.cookiesPs) {
|
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);
|
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);
|
||||||
@@ -714,7 +714,7 @@ CM.Cache.CacheBuildingsPP = function () {
|
|||||||
// Calculate PP of bulk-buy modes
|
// Calculate PP of bulk-buy modes
|
||||||
CM.Cache.CacheBuildingsBulkPP('Objects10');
|
CM.Cache.CacheBuildingsBulkPP('Objects10');
|
||||||
CM.Cache.CacheBuildingsBulkPP('Objects100');
|
CM.Cache.CacheBuildingsBulkPP('Objects100');
|
||||||
} else {
|
} else if (Game.buyMode > 0) {
|
||||||
// Calculate PP and colors when compared to purchase of selected bulk mode
|
// Calculate PP and colors when compared to purchase of selected bulk mode
|
||||||
const target = `Objects${Game.buyBulk}`;
|
const target = `Objects${Game.buyBulk}`;
|
||||||
for (const i of Object.keys(CM.Cache[target])) {
|
for (const i of Object.keys(CM.Cache[target])) {
|
||||||
|
|||||||
+26
-4
@@ -374,10 +374,15 @@ CM.Disp.CreateBotBar = function () {
|
|||||||
* It is called by CM.Disp.Draw()
|
* It is called by CM.Disp.Draw()
|
||||||
*/
|
*/
|
||||||
CM.Disp.UpdateBotBar = function () {
|
CM.Disp.UpdateBotBar = function () {
|
||||||
if (CM.Options.BotBar === 1 && CM.Cache.Objects1) {
|
if (CM.Options.BotBar === 1 && CM.Cache.Objects1 && Game.buyMode === 1) {
|
||||||
let count = 0;
|
let count = 0;
|
||||||
for (const i of Object.keys(CM.Cache.Objects1)) {
|
for (const i of Object.keys(CM.Cache.Objects1)) {
|
||||||
const target = `Objects${Game.buyBulk}`;
|
let target = `Objects${Game.buyBulk}`;
|
||||||
|
if (Game.buyMode === 1) {
|
||||||
|
CM.Disp.LastTargetBotBar = target;
|
||||||
|
} else {
|
||||||
|
target = CM.Disp.LastTargetBotBar;
|
||||||
|
}
|
||||||
count++;
|
count++;
|
||||||
CM.Disp.BotBar.firstChild.firstChild.childNodes[0].childNodes[count].childNodes[1].textContent = Game.Objects[i].amount;
|
CM.Disp.BotBar.firstChild.firstChild.childNodes[0].childNodes[count].childNodes[1].textContent = Game.Objects[i].amount;
|
||||||
CM.Disp.BotBar.firstChild.firstChild.childNodes[1].childNodes[count].textContent = Beautify(CM.Cache[target][i].bonus, 2);
|
CM.Disp.BotBar.firstChild.firstChild.childNodes[1].childNodes[count].textContent = Beautify(CM.Cache[target][i].bonus, 2);
|
||||||
@@ -670,7 +675,12 @@ CM.Disp.UpdateBotTimerBarPosition = function () {
|
|||||||
* And by changes in CM.Options.BuildColor, CM.Options.SortBuild & CM.Data.Config.BulkBuildColor
|
* And by changes in CM.Options.BuildColor, CM.Options.SortBuild & CM.Data.Config.BulkBuildColor
|
||||||
*/
|
*/
|
||||||
CM.Disp.UpdateBuildings = function () {
|
CM.Disp.UpdateBuildings = function () {
|
||||||
const target = `Objects${Game.buyBulk}`;
|
let target = `Objects${Game.buyBulk}`;
|
||||||
|
if (Game.buyMode === 1) {
|
||||||
|
CM.Disp.LastTargetBuildings = target;
|
||||||
|
} else {
|
||||||
|
target = CM.Disp.LastTargetBuildings;
|
||||||
|
}
|
||||||
if (Game.buyMode === 1) {
|
if (Game.buyMode === 1) {
|
||||||
if (CM.Options.BuildColor === 1) {
|
if (CM.Options.BuildColor === 1) {
|
||||||
for (const i of Object.keys(CM.Cache[target])) {
|
for (const i of Object.keys(CM.Cache[target])) {
|
||||||
@@ -1388,7 +1398,12 @@ CM.Disp.UpdateTooltipBuilding = function () {
|
|||||||
const tooltipBox = l('CMTooltipBorder');
|
const tooltipBox = l('CMTooltipBorder');
|
||||||
CM.Disp.TooltipCreateCalculationSection(tooltipBox);
|
CM.Disp.TooltipCreateCalculationSection(tooltipBox);
|
||||||
|
|
||||||
const target = `Objects${Game.buyBulk}`;
|
let target = `Objects${Game.buyBulk}`;
|
||||||
|
if (Game.buyMode === 1) {
|
||||||
|
CM.Disp.LastTargetTooltipBuilding = target;
|
||||||
|
} else {
|
||||||
|
target = CM.Disp.LastTargetTooltipBuilding;
|
||||||
|
}
|
||||||
|
|
||||||
CM.Disp.TooltipPrice = Game.Objects[CM.Disp.tooltipName].bulkPrice;
|
CM.Disp.TooltipPrice = Game.Objects[CM.Disp.tooltipName].bulkPrice;
|
||||||
CM.Disp.TooltipBonusIncome = CM.Cache[target][CM.Disp.tooltipName].bonus;
|
CM.Disp.TooltipBonusIncome = CM.Cache[target][CM.Disp.tooltipName].bonus;
|
||||||
@@ -2954,3 +2969,10 @@ CM.Disp.TooltipWrinkler = -1;
|
|||||||
* Used to store the number of cookies to be displayed in the tab-title
|
* Used to store the number of cookies to be displayed in the tab-title
|
||||||
*/
|
*/
|
||||||
CM.Disp.Title = '';
|
CM.Disp.Title = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* These are variables used to create various displays when the game is loaded on the "sell all" screen
|
||||||
|
*/
|
||||||
|
CM.Disp.LastTargetBotBar = 1;
|
||||||
|
CM.Disp.LastTargetBuildings = 1;
|
||||||
|
CM.Disp.LastTargetTooltipBuilding = 1;
|
||||||
Reference in new issue
Block a user