Fixed crash with no upgrades purchased #528
This commit is contained in:
1 parent
6f67c171f4
commit
1aecb8a8e1
2 files changed
+48
-44
No files matched your search
+1
-1
@@ -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){var chain=1+Math.max(0,Math.ceil(Math.log(Game.cookies)/Math.LN10)-10);var moni=Math.max(digit,Math.min(Math.floor(1/9*Math.pow(10,chain)*digit*mult),maxPayout));var nextMoni=Math.max(digit,Math.min(Math.floor(1/9*Math.pow(10,chain+1)*digit*mult),maxPayout));while(nextMoni<maxPayout){chain++;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))}return[moni,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.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.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.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.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.queuLine 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.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){var chain=1+Math.max(0,Math.ceil(Math.log(Game.cookies)/Math.LN10)-10);var moni=Math.max(digit,Math.min(Math.floor(1/9*Math.pow(10,chain)*digit*mult),maxPayout));var nextMoni=Math.max(digit,Math.min(Math.floor(1/9*Math.pow(10,chain+1)*digit*mult),maxPayout));while(nextMoni<maxPayout){chain++;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))}return[moni,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.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.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.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.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.queuLine truncated
|
||||||
+47
-43
@@ -2750,49 +2750,53 @@ CM.Disp.CreateStatsPrestigeSection = function() {
|
|||||||
* It is called by CM.Disp.AddMenuStats() when CM.Options.MissingUpgrades is set
|
* It is called by CM.Disp.AddMenuStats() when CM.Options.MissingUpgrades is set
|
||||||
*/
|
*/
|
||||||
CM.Disp.AddMissingUpgrades = function() {
|
CM.Disp.AddMissingUpgrades = function() {
|
||||||
if (CM.Cache.MissingUpgradesPrestige) {
|
for (let menuSection of (l('menu').children)) {
|
||||||
var prestigeUpgradesOwned = Game.PrestigeUpgrades.length - l('menu').children[5].children[3].children.length;
|
if (menuSection.children[0]) {
|
||||||
let title = document.createElement('div');
|
if (menuSection.children[0].innerHTML === "Prestige" && CM.Cache.MissingUpgradesPrestige) {
|
||||||
title.id = "CMMissingUpgradesPrestigeTitle";
|
let prestigeUpgradesMissing = CM.Cache.MissingUpgradesPrestige.match(new RegExp("div", "g") || []).length / 2;
|
||||||
title.className = "listing";
|
let title = document.createElement('div');
|
||||||
let titlefrag = document.createElement('div');
|
title.id = "CMMissingUpgradesPrestigeTitle";
|
||||||
titlefrag.innerHTML = '<b>Missing Prestige upgrades:</b> '+ prestigeUpgradesOwned + '/' + Game.PrestigeUpgrades.length + ' (' + Math.floor((prestigeUpgradesOwned / Game.PrestigeUpgrades.length) * 100) + '%)';
|
title.className = "listing";
|
||||||
title.appendChild(titlefrag);
|
let titlefrag = document.createElement('div');
|
||||||
l('menu').children[5].appendChild(title);
|
titlefrag.innerHTML = '<b>Missing Prestige upgrades:</b> '+ prestigeUpgradesMissing + '/' + Game.PrestigeUpgrades.length + ' (' + Math.floor((prestigeUpgradesMissing / Game.PrestigeUpgrades.length) * 100) + '%)';
|
||||||
let upgrades = document.createElement('div');
|
title.appendChild(titlefrag);
|
||||||
upgrades.className = "listing crateBox";
|
menuSection.appendChild(title);
|
||||||
upgrades.innerHTML = CM.Cache.MissingUpgradesPrestige;
|
let upgrades = document.createElement('div');
|
||||||
l('menu').children[5].appendChild(upgrades);
|
upgrades.className = "listing crateBox";
|
||||||
}
|
upgrades.innerHTML = CM.Cache.MissingUpgradesPrestige;
|
||||||
if (CM.Cache.MissingUpgrades) {
|
menuSection.appendChild(upgrades);
|
||||||
let normalUpgradesOwned = 0;
|
}
|
||||||
if (Game.UpgradesOwned) normalUpgradesOwned = Game.UpgradesByPool[""].length + Game.UpgradesByPool.tech.length - l('menu').children[6].childNodes[2].children.length;
|
else if (menuSection.children[0].innerHTML === "Upgrades") {
|
||||||
let title = document.createElement('div');
|
if (CM.Cache.MissingUpgrades) {
|
||||||
title.id = "CMMissingUpgradesTitle";
|
let normalUpgradesMissing = CM.Cache.MissingUpgrades.match(new RegExp("div", "g") || []).length / 2;
|
||||||
title.className = "listing";
|
let title = document.createElement('div');
|
||||||
let titlefrag = document.createElement('div');
|
title.id = "CMMissingUpgradesTitle";
|
||||||
titlefrag.innerHTML = '<b>Missing normal upgrades:</b> '+ normalUpgradesOwned + '/' + (Game.UpgradesByPool[""].length + Game.UpgradesByPool.tech.length) + ' (' + Math.floor((normalUpgradesOwned / ( Game.UpgradesByPool[""].length + Game.UpgradesByPool.tech.length)) * 100) + '%)';
|
title.className = "listing";
|
||||||
title.appendChild(titlefrag);
|
let titlefrag = document.createElement('div');
|
||||||
l('menu').children[6].insertBefore(title, l('menu').children[6].childNodes[3]);
|
titlefrag.innerHTML = '<b>Missing normal upgrades:</b> '+ normalUpgradesMissing + '/' + (Game.UpgradesByPool[""].length + Game.UpgradesByPool.tech.length) + ' (' + Math.floor((normalUpgradesMissing / ( Game.UpgradesByPool[""].length + Game.UpgradesByPool.tech.length)) * 100) + '%)';
|
||||||
let upgrades = document.createElement('div');
|
title.appendChild(titlefrag);
|
||||||
upgrades.className = "listing crateBox";
|
menuSection.insertBefore(title, l('menu').children[6].childNodes[3]);
|
||||||
upgrades.innerHTML = CM.Cache.MissingUpgrades;
|
let upgrades = document.createElement('div');
|
||||||
l('menu').children[6].insertBefore(upgrades, document.getElementById("CMMissingUpgradesTitle").nextSibling);
|
upgrades.className = "listing crateBox";
|
||||||
}
|
upgrades.innerHTML = CM.Cache.MissingUpgrades;
|
||||||
if (CM.Cache.MissingUpgradesCookies) {
|
menuSection.insertBefore(upgrades, document.getElementById("CMMissingUpgradesTitle").nextSibling);
|
||||||
var cookieUpgradesOwned = Game.UpgradesByPool.cookie.length - l('menu').children[6].lastChild.children.length;
|
}
|
||||||
let title = document.createElement('div');
|
if (CM.Cache.MissingUpgradesCookies) {
|
||||||
title.id = "CMMissingUpgradesCookiesTitle";
|
let cookieUpgradesMissing = CM.Cache.MissingUpgradesCookies.match(new RegExp("div", "g") || []).length / 2;
|
||||||
title.className = "listing";
|
let title = document.createElement('div');
|
||||||
let titlefrag = document.createElement('div');
|
title.id = "CMMissingUpgradesCookiesTitle";
|
||||||
titlefrag.innerHTML = '<b>Missing Cookie upgrades:</b> '+ cookieUpgradesOwned + '/' + Game.UpgradesByPool.cookie.length + ' (' + Math.floor((cookieUpgradesOwned / Game.UpgradesByPool.cookie.length) * 100) + '%)';
|
title.className = "listing";
|
||||||
title.appendChild(titlefrag);
|
let titlefrag = document.createElement('div');
|
||||||
l('menu').children[6].appendChild(title);
|
titlefrag.innerHTML = '<b>Missing Cookie upgrades:</b> '+ cookieUpgradesMissing + '/' + Game.UpgradesByPool.cookie.length + ' (' + Math.floor((cookieUpgradesMissing / Game.UpgradesByPool.cookie.length) * 100) + '%)';
|
||||||
let upgrades = document.createElement('div');
|
title.appendChild(titlefrag);
|
||||||
upgrades.className = "listing crateBox";
|
menuSection.appendChild(title);
|
||||||
upgrades.innerHTML = CM.Cache.MissingUpgradesCookies;
|
let upgrades = document.createElement('div');
|
||||||
l('menu').children[6].appendChild(upgrades);
|
upgrades.className = "listing crateBox";
|
||||||
|
upgrades.innerHTML = CM.Cache.MissingUpgradesCookies;
|
||||||
|
menuSection.appendChild(upgrades);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user