Merge pull request #622 from DanielNoord/hotfixes

Hotfixes
This commit is contained in:
Daniël van Noord authored and GitHub committed 2021-02-26 00:13:22 +01:00
commit 5cd266b91f
5 files changed
+59 -20

No files matched your search

+1 -1
View File
@@ -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
View File
@@ -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])) {
+31 -9
View File
@@ -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;
@@ -1443,7 +1458,7 @@ CM.Disp.UpdateTooltipUpgrade = function () {
l('CMTooltipIncome').textContent = Beautify(CM.Disp.TooltipBonusIncome, 2); l('CMTooltipIncome').textContent = Beautify(CM.Disp.TooltipBonusIncome, 2);
const increase = Math.round(CM.Disp.TooltipBonusIncome / Game.cookiesPs * 10000); const increase = Math.round(CM.Disp.TooltipBonusIncome / Game.cookiesPs * 10000);
// Don't display certain parts of tooltip if not applicable // Don't display certain parts of tooltip if not applicable
if (l('CMTooltipIncome').textContent === '0') { if (l('CMTooltipIncome').textContent === '0' && (CM.Disp.tooltipType === 'b' || CM.Disp.tooltipType === 'u')) {
l('Bonus IncomeTitle').style.display = 'none'; l('Bonus IncomeTitle').style.display = 'none';
l('CMTooltipIncome').style.display = 'none'; l('CMTooltipIncome').style.display = 'none';
l('Payback PeriodTitle').style.display = 'none'; l('Payback PeriodTitle').style.display = 'none';
@@ -1540,10 +1555,10 @@ CM.Disp.UpdateTooltipGrimoire = function () {
} }
// Extra information on cookies gained when spell is Conjure Baked Goods (Name === 0) // Extra information on cookies gained when spell is Conjure Baked Goods (Name === 0)
if (CM.Disp.tooltipName === 0) { if (CM.Disp.tooltipName === '0') {
tooltipBox.appendChild(CM.Disp.TooltipCreateHeader('Cookies to be gained/lost')); tooltipBox.appendChild(CM.Disp.TooltipCreateHeader('Cookies to be gained/lost'));
const conjure = document.createElement('div'); const conjure = document.createElement('div');
conjure.id = 'CMTooltipConjure'; conjure.id = 'x';
tooltipBox.appendChild(conjure); tooltipBox.appendChild(conjure);
const reward = document.createElement('span'); const reward = document.createElement('span');
reward.style.color = '#33FF00'; reward.style.color = '#33FF00';
@@ -2182,7 +2197,7 @@ CM.Disp.AddMenuStats = function (title) {
const popFattestA = document.createElement('a'); const popFattestA = document.createElement('a');
popFattestA.textContent = 'Pop Single Fattest'; popFattestA.textContent = 'Pop Single Fattest';
popFattestA.className = 'option'; popFattestA.className = 'option';
popFattestA.onclick = function () { if (CM.Cache.WrinklersFattest[1]) Game.wrinklers[CM.Cache.WrinklersFattest[1]].hp = 0; }; popFattestA.onclick = function () { if (CM.Cache.WrinklersFattest[1] !== null) Game.wrinklers[CM.Cache.WrinklersFattest[1]].hp = 0; };
popFattestFrag.appendChild(popFattestA); popFattestFrag.appendChild(popFattestA);
stats.appendChild(CM.Disp.CreateStatsListing('basic', `Rewards of Popping Single Fattest Non-Shiny Wrinkler (id: ${CM.Cache.WrinklersFattest[1] !== null ? CM.Cache.WrinklersFattest[1] : 'None'})`, popFattestFrag)); stats.appendChild(CM.Disp.CreateStatsListing('basic', `Rewards of Popping Single Fattest Non-Shiny Wrinkler (id: ${CM.Cache.WrinklersFattest[1] !== null ? CM.Cache.WrinklersFattest[1] : 'None'})`, popFattestFrag));
} }
@@ -2857,7 +2872,7 @@ CM.Disp.CreateWrinklerButtons = function () {
popFattestA.id = 'PopFattestWrinklerButton'; popFattestA.id = 'PopFattestWrinklerButton';
popFattestA.textContent = 'Pop Single Fattest'; popFattestA.textContent = 'Pop Single Fattest';
popFattestA.className = 'option'; popFattestA.className = 'option';
popFattestA.onclick = function () { if (CM.Cache.WrinklersFattest[1]) Game.wrinklers[CM.Cache.WrinklersFattest[1]].hp = 0; }; popFattestA.onclick = function () { if (CM.Cache.WrinklersFattest[1] !== null) Game.wrinklers[CM.Cache.WrinklersFattest[1]].hp = 0; };
l('sectionLeftExtra').children[0].append(popFattestA); l('sectionLeftExtra').children[0].append(popFattestA);
}; };
@@ -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;
+1
View File
@@ -43,6 +43,7 @@ CM.save = function () {
*/ */
CM.load = function (str) { CM.load = function (str) {
const save = JSON.parse(str); const save = JSON.parse(str);
CM.Sim.InitData();
CM.Config.LoadConfig(save.settings); CM.Config.LoadConfig(save.settings);
if (save.version !== `${CM.VersionMajor}.${CM.VersionMinor}`) { if (save.version !== `${CM.VersionMajor}.${CM.VersionMinor}`) {
if (Game.prefs.popups) Game.Popup('A new version of Cookie Monster has been loaded, check out the release notes in the info tab!'); if (Game.prefs.popups) Game.Popup('A new version of Cookie Monster has been loaded, check out the release notes in the info tab!');
+24 -8
View File
@@ -129,10 +129,6 @@ CM.Sim.ReplaceFunction = function (funcToBeReplaced) {
.join('CM.Sim.auraMult') .join('CM.Sim.auraMult')
.split('Game.hasGod') .split('Game.hasGod')
.join('CM.Sim.hasGod') .join('CM.Sim.hasGod')
.split('M.gods[what]') // Replaces code in the Pantheon minigame
.join('CM.Sim.Objects.Temple.minigame.gods[what]')
.split('M.slot[i]') // Replaces code in the Pantheon minigame
.join('CM.Sim.Objects.Temple.minigame.slot[i]')
.split('Game.effs') // Replaces code in the Pantheon minigame .split('Game.effs') // Replaces code in the Pantheon minigame
.join('CM.Sim.effs') .join('CM.Sim.effs')
.split('Game.Objects') .split('Game.Objects')
@@ -158,7 +154,6 @@ CM.Sim.CreateSimFunctions = function () {
CM.Sim.Has = new Function(`return ${CM.Sim.ReplaceFunction(Game.Has)}`)(); CM.Sim.Has = new Function(`return ${CM.Sim.ReplaceFunction(Game.Has)}`)();
CM.Sim.HasAchiev = new Function(`return ${CM.Sim.ReplaceFunction(Game.HasAchiev)}`)(); CM.Sim.HasAchiev = new Function(`return ${CM.Sim.ReplaceFunction(Game.HasAchiev)}`)();
CM.Sim.hasAura = new Function(`return ${CM.Sim.ReplaceFunction(Game.hasAura)}`)(); CM.Sim.hasAura = new Function(`return ${CM.Sim.ReplaceFunction(Game.hasAura)}`)();
if (Game.hasGod) CM.Sim.hasGod = new Function(`return ${CM.Sim.ReplaceFunction(Game.hasGod)}`)();
CM.Sim.GetHeavenlyMultiplier = new Function(`return ${CM.Sim.ReplaceFunction(Game.GetHeavenlyMultiplier)}`)(); CM.Sim.GetHeavenlyMultiplier = new Function(`return ${CM.Sim.ReplaceFunction(Game.GetHeavenlyMultiplier)}`)();
CM.Sim.auraMult = new Function(`return ${CM.Sim.ReplaceFunction(Game.auraMult)}`)(); CM.Sim.auraMult = new Function(`return ${CM.Sim.ReplaceFunction(Game.auraMult)}`)();
CM.Sim.eff = new Function(`return ${CM.Sim.ReplaceFunction(Game.eff)}`)(); CM.Sim.eff = new Function(`return ${CM.Sim.ReplaceFunction(Game.eff)}`)();
@@ -180,6 +175,24 @@ CM.Sim.Win = function (what) {
} }
}; };
/**
* This function checks for the current God level in the sim data
* It functions similarly to Game.hasGod()
* It is not created by CM.Sim.CreateSimFunctions() as Game.hasGod() is not always available in each save
* @param {string} what Name of the achievement
*/
CM.Sim.hasGod = function (what) {
if (Game.hasGod) {
const god = CM.Sim.Objects.Temple.minigame.gods[what];
for (let i = 0; i < 3; i++) {
if (CM.Sim.Objects.Temple.minigame.slot[i] === god.id) {
return (i + 1);
}
}
}
return false;
};
/** /**
* Section: Functions used to create static objects of Buildings, Upgrades and Achievements */ * Section: Functions used to create static objects of Buildings, Upgrades and Achievements */
@@ -296,7 +309,10 @@ CM.Sim.CopyData = function () {
you.totalCookies = me.totalCookies; you.totalCookies = me.totalCookies;
you.basePrice = me.basePrice; you.basePrice = me.basePrice;
you.free = me.free; you.free = me.free;
if (me.minigameLoaded) you.minigameLoaded = me.minigameLoaded; you.minigame = me.minigame; if (me.minigameLoaded) {
you.minigameLoaded = me.minigameLoaded;
you.minigame = me.minigame;
}
} }
// Upgrades // Upgrades
@@ -825,8 +841,8 @@ CM.Sim.CalculateChangeAura = function (aura) {
// Sell highest building but only if aura is different // Sell highest building but only if aura is different
let price = 0; let price = 0;
if (CM.Sim.dragonAura !== CM.Cache.dragonAura || CM.Sim.dragonAura2 !== CM.Cache.dragonAura2) { if (CM.Sim.dragonAura !== CM.Cache.dragonAura || CM.Sim.dragonAura2 !== CM.Cache.dragonAura2) {
for (let i = Game.ObjectsById.length; i > -1; --i) { for (let i = Game.ObjectsById.length - 1; i > -1; --i) {
if (Game.ObjectsById[i].amount > 0) { if (Game.ObjectsById[i - 1].amount > 0) {
const highestBuilding = CM.Sim.Objects[Game.ObjectsById[i].name].name; const highestBuilding = CM.Sim.Objects[Game.ObjectsById[i].name].name;
CM.Sim.Objects[highestBuilding].amount -= 1; CM.Sim.Objects[highestBuilding].amount -= 1;
CM.Sim.buildingsOwned -= 1; CM.Sim.buildingsOwned -= 1;