From e4113d21e17d8202e0abfece2e73934226b03b38 Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Sat, 30 Jan 2021 14:50:40 +0100 Subject: [PATCH 1/6] Semicolons and var declarations in Cache.js --- CookieMonster.js | 76 ++++++++++++++++++++++++------------------------ src/Cache.js | 76 ++++++++++++++++++++++++------------------------ 2 files changed, 76 insertions(+), 76 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index b292c52..6a27b19 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -47,7 +47,7 @@ CM.Cache.InitCache = function() { CM.Cache.CacheWrinklers(); CM.Cache.CacheStats(); CM.Cache.CacheMissingUpgrades(); -} +}; /******** * Section: Functions related to Dragon Auras */ @@ -63,7 +63,7 @@ CM.Cache.CacheDragonAuras = function() { /** @global */ CM.Cache.dragonAura = Game.dragonAura; CM.Cache.dragonAura2 = Game.dragonAura2; -} +}; /******** * Section: Functions related to Wrinklers */ @@ -98,7 +98,7 @@ CM.Cache.CacheWrinklers = function() { if (sucked > CM.Cache.WrinklersFattest[0]) CM.Cache.WrinklersFattest = [sucked, i]; } } -} +}; /******** * Section: Functions related to Caching stats */ @@ -149,7 +149,7 @@ CM.Cache.CacheStats = function() { CM.Cache.EdificeBuilding = i; } } -} +}; /** * This functions caches variables related to missing upgrades @@ -171,7 +171,7 @@ CM.Cache.CacheMissingUpgrades = function() { if (a.order>b.order) return 1; else if (a.order this.maxLength) timePeriod = this.maxLength, console.log("Called for average of Queue for time-period longer than MaxLength"); if (timePeriod > this.queue.length) timePeriod = this.queue.length; - var ret = 0 + var ret = 0; for (var i = this.queue.length - 1; i >= 0 && i > this.queue.length - 1 - timePeriod; i--) { ret += this.queue[i]; } @@ -233,7 +233,7 @@ CM.Cache.InitCookiesDiff = function() { CM.Cache.WrinkFattestDiff = new CMAvgQueue(CM.Disp.cookieTimes[CM.Disp.cookieTimes.length - 1]); CM.Cache.ChoEggDiff = new CMAvgQueue(CM.Disp.cookieTimes[CM.Disp.cookieTimes.length - 1]); CM.Cache.ClicksDiff = new CMAvgQueue(CM.Disp.clickTimes[CM.Disp.clickTimes.length - 1]); -} +}; /** * This functions caches two variables related average CPS and Clicks @@ -254,7 +254,7 @@ CM.Cache.UpdateAvgCPS = function() { choEggTotal *= 0.05; if (CM.Cache.lastDate != -1) { - var timeDiff = currDate - CM.Cache.lastDate + var timeDiff = currDate - CM.Cache.lastDate; var bankDiffAvg = Math.max(0, (Game.cookies - CM.Cache.lastCookies)) / timeDiff; var wrinkDiffAvg = Math.max(0, (CM.Cache.WrinklersTotal - CM.Cache.lastWrinkCookies)) / timeDiff; var wrinkFattestDiffAvg = Math.max(0, (CM.Cache.WrinklersFattest[0] - CM.Cache.lastWrinkFattestCookies)) / timeDiff; @@ -282,7 +282,7 @@ CM.Cache.UpdateAvgCPS = function() { CM.Cache.AverageGainWrinkFattest = CM.Cache.WrinkFattestDiff.calcAverage(cpsLength); CM.Cache.AverageGainChoEgg = CM.Cache.ChoEggDiff.calcAverage(cpsLength); - CM.Cache.AvgCPS = CM.Cache.AverageGainBank + CM.Cache.AvgCPS = CM.Cache.AverageGainBank; if (CM.Options.CalcWrink == 1) CM.Cache.AvgCPS += CM.Cache.AverageGainWrink; if (CM.Options.CalcWrink == 2) CM.Cache.AvgCPS += CM.Cache.AverageGainWrinkFattest; @@ -296,7 +296,7 @@ CM.Cache.UpdateAvgCPS = function() { CM.Cache.AverageClicks = CM.Cache.ClicksDiff.calcAverage(CM.Disp.clickTimes[CM.Options.AvgClicksHist]); } -} +}; /** * This functions caches the current Wrinkler CPS multiplier @@ -308,7 +308,7 @@ CM.Cache.UpdateCurrWrinklerCPS = function() { CM.Cache.CurrWrinklerCPSMult = 0; let count = 0; for (let i in Game.wrinklers) { - if (Game.wrinklers[i].phase == 2) count++ + if (Game.wrinklers[i].phase == 2) count++; } let godMult = 1; if (CM.Sim.Objects.Temple.minigameLoaded) { @@ -319,7 +319,7 @@ CM.Cache.UpdateCurrWrinklerCPS = function() { } CM.Cache.CurrWrinklerCount = count; CM.Cache.CurrWrinklerCPSMult = count * (count * 0.05 * 1.1) * (Game.Has('Sacrilegious corruption') * 0.05 + 1) * (Game.Has('Wrinklerspawn') * 0.05 + 1) * godMult; -} +}; /******** * Section: Functions related to "Specials" (Dragon and Santa) */ @@ -341,10 +341,10 @@ CM.Cache.CacheDragonCost = function() { CM.Cache.CostDragonUpgrade = "Not enough buildings to sell"; } else { - var cost = 0; + let cost = 0; CM.Sim.CopyData(); for (var i = 0; i < amount; i++) { - var price = CM.Sim.Objects[target].basePrice * Math.pow(Game.priceIncrease, Math.max(0, CM.Sim.Objects[target].amount - 1 - CM.Sim.Objects[target].free)); + let price = CM.Sim.Objects[target].basePrice * Math.pow(Game.priceIncrease, Math.max(0, CM.Sim.Objects[target].amount - 1 - CM.Sim.Objects[target].free)); price = Game.modifyBuildingPrice(CM.Sim.Objects[target], price); price = Math.ceil(price); cost += price; @@ -354,17 +354,17 @@ CM.Cache.CacheDragonCost = function() { } } else { - var cost = 0; + let cost = 0; CM.Sim.CopyData(); for (var j in Game.Objects) { target = j; if (Game.Objects[target].amount < amount) { CM.Cache.CostDragonUpgrade = "Not enough buildings to sell"; - break + break; } else { for (var i = 0; i < amount; i++) { - var price = CM.Sim.Objects[target].basePrice * Math.pow(Game.priceIncrease, Math.max(0, CM.Sim.Objects[target].amount - 1 - CM.Sim.Objects[target].free)); + let price = CM.Sim.Objects[target].basePrice * Math.pow(Game.priceIncrease, Math.max(0, CM.Sim.Objects[target].amount - 1 - CM.Sim.Objects[target].free)); price = Game.modifyBuildingPrice(CM.Sim.Objects[target], price); price = Math.ceil(price); cost += price; @@ -377,7 +377,7 @@ CM.Cache.CacheDragonCost = function() { } CM.Cache.lastDragonLevel = Game.dragonLevel; } -} +}; /******** * Section: UNSORTED */ @@ -388,7 +388,7 @@ CM.Cache.NextNumber = function(base) { count = CM.Cache.NextNumber(count); } return (base + count); -} +}; CM.Cache.RemakeBuildingsPrices = function() { for (var i in Game.Objects) { @@ -396,7 +396,7 @@ CM.Cache.RemakeBuildingsPrices = function() { CM.Cache.Objects10[i].price = CM.Sim.BuildingGetPrice(Game.Objects[i], Game.Objects[i].basePrice, Game.Objects[i].amount, Game.Objects[i].free, 10); CM.Cache.Objects100[i].price = CM.Sim.BuildingGetPrice(Game.Objects[i], Game.Objects[i].basePrice, Game.Objects[i].amount, Game.Objects[i].free, 100); } -} +}; CM.Cache.RemakeIncome = function() { // Simulate Building Buys for 1 amount @@ -410,7 +410,7 @@ CM.Cache.RemakeIncome = function() { // Simulate Building Buys for 100 amount CM.Sim.BuyBuildings(100, 'Objects100'); -} +}; CM.Cache.RemakeBuildingsPP = function() { CM.Cache.min = -1; @@ -430,7 +430,7 @@ CM.Cache.RemakeBuildingsPP = function() { } CM.Cache.mid = ((CM.Cache.max - CM.Cache.min) / 2) + CM.Cache.min; for (var i in CM.Cache.Objects) { - var color = ''; + let color = ''; if (CM.Cache.Objects[i].pp == CM.Cache.min) color = CM.Disp.colorGreen; else if (CM.Cache.Objects[i].pp == CM.Cache.max) color = CM.Disp.colorRed; else if (CM.Cache.Objects[i].pp > CM.Cache.mid) color = CM.Disp.colorOrange; @@ -458,7 +458,7 @@ CM.Cache.RemakeBuildingsPP = function() { } CM.Cache.mid = ((CM.Cache.max - CM.Cache.min) / 2) + CM.Cache.min; for (var i in CM.Cache.Objects) { - var color = ''; + let color = ''; if (CM.Cache.Objects[i].pp == CM.Cache.min) color = CM.Disp.colorGreen; else if (CM.Cache.Objects[i].pp == CM.Cache.max) color = CM.Disp.colorRed; else if (CM.Cache.Objects[i].pp > CM.Cache.mid) color = CM.Disp.colorOrange; @@ -480,7 +480,7 @@ CM.Cache.RemakeBuildingsPP = function() { } CM.Cache.mid = ((CM.Cache.max - CM.Cache.min) / 2) + CM.Cache.min; for (var i in CM.Cache.Objects) { - var color = ''; + 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; @@ -502,7 +502,7 @@ CM.Cache.RemakeBuildingsPP = function() { } CM.Cache.mid = ((CM.Cache.max - CM.Cache.min) / 2) + CM.Cache.min; for (var i in CM.Cache.Objects) { - var color = ''; + 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; @@ -513,7 +513,7 @@ CM.Cache.RemakeBuildingsPP = function() { CM.Cache.RemakeBuildingsOtherPP(10, 'Objects10'); } } -} +}; CM.Cache.RemakeUpgradePP = function() { for (var i in CM.Cache.Upgrades) { @@ -524,7 +524,7 @@ CM.Cache.RemakeUpgradePP = function() { 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; - var color = ''; + let color = ''; if (CM.Cache.Upgrades[i].pp <= 0 || CM.Cache.Upgrades[i].pp == Infinity) color = CM.Disp.colorGray; else if (CM.Cache.Upgrades[i].pp < CM.Cache.min) color = CM.Disp.colorBlue; else if (CM.Cache.Upgrades[i].pp == CM.Cache.min) color = CM.Disp.colorGreen; @@ -534,7 +534,7 @@ CM.Cache.RemakeUpgradePP = function() { else color = CM.Disp.colorYellow; CM.Cache.Upgrades[i].color = color; } -} +}; CM.Cache.RemakeBuildingsOtherPP = function(amount, target) { for (var i in CM.Cache[target]) { @@ -544,7 +544,7 @@ CM.Cache.RemakeBuildingsOtherPP = function(amount, target) { } else { CM.Cache[target][i].pp = (CM.Cache[target][i].price / CM.Cache[target][i].bonus); } - var color = ''; + 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; @@ -554,7 +554,7 @@ CM.Cache.RemakeBuildingsOtherPP = function(amount, target) { else color = CM.Disp.colorYellow; CM.Cache[target][i].color = color; } -} +}; CM.Cache.RemakePP = function() { // Buildings @@ -562,7 +562,7 @@ CM.Cache.RemakePP = function() { // Upgrades CM.Cache.RemakeUpgradePP(); -} +}; CM.Cache.RemakeGoldenAndWrathCookiesMults = function() { var goldenMult = 1; @@ -590,7 +590,7 @@ CM.Cache.RemakeGoldenAndWrathCookiesMults = function() { 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) { var chain = 1 + Math.max(0, Math.ceil(Math.log(Game.cookies) / Math.LN10) - 10); @@ -602,7 +602,7 @@ CM.Cache.MaxChainMoni = function(digit, maxPayout, mult) { nextMoni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain + 1) * digit * mult), maxPayout)); } return moni; -} +}; CM.Cache.RemakeChain = function() { var maxPayout = CM.Cache.NoGoldSwitchCookiesPS * 60 * 60 * 6; @@ -650,7 +650,7 @@ CM.Cache.RemakeChain = function() { else { CM.Cache.ChainFrenzyWrath = CM.Cache.NextNumber(CM.Cache.ChainFrenzyWrathReward) / 0.5; } -} +}; CM.Cache.RemakeSeaSpec = function() { if (Game.season == 'christmas') { @@ -660,7 +660,7 @@ CM.Cache.RemakeSeaSpec = function() { 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; @@ -677,7 +677,7 @@ CM.Cache.RemakeSellForChoEgg = function() { // 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; diff --git a/src/Cache.js b/src/Cache.js index 7079c7f..bd97936 100644 --- a/src/Cache.js +++ b/src/Cache.js @@ -16,7 +16,7 @@ CM.Cache.InitCache = function() { CM.Cache.CacheWrinklers(); CM.Cache.CacheStats(); CM.Cache.CacheMissingUpgrades(); -} +}; /******** * Section: Functions related to Dragon Auras */ @@ -32,7 +32,7 @@ CM.Cache.CacheDragonAuras = function() { /** @global */ CM.Cache.dragonAura = Game.dragonAura; CM.Cache.dragonAura2 = Game.dragonAura2; -} +}; /******** * Section: Functions related to Wrinklers */ @@ -67,7 +67,7 @@ CM.Cache.CacheWrinklers = function() { if (sucked > CM.Cache.WrinklersFattest[0]) CM.Cache.WrinklersFattest = [sucked, i]; } } -} +}; /******** * Section: Functions related to Caching stats */ @@ -118,7 +118,7 @@ CM.Cache.CacheStats = function() { CM.Cache.EdificeBuilding = i; } } -} +}; /** * This functions caches variables related to missing upgrades @@ -140,7 +140,7 @@ CM.Cache.CacheMissingUpgrades = function() { if (a.order>b.order) return 1; else if (a.order this.maxLength) timePeriod = this.maxLength, console.log("Called for average of Queue for time-period longer than MaxLength"); if (timePeriod > this.queue.length) timePeriod = this.queue.length; - var ret = 0 + var ret = 0; for (var i = this.queue.length - 1; i >= 0 && i > this.queue.length - 1 - timePeriod; i--) { ret += this.queue[i]; } @@ -202,7 +202,7 @@ CM.Cache.InitCookiesDiff = function() { CM.Cache.WrinkFattestDiff = new CMAvgQueue(CM.Disp.cookieTimes[CM.Disp.cookieTimes.length - 1]); CM.Cache.ChoEggDiff = new CMAvgQueue(CM.Disp.cookieTimes[CM.Disp.cookieTimes.length - 1]); CM.Cache.ClicksDiff = new CMAvgQueue(CM.Disp.clickTimes[CM.Disp.clickTimes.length - 1]); -} +}; /** * This functions caches two variables related average CPS and Clicks @@ -223,7 +223,7 @@ CM.Cache.UpdateAvgCPS = function() { choEggTotal *= 0.05; if (CM.Cache.lastDate != -1) { - var timeDiff = currDate - CM.Cache.lastDate + var timeDiff = currDate - CM.Cache.lastDate; var bankDiffAvg = Math.max(0, (Game.cookies - CM.Cache.lastCookies)) / timeDiff; var wrinkDiffAvg = Math.max(0, (CM.Cache.WrinklersTotal - CM.Cache.lastWrinkCookies)) / timeDiff; var wrinkFattestDiffAvg = Math.max(0, (CM.Cache.WrinklersFattest[0] - CM.Cache.lastWrinkFattestCookies)) / timeDiff; @@ -251,7 +251,7 @@ CM.Cache.UpdateAvgCPS = function() { CM.Cache.AverageGainWrinkFattest = CM.Cache.WrinkFattestDiff.calcAverage(cpsLength); CM.Cache.AverageGainChoEgg = CM.Cache.ChoEggDiff.calcAverage(cpsLength); - CM.Cache.AvgCPS = CM.Cache.AverageGainBank + CM.Cache.AvgCPS = CM.Cache.AverageGainBank; if (CM.Options.CalcWrink == 1) CM.Cache.AvgCPS += CM.Cache.AverageGainWrink; if (CM.Options.CalcWrink == 2) CM.Cache.AvgCPS += CM.Cache.AverageGainWrinkFattest; @@ -265,7 +265,7 @@ CM.Cache.UpdateAvgCPS = function() { CM.Cache.AverageClicks = CM.Cache.ClicksDiff.calcAverage(CM.Disp.clickTimes[CM.Options.AvgClicksHist]); } -} +}; /** * This functions caches the current Wrinkler CPS multiplier @@ -277,7 +277,7 @@ CM.Cache.UpdateCurrWrinklerCPS = function() { CM.Cache.CurrWrinklerCPSMult = 0; let count = 0; for (let i in Game.wrinklers) { - if (Game.wrinklers[i].phase == 2) count++ + if (Game.wrinklers[i].phase == 2) count++; } let godMult = 1; if (CM.Sim.Objects.Temple.minigameLoaded) { @@ -288,7 +288,7 @@ CM.Cache.UpdateCurrWrinklerCPS = function() { } CM.Cache.CurrWrinklerCount = count; CM.Cache.CurrWrinklerCPSMult = count * (count * 0.05 * 1.1) * (Game.Has('Sacrilegious corruption') * 0.05 + 1) * (Game.Has('Wrinklerspawn') * 0.05 + 1) * godMult; -} +}; /******** * Section: Functions related to "Specials" (Dragon and Santa) */ @@ -310,10 +310,10 @@ CM.Cache.CacheDragonCost = function() { CM.Cache.CostDragonUpgrade = "Not enough buildings to sell"; } else { - var cost = 0; + let cost = 0; CM.Sim.CopyData(); for (var i = 0; i < amount; i++) { - var price = CM.Sim.Objects[target].basePrice * Math.pow(Game.priceIncrease, Math.max(0, CM.Sim.Objects[target].amount - 1 - CM.Sim.Objects[target].free)); + let price = CM.Sim.Objects[target].basePrice * Math.pow(Game.priceIncrease, Math.max(0, CM.Sim.Objects[target].amount - 1 - CM.Sim.Objects[target].free)); price = Game.modifyBuildingPrice(CM.Sim.Objects[target], price); price = Math.ceil(price); cost += price; @@ -323,17 +323,17 @@ CM.Cache.CacheDragonCost = function() { } } else { - var cost = 0; + let cost = 0; CM.Sim.CopyData(); for (var j in Game.Objects) { target = j; if (Game.Objects[target].amount < amount) { CM.Cache.CostDragonUpgrade = "Not enough buildings to sell"; - break + break; } else { for (var i = 0; i < amount; i++) { - var price = CM.Sim.Objects[target].basePrice * Math.pow(Game.priceIncrease, Math.max(0, CM.Sim.Objects[target].amount - 1 - CM.Sim.Objects[target].free)); + let price = CM.Sim.Objects[target].basePrice * Math.pow(Game.priceIncrease, Math.max(0, CM.Sim.Objects[target].amount - 1 - CM.Sim.Objects[target].free)); price = Game.modifyBuildingPrice(CM.Sim.Objects[target], price); price = Math.ceil(price); cost += price; @@ -346,7 +346,7 @@ CM.Cache.CacheDragonCost = function() { } CM.Cache.lastDragonLevel = Game.dragonLevel; } -} +}; /******** * Section: UNSORTED */ @@ -357,7 +357,7 @@ CM.Cache.NextNumber = function(base) { count = CM.Cache.NextNumber(count); } return (base + count); -} +}; CM.Cache.RemakeBuildingsPrices = function() { for (var i in Game.Objects) { @@ -365,7 +365,7 @@ CM.Cache.RemakeBuildingsPrices = function() { CM.Cache.Objects10[i].price = CM.Sim.BuildingGetPrice(Game.Objects[i], Game.Objects[i].basePrice, Game.Objects[i].amount, Game.Objects[i].free, 10); CM.Cache.Objects100[i].price = CM.Sim.BuildingGetPrice(Game.Objects[i], Game.Objects[i].basePrice, Game.Objects[i].amount, Game.Objects[i].free, 100); } -} +}; CM.Cache.RemakeIncome = function() { // Simulate Building Buys for 1 amount @@ -379,7 +379,7 @@ CM.Cache.RemakeIncome = function() { // Simulate Building Buys for 100 amount CM.Sim.BuyBuildings(100, 'Objects100'); -} +}; CM.Cache.RemakeBuildingsPP = function() { CM.Cache.min = -1; @@ -399,7 +399,7 @@ CM.Cache.RemakeBuildingsPP = function() { } CM.Cache.mid = ((CM.Cache.max - CM.Cache.min) / 2) + CM.Cache.min; for (var i in CM.Cache.Objects) { - var color = ''; + let color = ''; if (CM.Cache.Objects[i].pp == CM.Cache.min) color = CM.Disp.colorGreen; else if (CM.Cache.Objects[i].pp == CM.Cache.max) color = CM.Disp.colorRed; else if (CM.Cache.Objects[i].pp > CM.Cache.mid) color = CM.Disp.colorOrange; @@ -427,7 +427,7 @@ CM.Cache.RemakeBuildingsPP = function() { } CM.Cache.mid = ((CM.Cache.max - CM.Cache.min) / 2) + CM.Cache.min; for (var i in CM.Cache.Objects) { - var color = ''; + let color = ''; if (CM.Cache.Objects[i].pp == CM.Cache.min) color = CM.Disp.colorGreen; else if (CM.Cache.Objects[i].pp == CM.Cache.max) color = CM.Disp.colorRed; else if (CM.Cache.Objects[i].pp > CM.Cache.mid) color = CM.Disp.colorOrange; @@ -449,7 +449,7 @@ CM.Cache.RemakeBuildingsPP = function() { } CM.Cache.mid = ((CM.Cache.max - CM.Cache.min) / 2) + CM.Cache.min; for (var i in CM.Cache.Objects) { - var color = ''; + 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; @@ -471,7 +471,7 @@ CM.Cache.RemakeBuildingsPP = function() { } CM.Cache.mid = ((CM.Cache.max - CM.Cache.min) / 2) + CM.Cache.min; for (var i in CM.Cache.Objects) { - var color = ''; + 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; @@ -482,7 +482,7 @@ CM.Cache.RemakeBuildingsPP = function() { CM.Cache.RemakeBuildingsOtherPP(10, 'Objects10'); } } -} +}; CM.Cache.RemakeUpgradePP = function() { for (var i in CM.Cache.Upgrades) { @@ -493,7 +493,7 @@ CM.Cache.RemakeUpgradePP = function() { 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; - var color = ''; + let color = ''; if (CM.Cache.Upgrades[i].pp <= 0 || CM.Cache.Upgrades[i].pp == Infinity) color = CM.Disp.colorGray; else if (CM.Cache.Upgrades[i].pp < CM.Cache.min) color = CM.Disp.colorBlue; else if (CM.Cache.Upgrades[i].pp == CM.Cache.min) color = CM.Disp.colorGreen; @@ -503,7 +503,7 @@ CM.Cache.RemakeUpgradePP = function() { else color = CM.Disp.colorYellow; CM.Cache.Upgrades[i].color = color; } -} +}; CM.Cache.RemakeBuildingsOtherPP = function(amount, target) { for (var i in CM.Cache[target]) { @@ -513,7 +513,7 @@ CM.Cache.RemakeBuildingsOtherPP = function(amount, target) { } else { CM.Cache[target][i].pp = (CM.Cache[target][i].price / CM.Cache[target][i].bonus); } - var color = ''; + 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; @@ -523,7 +523,7 @@ CM.Cache.RemakeBuildingsOtherPP = function(amount, target) { else color = CM.Disp.colorYellow; CM.Cache[target][i].color = color; } -} +}; CM.Cache.RemakePP = function() { // Buildings @@ -531,7 +531,7 @@ CM.Cache.RemakePP = function() { // Upgrades CM.Cache.RemakeUpgradePP(); -} +}; CM.Cache.RemakeGoldenAndWrathCookiesMults = function() { var goldenMult = 1; @@ -559,7 +559,7 @@ CM.Cache.RemakeGoldenAndWrathCookiesMults = function() { 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) { var chain = 1 + Math.max(0, Math.ceil(Math.log(Game.cookies) / Math.LN10) - 10); @@ -571,7 +571,7 @@ CM.Cache.MaxChainMoni = function(digit, maxPayout, mult) { nextMoni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain + 1) * digit * mult), maxPayout)); } return moni; -} +}; CM.Cache.RemakeChain = function() { var maxPayout = CM.Cache.NoGoldSwitchCookiesPS * 60 * 60 * 6; @@ -619,7 +619,7 @@ CM.Cache.RemakeChain = function() { else { CM.Cache.ChainFrenzyWrath = CM.Cache.NextNumber(CM.Cache.ChainFrenzyWrathReward) / 0.5; } -} +}; CM.Cache.RemakeSeaSpec = function() { if (Game.season == 'christmas') { @@ -629,7 +629,7 @@ CM.Cache.RemakeSeaSpec = function() { 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; @@ -646,7 +646,7 @@ CM.Cache.RemakeSellForChoEgg = function() { // 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; From f7de9831e5c8d332808d3f68add2a666f7b9e003 Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Sat, 30 Jan 2021 15:25:19 +0100 Subject: [PATCH 2/6] Semicolons and easy fixes for all documents --- CookieMonster.js | 535 ++++++++++++++++++++++++----------------------- src/Config.js | 20 +- src/Data.js | 10 +- src/Disp.js | 313 +++++++++++++-------------- src/Footer.js | 10 +- src/Header.js | 2 +- src/Main.js | 107 +++++----- src/Sim.js | 73 +++---- 8 files changed, 538 insertions(+), 532 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 6a27b19..99eae09 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -23,7 +23,7 @@ RunCookieMonsterHeader = function() { CM.Options = {}; CM.Sim = {}; -} +}; if (typeof CM == "undefined") { RunCookieMonsterHeader(); @@ -722,9 +722,9 @@ CM.Config.SaveConfig = function() { CookieMonsterSave = saveString.match(/CookieMonster.*(;|$)/); if (CookieMonsterSave != null) { newSaveString = saveString.replace(CookieMonsterSave[0], "CookieMonster:" + CM.save()); - localStorage.setItem('CookieClickerGame', escape(utf8_to_b64(newSaveString)+'!END!')) + localStorage.setItem('CookieClickerGame', escape(utf8_to_b64(newSaveString)+'!END!')); } -} +}; /** * This function loads the config of CookieMonster saved in localStorage and loads it into CM.Options @@ -787,7 +787,7 @@ CM.Config.LoadConfig = function(settings) { else { // Default values CM.Config.RestoreDefault(); } -} +}; /** * This function reloads and resaves the default config as stored in CM.Data.ConfigDefault @@ -797,7 +797,7 @@ CM.Config.RestoreDefault = function() { CM.Config.LoadConfig(CM.Data.ConfigDefault); CM.Config.SaveConfig(); Game.UpdateMenu(); -} +}; /******** * Section: Functions related to toggling or changing configs */ @@ -822,7 +822,7 @@ CM.Config.ToggleConfig = function(config) { l(CM.ConfigPrefix + config).innerHTML = CM.ConfigData[config].label[CM.Options[config]]; CM.Config.SaveConfig(); -} +}; /** * This function sets the value of the specified volume-option and updates the display in the options menu @@ -835,7 +835,7 @@ CM.Config.ToggleConfigVolume = function(config) { CM.Options[config] = Math.round(l("slider" + config).value); } CM.Config.SaveConfig(); -} +}; /** * This function toggles header options by incrementing them with 1 and handling changes @@ -846,7 +846,7 @@ CM.Config.ToggleHeader = function(config) { CM.Options.Header[config]++; if (CM.Options.Header[config] > 1) CM.Options.Header[config] = 0; CM.Config.SaveConfig(); -} +}; /******** * Section: Functions related to notifications */ @@ -860,14 +860,14 @@ CM.Config.ToggleHeader = function(config) { CM.Config.CheckNotificationPermissions = function(ToggleOnOff) { if (ToggleOnOff == 1) { // Check if browser support Promise version of Notification Permissions - function checkNotificationPromise() { + checkNotificationPromise = function () { try { Notification.requestPermission().then(); } catch(e) { return false; } return true; - } + }; // Check if the browser supports notifications and which type if (!('Notification' in window)) { @@ -882,7 +882,7 @@ CM.Config.CheckNotificationPermissions = function(ToggleOnOff) { } } } -}/******** +};/******** * Data * ********/ @@ -917,7 +917,7 @@ CM.Data.Fortunes = [ CM.Data.HalloCookies = ['Skull cookies', 'Ghost cookies', 'Bat cookies', 'Slime cookies', 'Pumpkin cookies', 'Eyeball cookies', 'Spider cookies']; CM.Data.ChristCookies = ['Christmas tree biscuits', 'Snowflake biscuits', 'Snowman biscuits', 'Holly biscuits', 'Candy cane biscuits', 'Bell biscuits', 'Present biscuits']; CM.Data.ValCookies = ['Pure heart biscuits', 'Ardent heart biscuits', 'Sour heart biscuits', 'Weeping heart biscuits', 'Golden heart biscuits', 'Eternal heart biscuits', 'Prism heart biscuits']; -CM.Data.PlantDrops = ['Elderwort biscuits', 'Bakeberry cookies', 'Duketater cookies', 'Green yeast digestives', 'Wheat slims', 'Fern tea', 'Ichor syrup'] +CM.Data.PlantDrops = ['Elderwort biscuits', 'Bakeberry cookies', 'Duketater cookies', 'Green yeast digestives', 'Wheat slims', 'Fern tea', 'Ichor syrup']; /******** * Section: All possible effects plants and other items can have with an explanation */ @@ -944,7 +944,7 @@ CM.Data.Effects = { wrathCookieGain: "Wrath cookie gains", wrinklerEat: "Wrinkler ", wrinklerSpawn: "Wrinkler spawn frequency" -} +}; /******** * Section: Data for the various scales used by CookieMonster */ @@ -961,7 +961,7 @@ CM.Data.shortScaleAbbreviated = ['', 'K', 'M', 'B', 'T', 'Qa', 'Qi', 'Sx', 'Sp', 'USp', 'DSp', 'TSp', 'QaSp', 'QiSp', 'SxSp', 'SpSp', 'OSp', 'NSp', 'Oco', 'UOc', 'DOc', 'TOc', 'QaOc', 'QiOc', 'SxOc', 'SpOc', 'OOc', 'NOc', 'Noa', 'UNo', 'DNo', 'TNo', 'QaNo', 'QiNo', 'SxNo', 'SpNo', 'ONo', 'NNo', 'Ct', -'UCt'] +'UCt']; /******** * Section: Two array's containing all Config groups and their to-be displayed title */ @@ -974,7 +974,7 @@ CM.ConfigGroups = { Statistics: "Statistics", Notation: "Notation", Miscellaneous: "Miscellaneous" -} +}; CM.ConfigGroupsNotification = { NotificationGC: "Golden Cookie", @@ -984,7 +984,7 @@ CM.ConfigGroupsNotification = { NotificationMagi: "Full Magic Bar", NotificationWrink: "Wrinkler", NotificationWrinkMax: "Maximum Wrinklers", -} +}; /******** * Section: An array (CM.ConfigData) containing all Config options and an array of default settings */ @@ -1236,7 +1236,7 @@ CM.Disp.GetWrinkConfigBank = function() { return CM.Cache.WrinklersFattest[0];} else { return 0;} -} +}; /** * This function pops all normal wrinklers @@ -1248,7 +1248,7 @@ CM.Disp.PopAllNormalWrinklers = function() { Game.wrinklers[i].hp = 0; } } -} +}; /** * This function returns the cps as either current or average CPS depending on CM.Options.CPSMode @@ -1274,7 +1274,7 @@ CM.Disp.GetCPS = function() { } } } -} +}; /** * This function calculates the time it takes to reach a certain magic level @@ -1291,7 +1291,7 @@ CM.Disp.CalculateGrimoireRefillTime = function(currentMagic, maxMagic, targetMag count++; } return count / Game.fps; -} +}; /** * This function returns Name and Color as object for sugar lump type that is given as input param. @@ -1368,7 +1368,7 @@ CM.Disp.FormatTime = function(time, longFormat) { str += s + (longFormat ? (s == 1 ? ' second' : ' seconds') : 's'); } return str; -} +}; /** * This function returns the color to be used for time-strings @@ -1390,7 +1390,7 @@ CM.Disp.GetTimeColor = function(time) { else color = CM.Disp.colorYellow; } return {text: text, color: color}; -} +}; /** * This function returns formats number based on the Scale setting @@ -1407,13 +1407,13 @@ CM.Disp.Beautify = function(num, floats, forced) { else if (isFinite(num)) { var answer = ''; if (num == 0) { - return num.toString() + return num.toString(); } else if (0.001 < num && num < CM.Options.ScaleCutoff) { answer = num.toFixed(2); if (CM.Options.ScaleSeparator) answer = answer.toLocaleString('nl'); for (let i = 0; i < 3; i++) { - if (answer[answer.length - 1] == "0" | answer[answer.length - 1] == ".") answer = answer.slice(0, -1) + if (answer[answer.length - 1] == "0" || answer[answer.length - 1] == ".") answer = answer.slice(0, -1); } return answer; } @@ -1423,11 +1423,11 @@ CM.Disp.Beautify = function(num, floats, forced) { else { exponential = num.toExponential().toString(); AmountOfTenPowerThree = Math.floor(exponential.slice(exponential.indexOf("e") + 1) / 3); - answer = (num / Number("1e" + (AmountOfTenPowerThree * 3))).toFixed(decimals) + answer = (num / Number("1e" + (AmountOfTenPowerThree * 3))).toFixed(decimals); // answer is now "xxx.xx" (e.g., 123456789 would be 123.46) if (CM.Options.Scale == 1 && !forced || forced == 1) { // Metric scale, 123456789 => 123.457 M if (num >= 0.01 && num < Number("1e" + CM.Data.metric.length * 3)) { - answer += ' ' + CM.Data.metric[AmountOfTenPowerThree] + answer += ' ' + CM.Data.metric[AmountOfTenPowerThree]; } // If number is too large or little, revert to scientific notation else answer = CM.Disp.Beautify(num, 0, 4); @@ -1464,7 +1464,7 @@ CM.Disp.Beautify = function(num, floats, forced) { console.log("Could not beautify number with CM.Disp.Beautify:" + num); return CM.Backup.Beautify(num, floats); } -} +}; /******** * Section: General functions related to display, drawing and initialization of the page */ @@ -1484,7 +1484,7 @@ CM.Disp.UpdateAscendState = function() { CM.Disp.ToggleTimerBar(); } CM.Disp.UpdateBackground(); -} +}; /** * This function creates a CSS style that stores certain standard CSS classes used by CookieMonster @@ -1495,7 +1495,7 @@ CM.Disp.CreateCssArea = function() { CM.Disp.Css.type = 'text/css'; document.head.appendChild(CM.Disp.Css); -} +}; /** * This function sets the size of the background of the full game and the left column @@ -1507,7 +1507,7 @@ CM.Disp.UpdateBackground = function() { Game.Background.canvas.height = Game.Background.canvas.parentNode.offsetHeight; Game.LeftBackground.canvas.width = Game.LeftBackground.canvas.parentNode.offsetWidth; Game.LeftBackground.canvas.height = Game.LeftBackground.canvas.parentNode.offsetHeight; -} +}; /** * This function handles custom drawing for the Game.Draw() function. @@ -1524,7 +1524,7 @@ CM.Disp.Draw = function () { timer.innerText = Game.sayTime(Game.fps * 60 - (Game.T % (Game.fps * 60)), 4); } } -} +}; /******** * Section: Functions related to the Bottom Bar */ @@ -1542,7 +1542,7 @@ CM.Disp.ToggleBotBar = function() { CM.Disp.BotBar.style.display = 'none'; } CM.Disp.UpdateBotTimerBarPosition(); -} +}; /** * This function creates the bottom bar and appends it to l('wrapper') @@ -1593,7 +1593,7 @@ CM.Disp.CreateBotBar = function() { } l('wrapper').appendChild(CM.Disp.BotBar); -} +}; /** * This function updates the bonus-, pp-, and time-rows in the the bottom bar @@ -1619,7 +1619,7 @@ CM.Disp.UpdateBotBar = function() { else CM.Disp.BotBar.firstChild.firstChild.childNodes[3].childNodes[count].textContent = timeColor.text; } } -} +}; /** * This function extends the bottom bar (created by CM.Disp.CreateBotBar) with a column for the given building. @@ -1649,7 +1649,7 @@ CM.Disp.CreateBotBarBuildingColumn = function(buildingName) { bonus.appendChild(document.createElement('td')); pp.appendChild(document.createElement('td')); time.appendChild(document.createElement('td')); -} +}; /******** * Section: Functions related to the Timer Bar @@ -1672,21 +1672,21 @@ CM.Disp.CreateTimerBar = function() { CM.Disp.BuffTimerBars = {}; // Create standard Golden Cookie bar - CM.Disp.TimerBars['CMTimerBarGC'] = CM.Disp.TimerBarCreateBar('CMTimerBarGC', + CM.Disp.TimerBars.CMTimerBarGC = CM.Disp.TimerBarCreateBar('CMTimerBarGC', 'Next Cookie', [{id: 'CMTimerBarGCMinBar', color: CM.Disp.colorGray}, {id: 'CMTimerBarGCBar', color: CM.Disp.colorPurple}] ); - CM.Disp.TimerBar.appendChild(CM.Disp.TimerBars['CMTimerBarGC']) + CM.Disp.TimerBar.appendChild(CM.Disp.TimerBars.CMTimerBarGC) // Create standard Reindeer bar - CM.Disp.TimerBars['CMTimerBarRen'] = CM.Disp.TimerBarCreateBar('CMTimerBarRen', + CM.Disp.TimerBars. CMTimerBarRen = CM.Disp.TimerBarCreateBar('CMTimerBarRen', 'Next Reindeer', [{id: 'CMTimerBarRenMinBar', color: CM.Disp.colorGray}, {id: 'CMTimerBarRenBar', color: CM.Disp.colorOrange}] ); - CM.Disp.TimerBar.appendChild(CM.Disp.TimerBars['CMTimerBarRen']) + CM.Disp.TimerBar.appendChild(CM.Disp.TimerBars. CMTimerBarRen) l('wrapper').appendChild(CM.Disp.TimerBar); -} +}; /** * This function creates an indivudual timer for the timer bar @@ -1748,7 +1748,7 @@ CM.Disp.TimerBarCreateBar = function(id, name, bars) { timerBar.appendChild(div); return timerBar; -} +}; /** * This function updates indivudual timers in the timer bar @@ -1763,12 +1763,12 @@ CM.Disp.UpdateTimerBar = function() { var numberOfTimers = 0; // Regulates visibility of Golden Cookie timer - if (Game.shimmerTypes['golden'].spawned == 0 && !Game.Has('Golden switch [off]')) { - CM.Disp.TimerBars['CMTimerBarGC'].style.display = ''; - l('CMTimerBarGCMinBar').style.width = Math.round(Math.max(0, Game.shimmerTypes['golden'].minTime - Game.shimmerTypes['golden'].time) * maxWidthTwoBar / Game.shimmerTypes['golden'].maxTime) + 'px'; - if (CM.Options.TimerBarOverlay >= 1) l('CMTimerBarGCMinBar').textContent = Math.ceil((Game.shimmerTypes['golden'].minTime - Game.shimmerTypes['golden'].time)/ Game.fps) + if (Game.shimmerTypes.golden.spawned == 0 && !Game.Has('Golden switch [off]')) { + CM.Disp.TimerBars.CMTimerBarGC.style.display = ''; + l('CMTimerBarGCMinBar').style.width = Math.round(Math.max(0, Game.shimmerTypes.golden.minTime - Game.shimmerTypes.golden.time) * maxWidthTwoBar / Game.shimmerTypes.golden.maxTime) + 'px'; + if (CM.Options.TimerBarOverlay >= 1) l('CMTimerBarGCMinBar').textContent = Math.ceil((Game.shimmerTypes.golden.minTime - Game.shimmerTypes.golden.time)/ Game.fps); else l('CMTimerBarGCMinBar').textContent = ""; - if (Game.shimmerTypes['golden'].minTime == Game.shimmerTypes['golden'].maxTime) { + if (Game.shimmerTypes.golden.minTime == Game.shimmerTypes.golden.maxTime) { l('CMTimerBarGCMinBar').style.borderTopRightRadius = '10px'; l('CMTimerBarGCMinBar').style.borderBottomRightRadius = '10px'; } @@ -1776,38 +1776,38 @@ CM.Disp.UpdateTimerBar = function() { l('CMTimerBarGCMinBar').style.borderTopRightRadius = ''; l('CMTimerBarGCMinBar').style.borderBottomRightRadius = ''; } - l('CMTimerBarGCBar').style.width = Math.round(Math.min(Game.shimmerTypes['golden'].maxTime - Game.shimmerTypes['golden'].minTime, Game.shimmerTypes['golden'].maxTime - Game.shimmerTypes['golden'].time) * maxWidthTwoBar / Game.shimmerTypes['golden'].maxTime) + 'px'; - if (CM.Options.TimerBarOverlay >= 1) l('CMTimerBarGCBar').textContent = Math.ceil(Math.min(Game.shimmerTypes['golden'].maxTime - Game.shimmerTypes['golden'].minTime, Game.shimmerTypes['golden'].maxTime - Game.shimmerTypes['golden'].time) / Game.fps); + l('CMTimerBarGCBar').style.width = Math.round(Math.min(Game.shimmerTypes.golden.maxTime - Game.shimmerTypes.golden.minTime, Game.shimmerTypes.golden.maxTime - Game.shimmerTypes.golden.time) * maxWidthTwoBar / Game.shimmerTypes.golden.maxTime) + 'px'; + if (CM.Options.TimerBarOverlay >= 1) l('CMTimerBarGCBar').textContent = Math.ceil(Math.min(Game.shimmerTypes.golden.maxTime - Game.shimmerTypes.golden.minTime, Game.shimmerTypes.golden.maxTime - Game.shimmerTypes.golden.time) / Game.fps); else l('CMTimerBarGCBar').textContent = ""; - l('CMTimerBarGCTime').textContent = Math.ceil((Game.shimmerTypes['golden'].maxTime - Game.shimmerTypes['golden'].time) / Game.fps); + l('CMTimerBarGCTime').textContent = Math.ceil((Game.shimmerTypes.golden.maxTime - Game.shimmerTypes.golden.time) / Game.fps); numberOfTimers++; } - else CM.Disp.TimerBars['CMTimerBarGC'].style.display = 'none'; + else CM.Disp.TimerBars.CMTimerBarGC.style.display = 'none'; // Regulates visibility of Reindeer timer - if (Game.season == 'christmas' && Game.shimmerTypes['reindeer'].spawned == 0) { - CM.Disp.TimerBars['CMTimerBarRen'].style.display = ''; - l('CMTimerBarRenMinBar').style.width = Math.round(Math.max(0, Game.shimmerTypes['reindeer'].minTime - Game.shimmerTypes['reindeer'].time) * maxWidthTwoBar / Game.shimmerTypes['reindeer'].maxTime) + 'px'; - if (CM.Options.TimerBarOverlay >= 1) l('CMTimerBarRenMinBar').textContent = Math.ceil((Game.shimmerTypes['reindeer'].minTime - Game.shimmerTypes['reindeer'].time)/ Game.fps) + if (Game.season == 'christmas' && Game.shimmerTypes.reindeer.spawned == 0) { + CM.Disp.TimerBars. CMTimerBarRen.style.display = ''; + l('CMTimerBarRenMinBar').style.width = Math.round(Math.max(0, Game.shimmerTypes.reindeer.minTime - Game.shimmerTypes.reindeer.time) * maxWidthTwoBar / Game.shimmerTypes.reindeer.maxTime) + 'px'; + if (CM.Options.TimerBarOverlay >= 1) l('CMTimerBarRenMinBar').textContent = Math.ceil((Game.shimmerTypes.reindeer.minTime - Game.shimmerTypes.reindeer.time)/ Game.fps); else l('CMTimerBarRenMinBar').textContent = ""; - l('CMTimerBarRenBar').style.width = Math.round(Math.min(Game.shimmerTypes['reindeer'].maxTime - Game.shimmerTypes['reindeer'].minTime, Game.shimmerTypes['reindeer'].maxTime - Game.shimmerTypes['reindeer'].time) * maxWidthTwoBar / Game.shimmerTypes['reindeer'].maxTime) + 'px'; - if (CM.Options.TimerBarOverlay >= 1) l('CMTimerBarRenBar').textContent = Math.ceil(Math.min(Game.shimmerTypes['reindeer'].maxTime - Game.shimmerTypes['reindeer'].minTime, Game.shimmerTypes['reindeer'].maxTime - Game.shimmerTypes['reindeer'].time) / Game.fps); + l('CMTimerBarRenBar').style.width = Math.round(Math.min(Game.shimmerTypes.reindeer.maxTime - Game.shimmerTypes.reindeer.minTime, Game.shimmerTypes.reindeer.maxTime - Game.shimmerTypes.reindeer.time) * maxWidthTwoBar / Game.shimmerTypes.reindeer.maxTime) + 'px'; + if (CM.Options.TimerBarOverlay >= 1) l('CMTimerBarRenBar').textContent = Math.ceil(Math.min(Game.shimmerTypes.reindeer.maxTime - Game.shimmerTypes.reindeer.minTime, Game.shimmerTypes.reindeer.maxTime - Game.shimmerTypes.reindeer.time) / Game.fps); else l('CMTimerBarRenBar').textContent = ""; - l('CMTimerBarRenTime').textContent = Math.ceil((Game.shimmerTypes['reindeer'].maxTime - Game.shimmerTypes['reindeer'].time) / Game.fps); + l('CMTimerBarRenTime').textContent = Math.ceil((Game.shimmerTypes.reindeer.maxTime - Game.shimmerTypes.reindeer.time) / Game.fps); numberOfTimers++; } else { - CM.Disp.TimerBars['CMTimerBarRen'].style.display = 'none'; + CM.Disp.TimerBars. CMTimerBarRen.style.display = 'none'; } // On every frame all buff-timers are deleted and re-created for (var i in CM.Disp.BuffTimerBars) { - CM.Disp.BuffTimerBars[i].remove() + CM.Disp.BuffTimerBars[i].remove(); } CM.Disp.BuffTimerBars = {} for (var i in Game.buffs) { if (Game.buffs[i]) { - timer = CM.Disp.TimerBarCreateBar(Game.buffs[i].name, Game.buffs[i].name, [{id: Game.buffs[i].name + 'Bar'}]) + timer = CM.Disp.TimerBarCreateBar(Game.buffs[i].name, Game.buffs[i].name, [{id: Game.buffs[i].name + 'Bar'}]); timer.style.display = ''; var classColor = ''; // Gives specific timers specific colors @@ -1826,7 +1826,7 @@ CM.Disp.UpdateTimerBar = function() { } } for (var i in CM.Disp.BuffTimerBars) { - CM.Disp.TimerBar.appendChild(CM.Disp.BuffTimerBars[i]) + CM.Disp.TimerBar.appendChild(CM.Disp.BuffTimerBars[i]); } if (numberOfTimers != 0) { @@ -1837,7 +1837,7 @@ CM.Disp.UpdateTimerBar = function() { CM.Disp.UpdateBotTimerBarPosition(); } } -} +}; /** * This function changes the visibility of the timer bar @@ -1847,7 +1847,7 @@ CM.Disp.ToggleTimerBar = function() { if (CM.Options.TimerBar == 1) CM.Disp.TimerBar.style.display = ''; else CM.Disp.TimerBar.style.display = 'none'; CM.Disp.UpdateBotTimerBarPosition(); -} +}; /** * This function changes the position of the timer bar @@ -1865,7 +1865,7 @@ CM.Disp.ToggleTimerBarPos = function() { l('wrapper').appendChild(CM.Disp.TimerBar); } CM.Disp.UpdateBotTimerBarPosition(); -} +}; /******** * Section: Functions related to the both the bottom and timer bar @@ -1898,7 +1898,7 @@ CM.Disp.UpdateBotTimerBarPosition = function() { } CM.Disp.UpdateBackground(); -} +}; /******** * Section: Functions related to right column of the screen (buildings/upgrades) @@ -1971,7 +1971,7 @@ CM.Disp.UpdateBuildings = function() { Game.Objects[arr[x].name].l.style.gridRow = (x + 2) + "/" + (x + 2); } } -} +}; /** * This function adjusts some things in the upgrades section @@ -2036,15 +2036,17 @@ CM.Disp.UpdateUpgrades = function() { arr.push(o); } - if (CM.Options.SortUpgrades) + if (CM.Options.SortUpgrades) { arr.sort((a, b) => a.pp - b.pp); - else + } + else { arr.sort((a, b) => a.price - b.price); - + } + for (var x = 0; x < Game.UpgradesInStore.length; x++){ l("upgrade" + x).style.order = arr.findIndex(e => e.name === Game.UpgradesInStore[x].name) + 1 } -} +}; /******** * Section: Functions related to the Upgrade Bar @@ -2066,7 +2068,7 @@ CM.Disp.ToggleUpgradeBarAndColor = function() { CM.Disp.UpgradeBar.style.display = 'none'; Game.RebuildUpgrades(); } -} +}; /** * This function toggles the position of the upgrade bar from fixed or non-fixed mode @@ -2080,7 +2082,7 @@ CM.Disp.ToggleUpgradeBarFixedPos = function() { else { CM.Disp.UpgradeBar.style.position = ''; // Possible to scroll offscreen } -} +}; /** * This function creates the upgrade bar above the upgrade-section in the right section of the screen @@ -2119,7 +2121,7 @@ CM.Disp.CreateUpgradeBar = function() { CM.Disp.UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarGray', CM.Disp.colorGray)); l('upgrades').parentNode.insertBefore(CM.Disp.UpgradeBar, l('upgrades').parentNode.childNodes[3]); -} +}; /** * This function creates the legend for the upgrade bar, it is called by CM.Disp.CreateUpgradeBar @@ -2157,7 +2159,7 @@ CM.Disp.CreateUpgradeBarLegend = function() { legend.appendChild(legendLine(CM.Disp.colorPurple, 'Worse than worst PP building')); legend.appendChild(legendLine(CM.Disp.colorGray, 'Negative or infinity PP')); return legend; -} +}; /******** * Section: Functions related to the flashes/sound/notifications @@ -2176,7 +2178,7 @@ CM.Disp.CreateWhiteScreen = function() { CM.Disp.WhiteScreen.style.zIndex = '9999999999'; CM.Disp.WhiteScreen.style.position = 'absolute'; l('wrapper').appendChild(CM.Disp.WhiteScreen); -} +}; /** * This function creates a flash depending on configs. It is called by all functions @@ -2202,7 +2204,7 @@ CM.Disp.Flash = function(mode, config) { setTimeout(function() {CM.Disp.Flash(1, config);}, 1000/Game.fps); } else if (mode == 0) CM.Disp.WhiteScreen.style.display = 'none'; -} +}; /** * This function plays a sound depending on configs. It is called by all functions @@ -2218,7 +2220,7 @@ CM.Disp.PlaySound = function(url, sndConfig, volConfig) { sound.volume = (CM.Options[volConfig] / 100) * (Game.volume / 100); sound.play(); } -} +}; /** * This function creates a notifcation depending on configs. It is called by all functions @@ -2230,10 +2232,10 @@ CM.Disp.PlaySound = function(url, sndConfig, volConfig) { CM.Disp.Notification = function(notifyConfig, title, message) { // The arguments check makes the sound not play upon initialization of the mod if (CM.Options[notifyConfig] == 1 && document.visibilityState == 'hidden' && arguments.callee.caller.caller.caller.caller == null) { - var CookieIcon = 'https://orteil.dashnet.org/cookieclicker/favicon.ico' + var CookieIcon = 'https://orteil.dashnet.org/cookieclicker/favicon.ico'; notification = new Notification(title, {body: message, badge: CookieIcon}); } -} +}; /******** * Section: Functions related to updating the tab in the browser's tab-bar @@ -2247,7 +2249,7 @@ CM.Disp.CreateFavicon = function() { CM.Disp.Favicon.rel = 'shortcut icon'; CM.Disp.Favicon.href = 'https://orteil.dashnet.org/cookieclicker/favicon.ico'; document.getElementsByTagName('head')[0].appendChild(CM.Disp.Favicon); -} +}; /** * This function updates the Favicon depending on whether a Golden Cookie has spawned @@ -2260,7 +2262,7 @@ CM.Disp.UpdateFavicon = function() { else CM.Disp.Favicon.href = 'https://aktanusa.github.io/CookieMonster/favicon/goldenCookie.ico'; } else CM.Disp.Favicon.href = 'https://orteil.dashnet.org/cookieclicker/favicon.ico'; -} +}; /** * This function updates the tab title @@ -2282,9 +2284,9 @@ CM.Disp.UpdateTitle = function() { else titleGC = '[G ' + Math.ceil(CM.Cache.spawnedGoldenShimmer.life / Game.fps) + ']'; } else if (!Game.Has('Golden switch [off]')) { - titleGC = '[' + Math.ceil((Game.shimmerTypes['golden'].maxTime - Game.shimmerTypes['golden'].time) / Game.fps) + ']'; + titleGC = '[' + Math.ceil((Game.shimmerTypes.golden.maxTime - Game.shimmerTypes.golden.time) / Game.fps) + ']'; } - else titleGC = '[GS]' + else titleGC = '[GS]'; if (CM.Main.lastTickerFortuneState) { addFC = true; @@ -2295,7 +2297,7 @@ CM.Disp.UpdateTitle = function() { addSP = true; if (CM.Main.lastSeasonPopupState) titleSP = '[R ' + Math.ceil(CM.Cache.seasonPopShimmer.life / Game.fps) + ']'; else { - titleSP = '[' + Math.ceil((Game.shimmerTypes['reindeer'].maxTime - Game.shimmerTypes['reindeer'].time) / Game.fps) + ']'; + titleSP = '[' + Math.ceil((Game.shimmerTypes.reindeer.maxTime - Game.shimmerTypes.reindeer.time) / Game.fps) + ']'; } } @@ -2328,7 +2330,7 @@ CM.Disp.UpdateTitle = function() { str += title; document.title = str; } -} +}; /******** * Section: Functions related to the Golden Cookie Timers @@ -2340,7 +2342,7 @@ CM.Disp.UpdateTitle = function() { */ CM.Disp.CreateGCTimer = function(cookie) { GCTimer = document.createElement('div'); - GCTimer.id = 'GCTimer' + cookie.id + GCTimer.id = 'GCTimer' + cookie.id; GCTimer.style.width = '96px'; GCTimer.style.height = '96px'; GCTimer.style.position = 'absolute'; @@ -2360,7 +2362,7 @@ CM.Disp.CreateGCTimer = function(cookie) { CM.Disp.GCTimers[cookie.id] = GCTimer; l('shimmers').appendChild(GCTimer); -} +}; /** * This function toggles GC Timers are visible @@ -2377,7 +2379,7 @@ CM.Disp.ToggleGCTimer = function() { else { for (var i in CM.Disp.GCTimers) CM.Disp.GCTimers[i].style.display = 'none'; } -} +}; /******** * Section: Functions related to Tooltips @@ -2400,7 +2402,7 @@ CM.Disp.CreateSimpleTooltip = function(placeholder, text, minWidth) { div.textContent = text; desc.appendChild(div); CM.Disp[placeholder].appendChild(desc); -} +}; /** * This function replaces the original .onmouseover functions of upgrades so that it calls CM.Disp.Tooltip() @@ -2416,7 +2418,7 @@ CM.Disp.ReplaceTooltipUpgrade = function() { eval('l(\'upgrade\' + i).onmouseover = function() {if (!Game.mouseDown) {Game.setOnCrate(this); Game.tooltip.dynamic = 1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip(\'u\', \'' + i + '\');}, \'store\'); Game.tooltip.wobble();}}'); } } -} +}; /** * This function enhance the standard tooltips by creating and changing l('tooltip') @@ -2435,7 +2437,7 @@ CM.Disp.Tooltip = function(type, name) { if (amortizeAmount > 0) { l('tooltip').innerHTML = l('tooltip').innerHTML .split('so far') - .join('so far
' + Beautify(amortizeAmount) + ' ' + (Math.floor(amortizeAmount) == 1 ? 'cookie' : 'cookies') + ' left to amortize (' + CM.Disp.GetTimeColor((buildPrice - Game.Objects[name].totalCookies) / (Game.Objects[name].storedTotalCps * Game.globalCpsMult)).text + ')'); + .join('so far
' + Beautify(amortizeAmount) + ' ' + (Math.floor(amortizeAmount) == 1 ? 'cookie' : 'cookies') + ' left to amortize (' + CM.Disp.GetTimeColor((buildPrice - Game.Objects[name].totalCookies) / (Game.Objects[name].storedTotalCps * Game.globalCpsMult)).text + ')') } } if (Game.buyMode == -1) { @@ -2473,7 +2475,7 @@ CM.Disp.Tooltip = function(type, name) { CM.Disp.UpdateTooltip(); return l('tooltip').innerHTML; -} +}; /** * This function creates a tooltipBox object which contains all CookieMonster added tooltip information. @@ -2488,8 +2490,8 @@ CM.Disp.TooltipCreateTooltipBox = function() { tooltipBox.style.margin = '0px -4px'; tooltipBox.id = 'CMTooltipBorder'; tooltipBox.className = CM.Disp.colorTextPre + CM.Disp.colorGray; - return tooltipBox -} + return tooltipBox; +}; /** * This function creates a header object for tooltips. @@ -2503,7 +2505,7 @@ CM.Disp.TooltipCreateHeader = function(text) { div.className = CM.Disp.colorTextPre + CM.Disp.colorBlue; div.textContent = text; return div; -} +}; /** * This function appends the sections for Bonus Income, PP and Time left (to achiev) to the tooltip-object @@ -2546,7 +2548,7 @@ CM.Disp.TooltipCreateCalculationSection = function(tooltip) { production.id = 'CMTooltipProduction'; tooltip.appendChild(production); } -} +}; /** * This function creates the tooltip objectm for warnings @@ -2585,7 +2587,8 @@ CM.Disp.TooltipCreateWarningSection = function() { deficitDiv.appendChild(document.createTextNode('Deficit: ')); deficitDiv.appendChild(deficitSpan); return box; - } + }; + CM.Disp.TooltipWarn.appendChild(create('CMDispTooltipWarnLucky', CM.Disp.colorRed, 'Warning: ', 'Purchase of this item will put you under the number of Cookies required for "Lucky!"', 'CMDispTooltipWarnLuckyText')); CM.Disp.TooltipWarn.firstChild.style.marginBottom = '4px'; CM.Disp.TooltipWarn.appendChild(create('CMDispTooltipWarnLuckyFrenzy', CM.Disp.colorYellow, 'Warning: ', 'Purchase of this item will put you under the number of Cookies required for "Lucky!" (Frenzy)', 'CMDispTooltipWarnLuckyFrenzyText')); @@ -2597,7 +2600,7 @@ CM.Disp.TooltipCreateWarningSection = function() { CM.Disp.TooltipWarn.appendChild(create('CMDispTooltipWarnEdifice', CM.Disp.colorPurple, 'Warning: ', 'Purchase of this item will put you under the number of Cookies needed for "Spontaneous Edifice" to possibly give you your most expensive building"', 'CMDispTooltipWarnEdificeText')); return CM.Disp.TooltipWarn; -} +}; /** * This function updates the sections of the tooltips created by CookieMonster @@ -2635,7 +2638,7 @@ CM.Disp.UpdateTooltip = function() { l('CMDispTooltipWarningParent').remove(); } } -} +}; /** * This function adds extra info to the Building tooltips @@ -2649,11 +2652,11 @@ CM.Disp.UpdateTooltipBuilding = function() { var target = ''; // TODO: Change the Cache code and variables to use Objects1, Objectes10, Objects100 // That would depreciate this target setting code - if (Game.buyMode == 1 && Game.buyBulk == 10) target = 'Objects10' + if (Game.buyMode == 1 && Game.buyBulk == 10) target = 'Objects10'; else if (Game.buyMode == 1 && Game.buyBulk == 100) target = 'Objects100'; else target = 'Objects'; - 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; @@ -2678,8 +2681,8 @@ CM.Disp.UpdateTooltipBuilding = function() { // Add "production left till next achievement"-bar for (var i in Game.Objects[CM.Disp.tooltipName].productionAchievs) { if (!CM.Sim.HasAchiev(Game.Objects[CM.Disp.tooltipName].productionAchievs[i].achiev.name)) { - var nextProductionAchiev = Game.Objects[CM.Disp.tooltipName].productionAchievs[i] - break + var nextProductionAchiev = Game.Objects[CM.Disp.tooltipName].productionAchievs[i]; + break; } } if (typeof nextProductionAchiev != "undefined") { @@ -2694,7 +2697,7 @@ CM.Disp.UpdateTooltipBuilding = function() { } } else l('CMTooltipArea').style.display = "none"; -} +}; /** * This function adds extra info to the Upgrade tooltips @@ -2706,7 +2709,7 @@ CM.Disp.UpdateTooltipUpgrade = function() { CM.Disp.TooltipBonusIncome = CM.Cache.Upgrades[Game.UpgradesInStore[CM.Disp.tooltipName].name].bonus; CM.Disp.TooltipPrice = Game.Upgrades[Game.UpgradesInStore[CM.Disp.tooltipName].name].getPrice(); - CM.Disp.TooltipBonusMouse = CM.Cache.Upgrades[Game.UpgradesInStore[CM.Disp.tooltipName].name].bonusMouse + CM.Disp.TooltipBonusMouse = CM.Cache.Upgrades[Game.UpgradesInStore[CM.Disp.tooltipName].name].bonusMouse; if (CM.Options.TooltipBuildUpgrade == 1) { l('CMTooltipIncome').textContent = Beautify(CM.Disp.TooltipBonusIncome, 2); @@ -2717,13 +2720,13 @@ CM.Disp.UpdateTooltipUpgrade = function() { l('CMTooltipBorder').className = CM.Disp.colorTextPre + CM.Cache.Upgrades[Game.UpgradesInStore[CM.Disp.tooltipName].name].color; // If clicking power upgrade if (CM.Disp.TooltipBonusMouse) { - l('CMTooltipCookiePerClick').textContent = Beautify(CM.Disp.TooltipBonusMouse) + l('CMTooltipCookiePerClick').textContent = Beautify(CM.Disp.TooltipBonusMouse); l('CMTooltipCookiePerClick').style.display = "block"; l('CMTooltipCookiePerClick').previousSibling.style.display = "block"; } // If only a clicking power upgrade change PP to click-based period if (CM.Disp.TooltipBonusIncome == 0 && CM.Disp.TooltipBonusMouse) { - l('CMTooltipPP').textContent = Beautify(CM.Disp.TooltipPrice / CM.Disp.TooltipBonusMouse) + ' Clicks' + l('CMTooltipPP').textContent = Beautify(CM.Disp.TooltipPrice / CM.Disp.TooltipBonusMouse) + ' Clicks'; l('CMTooltipPP').style.color = "white"; } else { @@ -2749,7 +2752,7 @@ CM.Disp.UpdateTooltipUpgrade = function() { } } else l('CMTooltipArea').style.display = "none"; -} +}; /** * This function adds extra info to the Sugar Lump tooltip @@ -2770,7 +2773,7 @@ CM.Disp.UpdateTooltipSugarLump = function() { lumpType.className = CM.Disp.colorTextPre + lumpColor.color; } else l('CMTooltipArea').style.display = "none"; -} +}; /** * This function adds extra info to the Grimoire tooltips @@ -2811,22 +2814,22 @@ CM.Disp.UpdateTooltipGrimoire = function() { conjure.id = 'CMTooltipConjure'; tooltipBox.appendChild(conjure); var reward = document.createElement('span'); - reward.style.color = "#33FF00" - reward.textContent = Beautify(Math.min((Game.cookies + CM.Disp.GetWrinkConfigBank()) * 0.15, CM.Cache.NoGoldSwitchCookiesPS * 60 * 30), 2) - conjure.appendChild(reward) + reward.style.color = "#33FF00"; + reward.textContent = Beautify(Math.min((Game.cookies + CM.Disp.GetWrinkConfigBank()) * 0.15, CM.Cache.NoGoldSwitchCookiesPS * 60 * 30), 2); + conjure.appendChild(reward); var seperator = document.createElement('span'); - seperator.textContent = ' / ' - conjure.appendChild(seperator) + seperator.textContent = ' / '; + conjure.appendChild(seperator); var loss = document.createElement('span'); - loss.style.color = "red" + loss.style.color = "red"; loss.textContent = Beautify((CM.Cache.NoGoldSwitchCookiesPS * 60 * 15), 2); - conjure.appendChild(loss) + conjure.appendChild(loss); } l('CMTooltipArea').appendChild(tooltipBox); } else l('CMTooltipArea').style.display = "none"; -} +}; /** * This function adds extra info to the Garden plots tooltips @@ -2834,7 +2837,7 @@ CM.Disp.UpdateTooltipGrimoire = function() { * It adds to the additional information to l('CMTooltipArea') */ CM.Disp.UpdateTooltipGardenPlots = function() { - var minigame = Game.Objects['Farm'].minigame; + var minigame = Game.Objects.Farm.minigame; if (CM.Options.TooltipLump && minigame.plot[CM.Disp.tooltipName[1]][CM.Disp.tooltipName[0]][0] != 0) { var mature = minigame.plot[CM.Disp.tooltipName[1]][CM.Disp.tooltipName[0]][1] > minigame.plantsById[minigame.plot[CM.Disp.tooltipName[1]][CM.Disp.tooltipName[0]][0] - 1].matureBase; var plantName = minigame.plantsById[minigame.plot[CM.Disp.tooltipName[1]][CM.Disp.tooltipName[0]][0] - 1].name; @@ -2857,7 +2860,7 @@ CM.Disp.UpdateTooltipGardenPlots = function() { else l('CMTooltipArea').style.display = "none"; } else l('CMTooltipArea').style.display = "none"; -} +}; /** * This function adds extra info to the Garden Harvest All tooltip @@ -2865,7 +2868,7 @@ CM.Disp.UpdateTooltipGardenPlots = function() { * It adds to the additional information to l('CMTooltipArea') */ CM.Disp.UpdateTooltipHarvestAll = function() { - var minigame = Game.Objects['Farm'].minigame; + var minigame = Game.Objects.Farm.minigame; if (CM.Options.TooltipLump) { l('CMTooltipBorder').appendChild(CM.Disp.TooltipCreateHeader('Cookies gained from harvesting:')); var totalGain = 0; @@ -2875,7 +2878,7 @@ CM.Disp.UpdateTooltipHarvestAll = function() { if (minigame.plot[y][x][0]>=1) { let tile = minigame.plot[y][x]; let me = minigame.plantsById[tile[0] - 1]; - let plantName = me.name + let plantName = me.name; let count = true; if (mortal && me.immortal) count = false; @@ -2898,7 +2901,7 @@ CM.Disp.UpdateTooltipHarvestAll = function() { l('CMTooltipBorder').appendChild(document.createTextNode(CM.Disp.Beautify(totalGain))); } else l('CMTooltipArea').style.display = "none"; -} +}; /** * This function updates the warnings section of the building and upgrade tooltips @@ -2973,7 +2976,7 @@ CM.Disp.UpdateTooltipWarnings = function() { l('CMDispTooltipWarningParent').remove(); } } -} +}; /** * This function updates the location of the tooltip @@ -2991,7 +2994,7 @@ CM.Disp.UpdateTooltipLocation = function() { /*else if (!Game.onCrate && !Game.OnAscend && CM.Options.TimerBar == 1 && CM.Options.TimerBarPos == 0) { Game.tooltip.tta.style.top = (parseInt(Game.tooltip.tta.style.top) + parseInt(CM.Disp.TimerBar.style.height)) + 'px'; }*/ -} +}; /** * This function toggles the position of the warnings created by CM.Disp.TooltipCreateWarningSection() @@ -3011,7 +3014,7 @@ CM.Disp.ToggleToolWarnPos = function() { CM.Disp.TooltipWarn.style.padding = '4px 3px'; } } -} +}; /** * This function checks and create a tooltip for the wrinklers @@ -3049,7 +3052,7 @@ CM.Disp.CheckWrinklerTooltip = function() { Game.tooltip.hide(); } } -} +}; /** * This function updates the amount to be displayed by the wrinkler tooltip created by CM.Disp.CheckWrinklerTooltip() @@ -3072,7 +3075,7 @@ CM.Disp.UpdateWrinklerTooltip = function() { } l('CMTooltipWrinkler').textContent = Beautify(sucked); } -} +}; /******** * Section: Functions related to the Dragon */ @@ -3089,9 +3092,9 @@ CM.Disp.AddAuraInfo = function(aura) { var bonusCPSPercentage = CM.Disp.Beautify(bonusCPS / Game.cookiesPs); bonusCPS = CM.Disp.Beautify(bonusCPS); - l('dragonAuraInfo').style.minHeight = "60px" - l('dragonAuraInfo').style.margin = "8px" - l('dragonAuraInfo').appendChild(document.createElement("div")).className = "line" + l('dragonAuraInfo').style.minHeight = "60px"; + l('dragonAuraInfo').style.margin = "8px"; + l('dragonAuraInfo').appendChild(document.createElement("div")).className = "line"; var div = document.createElement("div"); div.style.minWidth = "200px"; div.style.textAlign = "center"; @@ -3103,7 +3106,7 @@ CM.Disp.AddAuraInfo = function(aura) { div2.textContent = "It will take " + timeToRecover + " to recover the cost."; l('dragonAuraInfo').appendChild(div2); } -} +}; /** * This functions adds a tooltip to the level up button displaying the cost of rebuying all @@ -3114,12 +3117,12 @@ CM.Disp.AddDragonLevelUpTooltip = function() { if ((l('specialPopup').className.match(/onScreen/) && l('specialPopup').children[0].style.background.match(/dragon/)) != null) { for (let i = 0; i < l('specialPopup').childNodes.length; i++) { if (l('specialPopup').childNodes[i].className == "optionBox") { - l('specialPopup').children[i].onmouseover = function() {CM.Cache.CacheDragonCost(); Game.tooltip.dynamic = 1; Game.tooltip.draw(l('specialPopup'), `
${CM.Cache.CostDragonUpgrade}
`, 'this'); Game.tooltip.wobble();} - l('specialPopup').children[i].onmouseout = function() {Game.tooltip.shouldHide = 1;} + l('specialPopup').children[i].onmouseover = function() {CM.Cache.CacheDragonCost(); Game.tooltip.dynamic = 1; Game.tooltip.draw(l('specialPopup'), `
${CM.Cache.CostDragonUpgrade}
`, 'this'); Game.tooltip.wobble();}; + l('specialPopup').children[i].onmouseout = function() {Game.tooltip.shouldHide = 1;}; } } } -} +}; /******** * Section: General functions related to the Options/Stats pages @@ -3134,7 +3137,7 @@ CM.Disp.AddMenu = function() { div.className = 'title ' + CM.Disp.colorTextPre + CM.Disp.colorBlue; div.textContent = 'Cookie Monster Goodies'; return div; - } + }; if (Game.onMenu == 'prefs') { CM.Disp.AddMenuPref(title); @@ -3144,7 +3147,7 @@ CM.Disp.AddMenu = function() { CM.Disp.AddMenuStats(title); } } -} +}; /** * This function refreshes the stats page, CM.Options.UpStats determines the rate at which that happens @@ -3152,7 +3155,7 @@ CM.Disp.AddMenu = function() { */ CM.Disp.RefreshMenu = function() { if (CM.Options.UpStats && Game.onMenu == 'stats' && (Game.drawT - 1) % (Game.fps * 5) != 0 && (Game.drawT - 1) % Game.fps == 0) Game.UpdateMenu(); -} +}; /******** * Section: Functions related to the Options/Preferences page @@ -3167,25 +3170,25 @@ CM.Disp.AddMenuPref = function(title) { frag.appendChild(title()); for (var group in CM.ConfigGroups) { - groupObject = CM.Disp.CreatePrefHeader(group, CM.ConfigGroups[group]) // (group, display-name of group) - frag.appendChild(groupObject) + groupObject = CM.Disp.CreatePrefHeader(group, CM.ConfigGroups[group]); // (group, display-name of group) + frag.appendChild(groupObject); if (CM.Options.Header[group]) { // 0 is show, 1 is collapsed // Make sub-sections of Notification section if (group == "Notification") { for (var subGroup in CM.ConfigGroupsNotification) { - subGroupObject = CM.Disp.CreatePrefHeader(subGroup, CM.ConfigGroupsNotification[subGroup]) // (group, display-name of group) + subGroupObject = CM.Disp.CreatePrefHeader(subGroup, CM.ConfigGroupsNotification[subGroup]); // (group, display-name of group) subGroupObject.style.fontSize = "15px"; subGroupObject.style.opacity = "0.5"; - frag.appendChild(subGroupObject) + frag.appendChild(subGroupObject); if (CM.Options.Header[subGroup]) { for (var option in CM.ConfigData) { - if (CM.ConfigData[option].group == subGroup) frag.appendChild(CM.Disp.CreatePrefOption(option)) + if (CM.ConfigData[option].group == subGroup) frag.appendChild(CM.Disp.CreatePrefOption(option)); } } } } else { for (var option in CM.ConfigData) { - if (CM.ConfigData[option].group == group) frag.appendChild(CM.Disp.CreatePrefOption(option)) + if (CM.ConfigData[option].group == group) frag.appendChild(CM.Disp.CreatePrefOption(option)); } } } @@ -3201,7 +3204,7 @@ CM.Disp.AddMenuPref = function(title) { frag.appendChild(resDef); l('menu').childNodes[2].insertBefore(frag, l('menu').childNodes[2].childNodes[l('menu').childNodes[2].childNodes.length - 1]); -} +}; /** * This function creates a header-object for the options page @@ -3232,7 +3235,7 @@ CM.Disp.CreatePrefHeader = function(config, text) { span.onclick = function() {CM.Config.ToggleHeader(config); Game.UpdateMenu();}; div.appendChild(span); return div; -} +}; /** * This function creates an option-object for the options page @@ -3331,11 +3334,11 @@ CM.Disp.CreatePrefOption = function(config) { input.setAttribute('value', CM.Options.Colors[CM.Disp.colors[i]]); innerDiv.appendChild(input); let change = function() {CM.Options.Colors[this.targetElement.id] = this.toHEXString(); CM.Disp.UpdateColors(); CM.Config.SaveConfig(); Game.UpdateMenu();}; - let picker = new JSColor(input, {hash: true, position: "right", onInput: change}) + let picker = new JSColor(input, {hash: true, position: "right", onInput: change}); var label = document.createElement('label'); label.textContent = CM.ConfigData.Colors.desc[CM.Disp.colors[i]]; innerDiv.appendChild(label); - div.appendChild(innerDiv) + div.appendChild(innerDiv); } return div } @@ -3356,7 +3359,7 @@ CM.Disp.CreatePrefOption = function(config) { input.oninput = function() {if (this.value > this.max) console.log("TEST"); CM.Options[config] = this.value; CM.Config.SaveConfig(); - CM.Disp.RefreshScale() + CM.Disp.RefreshScale(); } div.appendChild(input); div.appendChild(document.createTextNode(' ')); @@ -3365,7 +3368,7 @@ CM.Disp.CreatePrefOption = function(config) { div.appendChild(label); return div; } -} +}; /** * This function changes some of the time-displays in the game to be more detailed @@ -3374,7 +3377,7 @@ CM.Disp.CreatePrefOption = function(config) { CM.Disp.ToggleDetailedTime = function() { if (CM.Options.DetailedTime == 1) Game.sayTime = CM.Disp.sayTime; else Game.sayTime = CM.Backup.sayTime; -} +}; /** * This function refreshes all numbers after a change in scale-setting @@ -3388,7 +3391,7 @@ CM.Disp.RefreshScale = function() { CM.Disp.UpdateBotBar(); CM.Disp.UpdateBuildings(); CM.Disp.UpdateUpgrades(); -} +}; /** * This function changes/refreshes colours if the user has set new standard colours @@ -3407,7 +3410,7 @@ CM.Disp.UpdateColors = function() { } CM.Disp.Css.textContent = str; CM.Disp.UpdateBuildings(); // Class has been already set -} +}; /******** * Section: Functions related to the Stats page @@ -3561,7 +3564,7 @@ CM.Disp.AddMenuStats = function(title) { if (CM.Options.MissingUpgrades) { CM.Disp.AddMissingUpgrades(); } -} +}; /** * This function creates a header-object for the stats page @@ -3593,7 +3596,7 @@ CM.Disp.CreateStatsHeader = function(text, config) { span.onclick = function() {CM.Config.ToggleHeader(config); Game.UpdateMenu();}; div.appendChild(span); return div; -} +}; /** * This function creates an stats-listing-object for the stats page @@ -3634,7 +3637,7 @@ CM.Disp.CreateStatsListing = function(type, name, text, placeholder) { div.appendChild(document.createTextNode(': ')); div.appendChild(text); return div; -} +}; /** * This function creates a tooltip containing all missing holiday items contained in the list theMissDisp @@ -3677,7 +3680,7 @@ CM.Disp.CreateStatsMissDisp = function(theMissDisp) { span.textContent = '?'; frag.appendChild(span); return frag; -} +}; /** * This function creates the "Lucky" section of the stats page @@ -3742,7 +3745,7 @@ CM.Disp.CreateStatsLuckySection = function() { luckyCurSpan.textContent = Beautify(CM.Cache.GoldenCookiesMult * luckyCurBase) + (luckySplit ? (' / ' + Beautify(CM.Cache.WrathCookiesMult * luckyCurBase)) : '') section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Lucky!\" Reward (CUR)' + (luckySplit ? ' (Golden / Wrath)' : ''), luckyCurSpan, goldCookTooltip)); return section; -} +}; /** * This function creates the "Chain" section of the stats page @@ -3825,7 +3828,7 @@ CM.Disp.CreateStatsChainSection = function() { var chainCurWrath = CM.Cache.MaxChainMoni(6, chainCurMax, CM.Cache.WrathCookiesMult); section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Chain\" Reward (CUR) (Golden / Wrath)', document.createTextNode((Beautify(chainCur) + ' / ' + Beautify(chainCurWrath))), goldCookTooltip)); return section; -} +}; /** * This function creates the "Spells" section of the stats page @@ -3875,7 +3878,7 @@ CM.Disp.CreateStatsSpellsSection = function() { section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Spontaneous Edifice\" Cookies Required (most expensive building)', document.createTextNode(CM.Disp.Beautify(CM.Cache.Edifice) + ' (' + CM.Cache.EdificeBuilding + ")"), 'GoldCookTooltipPlaceholder')); } return section; -} +}; /** * This function creates the "Prestige" section of the stats page @@ -3945,7 +3948,7 @@ CM.Disp.CreateStatsPrestigeSection = function() { } return section; -} +}; /** * This function creates the missing upgrades sections for prestige, normal and cookie upgrades @@ -3959,8 +3962,8 @@ CM.Disp.AddMissingUpgrades = function() { title.className = "listing"; titlefrag = document.createElement('div'); titlefrag.innerHTML = 'Missing Prestige upgrades: '+ prestigeUpgradesOwned + '/' + Game.PrestigeUpgrades.length + ' (' + Math.floor((prestigeUpgradesOwned / Game.PrestigeUpgrades.length) * 100) + '%)'; - title.appendChild(titlefrag) - l('menu').children[5].appendChild(title) + title.appendChild(titlefrag); + l('menu').children[5].appendChild(title); upgrades = document.createElement('div'); upgrades.className = "listing crateBox"; upgrades.innerHTML = CM.Cache.MissingUpgradesPrestige; @@ -3975,8 +3978,8 @@ CM.Disp.AddMissingUpgrades = function() { title.className = "listing"; titlefrag = document.createElement('div'); titlefrag.innerHTML = 'Missing normal upgrades: '+ normalUpgradesOwned + '/' + (Game.UpgradesByPool[""].length + Game.UpgradesByPool["tech"].length) + ' (' + Math.floor((normalUpgradesOwned / ( Game.UpgradesByPool[""].length + Game.UpgradesByPool["tech"].length)) * 100) + '%)'; - title.appendChild(titlefrag) - l('menu').children[6].insertBefore(title, l('menu').children[6].childNodes[3]) + title.appendChild(titlefrag); + l('menu').children[6].insertBefore(title, l('menu').children[6].childNodes[3]); upgrades = document.createElement('div'); upgrades.className = "listing crateBox"; upgrades.innerHTML = CM.Cache.MissingUpgrades; @@ -3989,15 +3992,15 @@ CM.Disp.AddMissingUpgrades = function() { title.className = "listing"; titlefrag = document.createElement('div'); titlefrag.innerHTML = 'Missing Cookie upgrades: '+ cookieUpgradesOwned + '/' + Game.UpgradesByPool["cookie"].length + ' (' + Math.floor((cookieUpgradesOwned / Game.UpgradesByPool["cookie"].length) * 100) + '%)'; - title.appendChild(titlefrag) - l('menu').children[6].appendChild(title) + title.appendChild(titlefrag); + l('menu').children[6].appendChild(title); upgrades = document.createElement('div'); upgrades.className = "listing crateBox"; upgrades.innerHTML = CM.Cache.MissingUpgradesCookies; - l('menu').children[6].appendChild(upgrades) + l('menu').children[6].appendChild(upgrades); } -} +}; /** * This function returns the "crates" (icons) for missing upgrades in the stats sections @@ -4021,7 +4024,7 @@ CM.Disp.crateMissing = function(me) { ${Game.getDynamicTooltip(tooltip, 'top', true)} style = "${((icon[2] ? 'background-image: url(' + icon[2] + ');' : '') + 'background-position:' + (-icon[0] * 48)+ 'px ' + (-icon[1] * 48) + 'px')};"> `; -} +}; /******** * Section: Functions related to the left column of the page */ @@ -4043,7 +4046,7 @@ CM.Disp.CreateWrinklerButtons = function() { popFattestA.className = 'option'; popFattestA.onclick = function() {if (CM.Cache.WrinklersFattest[1]) Game.wrinklers[CM.Cache.WrinklersFattest[1]].hp = 0; }; l('sectionLeftExtra').children[0].append(popFattestA); -} +}; /** * This function updates the display setting of the two objects created by CM.Disp.CreateWrinklerButtons() @@ -4058,7 +4061,7 @@ CM.Disp.UpdateWrinklerButtons = function() { l('PopAllNormalWrinklerButton').style.display = "none"; l('PopFattestWrinklerButton').style.display = "none"; } -} +}; /******** * Section: Variables used in Disp functions */ @@ -4143,31 +4146,31 @@ CM.ReplaceNative = function() { Game.CalculateGains = function() { CM.Backup.CalculateGainsMod(); CM.Sim.DoSims = 1; - } + }; CM.Backup.tooltip = {}; CM.Backup.tooltip.draw = Game.tooltip.draw; eval('CM.Backup.tooltip.drawMod = ' + Game.tooltip.draw.toString().split('this').join('Game.tooltip')); Game.tooltip.draw = function(from, text, origin) { CM.Backup.tooltip.drawMod(from, text, origin); - } + }; CM.Backup.tooltip.update = Game.tooltip.update; eval('CM.Backup.tooltip.updateMod = ' + Game.tooltip.update.toString().split('this.').join('Game.tooltip.')); Game.tooltip.update = function() { CM.Backup.tooltip.updateMod(); CM.Disp.UpdateTooltipLocation(); - } + }; CM.Backup.UpdateWrinklers = Game.UpdateWrinklers; Game.UpdateWrinklers = function() { CM.Main.FixMouseY(CM.Backup.UpdateWrinklers); - } + }; CM.Backup.UpdateSpecial = Game.UpdateSpecial; Game.UpdateSpecial = function() { CM.Main.FixMouseY(CM.Backup.UpdateSpecial); - } + }; // Assumes newer browsers l('bigCookie').removeEventListener('click', Game.ClickCookie, false); @@ -4178,7 +4181,7 @@ CM.ReplaceNative = function() { CM.Backup.RebuildUpgrades(); CM.Disp.ReplaceTooltipUpgrade(); Game.CalculateGains(); - } + }; CM.Backup.DescribeDragonAura = Game.DescribeDragonAura; /** @@ -4189,7 +4192,7 @@ CM.ReplaceNative = function() { Game.DescribeDragonAura = function(aura) { CM.Backup.DescribeDragonAura(aura); CM.Disp.AddAuraInfo(aura); - } + }; CM.Backup.ToggleSpecialMenu = Game.ToggleSpecialMenu; /** @@ -4198,8 +4201,7 @@ CM.ReplaceNative = function() { Game.ToggleSpecialMenu = function(on) { CM.Backup.ToggleSpecialMenu(on); CM.Disp.AddDragonLevelUpTooltip(); - } - + }; CM.Backup.UpdateMenu = Game.UpdateMenu; Game.UpdateMenu = function() { @@ -4207,19 +4209,19 @@ CM.ReplaceNative = function() { CM.Backup.UpdateMenu(); CM.Disp.AddMenu(); } - } + }; CM.Backup.sayTime = Game.sayTime; CM.Disp.sayTime = function(time, detail) { if (isNaN(time) || time <= 0) return CM.Backup.sayTime(time, detail); else return CM.Disp.FormatTime(time / Game.fps, 1); - } + }; CM.Backup.Loop = Game.Loop; Game.Loop = function() { CM.Backup.Loop(); CM.Loop(); - } + }; CM.Backup.Logic = Game.Logic; eval('CM.Backup.LogicMod = ' + Game.Logic.toString().split('document.title').join('CM.Cache.Title')); @@ -4228,13 +4230,13 @@ CM.ReplaceNative = function() { // Update Title CM.Disp.UpdateTitle(); - } -} + }; +}; CM.ReplaceNativeGrimoire = function() { CM.ReplaceNativeGrimoireLaunch(); CM.ReplaceNativeGrimoireDraw(); -} +}; CM.ReplaceNativeGrimoireLaunch = function() { if (!CM.HasReplaceNativeGrimoireLaunch && Game.Objects['Wizard tower'].minigameLoaded) { @@ -4246,10 +4248,10 @@ CM.ReplaceNativeGrimoireLaunch = function() { CM.Main.ReplaceTooltipGrimoire(); CM.HasReplaceNativeGrimoireDraw = false; CM.ReplaceNativeGrimoireDraw(); - } + }; CM.HasReplaceNativeGrimoireLaunch = true; } -} +}; CM.ReplaceNativeGrimoireDraw = function() { if (!CM.HasReplaceNativeGrimoireDraw && Game.Objects['Wizard tower'].minigameLoaded) { @@ -4260,10 +4262,10 @@ CM.ReplaceNativeGrimoireDraw = function() { if (CM.Options.GrimoireBar == 1 && minigame.magic < minigame.magicM) { minigame.magicBarTextL.innerHTML += ' (' + CM.Disp.FormatTime(CM.Disp.CalculateGrimoireRefillTime(minigame.magic, minigame.magicM, minigame.magicM)) + ')'; } - } + }; CM.HasReplaceNativeGrimoireDraw = true; } -} +}; CM.Loop = function() { if (CM.Disp.lastAscendState != Game.OnAscend) { @@ -4343,7 +4345,7 @@ CM.Loop = function() { // Update Average CPS (might need to move) CM.Cache.UpdateCurrWrinklerCPS(); CM.Cache.UpdateAvgCPS(); -} +}; CM.DelayInit = function() { CM.Sim.InitData(); @@ -4381,7 +4383,7 @@ CM.DelayInit = function() { l("upgrades").style["flex-wrap"] = "wrap"; Game.Win('Third-party'); -} +}; /******** * Section: Functions related to first initizalition of CM */ @@ -4400,11 +4402,11 @@ CM.Main.ReplaceTooltips = function() { Game.LoadMinigames = function() { CM.Backup.LoadMinigames(); CM.Main.ReplaceTooltipGarden(); - CM.Main.ReplaceTooltipGrimoire() + CM.Main.ReplaceTooltipGrimoire(); CM.ReplaceNativeGrimoire(); - } + }; Game.LoadMinigames(); -} +}; /******** * Section: Functions related to replacing tooltips */ @@ -4424,7 +4426,7 @@ CM.Main.ReplaceTooltipBuild = function() { eval('l(\'product\' + me.id).onmouseover = function() {Game.tooltip.dynamic = 1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip(\'b\', \'' + i + '\');}, \'store\'); Game.tooltip.wobble();}'); } } -} +}; /** * This function replaces the original .onmouseover functions of the Grimoire minigame so that it calls CM.Disp.Tooltip() @@ -4441,7 +4443,7 @@ CM.Main.ReplaceTooltipGrimoire = function() { } } } -} +}; /** * This function replaces the original .onmouseover functions of sugar lumps so that it calls CM.Disp.Tooltip() @@ -4461,8 +4463,8 @@ CM.Main.ReplaceTooltipLump = function() { * It is called by CM.Main.ReplaceTooltips() */ CM.Main.ReplaceTooltipGarden = function() { - if (Game.Objects['Farm'].minigameLoaded) { - l('gardenTool-1').onmouseover = function() {Game.tooltip.dynamic=1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip('ha', 'HarvestAllButton');}, 'this'); Game.tooltip.wobble();} + if (Game.Objects.Farm.minigameLoaded) { + l('gardenTool-1').onmouseover = function() {Game.tooltip.dynamic=1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip('ha', 'HarvestAllButton');}, 'this'); Game.tooltip.wobble();}; Array.from(l('gardenPlot').children).forEach((child, index) => { var coords = child.id.slice(-3,); child.onmouseover = function() {Game.tooltip.dynamic=1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip('p', [`${coords[0]}`,`${coords[2]}`]);}, 'this'); Game.tooltip.wobble();}; @@ -4481,15 +4483,15 @@ CM.Main.ReplaceTooltipGarden = function() { */ CM.Main.FindShimmer = function() { CM.Main.currSpawnedGoldenCookieState = 0; - CM.Cache.goldenShimmersByID = {} + CM.Cache.goldenShimmersByID = {}; for (var i in Game.shimmers) { - CM.Cache.goldenShimmersByID[Game.shimmers[i].id] = Game.shimmers[i] + CM.Cache.goldenShimmersByID[Game.shimmers[i].id] = Game.shimmers[i]; if (Game.shimmers[i].spawnLead && Game.shimmers[i].type == 'golden') { CM.Cache.spawnedGoldenShimmer = Game.shimmers[i]; CM.Main.currSpawnedGoldenCookieState += 1; } } -} +}; /** * This function checks for changes in the amount of Golden Cookies @@ -4505,13 +4507,13 @@ CM.Main.CheckGoldenCookie = function() { delete CM.Disp.GCTimers[i]; } } - if (CM.Main.lastGoldenCookieState != Game.shimmerTypes['golden'].n) { - CM.Main.lastGoldenCookieState = Game.shimmerTypes['golden'].n; + if (CM.Main.lastGoldenCookieState != Game.shimmerTypes.golden.n) { + CM.Main.lastGoldenCookieState = Game.shimmerTypes.golden.n; if (CM.Main.lastGoldenCookieState) { if (CM.Main.lastSpawnedGoldenCookieState < CM.Main.currSpawnedGoldenCookieState) { CM.Disp.Flash(3, 'GCFlash'); CM.Disp.PlaySound(CM.Options.GCSoundURL, 'GCSound', 'GCVolume'); - CM.Disp.Notification('GCNotification', "Golden Cookie Spawned", "A Golden Cookie has spawned. Click it now!") + CM.Disp.Notification('GCNotification', "Golden Cookie Spawned", "A Golden Cookie has spawned. Click it now!"); } for (var i in Game.shimmers) { @@ -4531,15 +4533,15 @@ CM.Main.CheckGoldenCookie = function() { CM.Disp.GCTimers[i].textContent = Math.ceil(CM.Cache.goldenShimmersByID[i].life / Game.fps); } } -} +}; /** * This function checks if there is reindeer that has spawned * It is called by CM.Loop */ CM.Main.CheckSeasonPopup = function() { - if (CM.Main.lastSeasonPopupState != Game.shimmerTypes['reindeer'].spawned) { - CM.Main.lastSeasonPopupState = Game.shimmerTypes['reindeer'].spawned; + if (CM.Main.lastSeasonPopupState != Game.shimmerTypes.reindeer.spawned) { + CM.Main.lastSeasonPopupState = Game.shimmerTypes.reindeer.spawned; for (var i in Game.shimmers) { if (Game.shimmers[i].spawnLead && Game.shimmers[i].type == 'reindeer') { CM.Cache.seasonPopShimmer = Game.shimmers[i]; @@ -4548,9 +4550,9 @@ CM.Main.CheckSeasonPopup = function() { } CM.Disp.Flash(3, 'SeaFlash'); CM.Disp.PlaySound(CM.Options.SeaSoundURL, 'SeaSound', 'SeaVolume'); - CM.Disp.Notification('SeaNotification',"Reindeer sighted!", "A Reindeer has spawned. Click it now!") + CM.Disp.Notification('SeaNotification',"Reindeer sighted!", "A Reindeer has spawned. Click it now!"); } -} +}; /** * This function checks if there is a fortune cookie on the ticker @@ -4562,24 +4564,24 @@ CM.Main.CheckTickerFortune = function() { if (CM.Main.lastTickerFortuneState) { CM.Disp.Flash(3, 'FortuneFlash'); CM.Disp.PlaySound(CM.Options.FortuneSoundURL, 'FortuneSound', 'FortuneVolume'); - CM.Disp.Notification('FortuneNotification', "Fortune Cookie found", "A Fortune Cookie has appeared on the Ticker.") + CM.Disp.Notification('FortuneNotification', "Fortune Cookie found", "A Fortune Cookie has appeared on the Ticker."); } } -} +}; /** * This function checks if a garden tick has happened * It is called by CM.Loop */ CM.Main.CheckGardenTick = function() { - if (Game.Objects['Farm'].minigameLoaded && CM.Main.lastGardenNextStep != Game.Objects['Farm'].minigame.nextStep) { + if (Game.Objects.Farm.minigameLoaded && CM.Main.lastGardenNextStep != Game.Objects.Farm.minigame.nextStep) { if (CM.Main.lastGardenNextStep != 0 && CM.Main.lastGardenNextStep < Date.now()) { CM.Disp.Flash(3, 'GardFlash'); CM.Disp.PlaySound(CM.Options.GardSoundURL, 'GardSound', 'GardVolume'); } - CM.Main.lastGardenNextStep = Game.Objects['Farm'].minigame.nextStep; + CM.Main.lastGardenNextStep = Game.Objects.Farm.minigame.nextStep; } -} +}; /** * This function checks if the magic meter is full @@ -4593,10 +4595,10 @@ CM.Main.CheckMagicMeter = function() { CM.Main.lastMagicBarFull = true; CM.Disp.Flash(3, 'MagicFlash'); CM.Disp.PlaySound(CM.Options.MagicSoundURL, 'MagicSound', 'MagicVolume'); - CM.Disp.Notification('MagicNotification', "Magic Meter full", "Your Magic Meter is full. Cast a spell!") + CM.Disp.Notification('MagicNotification', "Magic Meter full", "Your Magic Meter is full. Cast a spell!"); } } -} +}; /** * This function checks if any new Wrinklers have popped up @@ -4609,7 +4611,7 @@ CM.Main.CheckWrinklerCount = function() { if (Game.wrinklers[i].phase == 2) CurrentWrinklers++; } if (CurrentWrinklers > CM.Main.lastWrinklerCount) { - CM.Main.lastWrinklerCount = CurrentWrinklers + CM.Main.lastWrinklerCount = CurrentWrinklers; if (CurrentWrinklers == Game.getWrinklersMax() && CM.Options.WrinklerMaxFlash) { CM.Disp.Flash(3, 'WrinklerMaxFlash'); } else { @@ -4621,15 +4623,15 @@ CM.Main.CheckWrinklerCount = function() { CM.Disp.PlaySound(CM.Options.WrinklerSoundURL, 'WrinklerSound', 'WrinklerVolume'); } if (CurrentWrinklers == Game.getWrinklersMax() && CM.Options.WrinklerMaxNotification) { - CM.Disp.Notification('WrinklerMaxNotification', "Maximum Wrinklers Reached", "You have reached your maximum ammount of wrinklers") + CM.Disp.Notification('WrinklerMaxNotification', "Maximum Wrinklers Reached", "You have reached your maximum ammount of wrinklers"); } else { - CM.Disp.Notification('WrinklerNotification', "A Wrinkler appeared", "A new wrinkler has appeared") + CM.Disp.Notification('WrinklerNotification', "A Wrinkler appeared", "A new wrinkler has appeared"); } } else { - CM.Main.lastWrinklerCount = CurrentWrinklers + CM.Main.lastWrinklerCount = CurrentWrinklers; } } -} +}; /** * This function creates .onmouseover/out events that determine if the mouse is hovering-over a Wrinkler @@ -4646,7 +4648,7 @@ CM.Main.AddWrinklerAreaDetect = function() { CM.Disp.TooltipWrinklerBeingShown[i] = 0; } }; -} +}; /******** * Section: Functions related to the mouse */ @@ -4666,14 +4668,14 @@ CM.Main.FixMouseY = function(target) { else { target(); } -} +}; CM.HasReplaceNativeGrimoireLaunch = false; CM.HasReplaceNativeGrimoireDraw = false; CM.Main.lastGoldenCookieState = 0; CM.Main.lastSpawnedGoldenCookieState = 0; -CM.Main.currSpawnedGoldenCookieState +CM.Main.currSpawnedGoldenCookieState; CM.Main.lastTickerFortuneState = 0; CM.Main.lastSeasonPopupState = 0; CM.Main.lastGardenNextStep = 0; @@ -4710,7 +4712,7 @@ CM.Sim.BuildingGetPrice = function(build, basePrice, start, free, increase) { start++; } return moni; -} +}; CM.Sim.BuildingSell = function(build, basePrice, start, free, amount, noSim) { /*var price=0; @@ -4748,13 +4750,13 @@ CM.Sim.BuildingSell = function(build, basePrice, start, free, amount, noSim) { } } return moni; -} +}; CM.Sim.Has = function(what) { var it = CM.Sim.Upgrades[what]; if (Game.ascensionMode == 1 && (it.pool == 'prestige' || it.tier == 'fortune')) return 0; return (it ? it.bought : 0); -} +}; CM.Sim.Win = function(what) { @@ -4764,7 +4766,7 @@ CM.Sim.Win = function(what) { if (Game.Achievements[what].pool != 'shadow') CM.Sim.AchievementsOwned++; } } -} +}; eval('CM.Sim.HasAchiev = ' + Game.HasAchiev.toString().split('Game').join('CM.Sim')); @@ -4776,7 +4778,7 @@ CM.Sim.hasAura = function(what) { return true; else return false; -} +}; // Check if multiplier auras are present // Used as CM.Sim.auraMult('Aura') * mult, i.e. CM.Sim.auraMult('Dragon God) * 0.05 @@ -4787,20 +4789,20 @@ CM.Sim.auraMult = function(what) { if (Game.dragonAuras[CM.Sim.dragonAura].name == 'Reality Bending' || Game.dragonAuras[CM.Sim.dragonAura2].name == 'Reality Bending') n += 0.1; return n; -} +}; CM.Sim.hasGod=function(what) { if (!CM.Sim.Objects.Temple.minigameLoaded) { - return false + return false; } - var possibleGods = CM.Sim.Objects.Temple.minigame.gods + var possibleGods = CM.Sim.Objects.Temple.minigame.gods; var god=possibleGods[what]; for (var i=0;i<3;i++) { if (CM.Sim.Objects.Temple.minigame.slot[i]==god.id) return (i+1); } return false; -} +}; CM.Sim.eff = function(name) { if (typeof CM.Sim.effs[name]==='undefined') { @@ -4810,7 +4812,7 @@ CM.Sim.eff = function(name) { else { return CM.Sim.effs[name]; } -} +}; eval('CM.Sim.GetTieredCpsMult = ' + Game.GetTieredCpsMult.toString() .split('Game.Has').join('CM.Sim.Has') @@ -4830,7 +4832,7 @@ CM.Sim.getCPSBuffMult = function() { if (typeof Game.buffs[i].multCpS != 'undefined') mult *= Game.buffs[i].multCpS; } return mult; -} +}; /** * Constructs an object with the static properties of a building, @@ -4855,7 +4857,7 @@ CM.Sim.InitialBuildingData = function(buildingName) { you.baseCps = me.baseCps; you.name = me.name; return you; -} +}; /** * Similar to the previous function, but for upgrades. @@ -4868,7 +4870,7 @@ CM.Sim.InitUpgrade = function(upgradeName) { you.pool = me.pool; you.name = me.name; return you; -} +}; /** * Similar to the previous function, but for achievements. @@ -4877,7 +4879,7 @@ CM.Sim.InitUpgrade = function(upgradeName) { */ CM.Sim.InitAchievement = function(achievementName) { return {}; -} +}; CM.Sim.InitData = function() { // Buildings @@ -4897,8 +4899,8 @@ CM.Sim.InitData = function() { for (var i in Game.Achievements) { CM.Sim.Achievements[i] = CM.Sim.InitAchievement(i); } - CM.Sim.CopyData -} + CM.Sim.CopyData; +}; CM.Sim.CopyData = function() { // Other variables @@ -5111,7 +5113,7 @@ CM.Sim.CalculateGains = function() { CM.Sim.cookiesPsRaw = rawCookiesPs; - var n = Game.shimmerTypes['golden'].n; + var n = Game.shimmerTypes.golden.n; var auraMult = CM.Sim.auraMult('Dragon\'s Fortune'); for (var i = 0; i < n; i++){ mult *= 1 + auraMult * 1.23; @@ -5207,7 +5209,7 @@ CM.Sim.CheckOtherAchiev = function() { if (buildingsOwned >= 4000 && CM.Sim.UpgradesOwned >= 300) CM.Sim.Win('Polymath'); if (buildingsOwned >= 8000 && CM.Sim.UpgradesOwned >= 400) CM.Sim.Win('Renaissance baker'); - if (CM.Sim.Objects['Cursor'].amount + CM.Sim.Objects['Grandma'].amount >= 777) CM.Sim.Win('The elder scrolls'); + if (CM.Sim.Objects.Cursor.amount + CM.Sim.Objects.Grandma.amount >= 777) CM.Sim.Win('The elder scrolls'); var hasAllHalloCook = true; for (var i in CM.Data.HalloCookies) { @@ -5222,14 +5224,14 @@ CM.Sim.CheckOtherAchiev = function() { if (hasAllChristCook) CM.Sim.Win('Let it snow'); if (CM.Sim.Has('Fortune cookies')) { - var list = Game.Tiers['fortune'].upgrades; + var list = Game.Tiers.fortune.upgrades; var fortunes = 0; for (var i in list) { if (CM.Sim.Has(list[i].name)) fortunes++; } if (fortunes >= list.length) CM.Sim.Win('O Fortuna'); } -} +}; CM.Sim.BuyBuildings = function(amount, target) { CM.Cache[target] = []; @@ -5274,7 +5276,7 @@ CM.Sim.BuyBuildings = function(amount, target) { CM.Cache.DoRemakeBuildPrices = 1; } } -} +}; CM.Sim.BuyUpgrades = function() { CM.Cache.Upgrades = []; @@ -5291,7 +5293,7 @@ CM.Sim.BuyUpgrades = function() { if (CM.Sim.pledges >= 5) CM.Sim.Win('Elder slumber'); } else if (i == 'Elder Covenant') { - CM.Sim.Win('Elder calm') + CM.Sim.Win('Elder calm'); } else if (i == 'Prism heart biscuits') { CM.Sim.Win('Lovely cookies'); @@ -5317,7 +5319,7 @@ CM.Sim.BuyUpgrades = function() { if (diffMouseCPS) CM.Cache.Upgrades[i].bonusMouse = diffMouseCPS; } } -} +}; /** * This functions calculates the cps and cost of changing a Dragon Aura @@ -5329,7 +5331,7 @@ CM.Sim.CalculateChangeAura = function(aura) { CM.Sim.CopyData(); // Check if aura being changed is first or second aura - var auraToBeChanged = l('promptContent').children[0].innerHTML.includes("secondary") + var auraToBeChanged = l('promptContent').children[0].innerHTML.includes("secondary"); if (auraToBeChanged) CM.Sim.dragonAura2 = aura; else CM.Sim.dragonAura = aura; @@ -5340,7 +5342,7 @@ CM.Sim.CalculateChangeAura = function(aura) { var highestBuilding = CM.Sim.Objects[Game.ObjectsById[i].name].name; CM.Sim.Objects[highestBuilding].amount -=1; CM.Sim.buildingsOwned -= 1; - break + break; } } // This calculates price of highest building @@ -5356,8 +5358,8 @@ CM.Sim.CalculateChangeAura = function(aura) { if (lastAchievementsOwned != CM.Sim.AchievementsOwned) { CM.Sim.CalculateGains(); } - return [CM.Sim.cookiesPs - Game.cookiesPs, price] -} + return [CM.Sim.cookiesPs - Game.cookiesPs, price]; +}; CM.Sim.NoGoldSwitchCookiesPS = function() { if (Game.Has('Golden switch [off]')) { @@ -5367,7 +5369,7 @@ CM.Sim.NoGoldSwitchCookiesPS = function() { CM.Cache.NoGoldSwitchCookiesPS = CM.Sim.cookiesPs; } else CM.Cache.NoGoldSwitchCookiesPS = Game.cookiesPs; -} +}; CM.Sim.ResetBonus = function(possiblePresMax) { var lastAchievementsOwned = -1; @@ -5427,19 +5429,19 @@ CM.Sim.ResetBonus = function(possiblePresMax) { CM.Sim.CalculateGains(); } - var ResetCPS = CM.Sim.cookiesPs - curCPS + var ResetCPS = CM.Sim.cookiesPs - curCPS; // Reset Pretige level after calculation CM.Sim.prestige = Game.prestige; return (ResetCPS); -} +}; CM.Sim.getSellMultiplier = function() { var giveBack = 0.25; giveBack *= 1 + CM.Sim.auraMult('Earth Shatterer'); return giveBack; -} +}; CM.Sim.modifyBuildingPrice = function(building,price) { if (CM.Sim.Has('Season savings')) price *= 0.99; @@ -5461,7 +5463,7 @@ CM.Sim.modifyBuildingPrice = function(building,price) { else if (godLvl == 3) price *= 0.98; } return price; -} +}; CM.Sim.SellBuildingsForChoEgg = function() { var sellTotal = 0; @@ -5507,7 +5509,7 @@ CM.Sim.SellBuildingsForChoEgg = function() { // CM.Cache.DoRemakeBuildPrices = 1; return sellTotal; -} +}; /******** * Section: Functions used to calculate clicking power */ @@ -5530,7 +5532,7 @@ CM.Sim.mouseCps = function() { if (CM.Sim.Has('Nonillion fingers')) add *= 20; var num=0; for (var i in CM.Sim.Objects) {num+=CM.Sim.Objects[i].amount;} - num -= CM.Sim.Objects['Cursor'].amount; + num -= CM.Sim.Objects.Cursor.amount; add = add * num; // Use CM.Sim.cookiesPs as function is always called after CM.Sim.CalculateGains() @@ -5559,7 +5561,7 @@ CM.Sim.mouseCps = function() { if (CM.Sim.Has('Aura gloves')) { - mult *= 1 + 0.05 * Math.min(Game.Objects['Cursor'].level, CM.Sim.Has('Luminous gloves') ? 20 : 10); + mult *= 1 + 0.05 * Math.min(Game.Objects.Cursor.level, CM.Sim.Has('Luminous gloves') ? 20 : 10); } mult *= CM.Sim.eff('click'); @@ -5589,7 +5591,8 @@ CM.Sim.mouseCps = function() { if (Game.hasBuff('Cursed finger')) out = Game.buffs['Cursed finger'].power; return out; -} +}; + /********** * Footer * **********/ @@ -5612,7 +5615,7 @@ CM.init = function() { CM.DelayInit(); Game.registerHook('draw', CM.Disp.Draw); } -} +}; /** * This registers a save function to the CM object. Per Game code/comments: @@ -5624,7 +5627,7 @@ CM.save = function() { settings: CM.Options, version: CM.VersionMajor + '.' + CM.VersionMinor, }); -} +}; /** * This registers a load function to the CM object. Per Game code/comments: @@ -5633,7 +5636,7 @@ CM.save = function() { CM.load = function(str) { let save = JSON.parse(str); CM.Config.LoadConfig(save.settings); -} +}; /******** * Section: Functions related to the initialization of CookieMonster */ @@ -5648,7 +5651,7 @@ CM.Footer.AddJscolor = function() { CM.Footer.Jscolor.type = 'text/javascript'; CM.Footer.Jscolor.setAttribute('src', 'https://aktanusa.github.io/CookieMonster/jscolor/jscolor.js'); document.head.appendChild(CM.Footer.Jscolor); -} +}; /** * This functions starts the initizialization and register CookieMonster @@ -5664,6 +5667,6 @@ if (!CM.isRunning) { clearInterval(delay); } }, 500); - CM.isRunning = 1 + CM.isRunning = 1; } diff --git a/src/Config.js b/src/Config.js index 54e467e..4e8cc80 100644 --- a/src/Config.js +++ b/src/Config.js @@ -16,9 +16,9 @@ CM.Config.SaveConfig = function() { CookieMonsterSave = saveString.match(/CookieMonster.*(;|$)/); if (CookieMonsterSave != null) { newSaveString = saveString.replace(CookieMonsterSave[0], "CookieMonster:" + CM.save()); - localStorage.setItem('CookieClickerGame', escape(utf8_to_b64(newSaveString)+'!END!')) + localStorage.setItem('CookieClickerGame', escape(utf8_to_b64(newSaveString)+'!END!')); } -} +}; /** * This function loads the config of CookieMonster saved in localStorage and loads it into CM.Options @@ -81,7 +81,7 @@ CM.Config.LoadConfig = function(settings) { else { // Default values CM.Config.RestoreDefault(); } -} +}; /** * This function reloads and resaves the default config as stored in CM.Data.ConfigDefault @@ -91,7 +91,7 @@ CM.Config.RestoreDefault = function() { CM.Config.LoadConfig(CM.Data.ConfigDefault); CM.Config.SaveConfig(); Game.UpdateMenu(); -} +}; /******** * Section: Functions related to toggling or changing configs */ @@ -116,7 +116,7 @@ CM.Config.ToggleConfig = function(config) { l(CM.ConfigPrefix + config).innerHTML = CM.ConfigData[config].label[CM.Options[config]]; CM.Config.SaveConfig(); -} +}; /** * This function sets the value of the specified volume-option and updates the display in the options menu @@ -129,7 +129,7 @@ CM.Config.ToggleConfigVolume = function(config) { CM.Options[config] = Math.round(l("slider" + config).value); } CM.Config.SaveConfig(); -} +}; /** * This function toggles header options by incrementing them with 1 and handling changes @@ -140,7 +140,7 @@ CM.Config.ToggleHeader = function(config) { CM.Options.Header[config]++; if (CM.Options.Header[config] > 1) CM.Options.Header[config] = 0; CM.Config.SaveConfig(); -} +}; /******** * Section: Functions related to notifications */ @@ -154,14 +154,14 @@ CM.Config.ToggleHeader = function(config) { CM.Config.CheckNotificationPermissions = function(ToggleOnOff) { if (ToggleOnOff == 1) { // Check if browser support Promise version of Notification Permissions - function checkNotificationPromise() { + checkNotificationPromise = function () { try { Notification.requestPermission().then(); } catch(e) { return false; } return true; - } + }; // Check if the browser supports notifications and which type if (!('Notification' in window)) { @@ -176,4 +176,4 @@ CM.Config.CheckNotificationPermissions = function(ToggleOnOff) { } } } -} \ No newline at end of file +}; \ No newline at end of file diff --git a/src/Data.js b/src/Data.js index 0ec0ce6..450620a 100644 --- a/src/Data.js +++ b/src/Data.js @@ -33,7 +33,7 @@ CM.Data.Fortunes = [ CM.Data.HalloCookies = ['Skull cookies', 'Ghost cookies', 'Bat cookies', 'Slime cookies', 'Pumpkin cookies', 'Eyeball cookies', 'Spider cookies']; CM.Data.ChristCookies = ['Christmas tree biscuits', 'Snowflake biscuits', 'Snowman biscuits', 'Holly biscuits', 'Candy cane biscuits', 'Bell biscuits', 'Present biscuits']; CM.Data.ValCookies = ['Pure heart biscuits', 'Ardent heart biscuits', 'Sour heart biscuits', 'Weeping heart biscuits', 'Golden heart biscuits', 'Eternal heart biscuits', 'Prism heart biscuits']; -CM.Data.PlantDrops = ['Elderwort biscuits', 'Bakeberry cookies', 'Duketater cookies', 'Green yeast digestives', 'Wheat slims', 'Fern tea', 'Ichor syrup'] +CM.Data.PlantDrops = ['Elderwort biscuits', 'Bakeberry cookies', 'Duketater cookies', 'Green yeast digestives', 'Wheat slims', 'Fern tea', 'Ichor syrup']; /******** * Section: All possible effects plants and other items can have with an explanation */ @@ -60,7 +60,7 @@ CM.Data.Effects = { wrathCookieGain: "Wrath cookie gains", wrinklerEat: "Wrinkler ", wrinklerSpawn: "Wrinkler spawn frequency" -} +}; /******** * Section: Data for the various scales used by CookieMonster */ @@ -77,7 +77,7 @@ CM.Data.shortScaleAbbreviated = ['', 'K', 'M', 'B', 'T', 'Qa', 'Qi', 'Sx', 'Sp', 'USp', 'DSp', 'TSp', 'QaSp', 'QiSp', 'SxSp', 'SpSp', 'OSp', 'NSp', 'Oco', 'UOc', 'DOc', 'TOc', 'QaOc', 'QiOc', 'SxOc', 'SpOc', 'OOc', 'NOc', 'Noa', 'UNo', 'DNo', 'TNo', 'QaNo', 'QiNo', 'SxNo', 'SpNo', 'ONo', 'NNo', 'Ct', -'UCt'] +'UCt']; /******** * Section: Two array's containing all Config groups and their to-be displayed title */ @@ -90,7 +90,7 @@ CM.ConfigGroups = { Statistics: "Statistics", Notation: "Notation", Miscellaneous: "Miscellaneous" -} +}; CM.ConfigGroupsNotification = { NotificationGC: "Golden Cookie", @@ -100,7 +100,7 @@ CM.ConfigGroupsNotification = { NotificationMagi: "Full Magic Bar", NotificationWrink: "Wrinkler", NotificationWrinkMax: "Maximum Wrinklers", -} +}; /******** * Section: An array (CM.ConfigData) containing all Config options and an array of default settings */ diff --git a/src/Disp.js b/src/Disp.js index 85ad53a..f9a9fb9 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -22,7 +22,7 @@ CM.Disp.GetWrinkConfigBank = function() { return CM.Cache.WrinklersFattest[0];} else { return 0;} -} +}; /** * This function pops all normal wrinklers @@ -34,7 +34,7 @@ CM.Disp.PopAllNormalWrinklers = function() { Game.wrinklers[i].hp = 0; } } -} +}; /** * This function returns the cps as either current or average CPS depending on CM.Options.CPSMode @@ -60,7 +60,7 @@ CM.Disp.GetCPS = function() { } } } -} +}; /** * This function calculates the time it takes to reach a certain magic level @@ -77,7 +77,7 @@ CM.Disp.CalculateGrimoireRefillTime = function(currentMagic, maxMagic, targetMag count++; } return count / Game.fps; -} +}; /** * This function returns Name and Color as object for sugar lump type that is given as input param. @@ -154,7 +154,7 @@ CM.Disp.FormatTime = function(time, longFormat) { str += s + (longFormat ? (s == 1 ? ' second' : ' seconds') : 's'); } return str; -} +}; /** * This function returns the color to be used for time-strings @@ -176,7 +176,7 @@ CM.Disp.GetTimeColor = function(time) { else color = CM.Disp.colorYellow; } return {text: text, color: color}; -} +}; /** * This function returns formats number based on the Scale setting @@ -193,13 +193,13 @@ CM.Disp.Beautify = function(num, floats, forced) { else if (isFinite(num)) { var answer = ''; if (num == 0) { - return num.toString() + return num.toString(); } else if (0.001 < num && num < CM.Options.ScaleCutoff) { answer = num.toFixed(2); if (CM.Options.ScaleSeparator) answer = answer.toLocaleString('nl'); for (let i = 0; i < 3; i++) { - if (answer[answer.length - 1] == "0" | answer[answer.length - 1] == ".") answer = answer.slice(0, -1) + if (answer[answer.length - 1] == "0" || answer[answer.length - 1] == ".") answer = answer.slice(0, -1); } return answer; } @@ -209,11 +209,11 @@ CM.Disp.Beautify = function(num, floats, forced) { else { exponential = num.toExponential().toString(); AmountOfTenPowerThree = Math.floor(exponential.slice(exponential.indexOf("e") + 1) / 3); - answer = (num / Number("1e" + (AmountOfTenPowerThree * 3))).toFixed(decimals) + answer = (num / Number("1e" + (AmountOfTenPowerThree * 3))).toFixed(decimals); // answer is now "xxx.xx" (e.g., 123456789 would be 123.46) if (CM.Options.Scale == 1 && !forced || forced == 1) { // Metric scale, 123456789 => 123.457 M if (num >= 0.01 && num < Number("1e" + CM.Data.metric.length * 3)) { - answer += ' ' + CM.Data.metric[AmountOfTenPowerThree] + answer += ' ' + CM.Data.metric[AmountOfTenPowerThree]; } // If number is too large or little, revert to scientific notation else answer = CM.Disp.Beautify(num, 0, 4); @@ -250,7 +250,7 @@ CM.Disp.Beautify = function(num, floats, forced) { console.log("Could not beautify number with CM.Disp.Beautify:" + num); return CM.Backup.Beautify(num, floats); } -} +}; /******** * Section: General functions related to display, drawing and initialization of the page */ @@ -270,7 +270,7 @@ CM.Disp.UpdateAscendState = function() { CM.Disp.ToggleTimerBar(); } CM.Disp.UpdateBackground(); -} +}; /** * This function creates a CSS style that stores certain standard CSS classes used by CookieMonster @@ -281,7 +281,7 @@ CM.Disp.CreateCssArea = function() { CM.Disp.Css.type = 'text/css'; document.head.appendChild(CM.Disp.Css); -} +}; /** * This function sets the size of the background of the full game and the left column @@ -293,7 +293,7 @@ CM.Disp.UpdateBackground = function() { Game.Background.canvas.height = Game.Background.canvas.parentNode.offsetHeight; Game.LeftBackground.canvas.width = Game.LeftBackground.canvas.parentNode.offsetWidth; Game.LeftBackground.canvas.height = Game.LeftBackground.canvas.parentNode.offsetHeight; -} +}; /** * This function handles custom drawing for the Game.Draw() function. @@ -310,7 +310,7 @@ CM.Disp.Draw = function () { timer.innerText = Game.sayTime(Game.fps * 60 - (Game.T % (Game.fps * 60)), 4); } } -} +}; /******** * Section: Functions related to the Bottom Bar */ @@ -328,7 +328,7 @@ CM.Disp.ToggleBotBar = function() { CM.Disp.BotBar.style.display = 'none'; } CM.Disp.UpdateBotTimerBarPosition(); -} +}; /** * This function creates the bottom bar and appends it to l('wrapper') @@ -379,7 +379,7 @@ CM.Disp.CreateBotBar = function() { } l('wrapper').appendChild(CM.Disp.BotBar); -} +}; /** * This function updates the bonus-, pp-, and time-rows in the the bottom bar @@ -405,7 +405,7 @@ CM.Disp.UpdateBotBar = function() { else CM.Disp.BotBar.firstChild.firstChild.childNodes[3].childNodes[count].textContent = timeColor.text; } } -} +}; /** * This function extends the bottom bar (created by CM.Disp.CreateBotBar) with a column for the given building. @@ -435,7 +435,7 @@ CM.Disp.CreateBotBarBuildingColumn = function(buildingName) { bonus.appendChild(document.createElement('td')); pp.appendChild(document.createElement('td')); time.appendChild(document.createElement('td')); -} +}; /******** * Section: Functions related to the Timer Bar @@ -458,21 +458,21 @@ CM.Disp.CreateTimerBar = function() { CM.Disp.BuffTimerBars = {}; // Create standard Golden Cookie bar - CM.Disp.TimerBars['CMTimerBarGC'] = CM.Disp.TimerBarCreateBar('CMTimerBarGC', + CM.Disp.TimerBars.CMTimerBarGC = CM.Disp.TimerBarCreateBar('CMTimerBarGC', 'Next Cookie', [{id: 'CMTimerBarGCMinBar', color: CM.Disp.colorGray}, {id: 'CMTimerBarGCBar', color: CM.Disp.colorPurple}] ); - CM.Disp.TimerBar.appendChild(CM.Disp.TimerBars['CMTimerBarGC']) + CM.Disp.TimerBar.appendChild(CM.Disp.TimerBars.CMTimerBarGC) // Create standard Reindeer bar - CM.Disp.TimerBars['CMTimerBarRen'] = CM.Disp.TimerBarCreateBar('CMTimerBarRen', + CM.Disp.TimerBars. CMTimerBarRen = CM.Disp.TimerBarCreateBar('CMTimerBarRen', 'Next Reindeer', [{id: 'CMTimerBarRenMinBar', color: CM.Disp.colorGray}, {id: 'CMTimerBarRenBar', color: CM.Disp.colorOrange}] ); - CM.Disp.TimerBar.appendChild(CM.Disp.TimerBars['CMTimerBarRen']) + CM.Disp.TimerBar.appendChild(CM.Disp.TimerBars. CMTimerBarRen) l('wrapper').appendChild(CM.Disp.TimerBar); -} +}; /** * This function creates an indivudual timer for the timer bar @@ -534,7 +534,7 @@ CM.Disp.TimerBarCreateBar = function(id, name, bars) { timerBar.appendChild(div); return timerBar; -} +}; /** * This function updates indivudual timers in the timer bar @@ -549,12 +549,12 @@ CM.Disp.UpdateTimerBar = function() { var numberOfTimers = 0; // Regulates visibility of Golden Cookie timer - if (Game.shimmerTypes['golden'].spawned == 0 && !Game.Has('Golden switch [off]')) { - CM.Disp.TimerBars['CMTimerBarGC'].style.display = ''; - l('CMTimerBarGCMinBar').style.width = Math.round(Math.max(0, Game.shimmerTypes['golden'].minTime - Game.shimmerTypes['golden'].time) * maxWidthTwoBar / Game.shimmerTypes['golden'].maxTime) + 'px'; - if (CM.Options.TimerBarOverlay >= 1) l('CMTimerBarGCMinBar').textContent = Math.ceil((Game.shimmerTypes['golden'].minTime - Game.shimmerTypes['golden'].time)/ Game.fps) + if (Game.shimmerTypes.golden.spawned == 0 && !Game.Has('Golden switch [off]')) { + CM.Disp.TimerBars.CMTimerBarGC.style.display = ''; + l('CMTimerBarGCMinBar').style.width = Math.round(Math.max(0, Game.shimmerTypes.golden.minTime - Game.shimmerTypes.golden.time) * maxWidthTwoBar / Game.shimmerTypes.golden.maxTime) + 'px'; + if (CM.Options.TimerBarOverlay >= 1) l('CMTimerBarGCMinBar').textContent = Math.ceil((Game.shimmerTypes.golden.minTime - Game.shimmerTypes.golden.time)/ Game.fps); else l('CMTimerBarGCMinBar').textContent = ""; - if (Game.shimmerTypes['golden'].minTime == Game.shimmerTypes['golden'].maxTime) { + if (Game.shimmerTypes.golden.minTime == Game.shimmerTypes.golden.maxTime) { l('CMTimerBarGCMinBar').style.borderTopRightRadius = '10px'; l('CMTimerBarGCMinBar').style.borderBottomRightRadius = '10px'; } @@ -562,38 +562,38 @@ CM.Disp.UpdateTimerBar = function() { l('CMTimerBarGCMinBar').style.borderTopRightRadius = ''; l('CMTimerBarGCMinBar').style.borderBottomRightRadius = ''; } - l('CMTimerBarGCBar').style.width = Math.round(Math.min(Game.shimmerTypes['golden'].maxTime - Game.shimmerTypes['golden'].minTime, Game.shimmerTypes['golden'].maxTime - Game.shimmerTypes['golden'].time) * maxWidthTwoBar / Game.shimmerTypes['golden'].maxTime) + 'px'; - if (CM.Options.TimerBarOverlay >= 1) l('CMTimerBarGCBar').textContent = Math.ceil(Math.min(Game.shimmerTypes['golden'].maxTime - Game.shimmerTypes['golden'].minTime, Game.shimmerTypes['golden'].maxTime - Game.shimmerTypes['golden'].time) / Game.fps); + l('CMTimerBarGCBar').style.width = Math.round(Math.min(Game.shimmerTypes.golden.maxTime - Game.shimmerTypes.golden.minTime, Game.shimmerTypes.golden.maxTime - Game.shimmerTypes.golden.time) * maxWidthTwoBar / Game.shimmerTypes.golden.maxTime) + 'px'; + if (CM.Options.TimerBarOverlay >= 1) l('CMTimerBarGCBar').textContent = Math.ceil(Math.min(Game.shimmerTypes.golden.maxTime - Game.shimmerTypes.golden.minTime, Game.shimmerTypes.golden.maxTime - Game.shimmerTypes.golden.time) / Game.fps); else l('CMTimerBarGCBar').textContent = ""; - l('CMTimerBarGCTime').textContent = Math.ceil((Game.shimmerTypes['golden'].maxTime - Game.shimmerTypes['golden'].time) / Game.fps); + l('CMTimerBarGCTime').textContent = Math.ceil((Game.shimmerTypes.golden.maxTime - Game.shimmerTypes.golden.time) / Game.fps); numberOfTimers++; } - else CM.Disp.TimerBars['CMTimerBarGC'].style.display = 'none'; + else CM.Disp.TimerBars.CMTimerBarGC.style.display = 'none'; // Regulates visibility of Reindeer timer - if (Game.season == 'christmas' && Game.shimmerTypes['reindeer'].spawned == 0) { - CM.Disp.TimerBars['CMTimerBarRen'].style.display = ''; - l('CMTimerBarRenMinBar').style.width = Math.round(Math.max(0, Game.shimmerTypes['reindeer'].minTime - Game.shimmerTypes['reindeer'].time) * maxWidthTwoBar / Game.shimmerTypes['reindeer'].maxTime) + 'px'; - if (CM.Options.TimerBarOverlay >= 1) l('CMTimerBarRenMinBar').textContent = Math.ceil((Game.shimmerTypes['reindeer'].minTime - Game.shimmerTypes['reindeer'].time)/ Game.fps) + if (Game.season == 'christmas' && Game.shimmerTypes.reindeer.spawned == 0) { + CM.Disp.TimerBars. CMTimerBarRen.style.display = ''; + l('CMTimerBarRenMinBar').style.width = Math.round(Math.max(0, Game.shimmerTypes.reindeer.minTime - Game.shimmerTypes.reindeer.time) * maxWidthTwoBar / Game.shimmerTypes.reindeer.maxTime) + 'px'; + if (CM.Options.TimerBarOverlay >= 1) l('CMTimerBarRenMinBar').textContent = Math.ceil((Game.shimmerTypes.reindeer.minTime - Game.shimmerTypes.reindeer.time)/ Game.fps); else l('CMTimerBarRenMinBar').textContent = ""; - l('CMTimerBarRenBar').style.width = Math.round(Math.min(Game.shimmerTypes['reindeer'].maxTime - Game.shimmerTypes['reindeer'].minTime, Game.shimmerTypes['reindeer'].maxTime - Game.shimmerTypes['reindeer'].time) * maxWidthTwoBar / Game.shimmerTypes['reindeer'].maxTime) + 'px'; - if (CM.Options.TimerBarOverlay >= 1) l('CMTimerBarRenBar').textContent = Math.ceil(Math.min(Game.shimmerTypes['reindeer'].maxTime - Game.shimmerTypes['reindeer'].minTime, Game.shimmerTypes['reindeer'].maxTime - Game.shimmerTypes['reindeer'].time) / Game.fps); + l('CMTimerBarRenBar').style.width = Math.round(Math.min(Game.shimmerTypes.reindeer.maxTime - Game.shimmerTypes.reindeer.minTime, Game.shimmerTypes.reindeer.maxTime - Game.shimmerTypes.reindeer.time) * maxWidthTwoBar / Game.shimmerTypes.reindeer.maxTime) + 'px'; + if (CM.Options.TimerBarOverlay >= 1) l('CMTimerBarRenBar').textContent = Math.ceil(Math.min(Game.shimmerTypes.reindeer.maxTime - Game.shimmerTypes.reindeer.minTime, Game.shimmerTypes.reindeer.maxTime - Game.shimmerTypes.reindeer.time) / Game.fps); else l('CMTimerBarRenBar').textContent = ""; - l('CMTimerBarRenTime').textContent = Math.ceil((Game.shimmerTypes['reindeer'].maxTime - Game.shimmerTypes['reindeer'].time) / Game.fps); + l('CMTimerBarRenTime').textContent = Math.ceil((Game.shimmerTypes.reindeer.maxTime - Game.shimmerTypes.reindeer.time) / Game.fps); numberOfTimers++; } else { - CM.Disp.TimerBars['CMTimerBarRen'].style.display = 'none'; + CM.Disp.TimerBars. CMTimerBarRen.style.display = 'none'; } // On every frame all buff-timers are deleted and re-created for (var i in CM.Disp.BuffTimerBars) { - CM.Disp.BuffTimerBars[i].remove() + CM.Disp.BuffTimerBars[i].remove(); } CM.Disp.BuffTimerBars = {} for (var i in Game.buffs) { if (Game.buffs[i]) { - timer = CM.Disp.TimerBarCreateBar(Game.buffs[i].name, Game.buffs[i].name, [{id: Game.buffs[i].name + 'Bar'}]) + timer = CM.Disp.TimerBarCreateBar(Game.buffs[i].name, Game.buffs[i].name, [{id: Game.buffs[i].name + 'Bar'}]); timer.style.display = ''; var classColor = ''; // Gives specific timers specific colors @@ -612,7 +612,7 @@ CM.Disp.UpdateTimerBar = function() { } } for (var i in CM.Disp.BuffTimerBars) { - CM.Disp.TimerBar.appendChild(CM.Disp.BuffTimerBars[i]) + CM.Disp.TimerBar.appendChild(CM.Disp.BuffTimerBars[i]); } if (numberOfTimers != 0) { @@ -623,7 +623,7 @@ CM.Disp.UpdateTimerBar = function() { CM.Disp.UpdateBotTimerBarPosition(); } } -} +}; /** * This function changes the visibility of the timer bar @@ -633,7 +633,7 @@ CM.Disp.ToggleTimerBar = function() { if (CM.Options.TimerBar == 1) CM.Disp.TimerBar.style.display = ''; else CM.Disp.TimerBar.style.display = 'none'; CM.Disp.UpdateBotTimerBarPosition(); -} +}; /** * This function changes the position of the timer bar @@ -651,7 +651,7 @@ CM.Disp.ToggleTimerBarPos = function() { l('wrapper').appendChild(CM.Disp.TimerBar); } CM.Disp.UpdateBotTimerBarPosition(); -} +}; /******** * Section: Functions related to the both the bottom and timer bar @@ -684,7 +684,7 @@ CM.Disp.UpdateBotTimerBarPosition = function() { } CM.Disp.UpdateBackground(); -} +}; /******** * Section: Functions related to right column of the screen (buildings/upgrades) @@ -757,7 +757,7 @@ CM.Disp.UpdateBuildings = function() { Game.Objects[arr[x].name].l.style.gridRow = (x + 2) + "/" + (x + 2); } } -} +}; /** * This function adjusts some things in the upgrades section @@ -822,15 +822,17 @@ CM.Disp.UpdateUpgrades = function() { arr.push(o); } - if (CM.Options.SortUpgrades) + if (CM.Options.SortUpgrades) { arr.sort((a, b) => a.pp - b.pp); - else + } + else { arr.sort((a, b) => a.price - b.price); - + } + for (var x = 0; x < Game.UpgradesInStore.length; x++){ l("upgrade" + x).style.order = arr.findIndex(e => e.name === Game.UpgradesInStore[x].name) + 1 } -} +}; /******** * Section: Functions related to the Upgrade Bar @@ -852,7 +854,7 @@ CM.Disp.ToggleUpgradeBarAndColor = function() { CM.Disp.UpgradeBar.style.display = 'none'; Game.RebuildUpgrades(); } -} +}; /** * This function toggles the position of the upgrade bar from fixed or non-fixed mode @@ -866,7 +868,7 @@ CM.Disp.ToggleUpgradeBarFixedPos = function() { else { CM.Disp.UpgradeBar.style.position = ''; // Possible to scroll offscreen } -} +}; /** * This function creates the upgrade bar above the upgrade-section in the right section of the screen @@ -905,7 +907,7 @@ CM.Disp.CreateUpgradeBar = function() { CM.Disp.UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarGray', CM.Disp.colorGray)); l('upgrades').parentNode.insertBefore(CM.Disp.UpgradeBar, l('upgrades').parentNode.childNodes[3]); -} +}; /** * This function creates the legend for the upgrade bar, it is called by CM.Disp.CreateUpgradeBar @@ -943,7 +945,7 @@ CM.Disp.CreateUpgradeBarLegend = function() { legend.appendChild(legendLine(CM.Disp.colorPurple, 'Worse than worst PP building')); legend.appendChild(legendLine(CM.Disp.colorGray, 'Negative or infinity PP')); return legend; -} +}; /******** * Section: Functions related to the flashes/sound/notifications @@ -962,7 +964,7 @@ CM.Disp.CreateWhiteScreen = function() { CM.Disp.WhiteScreen.style.zIndex = '9999999999'; CM.Disp.WhiteScreen.style.position = 'absolute'; l('wrapper').appendChild(CM.Disp.WhiteScreen); -} +}; /** * This function creates a flash depending on configs. It is called by all functions @@ -988,7 +990,7 @@ CM.Disp.Flash = function(mode, config) { setTimeout(function() {CM.Disp.Flash(1, config);}, 1000/Game.fps); } else if (mode == 0) CM.Disp.WhiteScreen.style.display = 'none'; -} +}; /** * This function plays a sound depending on configs. It is called by all functions @@ -1004,7 +1006,7 @@ CM.Disp.PlaySound = function(url, sndConfig, volConfig) { sound.volume = (CM.Options[volConfig] / 100) * (Game.volume / 100); sound.play(); } -} +}; /** * This function creates a notifcation depending on configs. It is called by all functions @@ -1016,10 +1018,10 @@ CM.Disp.PlaySound = function(url, sndConfig, volConfig) { CM.Disp.Notification = function(notifyConfig, title, message) { // The arguments check makes the sound not play upon initialization of the mod if (CM.Options[notifyConfig] == 1 && document.visibilityState == 'hidden' && arguments.callee.caller.caller.caller.caller == null) { - var CookieIcon = 'https://orteil.dashnet.org/cookieclicker/favicon.ico' + var CookieIcon = 'https://orteil.dashnet.org/cookieclicker/favicon.ico'; notification = new Notification(title, {body: message, badge: CookieIcon}); } -} +}; /******** * Section: Functions related to updating the tab in the browser's tab-bar @@ -1033,7 +1035,7 @@ CM.Disp.CreateFavicon = function() { CM.Disp.Favicon.rel = 'shortcut icon'; CM.Disp.Favicon.href = 'https://orteil.dashnet.org/cookieclicker/favicon.ico'; document.getElementsByTagName('head')[0].appendChild(CM.Disp.Favicon); -} +}; /** * This function updates the Favicon depending on whether a Golden Cookie has spawned @@ -1046,7 +1048,7 @@ CM.Disp.UpdateFavicon = function() { else CM.Disp.Favicon.href = 'https://aktanusa.github.io/CookieMonster/favicon/goldenCookie.ico'; } else CM.Disp.Favicon.href = 'https://orteil.dashnet.org/cookieclicker/favicon.ico'; -} +}; /** * This function updates the tab title @@ -1068,9 +1070,9 @@ CM.Disp.UpdateTitle = function() { else titleGC = '[G ' + Math.ceil(CM.Cache.spawnedGoldenShimmer.life / Game.fps) + ']'; } else if (!Game.Has('Golden switch [off]')) { - titleGC = '[' + Math.ceil((Game.shimmerTypes['golden'].maxTime - Game.shimmerTypes['golden'].time) / Game.fps) + ']'; + titleGC = '[' + Math.ceil((Game.shimmerTypes.golden.maxTime - Game.shimmerTypes.golden.time) / Game.fps) + ']'; } - else titleGC = '[GS]' + else titleGC = '[GS]'; if (CM.Main.lastTickerFortuneState) { addFC = true; @@ -1081,7 +1083,7 @@ CM.Disp.UpdateTitle = function() { addSP = true; if (CM.Main.lastSeasonPopupState) titleSP = '[R ' + Math.ceil(CM.Cache.seasonPopShimmer.life / Game.fps) + ']'; else { - titleSP = '[' + Math.ceil((Game.shimmerTypes['reindeer'].maxTime - Game.shimmerTypes['reindeer'].time) / Game.fps) + ']'; + titleSP = '[' + Math.ceil((Game.shimmerTypes.reindeer.maxTime - Game.shimmerTypes.reindeer.time) / Game.fps) + ']'; } } @@ -1114,7 +1116,7 @@ CM.Disp.UpdateTitle = function() { str += title; document.title = str; } -} +}; /******** * Section: Functions related to the Golden Cookie Timers @@ -1126,7 +1128,7 @@ CM.Disp.UpdateTitle = function() { */ CM.Disp.CreateGCTimer = function(cookie) { GCTimer = document.createElement('div'); - GCTimer.id = 'GCTimer' + cookie.id + GCTimer.id = 'GCTimer' + cookie.id; GCTimer.style.width = '96px'; GCTimer.style.height = '96px'; GCTimer.style.position = 'absolute'; @@ -1146,7 +1148,7 @@ CM.Disp.CreateGCTimer = function(cookie) { CM.Disp.GCTimers[cookie.id] = GCTimer; l('shimmers').appendChild(GCTimer); -} +}; /** * This function toggles GC Timers are visible @@ -1163,7 +1165,7 @@ CM.Disp.ToggleGCTimer = function() { else { for (var i in CM.Disp.GCTimers) CM.Disp.GCTimers[i].style.display = 'none'; } -} +}; /******** * Section: Functions related to Tooltips @@ -1186,7 +1188,7 @@ CM.Disp.CreateSimpleTooltip = function(placeholder, text, minWidth) { div.textContent = text; desc.appendChild(div); CM.Disp[placeholder].appendChild(desc); -} +}; /** * This function replaces the original .onmouseover functions of upgrades so that it calls CM.Disp.Tooltip() @@ -1202,7 +1204,7 @@ CM.Disp.ReplaceTooltipUpgrade = function() { eval('l(\'upgrade\' + i).onmouseover = function() {if (!Game.mouseDown) {Game.setOnCrate(this); Game.tooltip.dynamic = 1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip(\'u\', \'' + i + '\');}, \'store\'); Game.tooltip.wobble();}}'); } } -} +}; /** * This function enhance the standard tooltips by creating and changing l('tooltip') @@ -1221,7 +1223,7 @@ CM.Disp.Tooltip = function(type, name) { if (amortizeAmount > 0) { l('tooltip').innerHTML = l('tooltip').innerHTML .split('so far') - .join('so far
' + Beautify(amortizeAmount) + ' ' + (Math.floor(amortizeAmount) == 1 ? 'cookie' : 'cookies') + ' left to amortize (' + CM.Disp.GetTimeColor((buildPrice - Game.Objects[name].totalCookies) / (Game.Objects[name].storedTotalCps * Game.globalCpsMult)).text + ')'); + .join('so far
' + Beautify(amortizeAmount) + ' ' + (Math.floor(amortizeAmount) == 1 ? 'cookie' : 'cookies') + ' left to amortize (' + CM.Disp.GetTimeColor((buildPrice - Game.Objects[name].totalCookies) / (Game.Objects[name].storedTotalCps * Game.globalCpsMult)).text + ')') } } if (Game.buyMode == -1) { @@ -1259,7 +1261,7 @@ CM.Disp.Tooltip = function(type, name) { CM.Disp.UpdateTooltip(); return l('tooltip').innerHTML; -} +}; /** * This function creates a tooltipBox object which contains all CookieMonster added tooltip information. @@ -1274,8 +1276,8 @@ CM.Disp.TooltipCreateTooltipBox = function() { tooltipBox.style.margin = '0px -4px'; tooltipBox.id = 'CMTooltipBorder'; tooltipBox.className = CM.Disp.colorTextPre + CM.Disp.colorGray; - return tooltipBox -} + return tooltipBox; +}; /** * This function creates a header object for tooltips. @@ -1289,7 +1291,7 @@ CM.Disp.TooltipCreateHeader = function(text) { div.className = CM.Disp.colorTextPre + CM.Disp.colorBlue; div.textContent = text; return div; -} +}; /** * This function appends the sections for Bonus Income, PP and Time left (to achiev) to the tooltip-object @@ -1332,7 +1334,7 @@ CM.Disp.TooltipCreateCalculationSection = function(tooltip) { production.id = 'CMTooltipProduction'; tooltip.appendChild(production); } -} +}; /** * This function creates the tooltip objectm for warnings @@ -1371,7 +1373,8 @@ CM.Disp.TooltipCreateWarningSection = function() { deficitDiv.appendChild(document.createTextNode('Deficit: ')); deficitDiv.appendChild(deficitSpan); return box; - } + }; + CM.Disp.TooltipWarn.appendChild(create('CMDispTooltipWarnLucky', CM.Disp.colorRed, 'Warning: ', 'Purchase of this item will put you under the number of Cookies required for "Lucky!"', 'CMDispTooltipWarnLuckyText')); CM.Disp.TooltipWarn.firstChild.style.marginBottom = '4px'; CM.Disp.TooltipWarn.appendChild(create('CMDispTooltipWarnLuckyFrenzy', CM.Disp.colorYellow, 'Warning: ', 'Purchase of this item will put you under the number of Cookies required for "Lucky!" (Frenzy)', 'CMDispTooltipWarnLuckyFrenzyText')); @@ -1383,7 +1386,7 @@ CM.Disp.TooltipCreateWarningSection = function() { CM.Disp.TooltipWarn.appendChild(create('CMDispTooltipWarnEdifice', CM.Disp.colorPurple, 'Warning: ', 'Purchase of this item will put you under the number of Cookies needed for "Spontaneous Edifice" to possibly give you your most expensive building"', 'CMDispTooltipWarnEdificeText')); return CM.Disp.TooltipWarn; -} +}; /** * This function updates the sections of the tooltips created by CookieMonster @@ -1421,7 +1424,7 @@ CM.Disp.UpdateTooltip = function() { l('CMDispTooltipWarningParent').remove(); } } -} +}; /** * This function adds extra info to the Building tooltips @@ -1435,11 +1438,11 @@ CM.Disp.UpdateTooltipBuilding = function() { var target = ''; // TODO: Change the Cache code and variables to use Objects1, Objectes10, Objects100 // That would depreciate this target setting code - if (Game.buyMode == 1 && Game.buyBulk == 10) target = 'Objects10' + if (Game.buyMode == 1 && Game.buyBulk == 10) target = 'Objects10'; else if (Game.buyMode == 1 && Game.buyBulk == 100) target = 'Objects100'; else target = 'Objects'; - 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; @@ -1464,8 +1467,8 @@ CM.Disp.UpdateTooltipBuilding = function() { // Add "production left till next achievement"-bar for (var i in Game.Objects[CM.Disp.tooltipName].productionAchievs) { if (!CM.Sim.HasAchiev(Game.Objects[CM.Disp.tooltipName].productionAchievs[i].achiev.name)) { - var nextProductionAchiev = Game.Objects[CM.Disp.tooltipName].productionAchievs[i] - break + var nextProductionAchiev = Game.Objects[CM.Disp.tooltipName].productionAchievs[i]; + break; } } if (typeof nextProductionAchiev != "undefined") { @@ -1480,7 +1483,7 @@ CM.Disp.UpdateTooltipBuilding = function() { } } else l('CMTooltipArea').style.display = "none"; -} +}; /** * This function adds extra info to the Upgrade tooltips @@ -1492,7 +1495,7 @@ CM.Disp.UpdateTooltipUpgrade = function() { CM.Disp.TooltipBonusIncome = CM.Cache.Upgrades[Game.UpgradesInStore[CM.Disp.tooltipName].name].bonus; CM.Disp.TooltipPrice = Game.Upgrades[Game.UpgradesInStore[CM.Disp.tooltipName].name].getPrice(); - CM.Disp.TooltipBonusMouse = CM.Cache.Upgrades[Game.UpgradesInStore[CM.Disp.tooltipName].name].bonusMouse + CM.Disp.TooltipBonusMouse = CM.Cache.Upgrades[Game.UpgradesInStore[CM.Disp.tooltipName].name].bonusMouse; if (CM.Options.TooltipBuildUpgrade == 1) { l('CMTooltipIncome').textContent = Beautify(CM.Disp.TooltipBonusIncome, 2); @@ -1503,13 +1506,13 @@ CM.Disp.UpdateTooltipUpgrade = function() { l('CMTooltipBorder').className = CM.Disp.colorTextPre + CM.Cache.Upgrades[Game.UpgradesInStore[CM.Disp.tooltipName].name].color; // If clicking power upgrade if (CM.Disp.TooltipBonusMouse) { - l('CMTooltipCookiePerClick').textContent = Beautify(CM.Disp.TooltipBonusMouse) + l('CMTooltipCookiePerClick').textContent = Beautify(CM.Disp.TooltipBonusMouse); l('CMTooltipCookiePerClick').style.display = "block"; l('CMTooltipCookiePerClick').previousSibling.style.display = "block"; } // If only a clicking power upgrade change PP to click-based period if (CM.Disp.TooltipBonusIncome == 0 && CM.Disp.TooltipBonusMouse) { - l('CMTooltipPP').textContent = Beautify(CM.Disp.TooltipPrice / CM.Disp.TooltipBonusMouse) + ' Clicks' + l('CMTooltipPP').textContent = Beautify(CM.Disp.TooltipPrice / CM.Disp.TooltipBonusMouse) + ' Clicks'; l('CMTooltipPP').style.color = "white"; } else { @@ -1535,7 +1538,7 @@ CM.Disp.UpdateTooltipUpgrade = function() { } } else l('CMTooltipArea').style.display = "none"; -} +}; /** * This function adds extra info to the Sugar Lump tooltip @@ -1556,7 +1559,7 @@ CM.Disp.UpdateTooltipSugarLump = function() { lumpType.className = CM.Disp.colorTextPre + lumpColor.color; } else l('CMTooltipArea').style.display = "none"; -} +}; /** * This function adds extra info to the Grimoire tooltips @@ -1597,22 +1600,22 @@ CM.Disp.UpdateTooltipGrimoire = function() { conjure.id = 'CMTooltipConjure'; tooltipBox.appendChild(conjure); var reward = document.createElement('span'); - reward.style.color = "#33FF00" - reward.textContent = Beautify(Math.min((Game.cookies + CM.Disp.GetWrinkConfigBank()) * 0.15, CM.Cache.NoGoldSwitchCookiesPS * 60 * 30), 2) - conjure.appendChild(reward) + reward.style.color = "#33FF00"; + reward.textContent = Beautify(Math.min((Game.cookies + CM.Disp.GetWrinkConfigBank()) * 0.15, CM.Cache.NoGoldSwitchCookiesPS * 60 * 30), 2); + conjure.appendChild(reward); var seperator = document.createElement('span'); - seperator.textContent = ' / ' - conjure.appendChild(seperator) + seperator.textContent = ' / '; + conjure.appendChild(seperator); var loss = document.createElement('span'); - loss.style.color = "red" + loss.style.color = "red"; loss.textContent = Beautify((CM.Cache.NoGoldSwitchCookiesPS * 60 * 15), 2); - conjure.appendChild(loss) + conjure.appendChild(loss); } l('CMTooltipArea').appendChild(tooltipBox); } else l('CMTooltipArea').style.display = "none"; -} +}; /** * This function adds extra info to the Garden plots tooltips @@ -1620,7 +1623,7 @@ CM.Disp.UpdateTooltipGrimoire = function() { * It adds to the additional information to l('CMTooltipArea') */ CM.Disp.UpdateTooltipGardenPlots = function() { - var minigame = Game.Objects['Farm'].minigame; + var minigame = Game.Objects.Farm.minigame; if (CM.Options.TooltipLump && minigame.plot[CM.Disp.tooltipName[1]][CM.Disp.tooltipName[0]][0] != 0) { var mature = minigame.plot[CM.Disp.tooltipName[1]][CM.Disp.tooltipName[0]][1] > minigame.plantsById[minigame.plot[CM.Disp.tooltipName[1]][CM.Disp.tooltipName[0]][0] - 1].matureBase; var plantName = minigame.plantsById[minigame.plot[CM.Disp.tooltipName[1]][CM.Disp.tooltipName[0]][0] - 1].name; @@ -1643,7 +1646,7 @@ CM.Disp.UpdateTooltipGardenPlots = function() { else l('CMTooltipArea').style.display = "none"; } else l('CMTooltipArea').style.display = "none"; -} +}; /** * This function adds extra info to the Garden Harvest All tooltip @@ -1651,7 +1654,7 @@ CM.Disp.UpdateTooltipGardenPlots = function() { * It adds to the additional information to l('CMTooltipArea') */ CM.Disp.UpdateTooltipHarvestAll = function() { - var minigame = Game.Objects['Farm'].minigame; + var minigame = Game.Objects.Farm.minigame; if (CM.Options.TooltipLump) { l('CMTooltipBorder').appendChild(CM.Disp.TooltipCreateHeader('Cookies gained from harvesting:')); var totalGain = 0; @@ -1661,7 +1664,7 @@ CM.Disp.UpdateTooltipHarvestAll = function() { if (minigame.plot[y][x][0]>=1) { let tile = minigame.plot[y][x]; let me = minigame.plantsById[tile[0] - 1]; - let plantName = me.name + let plantName = me.name; let count = true; if (mortal && me.immortal) count = false; @@ -1684,7 +1687,7 @@ CM.Disp.UpdateTooltipHarvestAll = function() { l('CMTooltipBorder').appendChild(document.createTextNode(CM.Disp.Beautify(totalGain))); } else l('CMTooltipArea').style.display = "none"; -} +}; /** * This function updates the warnings section of the building and upgrade tooltips @@ -1759,7 +1762,7 @@ CM.Disp.UpdateTooltipWarnings = function() { l('CMDispTooltipWarningParent').remove(); } } -} +}; /** * This function updates the location of the tooltip @@ -1777,7 +1780,7 @@ CM.Disp.UpdateTooltipLocation = function() { /*else if (!Game.onCrate && !Game.OnAscend && CM.Options.TimerBar == 1 && CM.Options.TimerBarPos == 0) { Game.tooltip.tta.style.top = (parseInt(Game.tooltip.tta.style.top) + parseInt(CM.Disp.TimerBar.style.height)) + 'px'; }*/ -} +}; /** * This function toggles the position of the warnings created by CM.Disp.TooltipCreateWarningSection() @@ -1797,7 +1800,7 @@ CM.Disp.ToggleToolWarnPos = function() { CM.Disp.TooltipWarn.style.padding = '4px 3px'; } } -} +}; /** * This function checks and create a tooltip for the wrinklers @@ -1835,7 +1838,7 @@ CM.Disp.CheckWrinklerTooltip = function() { Game.tooltip.hide(); } } -} +}; /** * This function updates the amount to be displayed by the wrinkler tooltip created by CM.Disp.CheckWrinklerTooltip() @@ -1858,7 +1861,7 @@ CM.Disp.UpdateWrinklerTooltip = function() { } l('CMTooltipWrinkler').textContent = Beautify(sucked); } -} +}; /******** * Section: Functions related to the Dragon */ @@ -1875,9 +1878,9 @@ CM.Disp.AddAuraInfo = function(aura) { var bonusCPSPercentage = CM.Disp.Beautify(bonusCPS / Game.cookiesPs); bonusCPS = CM.Disp.Beautify(bonusCPS); - l('dragonAuraInfo').style.minHeight = "60px" - l('dragonAuraInfo').style.margin = "8px" - l('dragonAuraInfo').appendChild(document.createElement("div")).className = "line" + l('dragonAuraInfo').style.minHeight = "60px"; + l('dragonAuraInfo').style.margin = "8px"; + l('dragonAuraInfo').appendChild(document.createElement("div")).className = "line"; var div = document.createElement("div"); div.style.minWidth = "200px"; div.style.textAlign = "center"; @@ -1889,7 +1892,7 @@ CM.Disp.AddAuraInfo = function(aura) { div2.textContent = "It will take " + timeToRecover + " to recover the cost."; l('dragonAuraInfo').appendChild(div2); } -} +}; /** * This functions adds a tooltip to the level up button displaying the cost of rebuying all @@ -1900,12 +1903,12 @@ CM.Disp.AddDragonLevelUpTooltip = function() { if ((l('specialPopup').className.match(/onScreen/) && l('specialPopup').children[0].style.background.match(/dragon/)) != null) { for (let i = 0; i < l('specialPopup').childNodes.length; i++) { if (l('specialPopup').childNodes[i].className == "optionBox") { - l('specialPopup').children[i].onmouseover = function() {CM.Cache.CacheDragonCost(); Game.tooltip.dynamic = 1; Game.tooltip.draw(l('specialPopup'), `
${CM.Cache.CostDragonUpgrade}
`, 'this'); Game.tooltip.wobble();} - l('specialPopup').children[i].onmouseout = function() {Game.tooltip.shouldHide = 1;} + l('specialPopup').children[i].onmouseover = function() {CM.Cache.CacheDragonCost(); Game.tooltip.dynamic = 1; Game.tooltip.draw(l('specialPopup'), `
${CM.Cache.CostDragonUpgrade}
`, 'this'); Game.tooltip.wobble();}; + l('specialPopup').children[i].onmouseout = function() {Game.tooltip.shouldHide = 1;}; } } } -} +}; /******** * Section: General functions related to the Options/Stats pages @@ -1920,7 +1923,7 @@ CM.Disp.AddMenu = function() { div.className = 'title ' + CM.Disp.colorTextPre + CM.Disp.colorBlue; div.textContent = 'Cookie Monster Goodies'; return div; - } + }; if (Game.onMenu == 'prefs') { CM.Disp.AddMenuPref(title); @@ -1930,7 +1933,7 @@ CM.Disp.AddMenu = function() { CM.Disp.AddMenuStats(title); } } -} +}; /** * This function refreshes the stats page, CM.Options.UpStats determines the rate at which that happens @@ -1938,7 +1941,7 @@ CM.Disp.AddMenu = function() { */ CM.Disp.RefreshMenu = function() { if (CM.Options.UpStats && Game.onMenu == 'stats' && (Game.drawT - 1) % (Game.fps * 5) != 0 && (Game.drawT - 1) % Game.fps == 0) Game.UpdateMenu(); -} +}; /******** * Section: Functions related to the Options/Preferences page @@ -1953,25 +1956,25 @@ CM.Disp.AddMenuPref = function(title) { frag.appendChild(title()); for (var group in CM.ConfigGroups) { - groupObject = CM.Disp.CreatePrefHeader(group, CM.ConfigGroups[group]) // (group, display-name of group) - frag.appendChild(groupObject) + groupObject = CM.Disp.CreatePrefHeader(group, CM.ConfigGroups[group]); // (group, display-name of group) + frag.appendChild(groupObject); if (CM.Options.Header[group]) { // 0 is show, 1 is collapsed // Make sub-sections of Notification section if (group == "Notification") { for (var subGroup in CM.ConfigGroupsNotification) { - subGroupObject = CM.Disp.CreatePrefHeader(subGroup, CM.ConfigGroupsNotification[subGroup]) // (group, display-name of group) + subGroupObject = CM.Disp.CreatePrefHeader(subGroup, CM.ConfigGroupsNotification[subGroup]); // (group, display-name of group) subGroupObject.style.fontSize = "15px"; subGroupObject.style.opacity = "0.5"; - frag.appendChild(subGroupObject) + frag.appendChild(subGroupObject); if (CM.Options.Header[subGroup]) { for (var option in CM.ConfigData) { - if (CM.ConfigData[option].group == subGroup) frag.appendChild(CM.Disp.CreatePrefOption(option)) + if (CM.ConfigData[option].group == subGroup) frag.appendChild(CM.Disp.CreatePrefOption(option)); } } } } else { for (var option in CM.ConfigData) { - if (CM.ConfigData[option].group == group) frag.appendChild(CM.Disp.CreatePrefOption(option)) + if (CM.ConfigData[option].group == group) frag.appendChild(CM.Disp.CreatePrefOption(option)); } } } @@ -1987,7 +1990,7 @@ CM.Disp.AddMenuPref = function(title) { frag.appendChild(resDef); l('menu').childNodes[2].insertBefore(frag, l('menu').childNodes[2].childNodes[l('menu').childNodes[2].childNodes.length - 1]); -} +}; /** * This function creates a header-object for the options page @@ -2018,7 +2021,7 @@ CM.Disp.CreatePrefHeader = function(config, text) { span.onclick = function() {CM.Config.ToggleHeader(config); Game.UpdateMenu();}; div.appendChild(span); return div; -} +}; /** * This function creates an option-object for the options page @@ -2117,11 +2120,11 @@ CM.Disp.CreatePrefOption = function(config) { input.setAttribute('value', CM.Options.Colors[CM.Disp.colors[i]]); innerDiv.appendChild(input); let change = function() {CM.Options.Colors[this.targetElement.id] = this.toHEXString(); CM.Disp.UpdateColors(); CM.Config.SaveConfig(); Game.UpdateMenu();}; - let picker = new JSColor(input, {hash: true, position: "right", onInput: change}) + let picker = new JSColor(input, {hash: true, position: "right", onInput: change}); var label = document.createElement('label'); label.textContent = CM.ConfigData.Colors.desc[CM.Disp.colors[i]]; innerDiv.appendChild(label); - div.appendChild(innerDiv) + div.appendChild(innerDiv); } return div } @@ -2142,7 +2145,7 @@ CM.Disp.CreatePrefOption = function(config) { input.oninput = function() {if (this.value > this.max) console.log("TEST"); CM.Options[config] = this.value; CM.Config.SaveConfig(); - CM.Disp.RefreshScale() + CM.Disp.RefreshScale(); } div.appendChild(input); div.appendChild(document.createTextNode(' ')); @@ -2151,7 +2154,7 @@ CM.Disp.CreatePrefOption = function(config) { div.appendChild(label); return div; } -} +}; /** * This function changes some of the time-displays in the game to be more detailed @@ -2160,7 +2163,7 @@ CM.Disp.CreatePrefOption = function(config) { CM.Disp.ToggleDetailedTime = function() { if (CM.Options.DetailedTime == 1) Game.sayTime = CM.Disp.sayTime; else Game.sayTime = CM.Backup.sayTime; -} +}; /** * This function refreshes all numbers after a change in scale-setting @@ -2174,7 +2177,7 @@ CM.Disp.RefreshScale = function() { CM.Disp.UpdateBotBar(); CM.Disp.UpdateBuildings(); CM.Disp.UpdateUpgrades(); -} +}; /** * This function changes/refreshes colours if the user has set new standard colours @@ -2193,7 +2196,7 @@ CM.Disp.UpdateColors = function() { } CM.Disp.Css.textContent = str; CM.Disp.UpdateBuildings(); // Class has been already set -} +}; /******** * Section: Functions related to the Stats page @@ -2347,7 +2350,7 @@ CM.Disp.AddMenuStats = function(title) { if (CM.Options.MissingUpgrades) { CM.Disp.AddMissingUpgrades(); } -} +}; /** * This function creates a header-object for the stats page @@ -2379,7 +2382,7 @@ CM.Disp.CreateStatsHeader = function(text, config) { span.onclick = function() {CM.Config.ToggleHeader(config); Game.UpdateMenu();}; div.appendChild(span); return div; -} +}; /** * This function creates an stats-listing-object for the stats page @@ -2420,7 +2423,7 @@ CM.Disp.CreateStatsListing = function(type, name, text, placeholder) { div.appendChild(document.createTextNode(': ')); div.appendChild(text); return div; -} +}; /** * This function creates a tooltip containing all missing holiday items contained in the list theMissDisp @@ -2463,7 +2466,7 @@ CM.Disp.CreateStatsMissDisp = function(theMissDisp) { span.textContent = '?'; frag.appendChild(span); return frag; -} +}; /** * This function creates the "Lucky" section of the stats page @@ -2528,7 +2531,7 @@ CM.Disp.CreateStatsLuckySection = function() { luckyCurSpan.textContent = Beautify(CM.Cache.GoldenCookiesMult * luckyCurBase) + (luckySplit ? (' / ' + Beautify(CM.Cache.WrathCookiesMult * luckyCurBase)) : '') section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Lucky!\" Reward (CUR)' + (luckySplit ? ' (Golden / Wrath)' : ''), luckyCurSpan, goldCookTooltip)); return section; -} +}; /** * This function creates the "Chain" section of the stats page @@ -2611,7 +2614,7 @@ CM.Disp.CreateStatsChainSection = function() { var chainCurWrath = CM.Cache.MaxChainMoni(6, chainCurMax, CM.Cache.WrathCookiesMult); section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Chain\" Reward (CUR) (Golden / Wrath)', document.createTextNode((Beautify(chainCur) + ' / ' + Beautify(chainCurWrath))), goldCookTooltip)); return section; -} +}; /** * This function creates the "Spells" section of the stats page @@ -2661,7 +2664,7 @@ CM.Disp.CreateStatsSpellsSection = function() { section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Spontaneous Edifice\" Cookies Required (most expensive building)', document.createTextNode(CM.Disp.Beautify(CM.Cache.Edifice) + ' (' + CM.Cache.EdificeBuilding + ")"), 'GoldCookTooltipPlaceholder')); } return section; -} +}; /** * This function creates the "Prestige" section of the stats page @@ -2731,7 +2734,7 @@ CM.Disp.CreateStatsPrestigeSection = function() { } return section; -} +}; /** * This function creates the missing upgrades sections for prestige, normal and cookie upgrades @@ -2745,8 +2748,8 @@ CM.Disp.AddMissingUpgrades = function() { title.className = "listing"; titlefrag = document.createElement('div'); titlefrag.innerHTML = 'Missing Prestige upgrades: '+ prestigeUpgradesOwned + '/' + Game.PrestigeUpgrades.length + ' (' + Math.floor((prestigeUpgradesOwned / Game.PrestigeUpgrades.length) * 100) + '%)'; - title.appendChild(titlefrag) - l('menu').children[5].appendChild(title) + title.appendChild(titlefrag); + l('menu').children[5].appendChild(title); upgrades = document.createElement('div'); upgrades.className = "listing crateBox"; upgrades.innerHTML = CM.Cache.MissingUpgradesPrestige; @@ -2761,8 +2764,8 @@ CM.Disp.AddMissingUpgrades = function() { title.className = "listing"; titlefrag = document.createElement('div'); titlefrag.innerHTML = 'Missing normal upgrades: '+ normalUpgradesOwned + '/' + (Game.UpgradesByPool[""].length + Game.UpgradesByPool["tech"].length) + ' (' + Math.floor((normalUpgradesOwned / ( Game.UpgradesByPool[""].length + Game.UpgradesByPool["tech"].length)) * 100) + '%)'; - title.appendChild(titlefrag) - l('menu').children[6].insertBefore(title, l('menu').children[6].childNodes[3]) + title.appendChild(titlefrag); + l('menu').children[6].insertBefore(title, l('menu').children[6].childNodes[3]); upgrades = document.createElement('div'); upgrades.className = "listing crateBox"; upgrades.innerHTML = CM.Cache.MissingUpgrades; @@ -2775,15 +2778,15 @@ CM.Disp.AddMissingUpgrades = function() { title.className = "listing"; titlefrag = document.createElement('div'); titlefrag.innerHTML = 'Missing Cookie upgrades: '+ cookieUpgradesOwned + '/' + Game.UpgradesByPool["cookie"].length + ' (' + Math.floor((cookieUpgradesOwned / Game.UpgradesByPool["cookie"].length) * 100) + '%)'; - title.appendChild(titlefrag) - l('menu').children[6].appendChild(title) + title.appendChild(titlefrag); + l('menu').children[6].appendChild(title); upgrades = document.createElement('div'); upgrades.className = "listing crateBox"; upgrades.innerHTML = CM.Cache.MissingUpgradesCookies; - l('menu').children[6].appendChild(upgrades) + l('menu').children[6].appendChild(upgrades); } -} +}; /** * This function returns the "crates" (icons) for missing upgrades in the stats sections @@ -2807,7 +2810,7 @@ CM.Disp.crateMissing = function(me) { ${Game.getDynamicTooltip(tooltip, 'top', true)} style = "${((icon[2] ? 'background-image: url(' + icon[2] + ');' : '') + 'background-position:' + (-icon[0] * 48)+ 'px ' + (-icon[1] * 48) + 'px')};"> `; -} +}; /******** * Section: Functions related to the left column of the page */ @@ -2829,7 +2832,7 @@ CM.Disp.CreateWrinklerButtons = function() { popFattestA.className = 'option'; popFattestA.onclick = function() {if (CM.Cache.WrinklersFattest[1]) Game.wrinklers[CM.Cache.WrinklersFattest[1]].hp = 0; }; l('sectionLeftExtra').children[0].append(popFattestA); -} +}; /** * This function updates the display setting of the two objects created by CM.Disp.CreateWrinklerButtons() @@ -2844,7 +2847,7 @@ CM.Disp.UpdateWrinklerButtons = function() { l('PopAllNormalWrinklerButton').style.display = "none"; l('PopFattestWrinklerButton').style.display = "none"; } -} +}; /******** * Section: Variables used in Disp functions */ diff --git a/src/Footer.js b/src/Footer.js index ba6de7b..e386213 100644 --- a/src/Footer.js +++ b/src/Footer.js @@ -20,7 +20,7 @@ CM.init = function() { CM.DelayInit(); Game.registerHook('draw', CM.Disp.Draw); } -} +}; /** * This registers a save function to the CM object. Per Game code/comments: @@ -32,7 +32,7 @@ CM.save = function() { settings: CM.Options, version: CM.VersionMajor + '.' + CM.VersionMinor, }); -} +}; /** * This registers a load function to the CM object. Per Game code/comments: @@ -41,7 +41,7 @@ CM.save = function() { CM.load = function(str) { let save = JSON.parse(str); CM.Config.LoadConfig(save.settings); -} +}; /******** * Section: Functions related to the initialization of CookieMonster */ @@ -56,7 +56,7 @@ CM.Footer.AddJscolor = function() { CM.Footer.Jscolor.type = 'text/javascript'; CM.Footer.Jscolor.setAttribute('src', 'https://aktanusa.github.io/CookieMonster/jscolor/jscolor.js'); document.head.appendChild(CM.Footer.Jscolor); -} +}; /** * This functions starts the initizialization and register CookieMonster @@ -72,6 +72,6 @@ if (!CM.isRunning) { clearInterval(delay); } }, 500); - CM.isRunning = 1 + CM.isRunning = 1; } diff --git a/src/Header.js b/src/Header.js index aa8446f..f08c907 100644 --- a/src/Header.js +++ b/src/Header.js @@ -23,7 +23,7 @@ RunCookieMonsterHeader = function() { CM.Options = {}; CM.Sim = {}; -} +}; if (typeof CM == "undefined") { RunCookieMonsterHeader(); diff --git a/src/Main.js b/src/Main.js index 87b3c48..b544640 100644 --- a/src/Main.js +++ b/src/Main.js @@ -11,31 +11,31 @@ CM.ReplaceNative = function() { Game.CalculateGains = function() { CM.Backup.CalculateGainsMod(); CM.Sim.DoSims = 1; - } + }; CM.Backup.tooltip = {}; CM.Backup.tooltip.draw = Game.tooltip.draw; eval('CM.Backup.tooltip.drawMod = ' + Game.tooltip.draw.toString().split('this').join('Game.tooltip')); Game.tooltip.draw = function(from, text, origin) { CM.Backup.tooltip.drawMod(from, text, origin); - } + }; CM.Backup.tooltip.update = Game.tooltip.update; eval('CM.Backup.tooltip.updateMod = ' + Game.tooltip.update.toString().split('this.').join('Game.tooltip.')); Game.tooltip.update = function() { CM.Backup.tooltip.updateMod(); CM.Disp.UpdateTooltipLocation(); - } + }; CM.Backup.UpdateWrinklers = Game.UpdateWrinklers; Game.UpdateWrinklers = function() { CM.Main.FixMouseY(CM.Backup.UpdateWrinklers); - } + }; CM.Backup.UpdateSpecial = Game.UpdateSpecial; Game.UpdateSpecial = function() { CM.Main.FixMouseY(CM.Backup.UpdateSpecial); - } + }; // Assumes newer browsers l('bigCookie').removeEventListener('click', Game.ClickCookie, false); @@ -46,7 +46,7 @@ CM.ReplaceNative = function() { CM.Backup.RebuildUpgrades(); CM.Disp.ReplaceTooltipUpgrade(); Game.CalculateGains(); - } + }; CM.Backup.DescribeDragonAura = Game.DescribeDragonAura; /** @@ -57,7 +57,7 @@ CM.ReplaceNative = function() { Game.DescribeDragonAura = function(aura) { CM.Backup.DescribeDragonAura(aura); CM.Disp.AddAuraInfo(aura); - } + }; CM.Backup.ToggleSpecialMenu = Game.ToggleSpecialMenu; /** @@ -66,8 +66,7 @@ CM.ReplaceNative = function() { Game.ToggleSpecialMenu = function(on) { CM.Backup.ToggleSpecialMenu(on); CM.Disp.AddDragonLevelUpTooltip(); - } - + }; CM.Backup.UpdateMenu = Game.UpdateMenu; Game.UpdateMenu = function() { @@ -75,19 +74,19 @@ CM.ReplaceNative = function() { CM.Backup.UpdateMenu(); CM.Disp.AddMenu(); } - } + }; CM.Backup.sayTime = Game.sayTime; CM.Disp.sayTime = function(time, detail) { if (isNaN(time) || time <= 0) return CM.Backup.sayTime(time, detail); else return CM.Disp.FormatTime(time / Game.fps, 1); - } + }; CM.Backup.Loop = Game.Loop; Game.Loop = function() { CM.Backup.Loop(); CM.Loop(); - } + }; CM.Backup.Logic = Game.Logic; eval('CM.Backup.LogicMod = ' + Game.Logic.toString().split('document.title').join('CM.Cache.Title')); @@ -96,13 +95,13 @@ CM.ReplaceNative = function() { // Update Title CM.Disp.UpdateTitle(); - } -} + }; +}; CM.ReplaceNativeGrimoire = function() { CM.ReplaceNativeGrimoireLaunch(); CM.ReplaceNativeGrimoireDraw(); -} +}; CM.ReplaceNativeGrimoireLaunch = function() { if (!CM.HasReplaceNativeGrimoireLaunch && Game.Objects['Wizard tower'].minigameLoaded) { @@ -114,10 +113,10 @@ CM.ReplaceNativeGrimoireLaunch = function() { CM.Main.ReplaceTooltipGrimoire(); CM.HasReplaceNativeGrimoireDraw = false; CM.ReplaceNativeGrimoireDraw(); - } + }; CM.HasReplaceNativeGrimoireLaunch = true; } -} +}; CM.ReplaceNativeGrimoireDraw = function() { if (!CM.HasReplaceNativeGrimoireDraw && Game.Objects['Wizard tower'].minigameLoaded) { @@ -128,10 +127,10 @@ CM.ReplaceNativeGrimoireDraw = function() { if (CM.Options.GrimoireBar == 1 && minigame.magic < minigame.magicM) { minigame.magicBarTextL.innerHTML += ' (' + CM.Disp.FormatTime(CM.Disp.CalculateGrimoireRefillTime(minigame.magic, minigame.magicM, minigame.magicM)) + ')'; } - } + }; CM.HasReplaceNativeGrimoireDraw = true; } -} +}; CM.Loop = function() { if (CM.Disp.lastAscendState != Game.OnAscend) { @@ -211,7 +210,7 @@ CM.Loop = function() { // Update Average CPS (might need to move) CM.Cache.UpdateCurrWrinklerCPS(); CM.Cache.UpdateAvgCPS(); -} +}; CM.DelayInit = function() { CM.Sim.InitData(); @@ -249,7 +248,7 @@ CM.DelayInit = function() { l("upgrades").style["flex-wrap"] = "wrap"; Game.Win('Third-party'); -} +}; /******** * Section: Functions related to first initizalition of CM */ @@ -268,11 +267,11 @@ CM.Main.ReplaceTooltips = function() { Game.LoadMinigames = function() { CM.Backup.LoadMinigames(); CM.Main.ReplaceTooltipGarden(); - CM.Main.ReplaceTooltipGrimoire() + CM.Main.ReplaceTooltipGrimoire(); CM.ReplaceNativeGrimoire(); - } + }; Game.LoadMinigames(); -} +}; /******** * Section: Functions related to replacing tooltips */ @@ -292,7 +291,7 @@ CM.Main.ReplaceTooltipBuild = function() { eval('l(\'product\' + me.id).onmouseover = function() {Game.tooltip.dynamic = 1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip(\'b\', \'' + i + '\');}, \'store\'); Game.tooltip.wobble();}'); } } -} +}; /** * This function replaces the original .onmouseover functions of the Grimoire minigame so that it calls CM.Disp.Tooltip() @@ -309,7 +308,7 @@ CM.Main.ReplaceTooltipGrimoire = function() { } } } -} +}; /** * This function replaces the original .onmouseover functions of sugar lumps so that it calls CM.Disp.Tooltip() @@ -329,8 +328,8 @@ CM.Main.ReplaceTooltipLump = function() { * It is called by CM.Main.ReplaceTooltips() */ CM.Main.ReplaceTooltipGarden = function() { - if (Game.Objects['Farm'].minigameLoaded) { - l('gardenTool-1').onmouseover = function() {Game.tooltip.dynamic=1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip('ha', 'HarvestAllButton');}, 'this'); Game.tooltip.wobble();} + if (Game.Objects.Farm.minigameLoaded) { + l('gardenTool-1').onmouseover = function() {Game.tooltip.dynamic=1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip('ha', 'HarvestAllButton');}, 'this'); Game.tooltip.wobble();}; Array.from(l('gardenPlot').children).forEach((child, index) => { var coords = child.id.slice(-3,); child.onmouseover = function() {Game.tooltip.dynamic=1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip('p', [`${coords[0]}`,`${coords[2]}`]);}, 'this'); Game.tooltip.wobble();}; @@ -349,15 +348,15 @@ CM.Main.ReplaceTooltipGarden = function() { */ CM.Main.FindShimmer = function() { CM.Main.currSpawnedGoldenCookieState = 0; - CM.Cache.goldenShimmersByID = {} + CM.Cache.goldenShimmersByID = {}; for (var i in Game.shimmers) { - CM.Cache.goldenShimmersByID[Game.shimmers[i].id] = Game.shimmers[i] + CM.Cache.goldenShimmersByID[Game.shimmers[i].id] = Game.shimmers[i]; if (Game.shimmers[i].spawnLead && Game.shimmers[i].type == 'golden') { CM.Cache.spawnedGoldenShimmer = Game.shimmers[i]; CM.Main.currSpawnedGoldenCookieState += 1; } } -} +}; /** * This function checks for changes in the amount of Golden Cookies @@ -373,13 +372,13 @@ CM.Main.CheckGoldenCookie = function() { delete CM.Disp.GCTimers[i]; } } - if (CM.Main.lastGoldenCookieState != Game.shimmerTypes['golden'].n) { - CM.Main.lastGoldenCookieState = Game.shimmerTypes['golden'].n; + if (CM.Main.lastGoldenCookieState != Game.shimmerTypes.golden.n) { + CM.Main.lastGoldenCookieState = Game.shimmerTypes.golden.n; if (CM.Main.lastGoldenCookieState) { if (CM.Main.lastSpawnedGoldenCookieState < CM.Main.currSpawnedGoldenCookieState) { CM.Disp.Flash(3, 'GCFlash'); CM.Disp.PlaySound(CM.Options.GCSoundURL, 'GCSound', 'GCVolume'); - CM.Disp.Notification('GCNotification', "Golden Cookie Spawned", "A Golden Cookie has spawned. Click it now!") + CM.Disp.Notification('GCNotification', "Golden Cookie Spawned", "A Golden Cookie has spawned. Click it now!"); } for (var i in Game.shimmers) { @@ -399,15 +398,15 @@ CM.Main.CheckGoldenCookie = function() { CM.Disp.GCTimers[i].textContent = Math.ceil(CM.Cache.goldenShimmersByID[i].life / Game.fps); } } -} +}; /** * This function checks if there is reindeer that has spawned * It is called by CM.Loop */ CM.Main.CheckSeasonPopup = function() { - if (CM.Main.lastSeasonPopupState != Game.shimmerTypes['reindeer'].spawned) { - CM.Main.lastSeasonPopupState = Game.shimmerTypes['reindeer'].spawned; + if (CM.Main.lastSeasonPopupState != Game.shimmerTypes.reindeer.spawned) { + CM.Main.lastSeasonPopupState = Game.shimmerTypes.reindeer.spawned; for (var i in Game.shimmers) { if (Game.shimmers[i].spawnLead && Game.shimmers[i].type == 'reindeer') { CM.Cache.seasonPopShimmer = Game.shimmers[i]; @@ -416,9 +415,9 @@ CM.Main.CheckSeasonPopup = function() { } CM.Disp.Flash(3, 'SeaFlash'); CM.Disp.PlaySound(CM.Options.SeaSoundURL, 'SeaSound', 'SeaVolume'); - CM.Disp.Notification('SeaNotification',"Reindeer sighted!", "A Reindeer has spawned. Click it now!") + CM.Disp.Notification('SeaNotification',"Reindeer sighted!", "A Reindeer has spawned. Click it now!"); } -} +}; /** * This function checks if there is a fortune cookie on the ticker @@ -430,24 +429,24 @@ CM.Main.CheckTickerFortune = function() { if (CM.Main.lastTickerFortuneState) { CM.Disp.Flash(3, 'FortuneFlash'); CM.Disp.PlaySound(CM.Options.FortuneSoundURL, 'FortuneSound', 'FortuneVolume'); - CM.Disp.Notification('FortuneNotification', "Fortune Cookie found", "A Fortune Cookie has appeared on the Ticker.") + CM.Disp.Notification('FortuneNotification', "Fortune Cookie found", "A Fortune Cookie has appeared on the Ticker."); } } -} +}; /** * This function checks if a garden tick has happened * It is called by CM.Loop */ CM.Main.CheckGardenTick = function() { - if (Game.Objects['Farm'].minigameLoaded && CM.Main.lastGardenNextStep != Game.Objects['Farm'].minigame.nextStep) { + if (Game.Objects.Farm.minigameLoaded && CM.Main.lastGardenNextStep != Game.Objects.Farm.minigame.nextStep) { if (CM.Main.lastGardenNextStep != 0 && CM.Main.lastGardenNextStep < Date.now()) { CM.Disp.Flash(3, 'GardFlash'); CM.Disp.PlaySound(CM.Options.GardSoundURL, 'GardSound', 'GardVolume'); } - CM.Main.lastGardenNextStep = Game.Objects['Farm'].minigame.nextStep; + CM.Main.lastGardenNextStep = Game.Objects.Farm.minigame.nextStep; } -} +}; /** * This function checks if the magic meter is full @@ -461,10 +460,10 @@ CM.Main.CheckMagicMeter = function() { CM.Main.lastMagicBarFull = true; CM.Disp.Flash(3, 'MagicFlash'); CM.Disp.PlaySound(CM.Options.MagicSoundURL, 'MagicSound', 'MagicVolume'); - CM.Disp.Notification('MagicNotification', "Magic Meter full", "Your Magic Meter is full. Cast a spell!") + CM.Disp.Notification('MagicNotification', "Magic Meter full", "Your Magic Meter is full. Cast a spell!"); } } -} +}; /** * This function checks if any new Wrinklers have popped up @@ -477,7 +476,7 @@ CM.Main.CheckWrinklerCount = function() { if (Game.wrinklers[i].phase == 2) CurrentWrinklers++; } if (CurrentWrinklers > CM.Main.lastWrinklerCount) { - CM.Main.lastWrinklerCount = CurrentWrinklers + CM.Main.lastWrinklerCount = CurrentWrinklers; if (CurrentWrinklers == Game.getWrinklersMax() && CM.Options.WrinklerMaxFlash) { CM.Disp.Flash(3, 'WrinklerMaxFlash'); } else { @@ -489,15 +488,15 @@ CM.Main.CheckWrinklerCount = function() { CM.Disp.PlaySound(CM.Options.WrinklerSoundURL, 'WrinklerSound', 'WrinklerVolume'); } if (CurrentWrinklers == Game.getWrinklersMax() && CM.Options.WrinklerMaxNotification) { - CM.Disp.Notification('WrinklerMaxNotification', "Maximum Wrinklers Reached", "You have reached your maximum ammount of wrinklers") + CM.Disp.Notification('WrinklerMaxNotification', "Maximum Wrinklers Reached", "You have reached your maximum ammount of wrinklers"); } else { - CM.Disp.Notification('WrinklerNotification', "A Wrinkler appeared", "A new wrinkler has appeared") + CM.Disp.Notification('WrinklerNotification', "A Wrinkler appeared", "A new wrinkler has appeared"); } } else { - CM.Main.lastWrinklerCount = CurrentWrinklers + CM.Main.lastWrinklerCount = CurrentWrinklers; } } -} +}; /** * This function creates .onmouseover/out events that determine if the mouse is hovering-over a Wrinkler @@ -514,7 +513,7 @@ CM.Main.AddWrinklerAreaDetect = function() { CM.Disp.TooltipWrinklerBeingShown[i] = 0; } }; -} +}; /******** * Section: Functions related to the mouse */ @@ -534,14 +533,14 @@ CM.Main.FixMouseY = function(target) { else { target(); } -} +}; CM.HasReplaceNativeGrimoireLaunch = false; CM.HasReplaceNativeGrimoireDraw = false; CM.Main.lastGoldenCookieState = 0; CM.Main.lastSpawnedGoldenCookieState = 0; -CM.Main.currSpawnedGoldenCookieState +CM.Main.currSpawnedGoldenCookieState; CM.Main.lastTickerFortuneState = 0; CM.Main.lastSeasonPopupState = 0; CM.Main.lastGardenNextStep = 0; diff --git a/src/Sim.js b/src/Sim.js index 5df2a6a..3e52aa9 100644 --- a/src/Sim.js +++ b/src/Sim.js @@ -23,7 +23,7 @@ CM.Sim.BuildingGetPrice = function(build, basePrice, start, free, increase) { start++; } return moni; -} +}; CM.Sim.BuildingSell = function(build, basePrice, start, free, amount, noSim) { /*var price=0; @@ -61,13 +61,13 @@ CM.Sim.BuildingSell = function(build, basePrice, start, free, amount, noSim) { } } return moni; -} +}; CM.Sim.Has = function(what) { var it = CM.Sim.Upgrades[what]; if (Game.ascensionMode == 1 && (it.pool == 'prestige' || it.tier == 'fortune')) return 0; return (it ? it.bought : 0); -} +}; CM.Sim.Win = function(what) { @@ -77,7 +77,7 @@ CM.Sim.Win = function(what) { if (Game.Achievements[what].pool != 'shadow') CM.Sim.AchievementsOwned++; } } -} +}; eval('CM.Sim.HasAchiev = ' + Game.HasAchiev.toString().split('Game').join('CM.Sim')); @@ -89,7 +89,7 @@ CM.Sim.hasAura = function(what) { return true; else return false; -} +}; // Check if multiplier auras are present // Used as CM.Sim.auraMult('Aura') * mult, i.e. CM.Sim.auraMult('Dragon God) * 0.05 @@ -100,20 +100,20 @@ CM.Sim.auraMult = function(what) { if (Game.dragonAuras[CM.Sim.dragonAura].name == 'Reality Bending' || Game.dragonAuras[CM.Sim.dragonAura2].name == 'Reality Bending') n += 0.1; return n; -} +}; CM.Sim.hasGod=function(what) { if (!CM.Sim.Objects.Temple.minigameLoaded) { - return false + return false; } - var possibleGods = CM.Sim.Objects.Temple.minigame.gods + var possibleGods = CM.Sim.Objects.Temple.minigame.gods; var god=possibleGods[what]; for (var i=0;i<3;i++) { if (CM.Sim.Objects.Temple.minigame.slot[i]==god.id) return (i+1); } return false; -} +}; CM.Sim.eff = function(name) { if (typeof CM.Sim.effs[name]==='undefined') { @@ -123,7 +123,7 @@ CM.Sim.eff = function(name) { else { return CM.Sim.effs[name]; } -} +}; eval('CM.Sim.GetTieredCpsMult = ' + Game.GetTieredCpsMult.toString() .split('Game.Has').join('CM.Sim.Has') @@ -143,7 +143,7 @@ CM.Sim.getCPSBuffMult = function() { if (typeof Game.buffs[i].multCpS != 'undefined') mult *= Game.buffs[i].multCpS; } return mult; -} +}; /** * Constructs an object with the static properties of a building, @@ -168,7 +168,7 @@ CM.Sim.InitialBuildingData = function(buildingName) { you.baseCps = me.baseCps; you.name = me.name; return you; -} +}; /** * Similar to the previous function, but for upgrades. @@ -181,7 +181,7 @@ CM.Sim.InitUpgrade = function(upgradeName) { you.pool = me.pool; you.name = me.name; return you; -} +}; /** * Similar to the previous function, but for achievements. @@ -190,7 +190,7 @@ CM.Sim.InitUpgrade = function(upgradeName) { */ CM.Sim.InitAchievement = function(achievementName) { return {}; -} +}; CM.Sim.InitData = function() { // Buildings @@ -210,8 +210,8 @@ CM.Sim.InitData = function() { for (var i in Game.Achievements) { CM.Sim.Achievements[i] = CM.Sim.InitAchievement(i); } - CM.Sim.CopyData -} + CM.Sim.CopyData; +}; CM.Sim.CopyData = function() { // Other variables @@ -424,7 +424,7 @@ CM.Sim.CalculateGains = function() { CM.Sim.cookiesPsRaw = rawCookiesPs; - var n = Game.shimmerTypes['golden'].n; + var n = Game.shimmerTypes.golden.n; var auraMult = CM.Sim.auraMult('Dragon\'s Fortune'); for (var i = 0; i < n; i++){ mult *= 1 + auraMult * 1.23; @@ -520,7 +520,7 @@ CM.Sim.CheckOtherAchiev = function() { if (buildingsOwned >= 4000 && CM.Sim.UpgradesOwned >= 300) CM.Sim.Win('Polymath'); if (buildingsOwned >= 8000 && CM.Sim.UpgradesOwned >= 400) CM.Sim.Win('Renaissance baker'); - if (CM.Sim.Objects['Cursor'].amount + CM.Sim.Objects['Grandma'].amount >= 777) CM.Sim.Win('The elder scrolls'); + if (CM.Sim.Objects.Cursor.amount + CM.Sim.Objects.Grandma.amount >= 777) CM.Sim.Win('The elder scrolls'); var hasAllHalloCook = true; for (var i in CM.Data.HalloCookies) { @@ -535,14 +535,14 @@ CM.Sim.CheckOtherAchiev = function() { if (hasAllChristCook) CM.Sim.Win('Let it snow'); if (CM.Sim.Has('Fortune cookies')) { - var list = Game.Tiers['fortune'].upgrades; + var list = Game.Tiers.fortune.upgrades; var fortunes = 0; for (var i in list) { if (CM.Sim.Has(list[i].name)) fortunes++; } if (fortunes >= list.length) CM.Sim.Win('O Fortuna'); } -} +}; CM.Sim.BuyBuildings = function(amount, target) { CM.Cache[target] = []; @@ -587,7 +587,7 @@ CM.Sim.BuyBuildings = function(amount, target) { CM.Cache.DoRemakeBuildPrices = 1; } } -} +}; CM.Sim.BuyUpgrades = function() { CM.Cache.Upgrades = []; @@ -604,7 +604,7 @@ CM.Sim.BuyUpgrades = function() { if (CM.Sim.pledges >= 5) CM.Sim.Win('Elder slumber'); } else if (i == 'Elder Covenant') { - CM.Sim.Win('Elder calm') + CM.Sim.Win('Elder calm'); } else if (i == 'Prism heart biscuits') { CM.Sim.Win('Lovely cookies'); @@ -630,7 +630,7 @@ CM.Sim.BuyUpgrades = function() { if (diffMouseCPS) CM.Cache.Upgrades[i].bonusMouse = diffMouseCPS; } } -} +}; /** * This functions calculates the cps and cost of changing a Dragon Aura @@ -642,7 +642,7 @@ CM.Sim.CalculateChangeAura = function(aura) { CM.Sim.CopyData(); // Check if aura being changed is first or second aura - var auraToBeChanged = l('promptContent').children[0].innerHTML.includes("secondary") + var auraToBeChanged = l('promptContent').children[0].innerHTML.includes("secondary"); if (auraToBeChanged) CM.Sim.dragonAura2 = aura; else CM.Sim.dragonAura = aura; @@ -653,7 +653,7 @@ CM.Sim.CalculateChangeAura = function(aura) { var highestBuilding = CM.Sim.Objects[Game.ObjectsById[i].name].name; CM.Sim.Objects[highestBuilding].amount -=1; CM.Sim.buildingsOwned -= 1; - break + break; } } // This calculates price of highest building @@ -669,8 +669,8 @@ CM.Sim.CalculateChangeAura = function(aura) { if (lastAchievementsOwned != CM.Sim.AchievementsOwned) { CM.Sim.CalculateGains(); } - return [CM.Sim.cookiesPs - Game.cookiesPs, price] -} + return [CM.Sim.cookiesPs - Game.cookiesPs, price]; +}; CM.Sim.NoGoldSwitchCookiesPS = function() { if (Game.Has('Golden switch [off]')) { @@ -680,7 +680,7 @@ CM.Sim.NoGoldSwitchCookiesPS = function() { CM.Cache.NoGoldSwitchCookiesPS = CM.Sim.cookiesPs; } else CM.Cache.NoGoldSwitchCookiesPS = Game.cookiesPs; -} +}; CM.Sim.ResetBonus = function(possiblePresMax) { var lastAchievementsOwned = -1; @@ -740,19 +740,19 @@ CM.Sim.ResetBonus = function(possiblePresMax) { CM.Sim.CalculateGains(); } - var ResetCPS = CM.Sim.cookiesPs - curCPS + var ResetCPS = CM.Sim.cookiesPs - curCPS; // Reset Pretige level after calculation CM.Sim.prestige = Game.prestige; return (ResetCPS); -} +}; CM.Sim.getSellMultiplier = function() { var giveBack = 0.25; giveBack *= 1 + CM.Sim.auraMult('Earth Shatterer'); return giveBack; -} +}; CM.Sim.modifyBuildingPrice = function(building,price) { if (CM.Sim.Has('Season savings')) price *= 0.99; @@ -774,7 +774,7 @@ CM.Sim.modifyBuildingPrice = function(building,price) { else if (godLvl == 3) price *= 0.98; } return price; -} +}; CM.Sim.SellBuildingsForChoEgg = function() { var sellTotal = 0; @@ -820,7 +820,7 @@ CM.Sim.SellBuildingsForChoEgg = function() { // CM.Cache.DoRemakeBuildPrices = 1; return sellTotal; -} +}; /******** * Section: Functions used to calculate clicking power */ @@ -843,7 +843,7 @@ CM.Sim.mouseCps = function() { if (CM.Sim.Has('Nonillion fingers')) add *= 20; var num=0; for (var i in CM.Sim.Objects) {num+=CM.Sim.Objects[i].amount;} - num -= CM.Sim.Objects['Cursor'].amount; + num -= CM.Sim.Objects.Cursor.amount; add = add * num; // Use CM.Sim.cookiesPs as function is always called after CM.Sim.CalculateGains() @@ -872,7 +872,7 @@ CM.Sim.mouseCps = function() { if (CM.Sim.Has('Aura gloves')) { - mult *= 1 + 0.05 * Math.min(Game.Objects['Cursor'].level, CM.Sim.Has('Luminous gloves') ? 20 : 10); + mult *= 1 + 0.05 * Math.min(Game.Objects.Cursor.level, CM.Sim.Has('Luminous gloves') ? 20 : 10); } mult *= CM.Sim.eff('click'); @@ -902,4 +902,5 @@ CM.Sim.mouseCps = function() { if (Game.hasBuff('Cursed finger')) out = Game.buffs['Cursed finger'].power; return out; -} +}; + From 416637bac34b2ad0957545743d69eccd33fc5404 Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Sat, 30 Jan 2021 16:12:09 +0100 Subject: [PATCH 3/6] Cache.js, Config.js & Data.js compy with JSHint --- CookieMonster.js | 161 +++++++++++++++++++++++------------------------ src/Cache.js | 47 +++++++------- src/Config.js | 8 +-- src/Disp.js | 106 +++++++++++++++---------------- 4 files changed, 160 insertions(+), 162 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 99eae09..ffb4dde 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -79,7 +79,7 @@ CM.Cache.CacheWrinklers = function() { CM.Cache.WrinklersTotal = 0; CM.Cache.WrinklersNormal = 0; CM.Cache.WrinklersFattest = [0, null]; - for (var i in Game.wrinklers) { + 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; @@ -137,11 +137,11 @@ CM.Cache.CacheStats = function() { CM.Cache.Edifice = 0; var max = 0; var n = 0; - for (var i in Game.Objects) { + 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 (var i in Game.Objects) { + 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) { @@ -164,7 +164,7 @@ CM.Cache.CacheMissingUpgrades = function() { CM.Cache.MissingUpgradesPrestige = ""; var list = []; //sort the upgrades - for (var i in Game.Upgrades) { + for (let i of Object.keys(Game.Upgrades)) { list.push(Game.Upgrades[i]); } var sortMap = function(a, b) { @@ -174,7 +174,7 @@ CM.Cache.CacheMissingUpgrades = function() { }; list.sort(sortMap); - for (var i in list) { + for (let i of Object.keys(list)) { var me = list[i]; if (me.bought == 0) { @@ -213,10 +213,10 @@ class CMAvgQueue { // TODO: Might want to do this according to "https://stackoverflow.com/questions/10359907/how-to-compute-the-sum-and-average-of-elements-in-an-array" calcAverage (timePeriod) { - if (timePeriod > this.maxLength) timePeriod = this.maxLength, console.log("Called for average of Queue for time-period longer than MaxLength"); + if (timePeriod > this.maxLength) timePeriod = this.maxLength; if (timePeriod > this.queue.length) timePeriod = this.queue.length; var ret = 0; - for (var i = this.queue.length - 1; i >= 0 && i > this.queue.length - 1 - timePeriod; i--) { + for (let i = this.queue.length - 1; i >= 0 && i > this.queue.length - 1 - timePeriod; i--) { ret += this.queue[i]; } return ret / timePeriod; @@ -260,7 +260,7 @@ CM.Cache.UpdateAvgCPS = function() { var wrinkFattestDiffAvg = Math.max(0, (CM.Cache.WrinklersFattest[0] - CM.Cache.lastWrinkFattestCookies)) / timeDiff; var choEggDiffAvg = Math.max(0,(choEggTotal - CM.Cache.lastChoEgg)) / timeDiff; var clicksDiffAvg = (Game.cookieClicks - CM.Cache.lastClicks) / timeDiff; - for (var i = 0; i < timeDiff; i++) { + for (let i = 0; i < timeDiff; i++) { CM.Cache.CookiesDiff.addLatest(bankDiffAvg); CM.Cache.WrinkDiff.addLatest(wrinkDiffAvg); CM.Cache.WrinkFattestDiff.addLatest(wrinkFattestDiffAvg); @@ -343,7 +343,7 @@ CM.Cache.CacheDragonCost = function() { else { let cost = 0; CM.Sim.CopyData(); - for (var i = 0; i < amount; i++) { + for (let i = 0; i < amount; i++) { let price = CM.Sim.Objects[target].basePrice * Math.pow(Game.priceIncrease, Math.max(0, CM.Sim.Objects[target].amount - 1 - CM.Sim.Objects[target].free)); price = Game.modifyBuildingPrice(CM.Sim.Objects[target], price); price = Math.ceil(price); @@ -356,14 +356,14 @@ CM.Cache.CacheDragonCost = function() { else { let cost = 0; CM.Sim.CopyData(); - for (var j in Game.Objects) { + for (let j of Object.keys(Game.Objects)) { target = j; if (Game.Objects[target].amount < amount) { CM.Cache.CostDragonUpgrade = "Not enough buildings to sell"; break; } else { - for (var i = 0; i < amount; i++) { + for (let i = 0; i < amount; i++) { let price = CM.Sim.Objects[target].basePrice * Math.pow(Game.priceIncrease, Math.max(0, CM.Sim.Objects[target].amount - 1 - CM.Sim.Objects[target].free)); price = Game.modifyBuildingPrice(CM.Sim.Objects[target], price); price = Math.ceil(price); @@ -391,7 +391,7 @@ CM.Cache.NextNumber = function(base) { }; CM.Cache.RemakeBuildingsPrices = function() { - for (var i in Game.Objects) { + for (let i of Object.keys(Game.Objects)) { CM.Cache.Objects[i].price = CM.Sim.BuildingGetPrice(Game.Objects[i], Game.Objects[i].basePrice, Game.Objects[i].amount, Game.Objects[i].free, 1); CM.Cache.Objects10[i].price = CM.Sim.BuildingGetPrice(Game.Objects[i], Game.Objects[i].basePrice, Game.Objects[i].amount, Game.Objects[i].free, 10); CM.Cache.Objects100[i].price = CM.Sim.BuildingGetPrice(Game.Objects[i], Game.Objects[i].basePrice, Game.Objects[i].amount, Game.Objects[i].free, 100); @@ -418,7 +418,7 @@ CM.Cache.RemakeBuildingsPP = function() { CM.Cache.mid = -1; // Calculate PP and colors when compared to purchase of single optimal building if (CM.Options.ColorPPBulkMode == 0) { - for (var i in CM.Cache.Objects) { + for (let i of Object.keys(CM.Cache.Objects)) { //CM.Cache.Objects[i].pp = Game.Objects[i].getPrice() / CM.Cache.Objects[i].bonus; if (Game.cookiesPs) { CM.Cache.Objects[i].pp = (Math.max(Game.Objects[i].getPrice() - (Game.cookies + CM.Disp.GetWrinkConfigBank()), 0) / Game.cookiesPs) + (Game.Objects[i].getPrice() / CM.Cache.Objects[i].bonus); @@ -429,7 +429,7 @@ CM.Cache.RemakeBuildingsPP = function() { if (CM.Cache.max == -1 || CM.Cache.Objects[i].pp > CM.Cache.max) CM.Cache.max = CM.Cache.Objects[i].pp; } CM.Cache.mid = ((CM.Cache.max - CM.Cache.min) / 2) + CM.Cache.min; - for (var i in CM.Cache.Objects) { + for (let i of Object.keys(CM.Cache.Objects)) { let color = ''; if (CM.Cache.Objects[i].pp == CM.Cache.min) color = CM.Disp.colorGreen; else if (CM.Cache.Objects[i].pp == CM.Cache.max) color = CM.Disp.colorRed; @@ -446,7 +446,7 @@ CM.Cache.RemakeBuildingsPP = function() { // Calculate PP and colors when compared to purchase of selected bulk mode else { if (Game.buyBulk == 1) { - for (var i in CM.Cache.Objects) { + for (let i of Object.keys(CM.Cache.Objects)) { //CM.Cache.Objects[i].pp = Game.Objects[i].getPrice() / CM.Cache.Objects[i].bonus; if (Game.cookiesPs) { CM.Cache.Objects[i].pp = (Math.max(Game.Objects[i].getPrice() - (Game.cookies + CM.Disp.GetWrinkConfigBank()), 0) / Game.cookiesPs) + (Game.Objects[i].getPrice() / CM.Cache.Objects[i].bonus); @@ -457,7 +457,7 @@ CM.Cache.RemakeBuildingsPP = function() { if (CM.Cache.max == -1 || CM.Cache.Objects[i].pp > CM.Cache.max) CM.Cache.max = CM.Cache.Objects[i].pp; } CM.Cache.mid = ((CM.Cache.max - CM.Cache.min) / 2) + CM.Cache.min; - for (var i in CM.Cache.Objects) { + for (let i of Object.keys(CM.Cache.Objects)) { let color = ''; if (CM.Cache.Objects[i].pp == CM.Cache.min) color = CM.Disp.colorGreen; else if (CM.Cache.Objects[i].pp == CM.Cache.max) color = CM.Disp.colorRed; @@ -469,7 +469,7 @@ CM.Cache.RemakeBuildingsPP = function() { CM.Cache.RemakeBuildingsOtherPP(100, 'Objects100'); } else if (Game.buyBulk == 10) { - for (var i in CM.Cache.Objects) { + for (let i of Object.keys(CM.Cache.Objects)) { 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 { @@ -479,7 +479,7 @@ CM.Cache.RemakeBuildingsPP = function() { 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 (var i in CM.Cache.Objects) { + for (let i of Object.keys(CM.Cache.Objects)) { 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; @@ -491,7 +491,7 @@ CM.Cache.RemakeBuildingsPP = function() { CM.Cache.RemakeBuildingsOtherPP(100, 'Objects100'); } else if (Game.buyBulk == 100) { - for (var i in CM.Cache.Objects) { + for (let i of Object.keys(CM.Cache.Objects)) { 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 { @@ -501,7 +501,7 @@ CM.Cache.RemakeBuildingsPP = function() { 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 (var i in CM.Cache.Objects) { + for (let i of Object.keys(CM.Cache.Objects)) { 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; @@ -516,7 +516,7 @@ CM.Cache.RemakeBuildingsPP = function() { }; CM.Cache.RemakeUpgradePP = function() { - for (var i in CM.Cache.Upgrades) { + 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); @@ -537,7 +537,7 @@ CM.Cache.RemakeUpgradePP = function() { }; CM.Cache.RemakeBuildingsOtherPP = function(amount, target) { - for (var i in CM.Cache[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); @@ -668,7 +668,7 @@ CM.Cache.RemakeSellForChoEgg = function() { if (Game.Objects.Bank.minigameLoaded) { var marketGoods = Game.Objects.Bank.minigame.goods; var goodsVal = 0; - for (var i in marketGoods) { + for (let i of Object.keys(marketGoods)) { var marketGood = marketGoods[i]; goodsVal += marketGood.stock * marketGood.val; } @@ -700,7 +700,6 @@ CM.Cache.SellForChoEgg = 0; CM.Cache.Title = ''; CM.Cache.HadBuildAura = false; CM.Cache.RealCookiesEarned = -1; -CM.Cache.seasonPopShimmer; CM.Cache.goldenShimmersByID = {}; CM.Cache.spawnedGoldenShimmer = 0; @@ -740,7 +739,7 @@ CM.Config.LoadConfig = function(settings) { // Check values var mod = false; - for (var i in CM.Data.ConfigDefault) { + for (let i in CM.Data.ConfigDefault) { if (typeof CM.Options[i] === 'undefined') { mod = true; CM.Options[i] = CM.Data.ConfigDefault[i]; @@ -760,7 +759,7 @@ CM.Config.LoadConfig = function(settings) { } } else if (i == 'Header') { - for (var j in CM.Data.ConfigDefault.Header) { + for (let j in CM.Data.ConfigDefault.Header) { if (typeof CM.Options[i][j] === 'undefined' || !(CM.Options[i][j] > -1 && CM.Options[i][j] < 2)) { mod = true; CM.Options[i][j] = CM.Data.ConfigDefault[i][j]; @@ -768,7 +767,7 @@ CM.Config.LoadConfig = function(settings) { } } else { // Colors - for (var j in CM.Data.ConfigDefault.Colors) { + for (let j in CM.Data.ConfigDefault.Colors) { if (typeof CM.Options[i][j] === 'undefined' || typeof CM.Options[i][j] != 'string') { mod = true; CM.Options[i][j] = CM.Data.ConfigDefault[i][j]; @@ -778,7 +777,7 @@ CM.Config.LoadConfig = function(settings) { } if (mod) CM.Config.SaveConfig(); CM.Loop(); // Do loop once - for (var i in CM.Data.ConfigDefault) { + for (let i in CM.Data.ConfigDefault) { if (i != 'Header' && typeof CM.ConfigData[i].func !== 'undefined') { CM.ConfigData[i].func(); } @@ -1243,7 +1242,7 @@ CM.Disp.GetWrinkConfigBank = function() { * It is called by a click of the 'pop all' button created by CM.Disp.AddMenuStats() */ CM.Disp.PopAllNormalWrinklers = function() { - for (var i in Game.wrinklers) { + for (let i of Object.keys(Game.wrinklers)) { if (Game.wrinklers[i].sucked > 0 && Game.wrinklers[i].type == 0) { Game.wrinklers[i].hp = 0; } @@ -1577,7 +1576,7 @@ CM.Disp.CreateBotBar = function() { td.className = CM.Disp.colorTextPre + color; td.textContent = text; return td; - } + }; var type = tbody.appendChild(document.createElement('tr')); type.style.fontWeight = 'bold'; type.appendChild(firstCol('CM ' + CM.VersionMajor + '.' + CM.VersionMinor, CM.Disp.colorYellow)); @@ -1588,7 +1587,7 @@ CM.Disp.CreateBotBar = function() { var time = tbody.appendChild(document.createElement('tr')); time.appendChild(firstCol('Time Left', CM.Disp.colorBlue)); - for (var i in Game.Objects) { + for (let i of Object.keys(Game.Objects)) { CM.Disp.CreateBotBarBuildingColumn(i); } @@ -1600,9 +1599,9 @@ CM.Disp.CreateBotBar = function() { * It is called by CM.Loop() */ CM.Disp.UpdateBotBar = function() { - if (CM.Options.BotBar == 1) { + if (CM.Options.BotBar == 1 && CM.Cache.Objects) { var count = 0; - for (var i in CM.Cache.Objects) { + for (let i of Object.keys(CM.Cache.Objects)) { var target = 'Objects'; if (Game.buyBulk == 10) {target = 'Objects10';} if (Game.buyBulk == 100) {target = 'Objects100';} @@ -1676,14 +1675,14 @@ CM.Disp.CreateTimerBar = function() { 'Next Cookie', [{id: 'CMTimerBarGCMinBar', color: CM.Disp.colorGray}, {id: 'CMTimerBarGCBar', color: CM.Disp.colorPurple}] ); - CM.Disp.TimerBar.appendChild(CM.Disp.TimerBars.CMTimerBarGC) + CM.Disp.TimerBar.appendChild(CM.Disp.TimerBars.CMTimerBarGC); // Create standard Reindeer bar CM.Disp.TimerBars. CMTimerBarRen = CM.Disp.TimerBarCreateBar('CMTimerBarRen', 'Next Reindeer', [{id: 'CMTimerBarRenMinBar', color: CM.Disp.colorGray}, {id: 'CMTimerBarRenBar', color: CM.Disp.colorOrange}] ); - CM.Disp.TimerBar.appendChild(CM.Disp.TimerBars. CMTimerBarRen) + CM.Disp.TimerBar.appendChild(CM.Disp.TimerBars. CMTimerBarRen); l('wrapper').appendChild(CM.Disp.TimerBar); }; @@ -1724,7 +1723,7 @@ CM.Disp.TimerBarCreateBar = function(id, name, bars) { for (var i = 0; i < bars.length; i++) { var colorBar = document.createElement('span'); - colorBar.id = bars[i].id + colorBar.id = bars[i].id; colorBar.style.display = 'inline-block'; colorBar.style.height = '10px'; colorBar.style.verticalAlign = "text-top"; @@ -1801,11 +1800,11 @@ CM.Disp.UpdateTimerBar = function() { } // On every frame all buff-timers are deleted and re-created - for (var i in CM.Disp.BuffTimerBars) { + for (let i of Object.keys(CM.Disp.BuffTimerBars)) { CM.Disp.BuffTimerBars[i].remove(); } - CM.Disp.BuffTimerBars = {} - for (var i in Game.buffs) { + CM.Disp.BuffTimerBars = {}; + for (let i of Object.keys(Game.buffs)) { if (Game.buffs[i]) { timer = CM.Disp.TimerBarCreateBar(Game.buffs[i].name, Game.buffs[i].name, [{id: Game.buffs[i].name + 'Bar'}]); timer.style.display = ''; @@ -1822,10 +1821,10 @@ CM.Disp.UpdateTimerBar = function() { timer.lastChild.children[1].style.width = Math.round(Game.buffs[i].time * (maxWidthOneBar - Math.ceil(Game.buffs[i].time / Game.fps).toString().length * 8) / Game.buffs[i].maxTime) + 'px'; timer.lastChild.children[2].textContent = Math.ceil(Game.buffs[i].time / Game.fps); numberOfTimers++; - CM.Disp.BuffTimerBars[Game.buffs[i].name] = timer + CM.Disp.BuffTimerBars[Game.buffs[i].name] = timer; } } - for (var i in CM.Disp.BuffTimerBars) { + for (let i of Object.keys(CM.Disp.BuffTimerBars)) { CM.Disp.TimerBar.appendChild(CM.Disp.BuffTimerBars[i]); } @@ -1833,7 +1832,7 @@ CM.Disp.UpdateTimerBar = function() { CM.Disp.TimerBar.style.height = numberOfTimers * 12 + 2 + 'px'; } if (CM.Disp.LastNumberOfTimers != numberOfTimers) { - CM.Disp.LastNumberOfTimers = numberOfTimers + CM.Disp.LastNumberOfTimers = numberOfTimers; CM.Disp.UpdateBotTimerBarPosition(); } } @@ -1916,17 +1915,17 @@ CM.Disp.UpdateBuildings = function() { else if (Game.buyBulk == 100 && CM.Options.BulkBuildColor == 1) target = 'Objects100'; else target = 'Objects'; if (CM.Options.BuildColor == 1) { - for (var i in CM.Cache[target]) { + for (let i of Object.keys(CM.Cache[target])) { l('productPrice' + Game.Objects[i].id).style.color = CM.Options.Colors[CM.Cache[target][i].color]; } } else { - for (var i in Game.Objects) { + for (let i of Object.keys(Game.Objects)) { l('productPrice' + Game.Objects[i].id).style.removeProperty("color"); } } } else if (Game.buyMode == -1) { - for (var i in CM.Cache.Objects) { + for (let i of Object.keys(CM.Cache.Objects)) { var o = Game.Objects[i]; l('productPrice' + o.id).style.color = ''; /* @@ -1953,7 +1952,7 @@ CM.Disp.UpdateBuildings = function() { return o; }); - arr.sort(function(a, b){ return (a.pp > b.pp ? 1 : (a.pp < b.pp ? -1 : 0)) }); + arr.sort(function(a, b){ return (a.pp > b.pp ? 1 : (a.pp < b.pp ? -1 : 0)); }); for (var x = 0; x < arr.length; x++) { Game.Objects[arr[x].name].l.style.gridRow = (x + 2) + "/" + (x + 2); @@ -1990,7 +1989,7 @@ CM.Disp.UpdateUpgrades = function() { var purple = 0; var gray = 0; - for (var i in Game.UpgradesInStore) { + for (let i of Object.keys(Game.UpgradesInStore)) { var me = Game.UpgradesInStore[i]; var addedColor = false; for (var j = 0; j < l('upgrade' + i).childNodes.length; j++) { @@ -2044,7 +2043,7 @@ CM.Disp.UpdateUpgrades = function() { } for (var x = 0; x < Game.UpgradesInStore.length; x++){ - l("upgrade" + x).style.order = arr.findIndex(e => e.name === Game.UpgradesInStore[x].name) + 1 + l("upgrade" + x).style.order = arr.findIndex(e => e.name === Game.UpgradesInStore[x].name) + 1; } }; @@ -2111,7 +2110,7 @@ CM.Disp.CreateUpgradeBar = function() { span.style.display = 'inline-block'; span.textContent = '0'; return span; - } + }; CM.Disp.UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarBlue', CM.Disp.colorBlue)); CM.Disp.UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarGreen', CM.Disp.colorGreen)); CM.Disp.UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarYellow', CM.Disp.colorYellow)); @@ -2149,7 +2148,7 @@ CM.Disp.CreateUpgradeBarLegend = function() { div.appendChild(span); div.appendChild(document.createTextNode(text)); return div; - } + }; legend.appendChild(legendLine(CM.Disp.colorBlue, 'Better than best PP building')); legend.appendChild(legendLine(CM.Disp.colorGreen, 'Same as best PP building')); @@ -2370,14 +2369,14 @@ CM.Disp.CreateGCTimer = function(cookie) { */ CM.Disp.ToggleGCTimer = function() { if (CM.Options.GCTimer == 1) { - for (var i in CM.Disp.GCTimers) { + for (let i of Object.keys(CM.Disp.GCTimers)) { CM.Disp.GCTimers[i].style.display = 'block'; CM.Disp.GCTimers[i].style.left = CM.Cache.goldenShimmersByID[i].l.style.left; CM.Disp.GCTimers[i].style.top = CM.Cache.goldenShimmersByID[i].l.style.top; } } else { - for (var i in CM.Disp.GCTimers) CM.Disp.GCTimers[i].style.display = 'none'; + for (let i of Object.keys(CM.Disp.GCTimers)) CM.Disp.GCTimers[i].style.display = 'none'; } }; @@ -2411,7 +2410,7 @@ CM.Disp.CreateSimpleTooltip = function(placeholder, text, minWidth) { */ CM.Disp.ReplaceTooltipUpgrade = function() { CM.Disp.TooltipUpgradeBackup = []; - for (var i in Game.UpgradesInStore) { + for (let i of Object.keys(Game.UpgradesInStore)) { var me = Game.UpgradesInStore[i]; if (l('upgrade' + i).onmouseover != null) { CM.Disp.TooltipUpgradeBackup[i] = l('upgrade' + i).onmouseover; @@ -2437,7 +2436,7 @@ CM.Disp.Tooltip = function(type, name) { if (amortizeAmount > 0) { l('tooltip').innerHTML = l('tooltip').innerHTML .split('so far') - .join('so far
' + Beautify(amortizeAmount) + ' ' + (Math.floor(amortizeAmount) == 1 ? 'cookie' : 'cookies') + ' left to amortize (' + CM.Disp.GetTimeColor((buildPrice - Game.Objects[name].totalCookies) / (Game.Objects[name].storedTotalCps * Game.globalCpsMult)).text + ')') + .join('so far
' + Beautify(amortizeAmount) + ' ' + (Math.floor(amortizeAmount) == 1 ? 'cookie' : 'cookies') + ' left to amortize (' + CM.Disp.GetTimeColor((buildPrice - Game.Objects[name].totalCookies) / (Game.Objects[name].storedTotalCps * Game.globalCpsMult)).text + ')'); } } if (Game.buyMode == -1) { @@ -2679,7 +2678,7 @@ CM.Disp.UpdateTooltipBuilding = function() { } // Add "production left till next achievement"-bar - for (var i in Game.Objects[CM.Disp.tooltipName].productionAchievs) { + for (let i of Object.keys(Game.Objects[CM.Disp.tooltipName].productionAchievs)) { if (!CM.Sim.HasAchiev(Game.Objects[CM.Disp.tooltipName].productionAchievs[i].achiev.name)) { var nextProductionAchiev = Game.Objects[CM.Disp.tooltipName].productionAchievs[i]; break; @@ -3024,7 +3023,7 @@ CM.Disp.ToggleToolWarnPos = function() { CM.Disp.CheckWrinklerTooltip = function() { if (CM.Options.TooltipWrink == 1 && CM.Disp.TooltipWrinklerArea == 1) { // Latter is set by CM.Main.AddWrinklerAreaDetect var showingTooltip = false; - for (var i in Game.wrinklers) { + for (let i of Object.keys(Game.wrinklers)) { var me = Game.wrinklers[i]; if (me.phase > 0 && me.selected) { showingTooltip = true; @@ -3169,13 +3168,13 @@ CM.Disp.AddMenuPref = function(title) { var frag = document.createDocumentFragment(); frag.appendChild(title()); - for (var group in CM.ConfigGroups) { + for (let group of Object.keys(CM.ConfigGroups)) { groupObject = CM.Disp.CreatePrefHeader(group, CM.ConfigGroups[group]); // (group, display-name of group) frag.appendChild(groupObject); if (CM.Options.Header[group]) { // 0 is show, 1 is collapsed // Make sub-sections of Notification section if (group == "Notification") { - for (var subGroup in CM.ConfigGroupsNotification) { + for (let subGroup of Object.keys(CM.ConfigGroupsNotification)) { subGroupObject = CM.Disp.CreatePrefHeader(subGroup, CM.ConfigGroupsNotification[subGroup]); // (group, display-name of group) subGroupObject.style.fontSize = "15px"; subGroupObject.style.opacity = "0.5"; @@ -3187,7 +3186,7 @@ CM.Disp.AddMenuPref = function(title) { } } } else { - for (var option in CM.ConfigData) { + for (let option of Object.keys(CM.ConfigData)) { if (CM.ConfigData[option].group == group) frag.appendChild(CM.Disp.CreatePrefOption(option)); } } @@ -3286,8 +3285,8 @@ CM.Disp.CreatePrefOption = function(config) { slider.max = "100"; slider.step = "1"; slider.value = CM.Options[config]; - slider.oninput = function() {CM.Config.ToggleConfigVolume(config)}; - slider.onchange = function() {CM.Config.ToggleConfigVolume(config)}; + slider.oninput = function() {CM.Config.ToggleConfigVolume(config);}; + slider.onchange = function() {CM.Config.ToggleConfigVolume(config);}; volume.appendChild(slider); div.appendChild(volume); return div; @@ -3340,7 +3339,7 @@ CM.Disp.CreatePrefOption = function(config) { innerDiv.appendChild(label); div.appendChild(innerDiv); } - return div + return div; } else if (CM.ConfigData[config].type == "numscale") { var div = document.createElement('div'); @@ -3360,7 +3359,7 @@ CM.Disp.CreatePrefOption = function(config) { CM.Options[config] = this.value; CM.Config.SaveConfig(); CM.Disp.RefreshScale(); - } + }; div.appendChild(input); div.appendChild(document.createTextNode(' ')); var label = document.createElement('label'); @@ -3461,7 +3460,7 @@ CM.Disp.AddMenuStats = function(title) { var popFattestA = document.createElement('a'); popFattestA.textContent = 'Pop Single Fattest'; 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]) Game.wrinklers[CM.Cache.WrinklersFattest[1]].hp = 0; }; popFattestFrag.appendChild(popFattestA); stats.appendChild(CM.Disp.CreateStatsListing("basic", 'Rewards of Popping Single Fattest Non-Shiny Wrinkler (id: ' + (CM.Cache.WrinklersFattest[1] ? CM.Cache.WrinklersFattest[1] : "None") + ")", popFattestFrag)); } @@ -3470,42 +3469,42 @@ CM.Disp.AddMenuStats = function(title) { var specDisp = false; var missingHalloweenCookies = []; - for (var i in CM.Data.HalloCookies) { + for (let i of Object.keys(CM.Data.HalloCookies)) { if (!Game.Has(CM.Data.HalloCookies[i])) { missingHalloweenCookies.push(CM.Data.HalloCookies[i]); specDisp = true; } } var missingChristmasCookies = []; - for (var i in CM.Data.ChristCookies) { + for (let i of Object.keys(CM.Data.ChristCookies)) { if (!Game.Has(CM.Data.ChristCookies[i])) { missingChristmasCookies.push(CM.Data.ChristCookies[i]); specDisp = true; } } var missingValentineCookies = []; - for (var i in CM.Data.ValCookies) { + for (let i of Object.keys(CM.Data.ValCookies)) { if (!Game.Has(CM.Data.ValCookies[i])) { missingValentineCookies.push(CM.Data.ValCookies[i]); specDisp = true; } } var missingNormalEggs = []; - for (var i in Game.eggDrops) { + for (let i of Object.keys(Game.eggDrops)) { if (!Game.HasUnlocked(Game.eggDrops[i])) { missingNormalEggs.push(Game.eggDrops[i]); specDisp = true; } } var missingRareEggs = []; - for (var i in Game.rareEggDrops) { + for (let i of Object.keys(Game.rareEggDrops)) { if (!Game.HasUnlocked(Game.rareEggDrops[i])) { missingRareEggs.push(Game.rareEggDrops[i]); specDisp = true; } } var missingPlantDrops = []; - for (var i in CM.Data.PlantDrops) { + for (let i of Object.keys(CM.Data.PlantDrops)) { if (!Game.HasUnlocked(CM.Data.PlantDrops[i])) { missingPlantDrops.push(CM.Data.PlantDrops[i]); specDisp = true; @@ -3543,7 +3542,7 @@ CM.Disp.AddMenuStats = function(title) { stats.appendChild(CM.Disp.CreateStatsListing("basic", 'Average Cookie Clicks Per Second (Past ' + CM.Disp.clickTimes[CM.Options.AvgClicksHist] + (CM.Options.AvgClicksHist == 0 ? ' second' : ' seconds') + ')', document.createTextNode(Beautify(CM.Cache.AverageClicks, 1)))); if (Game.Has('Fortune cookies')) { var fortunes = []; - for (var i in CM.Data.Fortunes) { + for (let i of Object.keys(CM.Data.Fortunes)) { if (!Game.Has(CM.Data.Fortunes[i])) { fortunes.push(CM.Data.Fortunes[i]); } @@ -3659,7 +3658,7 @@ CM.Disp.CreateStatsMissDisp = function(theMissDisp) { title.style.textAlign = 'center'; title.textContent = 'Missing'; missing.appendChild(title); - for (var i in theMissDisp) { + for (let i of Object.keys(theMissDisp)) { var div = document.createElement('div'); div.style.textAlign = 'center'; div.appendChild(document.createTextNode(theMissDisp[i])); @@ -3742,7 +3741,7 @@ CM.Disp.CreateStatsLuckySection = function() { var luckyCurSpan = document.createElement('span'); luckyCurSpan.style.fontWeight = 'bold'; luckyCurSpan.className = CM.Disp.colorTextPre + luckyCurSpan; - luckyCurSpan.textContent = Beautify(CM.Cache.GoldenCookiesMult * luckyCurBase) + (luckySplit ? (' / ' + Beautify(CM.Cache.WrathCookiesMult * luckyCurBase)) : '') + luckyCurSpan.textContent = Beautify(CM.Cache.GoldenCookiesMult * luckyCurBase) + (luckySplit ? (' / ' + Beautify(CM.Cache.WrathCookiesMult * luckyCurBase)) : ''); section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Lucky!\" Reward (CUR)' + (luckySplit ? ' (Golden / Wrath)' : ''), luckyCurSpan, goldCookTooltip)); return section; }; @@ -3967,31 +3966,31 @@ CM.Disp.AddMissingUpgrades = function() { upgrades = document.createElement('div'); upgrades.className = "listing crateBox"; upgrades.innerHTML = CM.Cache.MissingUpgradesPrestige; - l('menu').children[5].appendChild(upgrades) + l('menu').children[5].appendChild(upgrades); } if (CM.Cache.MissingUpgrades) { if (Game.UpgradesOwned) { - var normalUpgradesOwned = Game.UpgradesByPool[""].length + Game.UpgradesByPool["tech"].length - l('menu').children[6].childNodes[2].children.length; + var normalUpgradesOwned = Game.UpgradesByPool[""].length + Game.UpgradesByPool.tech.length - l('menu').children[6].childNodes[2].children.length; } else var normalUpgradesOwned = 0; var title = document.createElement('div'); title.id = "CMMissingUpgradesTitle"; title.className = "listing"; titlefrag = document.createElement('div'); - titlefrag.innerHTML = 'Missing normal upgrades: '+ normalUpgradesOwned + '/' + (Game.UpgradesByPool[""].length + Game.UpgradesByPool["tech"].length) + ' (' + Math.floor((normalUpgradesOwned / ( Game.UpgradesByPool[""].length + Game.UpgradesByPool["tech"].length)) * 100) + '%)'; + titlefrag.innerHTML = 'Missing normal upgrades: '+ normalUpgradesOwned + '/' + (Game.UpgradesByPool[""].length + Game.UpgradesByPool.tech.length) + ' (' + Math.floor((normalUpgradesOwned / ( Game.UpgradesByPool[""].length + Game.UpgradesByPool.tech.length)) * 100) + '%)'; title.appendChild(titlefrag); l('menu').children[6].insertBefore(title, l('menu').children[6].childNodes[3]); upgrades = document.createElement('div'); upgrades.className = "listing crateBox"; upgrades.innerHTML = CM.Cache.MissingUpgrades; - l('menu').children[6].insertBefore(upgrades, document.getElementById("CMMissingUpgradesTitle").nextSibling) + l('menu').children[6].insertBefore(upgrades, document.getElementById("CMMissingUpgradesTitle").nextSibling); } if (CM.Cache.MissingUpgradesCookies) { - var cookieUpgradesOwned = Game.UpgradesByPool["cookie"].length - l('menu').children[6].lastChild.children.length; + var cookieUpgradesOwned = Game.UpgradesByPool.cookie.length - l('menu').children[6].lastChild.children.length; var title = document.createElement('div'); title.id = "CMMissingUpgradesCookiesTitle"; title.className = "listing"; titlefrag = document.createElement('div'); - titlefrag.innerHTML = 'Missing Cookie upgrades: '+ cookieUpgradesOwned + '/' + Game.UpgradesByPool["cookie"].length + ' (' + Math.floor((cookieUpgradesOwned / Game.UpgradesByPool["cookie"].length) * 100) + '%)'; + titlefrag.innerHTML = 'Missing Cookie upgrades: '+ cookieUpgradesOwned + '/' + Game.UpgradesByPool.cookie.length + ' (' + Math.floor((cookieUpgradesOwned / Game.UpgradesByPool.cookie.length) * 100) + '%)'; title.appendChild(titlefrag); l('menu').children[6].appendChild(title); upgrades = document.createElement('div'); @@ -4035,13 +4034,13 @@ CM.Disp.crateMissing = function(me) { */ CM.Disp.CreateWrinklerButtons = function() { var popAllA = document.createElement('a'); - popAllA.id = "PopAllNormalWrinklerButton" + popAllA.id = "PopAllNormalWrinklerButton"; popAllA.textContent = 'Pop All Normal'; popAllA.className = 'option'; popAllA.onclick = function() { CM.Disp.PopAllNormalWrinklers(); }; l('sectionLeftExtra').children[0].append(popAllA); var popFattestA = document.createElement('a'); - popFattestA.id = "PopFattestWrinklerButton" + popFattestA.id = "PopFattestWrinklerButton"; popFattestA.textContent = 'Pop Single Fattest'; popFattestA.className = 'option'; popFattestA.onclick = function() {if (CM.Cache.WrinklersFattest[1]) Game.wrinklers[CM.Cache.WrinklersFattest[1]].hp = 0; }; diff --git a/src/Cache.js b/src/Cache.js index bd97936..e86c8bf 100644 --- a/src/Cache.js +++ b/src/Cache.js @@ -48,7 +48,7 @@ CM.Cache.CacheWrinklers = function() { CM.Cache.WrinklersTotal = 0; CM.Cache.WrinklersNormal = 0; CM.Cache.WrinklersFattest = [0, null]; - for (var i in Game.wrinklers) { + 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; @@ -106,11 +106,11 @@ CM.Cache.CacheStats = function() { CM.Cache.Edifice = 0; var max = 0; var n = 0; - for (var i in Game.Objects) { + 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 (var i in Game.Objects) { + 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) { @@ -133,7 +133,7 @@ CM.Cache.CacheMissingUpgrades = function() { CM.Cache.MissingUpgradesPrestige = ""; var list = []; //sort the upgrades - for (var i in Game.Upgrades) { + for (let i of Object.keys(Game.Upgrades)) { list.push(Game.Upgrades[i]); } var sortMap = function(a, b) { @@ -143,7 +143,7 @@ CM.Cache.CacheMissingUpgrades = function() { }; list.sort(sortMap); - for (var i in list) { + for (let i of Object.keys(list)) { var me = list[i]; if (me.bought == 0) { @@ -182,10 +182,10 @@ class CMAvgQueue { // TODO: Might want to do this according to "https://stackoverflow.com/questions/10359907/how-to-compute-the-sum-and-average-of-elements-in-an-array" calcAverage (timePeriod) { - if (timePeriod > this.maxLength) timePeriod = this.maxLength, console.log("Called for average of Queue for time-period longer than MaxLength"); + if (timePeriod > this.maxLength) timePeriod = this.maxLength; if (timePeriod > this.queue.length) timePeriod = this.queue.length; var ret = 0; - for (var i = this.queue.length - 1; i >= 0 && i > this.queue.length - 1 - timePeriod; i--) { + for (let i = this.queue.length - 1; i >= 0 && i > this.queue.length - 1 - timePeriod; i--) { ret += this.queue[i]; } return ret / timePeriod; @@ -229,7 +229,7 @@ CM.Cache.UpdateAvgCPS = function() { var wrinkFattestDiffAvg = Math.max(0, (CM.Cache.WrinklersFattest[0] - CM.Cache.lastWrinkFattestCookies)) / timeDiff; var choEggDiffAvg = Math.max(0,(choEggTotal - CM.Cache.lastChoEgg)) / timeDiff; var clicksDiffAvg = (Game.cookieClicks - CM.Cache.lastClicks) / timeDiff; - for (var i = 0; i < timeDiff; i++) { + for (let i = 0; i < timeDiff; i++) { CM.Cache.CookiesDiff.addLatest(bankDiffAvg); CM.Cache.WrinkDiff.addLatest(wrinkDiffAvg); CM.Cache.WrinkFattestDiff.addLatest(wrinkFattestDiffAvg); @@ -312,7 +312,7 @@ CM.Cache.CacheDragonCost = function() { else { let cost = 0; CM.Sim.CopyData(); - for (var i = 0; i < amount; i++) { + for (let i = 0; i < amount; i++) { let price = CM.Sim.Objects[target].basePrice * Math.pow(Game.priceIncrease, Math.max(0, CM.Sim.Objects[target].amount - 1 - CM.Sim.Objects[target].free)); price = Game.modifyBuildingPrice(CM.Sim.Objects[target], price); price = Math.ceil(price); @@ -325,14 +325,14 @@ CM.Cache.CacheDragonCost = function() { else { let cost = 0; CM.Sim.CopyData(); - for (var j in Game.Objects) { + for (let j of Object.keys(Game.Objects)) { target = j; if (Game.Objects[target].amount < amount) { CM.Cache.CostDragonUpgrade = "Not enough buildings to sell"; break; } else { - for (var i = 0; i < amount; i++) { + for (let i = 0; i < amount; i++) { let price = CM.Sim.Objects[target].basePrice * Math.pow(Game.priceIncrease, Math.max(0, CM.Sim.Objects[target].amount - 1 - CM.Sim.Objects[target].free)); price = Game.modifyBuildingPrice(CM.Sim.Objects[target], price); price = Math.ceil(price); @@ -360,7 +360,7 @@ CM.Cache.NextNumber = function(base) { }; CM.Cache.RemakeBuildingsPrices = function() { - for (var i in Game.Objects) { + for (let i of Object.keys(Game.Objects)) { CM.Cache.Objects[i].price = CM.Sim.BuildingGetPrice(Game.Objects[i], Game.Objects[i].basePrice, Game.Objects[i].amount, Game.Objects[i].free, 1); CM.Cache.Objects10[i].price = CM.Sim.BuildingGetPrice(Game.Objects[i], Game.Objects[i].basePrice, Game.Objects[i].amount, Game.Objects[i].free, 10); CM.Cache.Objects100[i].price = CM.Sim.BuildingGetPrice(Game.Objects[i], Game.Objects[i].basePrice, Game.Objects[i].amount, Game.Objects[i].free, 100); @@ -387,7 +387,7 @@ CM.Cache.RemakeBuildingsPP = function() { CM.Cache.mid = -1; // Calculate PP and colors when compared to purchase of single optimal building if (CM.Options.ColorPPBulkMode == 0) { - for (var i in CM.Cache.Objects) { + for (let i of Object.keys(CM.Cache.Objects)) { //CM.Cache.Objects[i].pp = Game.Objects[i].getPrice() / CM.Cache.Objects[i].bonus; if (Game.cookiesPs) { CM.Cache.Objects[i].pp = (Math.max(Game.Objects[i].getPrice() - (Game.cookies + CM.Disp.GetWrinkConfigBank()), 0) / Game.cookiesPs) + (Game.Objects[i].getPrice() / CM.Cache.Objects[i].bonus); @@ -398,7 +398,7 @@ CM.Cache.RemakeBuildingsPP = function() { if (CM.Cache.max == -1 || CM.Cache.Objects[i].pp > CM.Cache.max) CM.Cache.max = CM.Cache.Objects[i].pp; } CM.Cache.mid = ((CM.Cache.max - CM.Cache.min) / 2) + CM.Cache.min; - for (var i in CM.Cache.Objects) { + for (let i of Object.keys(CM.Cache.Objects)) { let color = ''; if (CM.Cache.Objects[i].pp == CM.Cache.min) color = CM.Disp.colorGreen; else if (CM.Cache.Objects[i].pp == CM.Cache.max) color = CM.Disp.colorRed; @@ -415,7 +415,7 @@ CM.Cache.RemakeBuildingsPP = function() { // Calculate PP and colors when compared to purchase of selected bulk mode else { if (Game.buyBulk == 1) { - for (var i in CM.Cache.Objects) { + for (let i of Object.keys(CM.Cache.Objects)) { //CM.Cache.Objects[i].pp = Game.Objects[i].getPrice() / CM.Cache.Objects[i].bonus; if (Game.cookiesPs) { CM.Cache.Objects[i].pp = (Math.max(Game.Objects[i].getPrice() - (Game.cookies + CM.Disp.GetWrinkConfigBank()), 0) / Game.cookiesPs) + (Game.Objects[i].getPrice() / CM.Cache.Objects[i].bonus); @@ -426,7 +426,7 @@ CM.Cache.RemakeBuildingsPP = function() { if (CM.Cache.max == -1 || CM.Cache.Objects[i].pp > CM.Cache.max) CM.Cache.max = CM.Cache.Objects[i].pp; } CM.Cache.mid = ((CM.Cache.max - CM.Cache.min) / 2) + CM.Cache.min; - for (var i in CM.Cache.Objects) { + for (let i of Object.keys(CM.Cache.Objects)) { let color = ''; if (CM.Cache.Objects[i].pp == CM.Cache.min) color = CM.Disp.colorGreen; else if (CM.Cache.Objects[i].pp == CM.Cache.max) color = CM.Disp.colorRed; @@ -438,7 +438,7 @@ CM.Cache.RemakeBuildingsPP = function() { CM.Cache.RemakeBuildingsOtherPP(100, 'Objects100'); } else if (Game.buyBulk == 10) { - for (var i in CM.Cache.Objects) { + for (let i of Object.keys(CM.Cache.Objects)) { 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 { @@ -448,7 +448,7 @@ CM.Cache.RemakeBuildingsPP = function() { 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 (var i in CM.Cache.Objects) { + for (let i of Object.keys(CM.Cache.Objects)) { 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; @@ -460,7 +460,7 @@ CM.Cache.RemakeBuildingsPP = function() { CM.Cache.RemakeBuildingsOtherPP(100, 'Objects100'); } else if (Game.buyBulk == 100) { - for (var i in CM.Cache.Objects) { + for (let i of Object.keys(CM.Cache.Objects)) { 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 { @@ -470,7 +470,7 @@ CM.Cache.RemakeBuildingsPP = function() { 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 (var i in CM.Cache.Objects) { + for (let i of Object.keys(CM.Cache.Objects)) { 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; @@ -485,7 +485,7 @@ CM.Cache.RemakeBuildingsPP = function() { }; CM.Cache.RemakeUpgradePP = function() { - for (var i in CM.Cache.Upgrades) { + 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); @@ -506,7 +506,7 @@ CM.Cache.RemakeUpgradePP = function() { }; CM.Cache.RemakeBuildingsOtherPP = function(amount, target) { - for (var i in CM.Cache[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); @@ -637,7 +637,7 @@ CM.Cache.RemakeSellForChoEgg = function() { if (Game.Objects.Bank.minigameLoaded) { var marketGoods = Game.Objects.Bank.minigame.goods; var goodsVal = 0; - for (var i in marketGoods) { + for (let i of Object.keys(marketGoods)) { var marketGood = marketGoods[i]; goodsVal += marketGood.stock * marketGood.val; } @@ -669,7 +669,6 @@ CM.Cache.SellForChoEgg = 0; CM.Cache.Title = ''; CM.Cache.HadBuildAura = false; CM.Cache.RealCookiesEarned = -1; -CM.Cache.seasonPopShimmer; CM.Cache.goldenShimmersByID = {}; CM.Cache.spawnedGoldenShimmer = 0; diff --git a/src/Config.js b/src/Config.js index 4e8cc80..5fce331 100644 --- a/src/Config.js +++ b/src/Config.js @@ -34,7 +34,7 @@ CM.Config.LoadConfig = function(settings) { // Check values var mod = false; - for (var i in CM.Data.ConfigDefault) { + for (let i in CM.Data.ConfigDefault) { if (typeof CM.Options[i] === 'undefined') { mod = true; CM.Options[i] = CM.Data.ConfigDefault[i]; @@ -54,7 +54,7 @@ CM.Config.LoadConfig = function(settings) { } } else if (i == 'Header') { - for (var j in CM.Data.ConfigDefault.Header) { + for (let j in CM.Data.ConfigDefault.Header) { if (typeof CM.Options[i][j] === 'undefined' || !(CM.Options[i][j] > -1 && CM.Options[i][j] < 2)) { mod = true; CM.Options[i][j] = CM.Data.ConfigDefault[i][j]; @@ -62,7 +62,7 @@ CM.Config.LoadConfig = function(settings) { } } else { // Colors - for (var j in CM.Data.ConfigDefault.Colors) { + for (let j in CM.Data.ConfigDefault.Colors) { if (typeof CM.Options[i][j] === 'undefined' || typeof CM.Options[i][j] != 'string') { mod = true; CM.Options[i][j] = CM.Data.ConfigDefault[i][j]; @@ -72,7 +72,7 @@ CM.Config.LoadConfig = function(settings) { } if (mod) CM.Config.SaveConfig(); CM.Loop(); // Do loop once - for (var i in CM.Data.ConfigDefault) { + for (let i in CM.Data.ConfigDefault) { if (i != 'Header' && typeof CM.ConfigData[i].func !== 'undefined') { CM.ConfigData[i].func(); } diff --git a/src/Disp.js b/src/Disp.js index f9a9fb9..43e6659 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -29,7 +29,7 @@ CM.Disp.GetWrinkConfigBank = function() { * It is called by a click of the 'pop all' button created by CM.Disp.AddMenuStats() */ CM.Disp.PopAllNormalWrinklers = function() { - for (var i in Game.wrinklers) { + for (let i of Object.keys(Game.wrinklers)) { if (Game.wrinklers[i].sucked > 0 && Game.wrinklers[i].type == 0) { Game.wrinklers[i].hp = 0; } @@ -363,7 +363,7 @@ CM.Disp.CreateBotBar = function() { td.className = CM.Disp.colorTextPre + color; td.textContent = text; return td; - } + }; var type = tbody.appendChild(document.createElement('tr')); type.style.fontWeight = 'bold'; type.appendChild(firstCol('CM ' + CM.VersionMajor + '.' + CM.VersionMinor, CM.Disp.colorYellow)); @@ -374,7 +374,7 @@ CM.Disp.CreateBotBar = function() { var time = tbody.appendChild(document.createElement('tr')); time.appendChild(firstCol('Time Left', CM.Disp.colorBlue)); - for (var i in Game.Objects) { + for (let i of Object.keys(Game.Objects)) { CM.Disp.CreateBotBarBuildingColumn(i); } @@ -386,9 +386,9 @@ CM.Disp.CreateBotBar = function() { * It is called by CM.Loop() */ CM.Disp.UpdateBotBar = function() { - if (CM.Options.BotBar == 1) { + if (CM.Options.BotBar == 1 && CM.Cache.Objects) { var count = 0; - for (var i in CM.Cache.Objects) { + for (let i of Object.keys(CM.Cache.Objects)) { var target = 'Objects'; if (Game.buyBulk == 10) {target = 'Objects10';} if (Game.buyBulk == 100) {target = 'Objects100';} @@ -462,14 +462,14 @@ CM.Disp.CreateTimerBar = function() { 'Next Cookie', [{id: 'CMTimerBarGCMinBar', color: CM.Disp.colorGray}, {id: 'CMTimerBarGCBar', color: CM.Disp.colorPurple}] ); - CM.Disp.TimerBar.appendChild(CM.Disp.TimerBars.CMTimerBarGC) + CM.Disp.TimerBar.appendChild(CM.Disp.TimerBars.CMTimerBarGC); // Create standard Reindeer bar CM.Disp.TimerBars. CMTimerBarRen = CM.Disp.TimerBarCreateBar('CMTimerBarRen', 'Next Reindeer', [{id: 'CMTimerBarRenMinBar', color: CM.Disp.colorGray}, {id: 'CMTimerBarRenBar', color: CM.Disp.colorOrange}] ); - CM.Disp.TimerBar.appendChild(CM.Disp.TimerBars. CMTimerBarRen) + CM.Disp.TimerBar.appendChild(CM.Disp.TimerBars. CMTimerBarRen); l('wrapper').appendChild(CM.Disp.TimerBar); }; @@ -510,7 +510,7 @@ CM.Disp.TimerBarCreateBar = function(id, name, bars) { for (var i = 0; i < bars.length; i++) { var colorBar = document.createElement('span'); - colorBar.id = bars[i].id + colorBar.id = bars[i].id; colorBar.style.display = 'inline-block'; colorBar.style.height = '10px'; colorBar.style.verticalAlign = "text-top"; @@ -587,11 +587,11 @@ CM.Disp.UpdateTimerBar = function() { } // On every frame all buff-timers are deleted and re-created - for (var i in CM.Disp.BuffTimerBars) { + for (let i of Object.keys(CM.Disp.BuffTimerBars)) { CM.Disp.BuffTimerBars[i].remove(); } - CM.Disp.BuffTimerBars = {} - for (var i in Game.buffs) { + CM.Disp.BuffTimerBars = {}; + for (let i of Object.keys(Game.buffs)) { if (Game.buffs[i]) { timer = CM.Disp.TimerBarCreateBar(Game.buffs[i].name, Game.buffs[i].name, [{id: Game.buffs[i].name + 'Bar'}]); timer.style.display = ''; @@ -608,10 +608,10 @@ CM.Disp.UpdateTimerBar = function() { timer.lastChild.children[1].style.width = Math.round(Game.buffs[i].time * (maxWidthOneBar - Math.ceil(Game.buffs[i].time / Game.fps).toString().length * 8) / Game.buffs[i].maxTime) + 'px'; timer.lastChild.children[2].textContent = Math.ceil(Game.buffs[i].time / Game.fps); numberOfTimers++; - CM.Disp.BuffTimerBars[Game.buffs[i].name] = timer + CM.Disp.BuffTimerBars[Game.buffs[i].name] = timer; } } - for (var i in CM.Disp.BuffTimerBars) { + for (let i of Object.keys(CM.Disp.BuffTimerBars)) { CM.Disp.TimerBar.appendChild(CM.Disp.BuffTimerBars[i]); } @@ -619,7 +619,7 @@ CM.Disp.UpdateTimerBar = function() { CM.Disp.TimerBar.style.height = numberOfTimers * 12 + 2 + 'px'; } if (CM.Disp.LastNumberOfTimers != numberOfTimers) { - CM.Disp.LastNumberOfTimers = numberOfTimers + CM.Disp.LastNumberOfTimers = numberOfTimers; CM.Disp.UpdateBotTimerBarPosition(); } } @@ -702,17 +702,17 @@ CM.Disp.UpdateBuildings = function() { else if (Game.buyBulk == 100 && CM.Options.BulkBuildColor == 1) target = 'Objects100'; else target = 'Objects'; if (CM.Options.BuildColor == 1) { - for (var i in CM.Cache[target]) { + for (let i of Object.keys(CM.Cache[target])) { l('productPrice' + Game.Objects[i].id).style.color = CM.Options.Colors[CM.Cache[target][i].color]; } } else { - for (var i in Game.Objects) { + for (let i of Object.keys(Game.Objects)) { l('productPrice' + Game.Objects[i].id).style.removeProperty("color"); } } } else if (Game.buyMode == -1) { - for (var i in CM.Cache.Objects) { + for (let i of Object.keys(CM.Cache.Objects)) { var o = Game.Objects[i]; l('productPrice' + o.id).style.color = ''; /* @@ -739,7 +739,7 @@ CM.Disp.UpdateBuildings = function() { return o; }); - arr.sort(function(a, b){ return (a.pp > b.pp ? 1 : (a.pp < b.pp ? -1 : 0)) }); + arr.sort(function(a, b){ return (a.pp > b.pp ? 1 : (a.pp < b.pp ? -1 : 0)); }); for (var x = 0; x < arr.length; x++) { Game.Objects[arr[x].name].l.style.gridRow = (x + 2) + "/" + (x + 2); @@ -776,7 +776,7 @@ CM.Disp.UpdateUpgrades = function() { var purple = 0; var gray = 0; - for (var i in Game.UpgradesInStore) { + for (let i of Object.keys(Game.UpgradesInStore)) { var me = Game.UpgradesInStore[i]; var addedColor = false; for (var j = 0; j < l('upgrade' + i).childNodes.length; j++) { @@ -830,7 +830,7 @@ CM.Disp.UpdateUpgrades = function() { } for (var x = 0; x < Game.UpgradesInStore.length; x++){ - l("upgrade" + x).style.order = arr.findIndex(e => e.name === Game.UpgradesInStore[x].name) + 1 + l("upgrade" + x).style.order = arr.findIndex(e => e.name === Game.UpgradesInStore[x].name) + 1; } }; @@ -897,7 +897,7 @@ CM.Disp.CreateUpgradeBar = function() { span.style.display = 'inline-block'; span.textContent = '0'; return span; - } + }; CM.Disp.UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarBlue', CM.Disp.colorBlue)); CM.Disp.UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarGreen', CM.Disp.colorGreen)); CM.Disp.UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarYellow', CM.Disp.colorYellow)); @@ -935,7 +935,7 @@ CM.Disp.CreateUpgradeBarLegend = function() { div.appendChild(span); div.appendChild(document.createTextNode(text)); return div; - } + }; legend.appendChild(legendLine(CM.Disp.colorBlue, 'Better than best PP building')); legend.appendChild(legendLine(CM.Disp.colorGreen, 'Same as best PP building')); @@ -1156,14 +1156,14 @@ CM.Disp.CreateGCTimer = function(cookie) { */ CM.Disp.ToggleGCTimer = function() { if (CM.Options.GCTimer == 1) { - for (var i in CM.Disp.GCTimers) { + for (let i of Object.keys(CM.Disp.GCTimers)) { CM.Disp.GCTimers[i].style.display = 'block'; CM.Disp.GCTimers[i].style.left = CM.Cache.goldenShimmersByID[i].l.style.left; CM.Disp.GCTimers[i].style.top = CM.Cache.goldenShimmersByID[i].l.style.top; } } else { - for (var i in CM.Disp.GCTimers) CM.Disp.GCTimers[i].style.display = 'none'; + for (let i of Object.keys(CM.Disp.GCTimers)) CM.Disp.GCTimers[i].style.display = 'none'; } }; @@ -1197,7 +1197,7 @@ CM.Disp.CreateSimpleTooltip = function(placeholder, text, minWidth) { */ CM.Disp.ReplaceTooltipUpgrade = function() { CM.Disp.TooltipUpgradeBackup = []; - for (var i in Game.UpgradesInStore) { + for (let i of Object.keys(Game.UpgradesInStore)) { var me = Game.UpgradesInStore[i]; if (l('upgrade' + i).onmouseover != null) { CM.Disp.TooltipUpgradeBackup[i] = l('upgrade' + i).onmouseover; @@ -1223,7 +1223,7 @@ CM.Disp.Tooltip = function(type, name) { if (amortizeAmount > 0) { l('tooltip').innerHTML = l('tooltip').innerHTML .split('so far') - .join('so far
' + Beautify(amortizeAmount) + ' ' + (Math.floor(amortizeAmount) == 1 ? 'cookie' : 'cookies') + ' left to amortize (' + CM.Disp.GetTimeColor((buildPrice - Game.Objects[name].totalCookies) / (Game.Objects[name].storedTotalCps * Game.globalCpsMult)).text + ')') + .join('so far
' + Beautify(amortizeAmount) + ' ' + (Math.floor(amortizeAmount) == 1 ? 'cookie' : 'cookies') + ' left to amortize (' + CM.Disp.GetTimeColor((buildPrice - Game.Objects[name].totalCookies) / (Game.Objects[name].storedTotalCps * Game.globalCpsMult)).text + ')'); } } if (Game.buyMode == -1) { @@ -1465,7 +1465,7 @@ CM.Disp.UpdateTooltipBuilding = function() { } // Add "production left till next achievement"-bar - for (var i in Game.Objects[CM.Disp.tooltipName].productionAchievs) { + for (let i of Object.keys(Game.Objects[CM.Disp.tooltipName].productionAchievs)) { if (!CM.Sim.HasAchiev(Game.Objects[CM.Disp.tooltipName].productionAchievs[i].achiev.name)) { var nextProductionAchiev = Game.Objects[CM.Disp.tooltipName].productionAchievs[i]; break; @@ -1810,7 +1810,7 @@ CM.Disp.ToggleToolWarnPos = function() { CM.Disp.CheckWrinklerTooltip = function() { if (CM.Options.TooltipWrink == 1 && CM.Disp.TooltipWrinklerArea == 1) { // Latter is set by CM.Main.AddWrinklerAreaDetect var showingTooltip = false; - for (var i in Game.wrinklers) { + for (let i of Object.keys(Game.wrinklers)) { var me = Game.wrinklers[i]; if (me.phase > 0 && me.selected) { showingTooltip = true; @@ -1955,13 +1955,13 @@ CM.Disp.AddMenuPref = function(title) { var frag = document.createDocumentFragment(); frag.appendChild(title()); - for (var group in CM.ConfigGroups) { + for (let group of Object.keys(CM.ConfigGroups)) { groupObject = CM.Disp.CreatePrefHeader(group, CM.ConfigGroups[group]); // (group, display-name of group) frag.appendChild(groupObject); if (CM.Options.Header[group]) { // 0 is show, 1 is collapsed // Make sub-sections of Notification section if (group == "Notification") { - for (var subGroup in CM.ConfigGroupsNotification) { + for (let subGroup of Object.keys(CM.ConfigGroupsNotification)) { subGroupObject = CM.Disp.CreatePrefHeader(subGroup, CM.ConfigGroupsNotification[subGroup]); // (group, display-name of group) subGroupObject.style.fontSize = "15px"; subGroupObject.style.opacity = "0.5"; @@ -1973,7 +1973,7 @@ CM.Disp.AddMenuPref = function(title) { } } } else { - for (var option in CM.ConfigData) { + for (let option of Object.keys(CM.ConfigData)) { if (CM.ConfigData[option].group == group) frag.appendChild(CM.Disp.CreatePrefOption(option)); } } @@ -2072,8 +2072,8 @@ CM.Disp.CreatePrefOption = function(config) { slider.max = "100"; slider.step = "1"; slider.value = CM.Options[config]; - slider.oninput = function() {CM.Config.ToggleConfigVolume(config)}; - slider.onchange = function() {CM.Config.ToggleConfigVolume(config)}; + slider.oninput = function() {CM.Config.ToggleConfigVolume(config);}; + slider.onchange = function() {CM.Config.ToggleConfigVolume(config);}; volume.appendChild(slider); div.appendChild(volume); return div; @@ -2126,7 +2126,7 @@ CM.Disp.CreatePrefOption = function(config) { innerDiv.appendChild(label); div.appendChild(innerDiv); } - return div + return div; } else if (CM.ConfigData[config].type == "numscale") { var div = document.createElement('div'); @@ -2146,7 +2146,7 @@ CM.Disp.CreatePrefOption = function(config) { CM.Options[config] = this.value; CM.Config.SaveConfig(); CM.Disp.RefreshScale(); - } + }; div.appendChild(input); div.appendChild(document.createTextNode(' ')); var label = document.createElement('label'); @@ -2247,7 +2247,7 @@ CM.Disp.AddMenuStats = function(title) { var popFattestA = document.createElement('a'); popFattestA.textContent = 'Pop Single Fattest'; 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]) Game.wrinklers[CM.Cache.WrinklersFattest[1]].hp = 0; }; popFattestFrag.appendChild(popFattestA); stats.appendChild(CM.Disp.CreateStatsListing("basic", 'Rewards of Popping Single Fattest Non-Shiny Wrinkler (id: ' + (CM.Cache.WrinklersFattest[1] ? CM.Cache.WrinklersFattest[1] : "None") + ")", popFattestFrag)); } @@ -2256,42 +2256,42 @@ CM.Disp.AddMenuStats = function(title) { var specDisp = false; var missingHalloweenCookies = []; - for (var i in CM.Data.HalloCookies) { + for (let i of Object.keys(CM.Data.HalloCookies)) { if (!Game.Has(CM.Data.HalloCookies[i])) { missingHalloweenCookies.push(CM.Data.HalloCookies[i]); specDisp = true; } } var missingChristmasCookies = []; - for (var i in CM.Data.ChristCookies) { + for (let i of Object.keys(CM.Data.ChristCookies)) { if (!Game.Has(CM.Data.ChristCookies[i])) { missingChristmasCookies.push(CM.Data.ChristCookies[i]); specDisp = true; } } var missingValentineCookies = []; - for (var i in CM.Data.ValCookies) { + for (let i of Object.keys(CM.Data.ValCookies)) { if (!Game.Has(CM.Data.ValCookies[i])) { missingValentineCookies.push(CM.Data.ValCookies[i]); specDisp = true; } } var missingNormalEggs = []; - for (var i in Game.eggDrops) { + for (let i of Object.keys(Game.eggDrops)) { if (!Game.HasUnlocked(Game.eggDrops[i])) { missingNormalEggs.push(Game.eggDrops[i]); specDisp = true; } } var missingRareEggs = []; - for (var i in Game.rareEggDrops) { + for (let i of Object.keys(Game.rareEggDrops)) { if (!Game.HasUnlocked(Game.rareEggDrops[i])) { missingRareEggs.push(Game.rareEggDrops[i]); specDisp = true; } } var missingPlantDrops = []; - for (var i in CM.Data.PlantDrops) { + for (let i of Object.keys(CM.Data.PlantDrops)) { if (!Game.HasUnlocked(CM.Data.PlantDrops[i])) { missingPlantDrops.push(CM.Data.PlantDrops[i]); specDisp = true; @@ -2329,7 +2329,7 @@ CM.Disp.AddMenuStats = function(title) { stats.appendChild(CM.Disp.CreateStatsListing("basic", 'Average Cookie Clicks Per Second (Past ' + CM.Disp.clickTimes[CM.Options.AvgClicksHist] + (CM.Options.AvgClicksHist == 0 ? ' second' : ' seconds') + ')', document.createTextNode(Beautify(CM.Cache.AverageClicks, 1)))); if (Game.Has('Fortune cookies')) { var fortunes = []; - for (var i in CM.Data.Fortunes) { + for (let i of Object.keys(CM.Data.Fortunes)) { if (!Game.Has(CM.Data.Fortunes[i])) { fortunes.push(CM.Data.Fortunes[i]); } @@ -2445,7 +2445,7 @@ CM.Disp.CreateStatsMissDisp = function(theMissDisp) { title.style.textAlign = 'center'; title.textContent = 'Missing'; missing.appendChild(title); - for (var i in theMissDisp) { + for (let i of Object.keys(theMissDisp)) { var div = document.createElement('div'); div.style.textAlign = 'center'; div.appendChild(document.createTextNode(theMissDisp[i])); @@ -2528,7 +2528,7 @@ CM.Disp.CreateStatsLuckySection = function() { var luckyCurSpan = document.createElement('span'); luckyCurSpan.style.fontWeight = 'bold'; luckyCurSpan.className = CM.Disp.colorTextPre + luckyCurSpan; - luckyCurSpan.textContent = Beautify(CM.Cache.GoldenCookiesMult * luckyCurBase) + (luckySplit ? (' / ' + Beautify(CM.Cache.WrathCookiesMult * luckyCurBase)) : '') + luckyCurSpan.textContent = Beautify(CM.Cache.GoldenCookiesMult * luckyCurBase) + (luckySplit ? (' / ' + Beautify(CM.Cache.WrathCookiesMult * luckyCurBase)) : ''); section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Lucky!\" Reward (CUR)' + (luckySplit ? ' (Golden / Wrath)' : ''), luckyCurSpan, goldCookTooltip)); return section; }; @@ -2753,31 +2753,31 @@ CM.Disp.AddMissingUpgrades = function() { upgrades = document.createElement('div'); upgrades.className = "listing crateBox"; upgrades.innerHTML = CM.Cache.MissingUpgradesPrestige; - l('menu').children[5].appendChild(upgrades) + l('menu').children[5].appendChild(upgrades); } if (CM.Cache.MissingUpgrades) { if (Game.UpgradesOwned) { - var normalUpgradesOwned = Game.UpgradesByPool[""].length + Game.UpgradesByPool["tech"].length - l('menu').children[6].childNodes[2].children.length; + var normalUpgradesOwned = Game.UpgradesByPool[""].length + Game.UpgradesByPool.tech.length - l('menu').children[6].childNodes[2].children.length; } else var normalUpgradesOwned = 0; var title = document.createElement('div'); title.id = "CMMissingUpgradesTitle"; title.className = "listing"; titlefrag = document.createElement('div'); - titlefrag.innerHTML = 'Missing normal upgrades: '+ normalUpgradesOwned + '/' + (Game.UpgradesByPool[""].length + Game.UpgradesByPool["tech"].length) + ' (' + Math.floor((normalUpgradesOwned / ( Game.UpgradesByPool[""].length + Game.UpgradesByPool["tech"].length)) * 100) + '%)'; + titlefrag.innerHTML = 'Missing normal upgrades: '+ normalUpgradesOwned + '/' + (Game.UpgradesByPool[""].length + Game.UpgradesByPool.tech.length) + ' (' + Math.floor((normalUpgradesOwned / ( Game.UpgradesByPool[""].length + Game.UpgradesByPool.tech.length)) * 100) + '%)'; title.appendChild(titlefrag); l('menu').children[6].insertBefore(title, l('menu').children[6].childNodes[3]); upgrades = document.createElement('div'); upgrades.className = "listing crateBox"; upgrades.innerHTML = CM.Cache.MissingUpgrades; - l('menu').children[6].insertBefore(upgrades, document.getElementById("CMMissingUpgradesTitle").nextSibling) + l('menu').children[6].insertBefore(upgrades, document.getElementById("CMMissingUpgradesTitle").nextSibling); } if (CM.Cache.MissingUpgradesCookies) { - var cookieUpgradesOwned = Game.UpgradesByPool["cookie"].length - l('menu').children[6].lastChild.children.length; + var cookieUpgradesOwned = Game.UpgradesByPool.cookie.length - l('menu').children[6].lastChild.children.length; var title = document.createElement('div'); title.id = "CMMissingUpgradesCookiesTitle"; title.className = "listing"; titlefrag = document.createElement('div'); - titlefrag.innerHTML = 'Missing Cookie upgrades: '+ cookieUpgradesOwned + '/' + Game.UpgradesByPool["cookie"].length + ' (' + Math.floor((cookieUpgradesOwned / Game.UpgradesByPool["cookie"].length) * 100) + '%)'; + titlefrag.innerHTML = 'Missing Cookie upgrades: '+ cookieUpgradesOwned + '/' + Game.UpgradesByPool.cookie.length + ' (' + Math.floor((cookieUpgradesOwned / Game.UpgradesByPool.cookie.length) * 100) + '%)'; title.appendChild(titlefrag); l('menu').children[6].appendChild(title); upgrades = document.createElement('div'); @@ -2821,13 +2821,13 @@ CM.Disp.crateMissing = function(me) { */ CM.Disp.CreateWrinklerButtons = function() { var popAllA = document.createElement('a'); - popAllA.id = "PopAllNormalWrinklerButton" + popAllA.id = "PopAllNormalWrinklerButton"; popAllA.textContent = 'Pop All Normal'; popAllA.className = 'option'; popAllA.onclick = function() { CM.Disp.PopAllNormalWrinklers(); }; l('sectionLeftExtra').children[0].append(popAllA); var popFattestA = document.createElement('a'); - popFattestA.id = "PopFattestWrinklerButton" + popFattestA.id = "PopFattestWrinklerButton"; popFattestA.textContent = 'Pop Single Fattest'; popFattestA.className = 'option'; popFattestA.onclick = function() {if (CM.Cache.WrinklersFattest[1]) Game.wrinklers[CM.Cache.WrinklersFattest[1]].hp = 0; }; From 2d9af222c1b66af523b8bcf0f1f16b193801e8cf Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Sun, 31 Jan 2021 13:33:34 +0100 Subject: [PATCH 4/6] ESLint compliant --- CookieMonster.js | 439 +++++++++++++++++++++++------------------------ src/Cache.js | 7 +- src/Data.js | 14 +- src/Disp.js | 263 ++++++++++++++-------------- src/Main.js | 24 ++- src/Sim.js | 131 +++++++------- 6 files changed, 438 insertions(+), 440 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index ffb4dde..cc7eb4e 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -133,7 +133,7 @@ CM.Cache.CacheStats = function() { CM.Cache.LuckyWrathRewardFrenzy = wrathMult * (CM.Cache.LuckyFrenzy * 0.15) + 13; CM.Cache.Conjure = CM.Cache.Lucky * 2; CM.Cache.ConjureReward = CM.Cache.Conjure * 0.15; - + CM.Cache.Edifice = 0; var max = 0; var n = 0; @@ -336,7 +336,7 @@ CM.Cache.CacheDragonCost = function() { var target = Game.dragonLevels[Game.dragonLevel].buy.toString().match(/Objects\[(.*)\]/)[1]; var amount = Game.dragonLevels[Game.dragonLevel].buy.toString().match(/sacrifice\((.*?)\)/)[1]; if (target != "i") { - target = target.replaceAll("\'", ""); + target = target.replaceAll("'", ""); if (Game.Objects[target].amount < amount) { CM.Cache.CostDragonUpgrade = "Not enough buildings to sell"; } @@ -378,7 +378,7 @@ CM.Cache.CacheDragonCost = function() { CM.Cache.lastDragonLevel = Game.dragonLevel; } }; - + /******** * Section: UNSORTED */ @@ -702,7 +702,6 @@ CM.Cache.HadBuildAura = false; CM.Cache.RealCookiesEarned = -1; CM.Cache.goldenShimmersByID = {}; CM.Cache.spawnedGoldenShimmer = 0; - /********** * Config * **********/ @@ -1037,7 +1036,7 @@ CM.ConfigData.GCNotification = {type: 'bool', group: 'NotificationGC', label: [' CM.ConfigData.GCFlash = {type: 'bool', group: 'NotificationGC', label: ['Flash OFF', 'Flash ON'], desc: 'Flash screen on Golden Cookie', toggle: true}; CM.ConfigData.GCSound = {type: 'bool', group: 'NotificationGC', label: ['Sound OFF', 'Sound ON'], desc: 'Play a sound on Golden Cookie', toggle: true}; CM.ConfigData.GCVolume = {type: 'vol', group: 'NotificationGC', label: [], desc: 'Volume'}; -for (var i = 0; i < 101; i++) { +for (let i = 0; i < 101; i++) { CM.ConfigData.GCVolume.label[i] = i + '%'; } CM.ConfigData.GCSoundURL = {type: 'url', group: 'NotificationGC', label: 'Sound URL:', desc: 'URL of the sound to be played when a Golden Cookie spawns'}; @@ -1045,7 +1044,7 @@ CM.ConfigData.FortuneNotification = {type: 'bool', group: 'NotificationFC', labe CM.ConfigData.FortuneFlash = {type: 'bool', group: 'NotificationFC', label: ['Flash OFF', 'Flash ON'], desc: 'Flash screen on Fortune Cookie', toggle: true}; CM.ConfigData.FortuneSound = {type: 'bool', group: 'NotificationFC', label: ['Sound OFF', 'Sound ON'], desc: 'Play a sound on Fortune Cookie', toggle: true}; CM.ConfigData.FortuneVolume = {type: 'vol', group: 'NotificationFC', label: [], desc: 'Volume'}; -for (var i = 0; i < 101; i++) { +for (let i = 0; i < 101; i++) { CM.ConfigData.FortuneVolume.label[i] = i + '%'; } CM.ConfigData.FortuneSoundURL = {type: 'url', group: 'NotificationFC', label: 'Sound URL:', desc: 'URL of the sound to be played when the Ticker has a Fortune Cookie'}; @@ -1053,14 +1052,14 @@ CM.ConfigData.SeaNotification = {type: 'bool', group: 'NotificationSea', label: CM.ConfigData.SeaFlash = {type: 'bool', group: 'NotificationSea', label: ['Flash OFF', 'Flash ON'], desc: 'Flash screen on Season Popup', toggle: true}; CM.ConfigData.SeaSound = {type: 'bool', group: 'NotificationSea', label: ['Sound OFF', 'Sound ON'], desc: 'Play a sound on Season Popup', toggle: true}; CM.ConfigData.SeaVolume = {type: 'vol', group: 'NotificationSea', label: [], desc: 'Volume'}; -for (var i = 0; i < 101; i++) { +for (let i = 0; i < 101; i++) { CM.ConfigData.SeaVolume.label[i] = i + '%'; } CM.ConfigData.SeaSoundURL = {type: 'url', group: 'NotificationSea', label: 'Sound URL:', desc: 'URL of the sound to be played when a Season Special spawns'}; CM.ConfigData.GardFlash = {type: 'bool', group: 'NotificationGard', label: ['Garden Tick Flash OFF', 'Flash ON'], desc: 'Flash screen on Garden Tick', toggle: true}; CM.ConfigData.GardSound = {type: 'bool', group: 'NotificationGard', label: ['Sound OFF', 'Sound ON'], desc: 'Play a sound on Garden Tick', toggle: true}; CM.ConfigData.GardVolume = {type: 'vol', group: 'NotificationGard', label: [], desc: 'Volume'}; -for (var i = 0; i < 101; i++) { +for (let i = 0; i < 101; i++) { CM.ConfigData.GardVolume.label[i] = i + '%'; } CM.ConfigData.GardSoundURL = {type: 'url', group: 'NotificationGard', label: 'Garden Tick Sound URL:', desc: 'URL of the sound to be played when the garden ticks'}; @@ -1068,7 +1067,7 @@ CM.ConfigData.MagicNotification = {type: 'bool', group: 'NotificationMagi', labe CM.ConfigData.MagicFlash = {type: 'bool', group: 'NotificationMagi', label: ['Flash OFF', 'Flash ON'], desc: 'Flash screen when magic reaches maximum', toggle: true}; CM.ConfigData.MagicSound = {type: 'bool', group: 'NotificationMagi', label: ['Sound OFF', 'Sound ON'], desc: 'Play a sound when magic reaches maximum', toggle: true}; CM.ConfigData.MagicVolume = {type: 'vol', group: 'NotificationMagi', label: [], desc: 'Volume'}; -for (var i = 0; i < 101; i++) { +for (let i = 0; i < 101; i++) { CM.ConfigData.MagicVolume.label[i] = i + '%'; } CM.ConfigData.MagicSoundURL = {type: 'url', group: 'NotificationMagi', label: 'Sound URL:', desc: 'URL of the sound to be played when magic reaches maxium'}; @@ -1076,7 +1075,7 @@ CM.ConfigData.WrinklerNotification = {type: 'bool', group: 'NotificationWrink', CM.ConfigData.WrinklerFlash = {type: 'bool', group: 'NotificationWrink', label: ['Flash OFF', 'Flash ON'], desc: 'Flash screen when a Wrinkler appears', toggle: true}; CM.ConfigData.WrinklerSound = {type: 'bool', group: 'NotificationWrink', label: ['Sound OFF', 'Sound ON'], desc: 'Play a sound when a Wrinkler appears', toggle: true}; CM.ConfigData.WrinklerVolume = {type: 'vol', group: 'NotificationWrink', label: [], desc: 'Volume'}; -for (var i = 0; i < 101; i++) { +for (let i = 0; i < 101; i++) { CM.ConfigData.WrinklerVolume.label[i] = i + '%'; } CM.ConfigData.WrinklerSoundURL = {type: 'url', group: 'NotificationWrink', label: 'Sound URL:', desc: 'URL of the sound to be played when a Wrinkler appears'}; @@ -1084,7 +1083,7 @@ CM.ConfigData.WrinklerMaxNotification = {type: 'bool', group: 'NotificationWrink CM.ConfigData.WrinklerMaxFlash = {type: 'bool', group: 'NotificationWrinkMax', label: ['Flash OFF', 'Flash ON'], desc: 'Flash screen when the maximum amount of Wrinklers has appeared', toggle: true}; CM.ConfigData.WrinklerMaxSound = {type: 'bool', group: 'NotificationWrinkMax', label: ['Sound OFF', 'Sound ON'], desc: 'Play a sound when the maximum amount of Wrinklers has appeared', toggle: true}; CM.ConfigData.WrinklerMaxVolume = {type: 'vol', group: 'NotificationWrinkMax', label: [], desc: 'Volume'}; -for (var i = 0; i < 101; i++) { +for (let i = 0; i < 101; i++) { CM.ConfigData.WrinklerMaxVolume.label[i] = i + '%'; } CM.ConfigData.WrinklerMaxSoundURL = {type: 'url', group: 'NotificationWrinkMax', label: 'Sound URL:', desc: 'URL of the sound to be played when the maximum amount of Wrinklers has appeared'}; @@ -1350,7 +1349,7 @@ CM.Disp.FormatTime = function(time, longFormat) { var h = Math.floor(time % 86400 / 3600); var m = Math.floor(time % 3600 / 60); var s = Math.floor(time % 60); - var str = ''; + let str = ''; if (CM.Options.TimeFormat) { if (time > 3155760000) return 'XX:XX:XX:XX:XX'; str += (y < 10 ? '0' : '') + y + ':'; @@ -1637,11 +1636,11 @@ CM.Disp.CreateBotBarBuildingColumn = function(buildingName) { var pp = CM.Disp.BotBar.firstChild.firstChild.childNodes[2]; var time = CM.Disp.BotBar.firstChild.firstChild.childNodes[3]; - var i = buildingName; + let i = buildingName; var header = type.appendChild(document.createElement('td')); header.appendChild(document.createTextNode((i.indexOf(' ') != -1 ? i.substring(0, i.indexOf(' ')) : i) + ' (')); - var span = header.appendChild(document.createElement('span')); + let span = header.appendChild(document.createElement('span')); span.className = CM.Disp.colorTextPre + CM.Disp.colorBlue; header.appendChild(document.createTextNode(')')); @@ -1701,7 +1700,7 @@ CM.Disp.TimerBarCreateBar = function(id, name, bars) { timerBar.style.margin = '0px 10px'; timerBar.style.position = 'relative'; - var div = document.createElement('div'); + let div = document.createElement('div'); div.style.width = '100%'; div.style.height = '10px'; div.style.margin = 'auto'; @@ -1721,7 +1720,7 @@ CM.Disp.TimerBarCreateBar = function(id, name, bars) { type.textContent = name; div.appendChild(type); - for (var i = 0; i < bars.length; i++) { + for (let i = 0; i < bars.length; i++) { var colorBar = document.createElement('span'); colorBar.id = bars[i].id; colorBar.style.display = 'inline-block'; @@ -1909,11 +1908,10 @@ CM.Disp.UpdateBotTimerBarPosition = function() { * And by changes in CM.Options.BuildColor, CM.Options.SortBuild & CM.ConfigData.BulkBuildColor */ CM.Disp.UpdateBuildings = function() { + let target = 'Objects'; + if (Game.buyBulk == 10 && CM.Options.BulkBuildColor == 1) target = 'Objects10'; + else if (Game.buyBulk == 100 && CM.Options.BulkBuildColor == 1) target = 'Objects100'; if (Game.buyMode == 1) { - var target = ''; - if (Game.buyBulk == 10 && CM.Options.BulkBuildColor == 1) target = 'Objects10'; - else if (Game.buyBulk == 100 && CM.Options.BulkBuildColor == 1) target = 'Objects100'; - else target = 'Objects'; if (CM.Options.BuildColor == 1) { for (let i of Object.keys(CM.Cache[target])) { l('productPrice' + Game.Objects[i].id).style.color = CM.Options.Colors[CM.Cache[target][i].color]; @@ -1944,7 +1942,7 @@ CM.Disp.UpdateBuildings = function() { // (grid rows are 1-based indexing, and row 1 is the bulk buy/sell options) // This regulates sorting of buildings if (Game.buyMode == 1 && CM.Options.SortBuildings) { - var arr = Object.keys(CM.Cache[target]).map(k => + let arr = Object.keys(CM.Cache[target]).map(k => { var o = CM.Cache[target][k]; o.name = k; @@ -1954,11 +1952,11 @@ CM.Disp.UpdateBuildings = function() { arr.sort(function(a, b){ return (a.pp > b.pp ? 1 : (a.pp < b.pp ? -1 : 0)); }); - for (var x = 0; x < arr.length; x++) { + for (let x = 0; x < arr.length; x++) { Game.Objects[arr[x].name].l.style.gridRow = (x + 2) + "/" + (x + 2); } } else { - var arr = Object.keys(CM.Cache.Objects).map(k => + let arr = Object.keys(CM.Cache.Objects).map(k => { var o = CM.Cache.Objects[k]; o.name = k; @@ -1966,7 +1964,7 @@ CM.Disp.UpdateBuildings = function() { return o; }); arr.sort((a, b) => a.id - b.id); - for (var x = 0; x < arr.length; x++) { + for (let x = 0; x < arr.length; x++) { Game.Objects[arr[x].name].l.style.gridRow = (x + 2) + "/" + (x + 2); } } @@ -1992,7 +1990,7 @@ CM.Disp.UpdateUpgrades = function() { for (let i of Object.keys(Game.UpgradesInStore)) { var me = Game.UpgradesInStore[i]; var addedColor = false; - for (var j = 0; j < l('upgrade' + i).childNodes.length; j++) { + for (let j = 0; j < l('upgrade' + i).childNodes.length; j++) { if (l('upgrade' + i).childNodes[j].className.indexOf(CM.Disp.colorBackPre) != -1) { l('upgrade' + i).childNodes[j].className = CM.Disp.colorBackPre + CM.Cache.Upgrades[me.name].color; addedColor = true; @@ -2000,7 +1998,7 @@ CM.Disp.UpdateUpgrades = function() { } } if (!addedColor) { - var div = document.createElement('div'); + let div = document.createElement('div'); div.style.width = '10px'; div.style.height = '10px'; div.className = CM.Disp.colorBackPre + CM.Cache.Upgrades[me.name].color; @@ -2026,8 +2024,8 @@ CM.Disp.UpdateUpgrades = function() { // Build array of pointers, sort by pp, set flex positions // This regulates sorting of upgrades - var arr = []; - for (var x = 0; x < Game.UpgradesInStore.length; x++){ + let arr = []; + for (let x = 0; x < Game.UpgradesInStore.length; x++){ var o = {}; o.name = Game.UpgradesInStore[x].name; o.price = Game.UpgradesInStore[x].basePrice; @@ -2041,9 +2039,12 @@ CM.Disp.UpdateUpgrades = function() { else { arr.sort((a, b) => a.price - b.price); } - - for (var x = 0; x < Game.UpgradesInStore.length; x++){ - l("upgrade" + x).style.order = arr.findIndex(e => e.name === Game.UpgradesInStore[x].name) + 1; + + let nameChecker = function(arr, upgrade) { + return arr.findIndex(e => e.name === upgrade.name); + }; + for (let x = 0; x < Game.UpgradesInStore.length; x++){ + l("upgrade" + x).style.order = nameChecker(arr, Game.UpgradesInStore[x]) + 1; } }; @@ -2095,7 +2096,7 @@ CM.Disp.CreateUpgradeBar = function() { CM.Disp.UpgradeBar.style.textAlign = 'center'; CM.Disp.UpgradeBar.style.fontWeight = 'bold'; CM.Disp.UpgradeBar.style.display = 'none'; - CM.Disp.UpgradeBar.style.zIndex = '21'; + CM.Disp.UpgradeBar.style.zIndex = '21'; CM.Disp.UpgradeBar.onmouseout = function() { Game.tooltip.hide(); }; var placeholder = document.createElement('div'); @@ -2103,7 +2104,7 @@ CM.Disp.CreateUpgradeBar = function() { CM.Disp.UpgradeBar.onmouseover = function() {Game.tooltip.draw(this, escape(placeholder.innerHTML), 'store');}; var upgradeNumber = function(id, color) { - var span = document.createElement('span'); + let span = document.createElement('span'); span.id = id; span.className = CM.Disp.colorTextPre + color; span.style.width = '14.28571428571429%'; @@ -2130,16 +2131,16 @@ CM.Disp.CreateUpgradeBarLegend = function() { var legend = document.createElement('div'); legend.style.minWidth = '330px'; legend.style.marginBottom = '4px'; - var title = document.createElement('div'); + let title = document.createElement('div'); title.className = 'name'; title.style.marginBottom = '4px'; title.textContent = 'Legend'; legend.appendChild(title); var legendLine = function(color, text) { - var div = document.createElement('div'); + let div = document.createElement('div'); div.style.verticalAlign = 'middle'; - var span = document.createElement('span'); + let span = document.createElement('span'); span.className = CM.Disp.colorBackPre + color; span.style.display = 'inline-block'; span.style.height = '10px'; @@ -2188,7 +2189,7 @@ CM.Disp.CreateWhiteScreen = function() { */ CM.Disp.Flash = function(mode, config) { // The arguments check makes the sound not play upon initialization of the mod - if ((CM.Options[config] == 1 && mode == 3 && arguments.callee.caller.caller.caller.caller == null) || mode == 1) { + if ((CM.Options[config] == 1 && mode == 3 && CM.Disp.Flash.caller.caller.caller.caller == null) || mode == 1) { CM.Disp.WhiteScreen.style.opacity = '0.5'; if (mode == 3) { CM.Disp.WhiteScreen.style.display = 'inline'; @@ -2214,7 +2215,7 @@ CM.Disp.Flash = function(mode, config) { */ CM.Disp.PlaySound = function(url, sndConfig, volConfig) { // The arguments check makes the sound not play upon initialization of the mod - if (CM.Options[sndConfig] == 1 && arguments.callee.caller.caller.caller.caller == null) { + if (CM.Options[sndConfig] == 1 && CM.Disp.PlaySound.caller.caller.caller.caller == null) { var sound = new realAudio(url); sound.volume = (CM.Options[volConfig] / 100) * (Game.volume / 100); sound.play(); @@ -2230,7 +2231,7 @@ CM.Disp.PlaySound = function(url, sndConfig, volConfig) { */ CM.Disp.Notification = function(notifyConfig, title, message) { // The arguments check makes the sound not play upon initialization of the mod - if (CM.Options[notifyConfig] == 1 && document.visibilityState == 'hidden' && arguments.callee.caller.caller.caller.caller == null) { + if (CM.Options[notifyConfig] == 1 && document.visibilityState == 'hidden' && CM.Disp.Notification.caller.caller.caller.caller == null) { var CookieIcon = 'https://orteil.dashnet.org/cookieclicker/favicon.ico'; notification = new Notification(title, {body: message, badge: CookieIcon}); } @@ -2272,11 +2273,11 @@ CM.Disp.UpdateTitle = function() { document.title = CM.Cache.Title; } else if (CM.Options.Title == 1) { - var addFC = false; - var addSP = false; - var titleGC; - var titleFC; - var titleSP; + let addFC = false; + let addSP = false; + let titleGC; + let titleFC; + let titleSP; if (CM.Cache.spawnedGoldenShimmer) { if (CM.Cache.spawnedGoldenShimmer.wrath) titleGC = '[W ' + Math.ceil(CM.Cache.spawnedGoldenShimmer.life / Game.fps) + ']'; @@ -2301,15 +2302,15 @@ CM.Disp.UpdateTitle = function() { } // Remove previous timers and add current cookies - var str = CM.Cache.Title; + let str = CM.Cache.Title; if (str.charAt(0) == '[') { str = str.substring(str.lastIndexOf(']') + 1); } document.title = titleGC + (addFC ? titleFC : '') + (addSP ? titleSP : '') + ' ' + str; } else if (CM.Options.Title == 2) { - var str = ''; - var spawn = false; + let str = ''; + let spawn = false; if (CM.Cache.spawnedGoldenShimmer) { spawn = true; if (CM.Cache.spawnedGoldenShimmer.wrath) str += '[W ' + Math.ceil(CM.Cache.spawnedGoldenShimmer.life / Game.fps) + ']'; @@ -2324,7 +2325,7 @@ CM.Disp.UpdateTitle = function() { spawn = true; } if (spawn) str += ' - '; - var title = 'Cookie Clicker'; + let title = 'Cookie Clicker'; if (Game.season == 'fools') title = 'Cookie Baker'; str += title; document.title = str; @@ -2348,7 +2349,7 @@ CM.Disp.CreateGCTimer = function(cookie) { GCTimer.style.zIndex = '10000000001'; GCTimer.style.textAlign = 'center'; GCTimer.style.lineHeight = '96px'; - GCTimer.style.fontFamily = '\"Kavoon\", Georgia, serif'; + GCTimer.style.fontFamily = '"Kavoon", Georgia, serif'; GCTimer.style.fontSize = '35px'; GCTimer.style.cursor = 'pointer'; GCTimer.style.display = 'block'; @@ -2396,7 +2397,7 @@ CM.Disp.CreateSimpleTooltip = function(placeholder, text, minWidth) { var desc = document.createElement('div'); desc.style.minWidth = minWidth; desc.style.marginBottom = '4px'; - var div = document.createElement('div'); + let div = document.createElement('div'); div.style.textAlign = 'left'; div.textContent = text; desc.appendChild(div); @@ -2411,10 +2412,9 @@ CM.Disp.CreateSimpleTooltip = function(placeholder, text, minWidth) { CM.Disp.ReplaceTooltipUpgrade = function() { CM.Disp.TooltipUpgradeBackup = []; for (let i of Object.keys(Game.UpgradesInStore)) { - var me = Game.UpgradesInStore[i]; if (l('upgrade' + i).onmouseover != null) { CM.Disp.TooltipUpgradeBackup[i] = l('upgrade' + i).onmouseover; - eval('l(\'upgrade\' + i).onmouseover = function() {if (!Game.mouseDown) {Game.setOnCrate(this); Game.tooltip.dynamic = 1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip(\'u\', \'' + i + '\');}, \'store\'); Game.tooltip.wobble();}}'); + l('upgrade' + i).onmouseover = function() {if (!Game.mouseDown) {Game.setOnCrate(this); Game.tooltip.dynamic = 1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip('u', `${i}`);}, 'store'); Game.tooltip.wobble();}}; } } }; @@ -2499,7 +2499,7 @@ CM.Disp.TooltipCreateTooltipBox = function() { * @returns {object} div An object containing the stylized header */ CM.Disp.TooltipCreateHeader = function(text) { - var div = document.createElement('div'); + let div = document.createElement('div'); div.style.fontWeight = 'bold'; div.className = CM.Disp.colorTextPre + CM.Disp.colorBlue; div.textContent = text; @@ -2514,7 +2514,7 @@ CM.Disp.TooltipCreateHeader = function(text) { */ CM.Disp.TooltipCreateCalculationSection = function(tooltip) { tooltip.appendChild(CM.Disp.TooltipCreateHeader('Bonus Income')); - var income = document.createElement('div'); + let income = document.createElement('div'); income.style.marginBottom = '4px'; income.style.color = 'white'; income.id = 'CMTooltipIncome'; @@ -2661,7 +2661,7 @@ CM.Disp.UpdateTooltipBuilding = function() { if (CM.Options.TooltipBuildUpgrade == 1 && Game.buyMode == 1) { l('CMTooltipIncome').textContent = Beautify(CM.Disp.TooltipBonusIncome, 2); - var increase = Math.round(CM.Disp.TooltipBonusIncome / Game.cookiesPs * 10000); + let increase = Math.round(CM.Disp.TooltipBonusIncome / Game.cookiesPs * 10000); if (isFinite(increase) && increase != 0) { l('CMTooltipIncome').textContent += ' (' + (increase / 100) + '% of income)'; } @@ -2678,22 +2678,19 @@ CM.Disp.UpdateTooltipBuilding = function() { } // Add "production left till next achievement"-bar + l('CMTooltipProductionHeader').style.display = "none"; + l('CMTooltipTime').style.marginBottom = '0px'; for (let i of Object.keys(Game.Objects[CM.Disp.tooltipName].productionAchievs)) { if (!CM.Sim.HasAchiev(Game.Objects[CM.Disp.tooltipName].productionAchievs[i].achiev.name)) { - var nextProductionAchiev = Game.Objects[CM.Disp.tooltipName].productionAchievs[i]; + let nextProductionAchiev = Game.Objects[CM.Disp.tooltipName].productionAchievs[i]; + l('CMTooltipTime').style.marginBottom = '4px'; + l('CMTooltipProductionHeader').style.display = ""; + l('CMTooltipProduction').className = "ProdAchievement" + CM.Disp.tooltipName; + l('CMTooltipProduction').textContent = Beautify(nextProductionAchiev.pow - CM.Sim.Objects[CM.Disp.tooltipName].totalCookies, 15); + l('CMTooltipProduction').style.color = "white"; break; } } - if (typeof nextProductionAchiev != "undefined") { - l('CMTooltipTime').style.marginBottom = '4px'; - l('CMTooltipProductionHeader').style.display = ""; - l('CMTooltipProduction').className = "ProdAchievement" + CM.Disp.tooltipName; - l('CMTooltipProduction').textContent = Beautify(nextProductionAchiev.pow - CM.Sim.Objects[CM.Disp.tooltipName].totalCookies, 15); - l('CMTooltipProduction').style.color = "white"; - } else { - l('CMTooltipProductionHeader').style.display = "none"; - l('CMTooltipTime').style.marginBottom = '0px'; - } } else l('CMTooltipArea').style.display = "none"; }; @@ -2712,7 +2709,7 @@ CM.Disp.UpdateTooltipUpgrade = function() { if (CM.Options.TooltipBuildUpgrade == 1) { l('CMTooltipIncome').textContent = Beautify(CM.Disp.TooltipBonusIncome, 2); - var increase = Math.round(CM.Disp.TooltipBonusIncome / Game.cookiesPs * 10000); + let increase = Math.round(CM.Disp.TooltipBonusIncome / Game.cookiesPs * 10000); if (isFinite(increase) && increase != 0) { l('CMTooltipIncome').textContent += ' (' + (increase / 100) + '% of income)'; } @@ -2867,13 +2864,14 @@ CM.Disp.UpdateTooltipGardenPlots = function() { * It adds to the additional information to l('CMTooltipArea') */ CM.Disp.UpdateTooltipHarvestAll = function() { - var minigame = Game.Objects.Farm.minigame; + let minigame = Game.Objects.Farm.minigame; if (CM.Options.TooltipLump) { l('CMTooltipBorder').appendChild(CM.Disp.TooltipCreateHeader('Cookies gained from harvesting:')); - var totalGain = 0; - if (Game.keys[16] && Game.keys[17]) var mortal = 1; - for (var y=0;y<6;y++) { - for (var x=0;x<6;x++) { + let totalGain = 0; + let mortal = 0; + if (Game.keys[16] && Game.keys[17]) mortal = 1; + for (let y=0;y<6;y++) { + for (let x=0; x<6; x++) { if (minigame.plot[y][x][0]>=1) { let tile = minigame.plot[y][x]; let me = minigame.plantsById[tile[0] - 1]; @@ -3032,7 +3030,7 @@ CM.Disp.CheckWrinklerTooltip = function() { var wrinkler = document.createElement('div'); wrinkler.style.minWidth = '120px'; wrinkler.style.marginBottom = '4px'; - var div = document.createElement('div'); + let div = document.createElement('div'); div.style.textAlign = 'center'; div.id = 'CMTooltipWrinkler'; wrinkler.appendChild(div); @@ -3094,12 +3092,12 @@ CM.Disp.AddAuraInfo = function(aura) { l('dragonAuraInfo').style.minHeight = "60px"; l('dragonAuraInfo').style.margin = "8px"; l('dragonAuraInfo').appendChild(document.createElement("div")).className = "line"; - var div = document.createElement("div"); + let div = document.createElement("div"); div.style.minWidth = "200px"; div.style.textAlign = "center"; div.textContent = "Picking this aura will change CPS by " + bonusCPS + " (" + bonusCPSPercentage + "% of current CPS)."; l('dragonAuraInfo').appendChild(div); - var div2 = document.createElement("div"); + let div2 = document.createElement("div"); div2.style.minWidth = "200px"; div2.style.textAlign = "center"; div2.textContent = "It will take " + timeToRecover + " to recover the cost."; @@ -3131,8 +3129,8 @@ CM.Disp.AddDragonLevelUpTooltip = function() { * It is called by Game.UpdateMenu() */ CM.Disp.AddMenu = function() { - var title = function() { - var div = document.createElement('div'); + let title = function() { + let div = document.createElement('div'); div.className = 'title ' + CM.Disp.colorTextPre + CM.Disp.colorBlue; div.textContent = 'Cookie Monster Goodies'; return div; @@ -3213,13 +3211,13 @@ CM.Disp.AddMenuPref = function(title) { * @returns {object} div The header object */ CM.Disp.CreatePrefHeader = function(config, text) { - var div = document.createElement('div'); + let div = document.createElement('div'); div.className = 'title'; div.style.opacity = '0.7'; div.style.fontSize = '17px'; div.appendChild(document.createTextNode(text + ' ')); - var span = document.createElement('span'); // Creates the +/- button + let span = document.createElement('span'); // Creates the +/- button span.style.cursor = 'pointer'; span.style.display = 'inline-block'; span.style.height = '14px'; @@ -3244,9 +3242,9 @@ CM.Disp.CreatePrefHeader = function(config, text) { */ CM.Disp.CreatePrefOption = function(config) { if (CM.ConfigData[config].type == "bool") { - var div = document.createElement('div'); + let div = document.createElement('div'); div.className = 'listing'; - var a = document.createElement('a'); + let a = document.createElement('a'); if (CM.ConfigData[config].toggle && CM.Options[config] == 0) { a.className = 'option off'; } @@ -3257,21 +3255,21 @@ CM.Disp.CreatePrefOption = function(config) { a.onclick = function() {CM.Config.ToggleConfig(config);}; a.textContent = CM.ConfigData[config].label[CM.Options[config]]; div.appendChild(a); - var label = document.createElement('label'); + let label = document.createElement('label'); label.textContent = CM.ConfigData[config].desc; div.appendChild(label); return div; } else if (CM.ConfigData[config].type == "vol") { - var div = document.createElement('div'); + let div = document.createElement('div'); div.className = 'listing'; var volume = document.createElement('div'); volume.className = 'sliderBox'; - var title = document.createElement('div'); + let title = document.createElement('div'); title.style.float = "left"; title.innerHTML = CM.ConfigData[config].desc; volume.appendChild(title); - var percent = title = document.createElement('div'); + var percent = document.createElement('div'); percent.id = "slider" + config + "right"; percent.style.float = "right"; percent.innerHTML = CM.Options[config] + "%"; @@ -3292,13 +3290,13 @@ CM.Disp.CreatePrefOption = function(config) { return div; } else if (CM.ConfigData[config].type == "url") { - var div = document.createElement('div'); + let div = document.createElement('div'); div.className = 'listing'; - var span = document.createElement('span'); + let span = document.createElement('span'); span.className = 'option'; span.textContent = CM.ConfigData[config].label + ' '; div.appendChild(span); - var input = document.createElement('input'); + let input = document.createElement('input'); input.id = CM.ConfigPrefix + config; input.className = 'option'; input.type = 'text'; @@ -3307,34 +3305,34 @@ CM.Disp.CreatePrefOption = function(config) { input.style.width = '300px'; div.appendChild(input); div.appendChild(document.createTextNode(' ')); - var inputPrompt = document.createElement('input'); + let inputPrompt = document.createElement('input'); inputPrompt.id = CM.ConfigPrefix + config + 'Prompt'; inputPrompt.className = 'option'; inputPrompt.type = 'text'; inputPrompt.setAttribute('value', CM.Options[config]); - var a = document.createElement('a'); + let a = document.createElement('a'); a.className = 'option'; a.onclick = function() {Game.Prompt(inputPrompt.outerHTML, [['Save', 'CM.Options[\'' + config + '\'] = l(CM.ConfigPrefix + \'' + config + '\' + \'Prompt\').value; CM.Config.SaveConfig(); Game.ClosePrompt(); Game.UpdateMenu();'], 'Cancel']);}; a.textContent = 'Edit'; div.appendChild(a); - var label = document.createElement('label'); + let label = document.createElement('label'); label.textContent = CM.ConfigData[config].desc; div.appendChild(label); return div; } else if (CM.ConfigData[config].type == "color") { - var div = document.createElement('div'); - for (var i = 0; i < CM.Disp.colors.length; i++) { - var innerDiv = document.createElement('div'); + let div = document.createElement('div'); + for (let i = 0; i < CM.Disp.colors.length; i++) { + let innerDiv = document.createElement('div'); innerDiv.className = 'listing'; - var input = document.createElement('input'); + let input = document.createElement('input'); input.id = CM.Disp.colors[i]; input.style.width = '65px'; input.setAttribute('value', CM.Options.Colors[CM.Disp.colors[i]]); innerDiv.appendChild(input); let change = function() {CM.Options.Colors[this.targetElement.id] = this.toHEXString(); CM.Disp.UpdateColors(); CM.Config.SaveConfig(); Game.UpdateMenu();}; - let picker = new JSColor(input, {hash: true, position: "right", onInput: change}); - var label = document.createElement('label'); + let = new JSColor(input, {hash: true, position: "right", onInput: change}); + let label = document.createElement('label'); label.textContent = CM.ConfigData.Colors.desc[CM.Disp.colors[i]]; innerDiv.appendChild(label); div.appendChild(innerDiv); @@ -3342,13 +3340,13 @@ CM.Disp.CreatePrefOption = function(config) { return div; } else if (CM.ConfigData[config].type == "numscale") { - var div = document.createElement('div'); + let div = document.createElement('div'); div.className = 'listing'; - var span = document.createElement('span'); + let span = document.createElement('span'); span.className = 'option'; span.textContent = CM.ConfigData[config].label + ' '; div.appendChild(span); - var input = document.createElement('input'); + let input = document.createElement('input'); input.id = CM.ConfigPrefix + config; input.className = 'option'; input.type = 'number'; @@ -3356,13 +3354,13 @@ CM.Disp.CreatePrefOption = function(config) { input.min = CM.ConfigData[config].min; input.max = CM.ConfigData[config].max; input.oninput = function() {if (this.value > this.max) console.log("TEST"); - CM.Options[config] = this.value; - CM.Config.SaveConfig(); - CM.Disp.RefreshScale(); - }; + CM.Options[config] = this.value; + CM.Config.SaveConfig(); + CM.Disp.RefreshScale(); + }; div.appendChild(input); div.appendChild(document.createTextNode(' ')); - var label = document.createElement('label'); + let label = document.createElement('label'); label.textContent = CM.ConfigData[config].desc; div.appendChild(label); return div; @@ -3397,14 +3395,14 @@ CM.Disp.RefreshScale = function() { * The function is therefore called by a change in CM.Options.Colors */ CM.Disp.UpdateColors = function() { - var str = ''; - for (var i = 0; i < CM.Disp.colors.length; i++) { + let str = ''; + for (let i = 0; i < CM.Disp.colors.length; i++) { str += '.' + CM.Disp.colorTextPre + CM.Disp.colors[i] + ' { color: ' + CM.Options.Colors[CM.Disp.colors[i]] + '; }\n'; } - for (var i = 0; i < CM.Disp.colors.length; i++) { + for (let i = 0; i < CM.Disp.colors.length; i++) { str += '.' + CM.Disp.colorBackPre + CM.Disp.colors[i] + ' { background-color: ' + CM.Options.Colors[CM.Disp.colors[i]] + '; }\n'; } - for (var i = 0; i < CM.Disp.colors.length; i++) { + for (let i = 0; i < CM.Disp.colors.length; i++) { str += '.' + CM.Disp.colorBorderPre + CM.Disp.colors[i] + ' { border: 1px solid ' + CM.Options.Colors[CM.Disp.colors[i]] + '; }\n'; } CM.Disp.Css.textContent = str; @@ -3437,7 +3435,7 @@ CM.Disp.AddMenuStats = function(title) { stats.appendChild(CM.Disp.CreateStatsHeader('Spells', 'Spells')); if (CM.Options.Header.Spells) { stats.appendChild(CM.Disp.CreateStatsSpellsSection()); - } + } stats.appendChild(CM.Disp.CreateStatsHeader('Prestige', 'Prestige')); if (CM.Options.Header.Prestige) { @@ -3573,14 +3571,14 @@ CM.Disp.AddMenuStats = function(title) { * @returns {object} div The header object */ CM.Disp.CreateStatsHeader = function(text, config) { - var div = document.createElement('div'); + let div = document.createElement('div'); div.className = 'listing'; div.style.padding = '5px 16px'; div.style.opacity = '0.7'; div.style.fontSize = '17px'; - div.style.fontFamily = '\"Kavoon\", Georgia, serif'; + div.style.fontFamily = '"Kavoon", Georgia, serif'; div.appendChild(document.createTextNode(text + ' ')); - var span = document.createElement('span'); + let span = document.createElement('span'); span.style.cursor = 'pointer'; span.style.display = 'inline-block'; span.style.height = '14px'; @@ -3607,7 +3605,7 @@ CM.Disp.CreateStatsHeader = function(text, config) { * @returns {object} div The option object */ CM.Disp.CreateStatsListing = function(type, name, text, placeholder) { - var div = document.createElement('div'); + let div = document.createElement('div'); div.className = 'listing'; var listingName = document.createElement('b'); @@ -3646,20 +3644,20 @@ CM.Disp.CreateStatsListing = function(type, name, text, placeholder) { CM.Disp.CreateStatsMissDisp = function(theMissDisp) { var frag = document.createDocumentFragment(); frag.appendChild(document.createTextNode(theMissDisp.length + ' ')); - var span = document.createElement('span'); + let span = document.createElement('span'); span.onmouseout = function() { Game.tooltip.hide(); }; var placeholder = document.createElement('div'); var missing = document.createElement('div'); missing.style.minWidth = '140px'; missing.style.marginBottom = '4px'; - var title = document.createElement('div'); + let title = document.createElement('div'); title.className = 'name'; title.style.marginBottom = '4px'; title.style.textAlign = 'center'; title.textContent = 'Missing'; missing.appendChild(title); for (let i of Object.keys(theMissDisp)) { - var div = document.createElement('div'); + let div = document.createElement('div'); div.style.textAlign = 'center'; div.appendChild(document.createTextNode(theMissDisp[i])); missing.appendChild(div); @@ -3705,7 +3703,7 @@ CM.Disp.CreateStatsLuckySection = function() { luckyReqSmall.textContent = ' (' + luckyTime + ')'; luckyReqFrag.appendChild(luckyReqSmall); } - section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Lucky!\" Cookies Required', luckyReqFrag, goldCookTooltip)); + section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '"Lucky!" Cookies Required', luckyReqFrag, goldCookTooltip)); var luckyColorFrenzy = ((Game.cookies + CM.Disp.GetWrinkConfigBank()) < CM.Cache.LuckyFrenzy) ? CM.Disp.colorRed : CM.Disp.colorGreen; @@ -3721,7 +3719,7 @@ CM.Disp.CreateStatsLuckySection = function() { luckyReqFrenSmall.textContent = ' (' + luckyTimeFrenzy + ')'; luckyReqFrenFrag.appendChild(luckyReqFrenSmall); } - section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Lucky!\" Cookies Required (Frenzy)', luckyReqFrenFrag, goldCookTooltip)); + section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '"Lucky!" Cookies Required (Frenzy)', luckyReqFrenFrag, goldCookTooltip)); var luckySplit = CM.Cache.LuckyReward != CM.Cache.LuckyWrathReward; @@ -3729,20 +3727,20 @@ CM.Disp.CreateStatsLuckySection = function() { luckyRewardMaxSpan.style.fontWeight = 'bold'; luckyRewardMaxSpan.className = CM.Disp.colorTextPre + CM.Cache.LuckyReward; luckyRewardMaxSpan.textContent = Beautify(CM.Cache.LuckyReward) + (luckySplit ? (' / ' + Beautify(CM.Cache.LuckyWrathReward)) : ''); - section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Lucky!\" Reward (MAX)' + (luckySplit ? ' (Golden / Wrath)' : ''), luckyRewardMaxSpan, goldCookTooltip)); + section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '"Lucky!" Reward (MAX)' + (luckySplit ? ' (Golden / Wrath)' : ''), luckyRewardMaxSpan, goldCookTooltip)); var luckyRewardFrenzyMaxSpan = document.createElement('span'); luckyRewardFrenzyMaxSpan.style.fontWeight = 'bold'; luckyRewardFrenzyMaxSpan.className = CM.Disp.colorTextPre + luckyRewardFrenzyMaxSpan; luckyRewardFrenzyMaxSpan.textContent = Beautify(CM.Cache.LuckyRewardFrenzy) + (luckySplit ? (' / ' + Beautify(CM.Cache.LuckyWrathRewardFrenzy)) : ''); - section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Lucky!\" Reward (MAX) (Frenzy)' + (luckySplit ? ' (Golden / Wrath)' : ''), luckyRewardFrenzyMaxSpan , goldCookTooltip)); + section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '"Lucky!" Reward (MAX) (Frenzy)' + (luckySplit ? ' (Golden / Wrath)' : ''), luckyRewardFrenzyMaxSpan , goldCookTooltip)); var luckyCurBase = Math.min((Game.cookies + CM.Disp.GetWrinkConfigBank()) * 0.15, CM.Cache.NoGoldSwitchCookiesPS * CM.Cache.DragonsFortuneMultAdjustment * 60 * 15) + 13; var luckyCurSpan = document.createElement('span'); luckyCurSpan.style.fontWeight = 'bold'; luckyCurSpan.className = CM.Disp.colorTextPre + luckyCurSpan; luckyCurSpan.textContent = Beautify(CM.Cache.GoldenCookiesMult * luckyCurBase) + (luckySplit ? (' / ' + Beautify(CM.Cache.WrathCookiesMult * luckyCurBase)) : ''); - section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Lucky!\" Reward (CUR)' + (luckySplit ? ' (Golden / Wrath)' : ''), luckyCurSpan, goldCookTooltip)); + section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '"Lucky!" Reward (CUR)' + (luckySplit ? ' (Golden / Wrath)' : ''), luckyCurSpan, goldCookTooltip)); return section; }; @@ -3770,7 +3768,7 @@ CM.Disp.CreateStatsChainSection = function() { chainReqSmall.textContent = ' (' + chainTime + ')'; chainReqFrag.appendChild(chainReqSmall); } - section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Chain\" Cookies Required', chainReqFrag, goldCookTooltip)); + section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '"Chain" Cookies Required', chainReqFrag, goldCookTooltip)); var chainWrathColor = ((Game.cookies + CM.Disp.GetWrinkConfigBank()) < CM.Cache.ChainWrath) ? CM.Disp.colorRed : CM.Disp.colorGreen; var chainWrathTime = ((Game.cookies + CM.Disp.GetWrinkConfigBank()) < CM.Cache.ChainWrath) ? CM.Disp.FormatTime((CM.Cache.ChainWrath - (Game.cookies + CM.Disp.GetWrinkConfigBank())) / CM.Disp.GetCPS()) : ''; @@ -3785,7 +3783,7 @@ CM.Disp.CreateStatsChainSection = function() { chainWrathReqSmall.textContent = ' (' + chainWrathTime + ')'; chainWrathReqFrag.appendChild(chainWrathReqSmall); } - section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Chain\" Cookies Required (Wrath)', chainWrathReqFrag, goldCookTooltip)); + section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '"Chain" Cookies Required (Wrath)', chainWrathReqFrag, goldCookTooltip)); var chainColorFrenzy = ((Game.cookies + CM.Disp.GetWrinkConfigBank()) < CM.Cache.ChainFrenzy) ? CM.Disp.colorRed : CM.Disp.colorGreen; var chainTimeFrenzy = ((Game.cookies + CM.Disp.GetWrinkConfigBank()) < CM.Cache.ChainFrenzy) ? CM.Disp.FormatTime((CM.Cache.ChainFrenzy - (Game.cookies + CM.Disp.GetWrinkConfigBank())) / CM.Disp.GetCPS()) : ''; @@ -3800,7 +3798,7 @@ CM.Disp.CreateStatsChainSection = function() { chainReqFrenSmall.textContent = ' (' + chainTimeFrenzy + ')'; chainReqFrenFrag.appendChild(chainReqFrenSmall); } - section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Chain\" Cookies Required (Frenzy)', chainReqFrenFrag, goldCookTooltip)); + section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '"Chain" Cookies Required (Frenzy)', chainReqFrenFrag, goldCookTooltip)); var chainWrathColorFrenzy = ((Game.cookies + CM.Disp.GetWrinkConfigBank()) < CM.Cache.ChainFrenzyWrath) ? CM.Disp.colorRed : CM.Disp.colorGreen; var chainWrathTimeFrenzy = ((Game.cookies + CM.Disp.GetWrinkConfigBank()) < CM.Cache.ChainFrenzyWrath) ? CM.Disp.FormatTime((CM.Cache.ChainFrenzyWrath - (Game.cookies + CM.Disp.GetWrinkConfigBank())) / CM.Disp.GetCPS()) : ''; @@ -3815,17 +3813,17 @@ CM.Disp.CreateStatsChainSection = function() { chainWrathReqFrenSmall.textContent = ' (' + chainWrathTimeFrenzy + ')'; chainWrathReqFrenFrag.appendChild(chainWrathReqFrenSmall); } - section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Chain\" Cookies Required (Frenzy) (Wrath)', chainWrathReqFrenFrag, goldCookTooltip)); + 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) + ' / ' + Beautify(CM.Cache.ChainWrathReward)), goldCookTooltip)); + section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '"Chain" Reward (MAX) (Golden / Wrath)', document.createTextNode(Beautify(CM.Cache.ChainReward) + ' / ' + Beautify(CM.Cache.ChainWrathReward)), goldCookTooltip)); - section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Chain\" Reward (MAX) (Frenzy) (Golden / Wrath)', document.createTextNode((Beautify(CM.Cache.ChainFrenzyReward) + ' / ' + Beautify(CM.Cache.ChainFrenzyWrathReward))), goldCookTooltip)); + section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '"Chain" Reward (MAX) (Frenzy) (Golden / Wrath)', document.createTextNode((Beautify(CM.Cache.ChainFrenzyReward) + ' / ' + Beautify(CM.Cache.ChainFrenzyWrathReward))), goldCookTooltip)); // TODO: Place MaxChainMoni function into CM.Cache.RemakeChain and create global variables to store it var chainCurMax = Math.min(CM.Cache.NoGoldSwitchCookiesPS * CM.Cache.DragonsFortuneMultAdjustment * 60 * 60 * 6, (Game.cookies + CM.Disp.GetWrinkConfigBank()) * 0.5); var chainCur = CM.Cache.MaxChainMoni(7, chainCurMax, CM.Cache.GoldenCookiesMult); var chainCurWrath = CM.Cache.MaxChainMoni(6, chainCurMax, CM.Cache.WrathCookiesMult); - section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Chain\" Reward (CUR) (Golden / Wrath)', document.createTextNode((Beautify(chainCur) + ' / ' + Beautify(chainCurWrath))), goldCookTooltip)); + section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '"Chain" Reward (CUR) (Golden / Wrath)', document.createTextNode((Beautify(chainCur) + ' / ' + Beautify(chainCurWrath))), goldCookTooltip)); return section; }; @@ -3838,7 +3836,6 @@ CM.Disp.CreateStatsSpellsSection = function() { section.className = 'CMStatsSpellsSection'; var conjureColor = ((Game.cookies + CM.Disp.GetWrinkConfigBank()) < CM.Cache.Conjure) ? CM.Disp.colorRed : CM.Disp.colorGreen; - var conjureCur = Math.min((Game.cookies + CM.Disp.GetWrinkConfigBank()) * 0.15, CM.Cache.NoGoldSwitchCookiesPS * 60 * 30); var conjureTime = ((Game.cookies + CM.Disp.GetWrinkConfigBank()) < CM.Cache.Conjure) ? CM.Disp.FormatTime((CM.Cache.Conjure - (Game.cookies + CM.Disp.GetWrinkConfigBank())) / CM.Disp.GetCPS()) : ''; var conjureReqFrag = document.createDocumentFragment(); @@ -3852,8 +3849,8 @@ CM.Disp.CreateStatsSpellsSection = function() { conjureReqSmall.textContent = ' (' + conjureTime + ')'; conjureReqFrag.appendChild(conjureReqSmall); } - section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Conjure Baked Goods\" Cookies Required', conjureReqFrag, 'GoldCookTooltipPlaceholder')); - section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Conjure Baked Goods\" Reward (MAX)', document.createTextNode(CM.Disp.Beautify(CM.Cache.ConjureReward)), 'GoldCookTooltipPlaceholder')); + section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '"Conjure Baked Goods" Cookies Required', conjureReqFrag, 'GoldCookTooltipPlaceholder')); + section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '"Conjure Baked Goods" Reward (MAX)', document.createTextNode(CM.Disp.Beautify(CM.Cache.ConjureReward)), 'GoldCookTooltipPlaceholder')); var conjureFrenzyColor = ((Game.cookies + CM.Disp.GetWrinkConfigBank()) < CM.Cache.Conjure * 7) ? CM.Disp.colorRed : CM.Disp.colorGreen; var conjureFrenzyCur = Math.min((Game.cookies + CM.Disp.GetWrinkConfigBank()) * 0.15, CM.Cache.NoGoldSwitchCookiesPS * 60 * 30); @@ -3870,11 +3867,11 @@ CM.Disp.CreateStatsSpellsSection = function() { conjureFrenzyReqSmall.textContent = ' (' + conjureFrenzyTime + ')'; conjureFrenzyReqFrag.appendChild(conjureFrenzyReqSmall); } - section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Conjure Baked Goods\" Cookies Required (Frenzy)', conjureFrenzyReqFrag, 'GoldCookTooltipPlaceholder')); - section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Conjure Baked Goods\" Reward (MAX) (Frenzy)', document.createTextNode(CM.Disp.Beautify(CM.Cache.ConjureReward * 7)), 'GoldCookTooltipPlaceholder')); - section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Conjure Baked Goods\" Reward (CUR)', document.createTextNode(CM.Disp.Beautify(conjureFrenzyCur)), 'GoldCookTooltipPlaceholder')); + section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '"Conjure Baked Goods" Cookies Required (Frenzy)', conjureFrenzyReqFrag, 'GoldCookTooltipPlaceholder')); + section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '"Conjure Baked Goods" Reward (MAX) (Frenzy)', document.createTextNode(CM.Disp.Beautify(CM.Cache.ConjureReward * 7)), 'GoldCookTooltipPlaceholder')); + section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '"Conjure Baked Goods" Reward (CUR)', document.createTextNode(CM.Disp.Beautify(conjureFrenzyCur)), 'GoldCookTooltipPlaceholder')); if (CM.Cache.Edifice) { - section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Spontaneous Edifice\" Cookies Required (most expensive building)', document.createTextNode(CM.Disp.Beautify(CM.Cache.Edifice) + ' (' + CM.Cache.EdificeBuilding + ")"), 'GoldCookTooltipPlaceholder')); + section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '"Spontaneous Edifice" Cookies Required (most expensive building)', document.createTextNode(CM.Disp.Beautify(CM.Cache.Edifice) + ' (' + CM.Cache.EdificeBuilding + ")"), 'GoldCookTooltipPlaceholder')); } return section; }; @@ -3905,7 +3902,7 @@ CM.Disp.CreateStatsPrestigeSection = function() { var resetBonus = CM.Sim.ResetBonus(possiblePresMax); var resetFrag = document.createDocumentFragment(); resetFrag.appendChild(document.createTextNode(Beautify(resetBonus))); - var increase = Math.round(resetBonus / Game.cookiesPs * 10000); + let increase = Math.round(resetBonus / Game.cookiesPs * 10000); if (isFinite(increase) && increase != 0) { var resetSmall = document.createElement('small'); resetSmall.textContent = ' (' + (increase / 100) + '% of income)'; @@ -3956,7 +3953,7 @@ CM.Disp.CreateStatsPrestigeSection = function() { CM.Disp.AddMissingUpgrades = function() { if (CM.Cache.MissingUpgradesPrestige) { var prestigeUpgradesOwned = Game.PrestigeUpgrades.length - l('menu').children[5].children[3].children.length; - var title = document.createElement('div'); + let title = document.createElement('div'); title.id = "CMMissingUpgradesPrestigeTitle"; title.className = "listing"; titlefrag = document.createElement('div'); @@ -3969,10 +3966,9 @@ CM.Disp.AddMissingUpgrades = function() { l('menu').children[5].appendChild(upgrades); } if (CM.Cache.MissingUpgrades) { - if (Game.UpgradesOwned) { - var normalUpgradesOwned = Game.UpgradesByPool[""].length + Game.UpgradesByPool.tech.length - l('menu').children[6].childNodes[2].children.length; - } else var normalUpgradesOwned = 0; - var title = document.createElement('div'); + let normalUpgradesOwned = 0; + if (Game.UpgradesOwned) normalUpgradesOwned = Game.UpgradesByPool[""].length + Game.UpgradesByPool.tech.length - l('menu').children[6].childNodes[2].children.length; + let title = document.createElement('div'); title.id = "CMMissingUpgradesTitle"; title.className = "listing"; titlefrag = document.createElement('div'); @@ -3986,7 +3982,7 @@ CM.Disp.AddMissingUpgrades = function() { } if (CM.Cache.MissingUpgradesCookies) { var cookieUpgradesOwned = Game.UpgradesByPool.cookie.length - l('menu').children[6].lastChild.children.length; - var title = document.createElement('div'); + let title = document.createElement('div'); title.id = "CMMissingUpgradesCookiesTitle"; title.className = "listing"; titlefrag = document.createElement('div'); @@ -4016,7 +4012,7 @@ CM.Disp.crateMissing = function(me) { if (!Game.prefs.crates) noFrame = 1; if (noFrame) classes += ' noFrame'; - var icon = me.icon; + let icon = me.icon; if (me.iconFunction) icon = me.iconFunction(); tooltip = `function() {return Game.crateTooltip(Game.UpgradesById[${me.id}], 'stats');}`; return `
{ + Array.from(l('gardenPlot').children).forEach((child) => { var coords = child.id.slice(-3,); child.onmouseover = function() {Game.tooltip.dynamic=1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip('p', [`${coords[0]}`,`${coords[2]}`]);}, 'this'); Game.tooltip.wobble();}; }); @@ -4483,7 +4478,7 @@ CM.Main.ReplaceTooltipGarden = function() { CM.Main.FindShimmer = function() { CM.Main.currSpawnedGoldenCookieState = 0; CM.Cache.goldenShimmersByID = {}; - for (var i in Game.shimmers) { + for (let i of Object.keys(Game.shimmers)) { CM.Cache.goldenShimmersByID[Game.shimmers[i].id] = Game.shimmers[i]; if (Game.shimmers[i].spawnLead && Game.shimmers[i].type == 'golden') { CM.Cache.spawnedGoldenShimmer = Game.shimmers[i]; @@ -4499,7 +4494,7 @@ CM.Main.FindShimmer = function() { */ CM.Main.CheckGoldenCookie = function() { CM.Main.FindShimmer(); - for (var i in CM.Disp.GCTimers) { + for (let i of Object.keys(CM.Disp.GCTimers)) { if (typeof CM.Cache.goldenShimmersByID[i] == "undefined") { CM.Disp.GCTimers[i].parentNode.removeChild(CM.Disp.GCTimers[i]); // TODO remove delete here @@ -4515,7 +4510,7 @@ CM.Main.CheckGoldenCookie = function() { CM.Disp.Notification('GCNotification', "Golden Cookie Spawned", "A Golden Cookie has spawned. Click it now!"); } - for (var i in Game.shimmers) { + for (let i of Object.keys(Game.shimmers)) { if (typeof CM.Disp.GCTimers[Game.shimmers[i].id] == "undefined") { CM.Disp.CreateGCTimer(Game.shimmers[i]); } @@ -4526,7 +4521,7 @@ CM.Main.CheckGoldenCookie = function() { if (CM.Main.currSpawnedGoldenCookieState == 0) CM.Cache.spawnedGoldenShimmer = 0; } else if (CM.Options.GCTimer == 1 && CM.Main.lastGoldenCookieState) { - for (var i in CM.Disp.GCTimers) { + for (let i of Object.keys(CM.Disp.GCTimers)) { CM.Disp.GCTimers[i].style.opacity = CM.Cache.goldenShimmersByID[i].l.style.opacity; CM.Disp.GCTimers[i].style.transform = CM.Cache.goldenShimmersByID[i].l.style.transform; CM.Disp.GCTimers[i].textContent = Math.ceil(CM.Cache.goldenShimmersByID[i].life / Game.fps); @@ -4541,7 +4536,7 @@ CM.Main.CheckGoldenCookie = function() { CM.Main.CheckSeasonPopup = function() { if (CM.Main.lastSeasonPopupState != Game.shimmerTypes.reindeer.spawned) { CM.Main.lastSeasonPopupState = Game.shimmerTypes.reindeer.spawned; - for (var i in Game.shimmers) { + for (let i of Object.keys(Game.shimmers)) { if (Game.shimmers[i].spawnLead && Game.shimmers[i].type == 'reindeer') { CM.Cache.seasonPopShimmer = Game.shimmers[i]; break; @@ -4606,7 +4601,7 @@ CM.Main.CheckMagicMeter = function() { CM.Main.CheckWrinklerCount = function() { if (Game.elderWrath > 0) { var CurrentWrinklers = 0; - for (var i in Game.wrinklers) { + for (let i in Game.wrinklers) { if (Game.wrinklers[i].phase == 2) CurrentWrinklers++; } if (CurrentWrinklers > CM.Main.lastWrinklerCount) { @@ -4643,7 +4638,7 @@ CM.Main.AddWrinklerAreaDetect = function() { l('backgroundLeftCanvas').onmouseout = function() { CM.Disp.TooltipWrinklerArea = 0; Game.tooltip.hide(); - for (var i in Game.wrinklers) { + for (let i of Object.keys(Game.wrinklers)) { CM.Disp.TooltipWrinklerBeingShown[i] = 0; } }; @@ -4674,7 +4669,6 @@ CM.HasReplaceNativeGrimoireDraw = false; CM.Main.lastGoldenCookieState = 0; CM.Main.lastSpawnedGoldenCookieState = 0; -CM.Main.currSpawnedGoldenCookieState; CM.Main.lastTickerFortuneState = 0; CM.Main.lastSeasonPopupState = 0; CM.Main.lastGardenNextStep = 0; @@ -4691,8 +4685,8 @@ CM.VersionMinor = '3'; *******/ CM.Sim.BuildingGetPrice = function(build, basePrice, start, free, increase) { - /*var price=0; - for (var i = Math.max(0 , start); i < Math.max(0, start + increase); i++) { + /*let price=0; + for (let i = Math.max(0 , start); i < Math.max(0, start + increase); i++) { price += basePrice * Math.pow(Game.priceIncrease, Math.max(0, i - free)); } if (Game.Has('Season savings')) price *= 0.99; @@ -4703,8 +4697,8 @@ CM.Sim.BuildingGetPrice = function(build, basePrice, start, free, increase) { return Math.ceil(price);*/ var moni = 0; - for (var i = 0; i < increase; i++) { - var price = basePrice * Math.pow(Game.priceIncrease, Math.max(0, start - free)); + for (let i = 0; i < increase; i++) { + let price = basePrice * Math.pow(Game.priceIncrease, Math.max(0, start - free)); price = Game.modifyBuildingPrice(build, price); price = Math.ceil(price); moni += price; @@ -4714,8 +4708,8 @@ CM.Sim.BuildingGetPrice = function(build, basePrice, start, free, increase) { }; CM.Sim.BuildingSell = function(build, basePrice, start, free, amount, noSim) { - /*var price=0; - for (var i = Math.max(0, start - amount); i < Math.max(0, start); i++) { + /*let price=0; + for (let i = Math.max(0, start - amount); i < Math.max(0, start); i++) { price += basePrice * Math.pow(Game.priceIncrease, Math.max(0, i - free)); } if (Game.Has('Season savings')) price*=0.99; @@ -4737,8 +4731,8 @@ CM.Sim.BuildingSell = function(build, basePrice, start, free, amount, noSim) { var moni = 0; if (amount == -1) amount = start; if (!amount) amount = Game.buyBulk; - for (var i = 0; i < amount; i++) { - var price = basePrice * Math.pow(Game.priceIncrease, Math.max(0, start - free)); + for (let i = 0; i < amount; i++) { + let price = basePrice * Math.pow(Game.priceIncrease, Math.max(0, start - free)); price = noSim ? Game.modifyBuildingPrice(build, price) : CM.Sim.modifyBuildingPrice(build, price); price = Math.ceil(price); var giveBack = noSim ? build.getSellMultiplier() : CM.Sim.getSellMultiplier(); @@ -4752,7 +4746,7 @@ CM.Sim.BuildingSell = function(build, basePrice, start, free, amount, noSim) { }; CM.Sim.Has = function(what) { - var it = CM.Sim.Upgrades[what]; + let it = CM.Sim.Upgrades[what]; if (Game.ascensionMode == 1 && (it.pool == 'prestige' || it.tier == 'fortune')) return 0; return (it ? it.bought : 0); }; @@ -4796,7 +4790,7 @@ CM.Sim.hasGod=function(what) { } var possibleGods = CM.Sim.Objects.Temple.minigame.gods; var god=possibleGods[what]; - for (var i=0;i<3;i++) + for (let i=0;i<3;i++) { if (CM.Sim.Objects.Temple.minigame.slot[i]==god.id) return (i+1); } @@ -4827,7 +4821,7 @@ eval('CM.Sim.GetTieredCpsMult = ' + Game.GetTieredCpsMult.toString() CM.Sim.getCPSBuffMult = function() { var mult = 1; - for (var i in Game.buffs) { + for (let i of Object.keys(Game.buffs)) { if (typeof Game.buffs[i].multCpS != 'undefined') mult *= Game.buffs[i].multCpS; } return mult; @@ -4843,8 +4837,8 @@ CM.Sim.getCPSBuffMult = function() { * are set by CM.Sim.CopyData. */ CM.Sim.InitialBuildingData = function(buildingName) { - var me = Game.Objects[buildingName]; - var you = {}; + let me = Game.Objects[buildingName]; + let you = {}; eval('you.cps = ' + me.cps.toString() .split('Game.Has').join('CM.Sim.Has') .split('Game.hasAura').join('CM.Sim.hasAura') @@ -4864,8 +4858,8 @@ CM.Sim.InitialBuildingData = function(buildingName) { * so this function just returns an empty object. */ CM.Sim.InitUpgrade = function(upgradeName) { - var me = Game.Upgrades[upgradeName]; - var you = {}; + let me = Game.Upgrades[upgradeName]; + let you = {}; you.pool = me.pool; you.name = me.name; return you; @@ -4877,28 +4871,31 @@ CM.Sim.InitUpgrade = function(upgradeName) { * so this function just returns an empty object. */ CM.Sim.InitAchievement = function(achievementName) { + let me = Game.Achievements[achievementName]; + let you = {}; + you.name = me.name; return {}; }; CM.Sim.InitData = function() { // Buildings CM.Sim.Objects = []; - for (var i in Game.Objects) { + for (let i of Object.keys(Game.Objects)) { CM.Sim.Objects[i] = CM.Sim.InitialBuildingData(i); } // Upgrades CM.Sim.Upgrades = []; - for (var i in Game.Upgrades) { + for (let i of Object.keys(Game.Upgrades)) { CM.Sim.Upgrades[i] = CM.Sim.InitUpgrade(i); } // Achievements CM.Sim.Achievements = []; - for (var i in Game.Achievements) { + for (let i of Object.keys(Game.Achievements)) { CM.Sim.Achievements[i] = CM.Sim.InitAchievement(i); } - CM.Sim.CopyData; + CM.Sim.CopyData(); }; CM.Sim.CopyData = function() { @@ -4910,9 +4907,9 @@ CM.Sim.CopyData = function() { CM.Sim.prestige = Game.prestige; // Buildings - for (var i in Game.Objects) { - var me = Game.Objects[i]; - var you = CM.Sim.Objects[i]; + for (let i of Object.keys(Game.Objects)) { + let me = Game.Objects[i]; + let you = CM.Sim.Objects[i]; if (you == undefined) { // New building! you = CM.Sim.Objects[i] = CM.Sim.InitialBuildingData(i); CM.Disp.CreateBotBarBuildingColumn(i); // Add new building to the bottom bar @@ -4926,9 +4923,9 @@ CM.Sim.CopyData = function() { } // Upgrades - for (var i in Game.Upgrades) { - var me = Game.Upgrades[i]; - var you = CM.Sim.Upgrades[i]; + for (let i of Object.keys(Game.Upgrades)) { + let me = Game.Upgrades[i]; + let you = CM.Sim.Upgrades[i]; if (you == undefined) { you = CM.Sim.Upgrades[i] = CM.Sim.InitUpgrade(i); } @@ -4936,9 +4933,9 @@ CM.Sim.CopyData = function() { } // Achievements - for (var i in Game.Achievements) { - var me = Game.Achievements[i]; - var you = CM.Sim.Achievements[i]; + for (let i of Object.keys(Game.Achievements)) { + let me = Game.Achievements[i]; + let you = CM.Sim.Achievements[i]; if (you == undefined) { you = CM.Sim.Achievements[i] = CM.Sim.InitAchievement(i); } @@ -4956,12 +4953,12 @@ CM.Sim.CalculateGains = function() { var mult = 1; // Include minigame effects var effs={}; - for (var i in Game.Objects) { + for (let i of Object.keys(Game.Objects)) { // TODO Store minigames and effects in Cache // Include possibility of new/modded building and new/modded minigames if (CM.Sim.Objects[i].minigameLoaded && CM.Sim.Objects[i].minigame.effs) { var myEffs = CM.Sim.Objects[i].minigame.effs; - for (var ii in myEffs) { + for (let ii in myEffs) { if (effs[ii]) effs[ii]*=myEffs[ii]; else effs[ii]=myEffs[ii]; } @@ -4977,8 +4974,8 @@ CM.Sim.CalculateGains = function() { // TODO: Make function call cached function where Game.Has is replaced with CM.Has // Related to valentine cookies - for (var i in Game.cookieUpgrades) { - var me = Game.cookieUpgrades[i]; + for (let i of Object.keys(Game.cookieUpgrades)) { + let me = Game.cookieUpgrades[i]; if (CM.Sim.Has(me.name)) { mult *= (1 + (typeof(me.power) == 'function' ? me.power(me) : me.power) * 0.01); } @@ -5004,28 +5001,28 @@ CM.Sim.CalculateGains = function() { // Check effect of chosen Gods var buildMult = 1; if (CM.Sim.Objects.Temple.minigameLoaded) { - var godLvl = CM.Sim.hasGod('asceticism'); + let godLvl = CM.Sim.hasGod('asceticism'); if (godLvl == 1) mult *= 1.15; else if (godLvl == 2) mult *= 1.1; else if (godLvl == 3) mult *= 1.05; // TODO: What does DateAges do? - var godLvl = CM.Sim.hasGod('ages'); + godLvl = CM.Sim.hasGod('ages'); if (godLvl == 1) mult *= 1 + 0.15 * Math.sin((CM.Sim.DateAges / 1000 / (60 * 60 * 3)) * Math.PI * 2); else if (godLvl == 2) mult *= 1 + 0.15 * Math.sin((CM.Sim.DateAges / 1000 / (60 * 60 * 12)) * Math.PI*2); else if (godLvl == 3) mult *= 1 + 0.15 * Math.sin((CM.Sim.DateAges / 1000 / (60 * 60 * 24)) * Math.PI*2); - var godLvl = CM.Sim.hasGod('decadence'); + godLvl = CM.Sim.hasGod('decadence'); if (godLvl == 1) buildMult *= 0.93; else if (godLvl == 2) buildMult *= 0.95; else if (godLvl == 3) buildMult *= 0.98; - var godLvl = CM.Sim.hasGod('industry'); + godLvl = CM.Sim.hasGod('industry'); if (godLvl == 1) buildMult *= 1.1; else if (godLvl == 2) buildMult *= 1.06; else if (godLvl == 3) buildMult *= 1.03; - var godLvl = CM.Sim.hasGod('labor'); + godLvl = CM.Sim.hasGod('labor'); if (godLvl == 1) buildMult *= 0.97; else if (godLvl == 2) buildMult *= 0.98; else if (godLvl == 3) buildMult *= 0.99; @@ -5039,7 +5036,7 @@ CM.Sim.CalculateGains = function() { //if (CM.Sim.hasAura('Breath of Milk')) milkMult *= 1.05; milkMult *= 1 + CM.Sim.auraMult('Breath of Milk') * 0.05; if (CM.Sim.Objects.Temple.minigameLoaded) { - var godLvl = CM.Sim.hasGod('mother'); + let godLvl = CM.Sim.hasGod('mother'); if (godLvl == 1) milkMult *= 1.1; else if (godLvl == 2) milkMult *= 1.05; else if (godLvl == 3) milkMult *= 1.03; @@ -5065,8 +5062,8 @@ CM.Sim.CalculateGains = function() { if (CM.Sim.Has('Kitten angels')) catMult *= (1 + milkProgress * 0.1 * milkMult); if (CM.Sim.Has('Fortune #103')) catMult *= (1 + milkProgress * 0.05 * milkMult); - for (var i in CM.Sim.Objects) { - var me = CM.Sim.Objects[i]; + for (let i of Object.keys(CM.Sim.Objects)) { + let me = CM.Sim.Objects[i]; var storedCps = (typeof(me.cps) == 'function' ? me.cps(me) : me.cps); if (Game.ascensionMode != 1) storedCps *= (1 + me.level * 0.01) * buildMult; if (me.name == "Grandma" && CM.Sim.Has('Milkhelp® lactose intolerance relief tablets')) storedCps *= 1 + 0.05 * milkProgress * milkMult; @@ -5106,7 +5103,7 @@ CM.Sim.CalculateGains = function() { mult *= 1 + CM.Sim.auraMult('Radiant Appetite'); var rawCookiesPs = CM.Sim.cookiesPs * mult; - for (var i in Game.CpsAchievements) { + for (let i of Object.keys(Game.CpsAchievements)) { if (rawCookiesPs >= Game.CpsAchievements[i].threshold) CM.Sim.Win(Game.CpsAchievements[i].name); } @@ -5114,7 +5111,7 @@ CM.Sim.CalculateGains = function() { var n = Game.shimmerTypes.golden.n; var auraMult = CM.Sim.auraMult('Dragon\'s Fortune'); - for (var i = 0; i < n; i++){ + for (let i = 0; i < n; i++){ mult *= 1 + auraMult * 1.23; } @@ -5130,7 +5127,7 @@ CM.Sim.CalculateGains = function() { var goldenSwitchMult = 1.5; if (CM.Sim.Has('Residual luck')) { var upgrades = Game.goldenCookieUpgrades; - for (var i in upgrades) { + for (let i of Object.keys(upgrades)) { if (CM.Sim.Has(upgrades[i])) goldenSwitchMult += 0.1; } } @@ -5156,7 +5153,7 @@ CM.Sim.CalculateGains = function() { CM.Sim.CheckOtherAchiev = function() { var grandmas = 0; - for (var i in Game.GrandmaSynergies) { + for (let i of Object.keys(Game.GrandmaSynergies)) { if (CM.Sim.Has(Game.GrandmaSynergies[i])) grandmas++; } if (!CM.Sim.HasAchiev('Elder') && grandmas >= 7) CM.Sim.Win('Elder'); @@ -5166,7 +5163,7 @@ CM.Sim.CheckOtherAchiev = function() { var mathematician = 1; var base10 = 1; var minAmount = 100000; - for (var i in CM.Sim.Objects) { + for (let i of Object.keys(CM.Sim.Objects)) { buildingsOwned += CM.Sim.Objects[i].amount; minAmount = Math.min(CM.Sim.Objects[i].amount, minAmount); if (!CM.Sim.HasAchiev('Mathematician')) { @@ -5211,13 +5208,13 @@ CM.Sim.CheckOtherAchiev = function() { if (CM.Sim.Objects.Cursor.amount + CM.Sim.Objects.Grandma.amount >= 777) CM.Sim.Win('The elder scrolls'); var hasAllHalloCook = true; - for (var i in CM.Data.HalloCookies) { + for (let i of Object.keys(CM.Data.HalloCookies)) { if (!CM.Sim.Has(CM.Data.HalloCookies[i])) hasAllHalloCook = false; } if (hasAllHalloCook) CM.Sim.Win('Spooky cookies'); var hasAllChristCook = true; - for (var i in CM.Data.ChristCookies) { + for (let i of Object.keys(CM.Data.ChristCookies)) { if (!CM.Sim.Has(CM.Data.ChristCookies[i])) hasAllChristCook = false; } if (hasAllChristCook) CM.Sim.Win('Let it snow'); @@ -5225,7 +5222,7 @@ CM.Sim.CheckOtherAchiev = function() { if (CM.Sim.Has('Fortune cookies')) { var list = Game.Tiers.fortune.upgrades; var fortunes = 0; - for (var i in list) { + for (let i of Object.keys(list)) { if (CM.Sim.Has(list[i].name)) fortunes++; } if (fortunes >= list.length) CM.Sim.Win('O Fortuna'); @@ -5234,9 +5231,9 @@ CM.Sim.CheckOtherAchiev = function() { CM.Sim.BuyBuildings = function(amount, target) { CM.Cache[target] = []; - for (var i in Game.Objects) { + for (let i of Object.keys(Game.Objects)) { CM.Sim.CopyData(); - var me = CM.Sim.Objects[i]; + let me = CM.Sim.Objects[i]; me.amount += amount; if (i == 'Cursor') { @@ -5279,10 +5276,10 @@ CM.Sim.BuyBuildings = function(amount, target) { CM.Sim.BuyUpgrades = function() { CM.Cache.Upgrades = []; - for (var i in Game.Upgrades) { + for (let i of Object.keys(Game.Upgrades)) { if (Game.Upgrades[i].pool == 'toggle' || (Game.Upgrades[i].bought == 0 && Game.Upgrades[i].unlocked && Game.Upgrades[i].pool != 'prestige')) { CM.Sim.CopyData(); - var me = CM.Sim.Upgrades[i]; + let me = CM.Sim.Upgrades[i]; me.bought = 1; if (Game.CountsAsUpgradeOwned(Game.Upgrades[i].pool)) CM.Sim.UpgradesOwned++; @@ -5335,20 +5332,22 @@ CM.Sim.CalculateChangeAura = function(aura) { else CM.Sim.dragonAura = aura; // Sell highest building but only if aura is different + let price = 0; if (CM.Sim.dragonAura != CM.Cache.dragonAura || CM.Sim.dragonAura2 != CM.Cache.dragonAura2) { - for (var i = Game.ObjectsById.length; i > -1, --i;) { + for (let i = Game.ObjectsById.length; i > -1, --i;) { if (Game.ObjectsById[i].amount > 0) { var highestBuilding = CM.Sim.Objects[Game.ObjectsById[i].name].name; CM.Sim.Objects[highestBuilding].amount -=1; CM.Sim.buildingsOwned -= 1; + price = CM.Sim.Objects[highestBuilding].basePrice * Math.pow(Game.priceIncrease, Math.max(0, CM.Sim.Objects[highestBuilding].amount - 1 -CM.Sim.Objects[highestBuilding].free)); + price = Game.modifyBuildingPrice(CM.Sim.Objects[highestBuilding], price); + price = Math.ceil(price); break; } } // This calculates price of highest building - var price = CM.Sim.Objects[highestBuilding].basePrice * Math.pow(Game.priceIncrease, Math.max(0, CM.Sim.Objects[highestBuilding].amount - 1 -CM.Sim.Objects[highestBuilding].free)); - price = Game.modifyBuildingPrice(CM.Sim.Objects[highestBuilding], price); - price = Math.ceil(price); - } else var price = 0; + + } var lastAchievementsOwned = CM.Sim.AchievementsOwned; CM.Sim.CalculateGains(); @@ -5456,7 +5455,7 @@ CM.Sim.modifyBuildingPrice = function(building,price) { if (building.fortune && CM.Sim.Has(building.fortune.name)) price *= 0.93; price *= CM.Sim.eff('buildingCost'); if (CM.Sim.Objects.Temple.minigameLoaded) { - var godLvl = CM.Sim.hasGod('creation'); + let godLvl = CM.Sim.hasGod('creation'); if (godLvl == 1) price *= 0.93; else if (godLvl == 2) price *= 0.95; else if (godLvl == 3) price *= 0.98; @@ -5480,7 +5479,7 @@ CM.Sim.SellBuildingsForChoEgg = function() { CM.Sim.dragonAura = 5; CM.Sim.dragonAura2 = 18; // Sacrifice highest buildings for the aura switch - for (var i = 0; i < buildingsToSacrifice; ++i) { + for (let i = 0; i < buildingsToSacrifice; ++i) { var highestBuilding = 0; for (var j in CM.Sim.Objects) { if (CM.Sim.Objects[j].amount > 0) { @@ -5492,8 +5491,8 @@ CM.Sim.SellBuildingsForChoEgg = function() { } // Get money made by selling all remaining buildings - for (var i in CM.Sim.Objects) { - var me = CM.Sim.Objects[i]; + for (let i of Object.keys(CM.Sim.Objects)) { + let me = CM.Sim.Objects[i]; sellTotal += CM.Sim.BuildingSell(Game.Objects[me.name], Game.Objects[i].basePrice, me.amount, Game.Objects[i].free, me.amount); } @@ -5530,7 +5529,7 @@ CM.Sim.mouseCps = function() { if (CM.Sim.Has('Octillion fingers')) add *= 20; if (CM.Sim.Has('Nonillion fingers')) add *= 20; var num=0; - for (var i in CM.Sim.Objects) {num+=CM.Sim.Objects[i].amount;} + for (let i of Object.keys(CM.Sim.Objects)) {num+=CM.Sim.Objects[i].amount;} num -= CM.Sim.Objects.Cursor.amount; add = add * num; @@ -5574,7 +5573,7 @@ CM.Sim.mouseCps = function() { } } - for (var i in Game.buffs) + for (let i of Object.keys(Game.buffs)) { if (typeof Game.buffs[i].multClick != 'undefined') mult*=Game.buffs[i].multClick; } diff --git a/src/Cache.js b/src/Cache.js index e86c8bf..9f42b2f 100644 --- a/src/Cache.js +++ b/src/Cache.js @@ -102,7 +102,7 @@ CM.Cache.CacheStats = function() { CM.Cache.LuckyWrathRewardFrenzy = wrathMult * (CM.Cache.LuckyFrenzy * 0.15) + 13; CM.Cache.Conjure = CM.Cache.Lucky * 2; CM.Cache.ConjureReward = CM.Cache.Conjure * 0.15; - + CM.Cache.Edifice = 0; var max = 0; var n = 0; @@ -305,7 +305,7 @@ CM.Cache.CacheDragonCost = function() { var target = Game.dragonLevels[Game.dragonLevel].buy.toString().match(/Objects\[(.*)\]/)[1]; var amount = Game.dragonLevels[Game.dragonLevel].buy.toString().match(/sacrifice\((.*?)\)/)[1]; if (target != "i") { - target = target.replaceAll("\'", ""); + target = target.replaceAll("'", ""); if (Game.Objects[target].amount < amount) { CM.Cache.CostDragonUpgrade = "Not enough buildings to sell"; } @@ -347,7 +347,7 @@ CM.Cache.CacheDragonCost = function() { CM.Cache.lastDragonLevel = Game.dragonLevel; } }; - + /******** * Section: UNSORTED */ @@ -671,4 +671,3 @@ CM.Cache.HadBuildAura = false; CM.Cache.RealCookiesEarned = -1; CM.Cache.goldenShimmersByID = {}; CM.Cache.spawnedGoldenShimmer = 0; - diff --git a/src/Data.js b/src/Data.js index 450620a..344feb2 100644 --- a/src/Data.js +++ b/src/Data.js @@ -154,7 +154,7 @@ CM.ConfigData.GCNotification = {type: 'bool', group: 'NotificationGC', label: [' CM.ConfigData.GCFlash = {type: 'bool', group: 'NotificationGC', label: ['Flash OFF', 'Flash ON'], desc: 'Flash screen on Golden Cookie', toggle: true}; CM.ConfigData.GCSound = {type: 'bool', group: 'NotificationGC', label: ['Sound OFF', 'Sound ON'], desc: 'Play a sound on Golden Cookie', toggle: true}; CM.ConfigData.GCVolume = {type: 'vol', group: 'NotificationGC', label: [], desc: 'Volume'}; -for (var i = 0; i < 101; i++) { +for (let i = 0; i < 101; i++) { CM.ConfigData.GCVolume.label[i] = i + '%'; } CM.ConfigData.GCSoundURL = {type: 'url', group: 'NotificationGC', label: 'Sound URL:', desc: 'URL of the sound to be played when a Golden Cookie spawns'}; @@ -162,7 +162,7 @@ CM.ConfigData.FortuneNotification = {type: 'bool', group: 'NotificationFC', labe CM.ConfigData.FortuneFlash = {type: 'bool', group: 'NotificationFC', label: ['Flash OFF', 'Flash ON'], desc: 'Flash screen on Fortune Cookie', toggle: true}; CM.ConfigData.FortuneSound = {type: 'bool', group: 'NotificationFC', label: ['Sound OFF', 'Sound ON'], desc: 'Play a sound on Fortune Cookie', toggle: true}; CM.ConfigData.FortuneVolume = {type: 'vol', group: 'NotificationFC', label: [], desc: 'Volume'}; -for (var i = 0; i < 101; i++) { +for (let i = 0; i < 101; i++) { CM.ConfigData.FortuneVolume.label[i] = i + '%'; } CM.ConfigData.FortuneSoundURL = {type: 'url', group: 'NotificationFC', label: 'Sound URL:', desc: 'URL of the sound to be played when the Ticker has a Fortune Cookie'}; @@ -170,14 +170,14 @@ CM.ConfigData.SeaNotification = {type: 'bool', group: 'NotificationSea', label: CM.ConfigData.SeaFlash = {type: 'bool', group: 'NotificationSea', label: ['Flash OFF', 'Flash ON'], desc: 'Flash screen on Season Popup', toggle: true}; CM.ConfigData.SeaSound = {type: 'bool', group: 'NotificationSea', label: ['Sound OFF', 'Sound ON'], desc: 'Play a sound on Season Popup', toggle: true}; CM.ConfigData.SeaVolume = {type: 'vol', group: 'NotificationSea', label: [], desc: 'Volume'}; -for (var i = 0; i < 101; i++) { +for (let i = 0; i < 101; i++) { CM.ConfigData.SeaVolume.label[i] = i + '%'; } CM.ConfigData.SeaSoundURL = {type: 'url', group: 'NotificationSea', label: 'Sound URL:', desc: 'URL of the sound to be played when a Season Special spawns'}; CM.ConfigData.GardFlash = {type: 'bool', group: 'NotificationGard', label: ['Garden Tick Flash OFF', 'Flash ON'], desc: 'Flash screen on Garden Tick', toggle: true}; CM.ConfigData.GardSound = {type: 'bool', group: 'NotificationGard', label: ['Sound OFF', 'Sound ON'], desc: 'Play a sound on Garden Tick', toggle: true}; CM.ConfigData.GardVolume = {type: 'vol', group: 'NotificationGard', label: [], desc: 'Volume'}; -for (var i = 0; i < 101; i++) { +for (let i = 0; i < 101; i++) { CM.ConfigData.GardVolume.label[i] = i + '%'; } CM.ConfigData.GardSoundURL = {type: 'url', group: 'NotificationGard', label: 'Garden Tick Sound URL:', desc: 'URL of the sound to be played when the garden ticks'}; @@ -185,7 +185,7 @@ CM.ConfigData.MagicNotification = {type: 'bool', group: 'NotificationMagi', labe CM.ConfigData.MagicFlash = {type: 'bool', group: 'NotificationMagi', label: ['Flash OFF', 'Flash ON'], desc: 'Flash screen when magic reaches maximum', toggle: true}; CM.ConfigData.MagicSound = {type: 'bool', group: 'NotificationMagi', label: ['Sound OFF', 'Sound ON'], desc: 'Play a sound when magic reaches maximum', toggle: true}; CM.ConfigData.MagicVolume = {type: 'vol', group: 'NotificationMagi', label: [], desc: 'Volume'}; -for (var i = 0; i < 101; i++) { +for (let i = 0; i < 101; i++) { CM.ConfigData.MagicVolume.label[i] = i + '%'; } CM.ConfigData.MagicSoundURL = {type: 'url', group: 'NotificationMagi', label: 'Sound URL:', desc: 'URL of the sound to be played when magic reaches maxium'}; @@ -193,7 +193,7 @@ CM.ConfigData.WrinklerNotification = {type: 'bool', group: 'NotificationWrink', CM.ConfigData.WrinklerFlash = {type: 'bool', group: 'NotificationWrink', label: ['Flash OFF', 'Flash ON'], desc: 'Flash screen when a Wrinkler appears', toggle: true}; CM.ConfigData.WrinklerSound = {type: 'bool', group: 'NotificationWrink', label: ['Sound OFF', 'Sound ON'], desc: 'Play a sound when a Wrinkler appears', toggle: true}; CM.ConfigData.WrinklerVolume = {type: 'vol', group: 'NotificationWrink', label: [], desc: 'Volume'}; -for (var i = 0; i < 101; i++) { +for (let i = 0; i < 101; i++) { CM.ConfigData.WrinklerVolume.label[i] = i + '%'; } CM.ConfigData.WrinklerSoundURL = {type: 'url', group: 'NotificationWrink', label: 'Sound URL:', desc: 'URL of the sound to be played when a Wrinkler appears'}; @@ -201,7 +201,7 @@ CM.ConfigData.WrinklerMaxNotification = {type: 'bool', group: 'NotificationWrink CM.ConfigData.WrinklerMaxFlash = {type: 'bool', group: 'NotificationWrinkMax', label: ['Flash OFF', 'Flash ON'], desc: 'Flash screen when the maximum amount of Wrinklers has appeared', toggle: true}; CM.ConfigData.WrinklerMaxSound = {type: 'bool', group: 'NotificationWrinkMax', label: ['Sound OFF', 'Sound ON'], desc: 'Play a sound when the maximum amount of Wrinklers has appeared', toggle: true}; CM.ConfigData.WrinklerMaxVolume = {type: 'vol', group: 'NotificationWrinkMax', label: [], desc: 'Volume'}; -for (var i = 0; i < 101; i++) { +for (let i = 0; i < 101; i++) { CM.ConfigData.WrinklerMaxVolume.label[i] = i + '%'; } CM.ConfigData.WrinklerMaxSoundURL = {type: 'url', group: 'NotificationWrinkMax', label: 'Sound URL:', desc: 'URL of the sound to be played when the maximum amount of Wrinklers has appeared'}; diff --git a/src/Disp.js b/src/Disp.js index 43e6659..a6c10cf 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -137,7 +137,7 @@ CM.Disp.FormatTime = function(time, longFormat) { var h = Math.floor(time % 86400 / 3600); var m = Math.floor(time % 3600 / 60); var s = Math.floor(time % 60); - var str = ''; + let str = ''; if (CM.Options.TimeFormat) { if (time > 3155760000) return 'XX:XX:XX:XX:XX'; str += (y < 10 ? '0' : '') + y + ':'; @@ -424,11 +424,11 @@ CM.Disp.CreateBotBarBuildingColumn = function(buildingName) { var pp = CM.Disp.BotBar.firstChild.firstChild.childNodes[2]; var time = CM.Disp.BotBar.firstChild.firstChild.childNodes[3]; - var i = buildingName; + let i = buildingName; var header = type.appendChild(document.createElement('td')); header.appendChild(document.createTextNode((i.indexOf(' ') != -1 ? i.substring(0, i.indexOf(' ')) : i) + ' (')); - var span = header.appendChild(document.createElement('span')); + let span = header.appendChild(document.createElement('span')); span.className = CM.Disp.colorTextPre + CM.Disp.colorBlue; header.appendChild(document.createTextNode(')')); @@ -488,7 +488,7 @@ CM.Disp.TimerBarCreateBar = function(id, name, bars) { timerBar.style.margin = '0px 10px'; timerBar.style.position = 'relative'; - var div = document.createElement('div'); + let div = document.createElement('div'); div.style.width = '100%'; div.style.height = '10px'; div.style.margin = 'auto'; @@ -508,7 +508,7 @@ CM.Disp.TimerBarCreateBar = function(id, name, bars) { type.textContent = name; div.appendChild(type); - for (var i = 0; i < bars.length; i++) { + for (let i = 0; i < bars.length; i++) { var colorBar = document.createElement('span'); colorBar.id = bars[i].id; colorBar.style.display = 'inline-block'; @@ -696,11 +696,10 @@ CM.Disp.UpdateBotTimerBarPosition = function() { * And by changes in CM.Options.BuildColor, CM.Options.SortBuild & CM.ConfigData.BulkBuildColor */ CM.Disp.UpdateBuildings = function() { + let target = 'Objects'; + if (Game.buyBulk == 10 && CM.Options.BulkBuildColor == 1) target = 'Objects10'; + else if (Game.buyBulk == 100 && CM.Options.BulkBuildColor == 1) target = 'Objects100'; if (Game.buyMode == 1) { - var target = ''; - if (Game.buyBulk == 10 && CM.Options.BulkBuildColor == 1) target = 'Objects10'; - else if (Game.buyBulk == 100 && CM.Options.BulkBuildColor == 1) target = 'Objects100'; - else target = 'Objects'; if (CM.Options.BuildColor == 1) { for (let i of Object.keys(CM.Cache[target])) { l('productPrice' + Game.Objects[i].id).style.color = CM.Options.Colors[CM.Cache[target][i].color]; @@ -731,7 +730,7 @@ CM.Disp.UpdateBuildings = function() { // (grid rows are 1-based indexing, and row 1 is the bulk buy/sell options) // This regulates sorting of buildings if (Game.buyMode == 1 && CM.Options.SortBuildings) { - var arr = Object.keys(CM.Cache[target]).map(k => + let arr = Object.keys(CM.Cache[target]).map(k => { var o = CM.Cache[target][k]; o.name = k; @@ -741,11 +740,11 @@ CM.Disp.UpdateBuildings = function() { arr.sort(function(a, b){ return (a.pp > b.pp ? 1 : (a.pp < b.pp ? -1 : 0)); }); - for (var x = 0; x < arr.length; x++) { + for (let x = 0; x < arr.length; x++) { Game.Objects[arr[x].name].l.style.gridRow = (x + 2) + "/" + (x + 2); } } else { - var arr = Object.keys(CM.Cache.Objects).map(k => + let arr = Object.keys(CM.Cache.Objects).map(k => { var o = CM.Cache.Objects[k]; o.name = k; @@ -753,7 +752,7 @@ CM.Disp.UpdateBuildings = function() { return o; }); arr.sort((a, b) => a.id - b.id); - for (var x = 0; x < arr.length; x++) { + for (let x = 0; x < arr.length; x++) { Game.Objects[arr[x].name].l.style.gridRow = (x + 2) + "/" + (x + 2); } } @@ -779,7 +778,7 @@ CM.Disp.UpdateUpgrades = function() { for (let i of Object.keys(Game.UpgradesInStore)) { var me = Game.UpgradesInStore[i]; var addedColor = false; - for (var j = 0; j < l('upgrade' + i).childNodes.length; j++) { + for (let j = 0; j < l('upgrade' + i).childNodes.length; j++) { if (l('upgrade' + i).childNodes[j].className.indexOf(CM.Disp.colorBackPre) != -1) { l('upgrade' + i).childNodes[j].className = CM.Disp.colorBackPre + CM.Cache.Upgrades[me.name].color; addedColor = true; @@ -787,7 +786,7 @@ CM.Disp.UpdateUpgrades = function() { } } if (!addedColor) { - var div = document.createElement('div'); + let div = document.createElement('div'); div.style.width = '10px'; div.style.height = '10px'; div.className = CM.Disp.colorBackPre + CM.Cache.Upgrades[me.name].color; @@ -813,8 +812,8 @@ CM.Disp.UpdateUpgrades = function() { // Build array of pointers, sort by pp, set flex positions // This regulates sorting of upgrades - var arr = []; - for (var x = 0; x < Game.UpgradesInStore.length; x++){ + let arr = []; + for (let x = 0; x < Game.UpgradesInStore.length; x++){ var o = {}; o.name = Game.UpgradesInStore[x].name; o.price = Game.UpgradesInStore[x].basePrice; @@ -828,9 +827,12 @@ CM.Disp.UpdateUpgrades = function() { else { arr.sort((a, b) => a.price - b.price); } - - for (var x = 0; x < Game.UpgradesInStore.length; x++){ - l("upgrade" + x).style.order = arr.findIndex(e => e.name === Game.UpgradesInStore[x].name) + 1; + + let nameChecker = function(arr, upgrade) { + return arr.findIndex(e => e.name === upgrade.name); + }; + for (let x = 0; x < Game.UpgradesInStore.length; x++){ + l("upgrade" + x).style.order = nameChecker(arr, Game.UpgradesInStore[x]) + 1; } }; @@ -882,7 +884,7 @@ CM.Disp.CreateUpgradeBar = function() { CM.Disp.UpgradeBar.style.textAlign = 'center'; CM.Disp.UpgradeBar.style.fontWeight = 'bold'; CM.Disp.UpgradeBar.style.display = 'none'; - CM.Disp.UpgradeBar.style.zIndex = '21'; + CM.Disp.UpgradeBar.style.zIndex = '21'; CM.Disp.UpgradeBar.onmouseout = function() { Game.tooltip.hide(); }; var placeholder = document.createElement('div'); @@ -890,7 +892,7 @@ CM.Disp.CreateUpgradeBar = function() { CM.Disp.UpgradeBar.onmouseover = function() {Game.tooltip.draw(this, escape(placeholder.innerHTML), 'store');}; var upgradeNumber = function(id, color) { - var span = document.createElement('span'); + let span = document.createElement('span'); span.id = id; span.className = CM.Disp.colorTextPre + color; span.style.width = '14.28571428571429%'; @@ -917,16 +919,16 @@ CM.Disp.CreateUpgradeBarLegend = function() { var legend = document.createElement('div'); legend.style.minWidth = '330px'; legend.style.marginBottom = '4px'; - var title = document.createElement('div'); + let title = document.createElement('div'); title.className = 'name'; title.style.marginBottom = '4px'; title.textContent = 'Legend'; legend.appendChild(title); var legendLine = function(color, text) { - var div = document.createElement('div'); + let div = document.createElement('div'); div.style.verticalAlign = 'middle'; - var span = document.createElement('span'); + let span = document.createElement('span'); span.className = CM.Disp.colorBackPre + color; span.style.display = 'inline-block'; span.style.height = '10px'; @@ -975,7 +977,7 @@ CM.Disp.CreateWhiteScreen = function() { */ CM.Disp.Flash = function(mode, config) { // The arguments check makes the sound not play upon initialization of the mod - if ((CM.Options[config] == 1 && mode == 3 && arguments.callee.caller.caller.caller.caller == null) || mode == 1) { + if ((CM.Options[config] == 1 && mode == 3 && CM.Disp.Flash.caller.caller.caller.caller == null) || mode == 1) { CM.Disp.WhiteScreen.style.opacity = '0.5'; if (mode == 3) { CM.Disp.WhiteScreen.style.display = 'inline'; @@ -1001,7 +1003,7 @@ CM.Disp.Flash = function(mode, config) { */ CM.Disp.PlaySound = function(url, sndConfig, volConfig) { // The arguments check makes the sound not play upon initialization of the mod - if (CM.Options[sndConfig] == 1 && arguments.callee.caller.caller.caller.caller == null) { + if (CM.Options[sndConfig] == 1 && CM.Disp.PlaySound.caller.caller.caller.caller == null) { var sound = new realAudio(url); sound.volume = (CM.Options[volConfig] / 100) * (Game.volume / 100); sound.play(); @@ -1017,7 +1019,7 @@ CM.Disp.PlaySound = function(url, sndConfig, volConfig) { */ CM.Disp.Notification = function(notifyConfig, title, message) { // The arguments check makes the sound not play upon initialization of the mod - if (CM.Options[notifyConfig] == 1 && document.visibilityState == 'hidden' && arguments.callee.caller.caller.caller.caller == null) { + if (CM.Options[notifyConfig] == 1 && document.visibilityState == 'hidden' && CM.Disp.Notification.caller.caller.caller.caller == null) { var CookieIcon = 'https://orteil.dashnet.org/cookieclicker/favicon.ico'; notification = new Notification(title, {body: message, badge: CookieIcon}); } @@ -1059,11 +1061,11 @@ CM.Disp.UpdateTitle = function() { document.title = CM.Cache.Title; } else if (CM.Options.Title == 1) { - var addFC = false; - var addSP = false; - var titleGC; - var titleFC; - var titleSP; + let addFC = false; + let addSP = false; + let titleGC; + let titleFC; + let titleSP; if (CM.Cache.spawnedGoldenShimmer) { if (CM.Cache.spawnedGoldenShimmer.wrath) titleGC = '[W ' + Math.ceil(CM.Cache.spawnedGoldenShimmer.life / Game.fps) + ']'; @@ -1088,15 +1090,15 @@ CM.Disp.UpdateTitle = function() { } // Remove previous timers and add current cookies - var str = CM.Cache.Title; + let str = CM.Cache.Title; if (str.charAt(0) == '[') { str = str.substring(str.lastIndexOf(']') + 1); } document.title = titleGC + (addFC ? titleFC : '') + (addSP ? titleSP : '') + ' ' + str; } else if (CM.Options.Title == 2) { - var str = ''; - var spawn = false; + let str = ''; + let spawn = false; if (CM.Cache.spawnedGoldenShimmer) { spawn = true; if (CM.Cache.spawnedGoldenShimmer.wrath) str += '[W ' + Math.ceil(CM.Cache.spawnedGoldenShimmer.life / Game.fps) + ']'; @@ -1111,7 +1113,7 @@ CM.Disp.UpdateTitle = function() { spawn = true; } if (spawn) str += ' - '; - var title = 'Cookie Clicker'; + let title = 'Cookie Clicker'; if (Game.season == 'fools') title = 'Cookie Baker'; str += title; document.title = str; @@ -1135,7 +1137,7 @@ CM.Disp.CreateGCTimer = function(cookie) { GCTimer.style.zIndex = '10000000001'; GCTimer.style.textAlign = 'center'; GCTimer.style.lineHeight = '96px'; - GCTimer.style.fontFamily = '\"Kavoon\", Georgia, serif'; + GCTimer.style.fontFamily = '"Kavoon", Georgia, serif'; GCTimer.style.fontSize = '35px'; GCTimer.style.cursor = 'pointer'; GCTimer.style.display = 'block'; @@ -1183,7 +1185,7 @@ CM.Disp.CreateSimpleTooltip = function(placeholder, text, minWidth) { var desc = document.createElement('div'); desc.style.minWidth = minWidth; desc.style.marginBottom = '4px'; - var div = document.createElement('div'); + let div = document.createElement('div'); div.style.textAlign = 'left'; div.textContent = text; desc.appendChild(div); @@ -1198,10 +1200,9 @@ CM.Disp.CreateSimpleTooltip = function(placeholder, text, minWidth) { CM.Disp.ReplaceTooltipUpgrade = function() { CM.Disp.TooltipUpgradeBackup = []; for (let i of Object.keys(Game.UpgradesInStore)) { - var me = Game.UpgradesInStore[i]; if (l('upgrade' + i).onmouseover != null) { CM.Disp.TooltipUpgradeBackup[i] = l('upgrade' + i).onmouseover; - eval('l(\'upgrade\' + i).onmouseover = function() {if (!Game.mouseDown) {Game.setOnCrate(this); Game.tooltip.dynamic = 1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip(\'u\', \'' + i + '\');}, \'store\'); Game.tooltip.wobble();}}'); + l('upgrade' + i).onmouseover = function() {if (!Game.mouseDown) {Game.setOnCrate(this); Game.tooltip.dynamic = 1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip('u', `${i}`);}, 'store'); Game.tooltip.wobble();}}; } } }; @@ -1286,7 +1287,7 @@ CM.Disp.TooltipCreateTooltipBox = function() { * @returns {object} div An object containing the stylized header */ CM.Disp.TooltipCreateHeader = function(text) { - var div = document.createElement('div'); + let div = document.createElement('div'); div.style.fontWeight = 'bold'; div.className = CM.Disp.colorTextPre + CM.Disp.colorBlue; div.textContent = text; @@ -1301,7 +1302,7 @@ CM.Disp.TooltipCreateHeader = function(text) { */ CM.Disp.TooltipCreateCalculationSection = function(tooltip) { tooltip.appendChild(CM.Disp.TooltipCreateHeader('Bonus Income')); - var income = document.createElement('div'); + let income = document.createElement('div'); income.style.marginBottom = '4px'; income.style.color = 'white'; income.id = 'CMTooltipIncome'; @@ -1448,7 +1449,7 @@ CM.Disp.UpdateTooltipBuilding = function() { if (CM.Options.TooltipBuildUpgrade == 1 && Game.buyMode == 1) { l('CMTooltipIncome').textContent = Beautify(CM.Disp.TooltipBonusIncome, 2); - var increase = Math.round(CM.Disp.TooltipBonusIncome / Game.cookiesPs * 10000); + let increase = Math.round(CM.Disp.TooltipBonusIncome / Game.cookiesPs * 10000); if (isFinite(increase) && increase != 0) { l('CMTooltipIncome').textContent += ' (' + (increase / 100) + '% of income)'; } @@ -1465,22 +1466,19 @@ CM.Disp.UpdateTooltipBuilding = function() { } // Add "production left till next achievement"-bar + l('CMTooltipProductionHeader').style.display = "none"; + l('CMTooltipTime').style.marginBottom = '0px'; for (let i of Object.keys(Game.Objects[CM.Disp.tooltipName].productionAchievs)) { if (!CM.Sim.HasAchiev(Game.Objects[CM.Disp.tooltipName].productionAchievs[i].achiev.name)) { - var nextProductionAchiev = Game.Objects[CM.Disp.tooltipName].productionAchievs[i]; + let nextProductionAchiev = Game.Objects[CM.Disp.tooltipName].productionAchievs[i]; + l('CMTooltipTime').style.marginBottom = '4px'; + l('CMTooltipProductionHeader').style.display = ""; + l('CMTooltipProduction').className = "ProdAchievement" + CM.Disp.tooltipName; + l('CMTooltipProduction').textContent = Beautify(nextProductionAchiev.pow - CM.Sim.Objects[CM.Disp.tooltipName].totalCookies, 15); + l('CMTooltipProduction').style.color = "white"; break; } } - if (typeof nextProductionAchiev != "undefined") { - l('CMTooltipTime').style.marginBottom = '4px'; - l('CMTooltipProductionHeader').style.display = ""; - l('CMTooltipProduction').className = "ProdAchievement" + CM.Disp.tooltipName; - l('CMTooltipProduction').textContent = Beautify(nextProductionAchiev.pow - CM.Sim.Objects[CM.Disp.tooltipName].totalCookies, 15); - l('CMTooltipProduction').style.color = "white"; - } else { - l('CMTooltipProductionHeader').style.display = "none"; - l('CMTooltipTime').style.marginBottom = '0px'; - } } else l('CMTooltipArea').style.display = "none"; }; @@ -1499,7 +1497,7 @@ CM.Disp.UpdateTooltipUpgrade = function() { if (CM.Options.TooltipBuildUpgrade == 1) { l('CMTooltipIncome').textContent = Beautify(CM.Disp.TooltipBonusIncome, 2); - var increase = Math.round(CM.Disp.TooltipBonusIncome / Game.cookiesPs * 10000); + let increase = Math.round(CM.Disp.TooltipBonusIncome / Game.cookiesPs * 10000); if (isFinite(increase) && increase != 0) { l('CMTooltipIncome').textContent += ' (' + (increase / 100) + '% of income)'; } @@ -1654,13 +1652,14 @@ CM.Disp.UpdateTooltipGardenPlots = function() { * It adds to the additional information to l('CMTooltipArea') */ CM.Disp.UpdateTooltipHarvestAll = function() { - var minigame = Game.Objects.Farm.minigame; + let minigame = Game.Objects.Farm.minigame; if (CM.Options.TooltipLump) { l('CMTooltipBorder').appendChild(CM.Disp.TooltipCreateHeader('Cookies gained from harvesting:')); - var totalGain = 0; - if (Game.keys[16] && Game.keys[17]) var mortal = 1; - for (var y=0;y<6;y++) { - for (var x=0;x<6;x++) { + let totalGain = 0; + let mortal = 0; + if (Game.keys[16] && Game.keys[17]) mortal = 1; + for (let y=0;y<6;y++) { + for (let x=0; x<6; x++) { if (minigame.plot[y][x][0]>=1) { let tile = minigame.plot[y][x]; let me = minigame.plantsById[tile[0] - 1]; @@ -1819,7 +1818,7 @@ CM.Disp.CheckWrinklerTooltip = function() { var wrinkler = document.createElement('div'); wrinkler.style.minWidth = '120px'; wrinkler.style.marginBottom = '4px'; - var div = document.createElement('div'); + let div = document.createElement('div'); div.style.textAlign = 'center'; div.id = 'CMTooltipWrinkler'; wrinkler.appendChild(div); @@ -1881,12 +1880,12 @@ CM.Disp.AddAuraInfo = function(aura) { l('dragonAuraInfo').style.minHeight = "60px"; l('dragonAuraInfo').style.margin = "8px"; l('dragonAuraInfo').appendChild(document.createElement("div")).className = "line"; - var div = document.createElement("div"); + let div = document.createElement("div"); div.style.minWidth = "200px"; div.style.textAlign = "center"; div.textContent = "Picking this aura will change CPS by " + bonusCPS + " (" + bonusCPSPercentage + "% of current CPS)."; l('dragonAuraInfo').appendChild(div); - var div2 = document.createElement("div"); + let div2 = document.createElement("div"); div2.style.minWidth = "200px"; div2.style.textAlign = "center"; div2.textContent = "It will take " + timeToRecover + " to recover the cost."; @@ -1918,8 +1917,8 @@ CM.Disp.AddDragonLevelUpTooltip = function() { * It is called by Game.UpdateMenu() */ CM.Disp.AddMenu = function() { - var title = function() { - var div = document.createElement('div'); + let title = function() { + let div = document.createElement('div'); div.className = 'title ' + CM.Disp.colorTextPre + CM.Disp.colorBlue; div.textContent = 'Cookie Monster Goodies'; return div; @@ -2000,13 +1999,13 @@ CM.Disp.AddMenuPref = function(title) { * @returns {object} div The header object */ CM.Disp.CreatePrefHeader = function(config, text) { - var div = document.createElement('div'); + let div = document.createElement('div'); div.className = 'title'; div.style.opacity = '0.7'; div.style.fontSize = '17px'; div.appendChild(document.createTextNode(text + ' ')); - var span = document.createElement('span'); // Creates the +/- button + let span = document.createElement('span'); // Creates the +/- button span.style.cursor = 'pointer'; span.style.display = 'inline-block'; span.style.height = '14px'; @@ -2031,9 +2030,9 @@ CM.Disp.CreatePrefHeader = function(config, text) { */ CM.Disp.CreatePrefOption = function(config) { if (CM.ConfigData[config].type == "bool") { - var div = document.createElement('div'); + let div = document.createElement('div'); div.className = 'listing'; - var a = document.createElement('a'); + let a = document.createElement('a'); if (CM.ConfigData[config].toggle && CM.Options[config] == 0) { a.className = 'option off'; } @@ -2044,21 +2043,21 @@ CM.Disp.CreatePrefOption = function(config) { a.onclick = function() {CM.Config.ToggleConfig(config);}; a.textContent = CM.ConfigData[config].label[CM.Options[config]]; div.appendChild(a); - var label = document.createElement('label'); + let label = document.createElement('label'); label.textContent = CM.ConfigData[config].desc; div.appendChild(label); return div; } else if (CM.ConfigData[config].type == "vol") { - var div = document.createElement('div'); + let div = document.createElement('div'); div.className = 'listing'; var volume = document.createElement('div'); volume.className = 'sliderBox'; - var title = document.createElement('div'); + let title = document.createElement('div'); title.style.float = "left"; title.innerHTML = CM.ConfigData[config].desc; volume.appendChild(title); - var percent = title = document.createElement('div'); + var percent = document.createElement('div'); percent.id = "slider" + config + "right"; percent.style.float = "right"; percent.innerHTML = CM.Options[config] + "%"; @@ -2079,13 +2078,13 @@ CM.Disp.CreatePrefOption = function(config) { return div; } else if (CM.ConfigData[config].type == "url") { - var div = document.createElement('div'); + let div = document.createElement('div'); div.className = 'listing'; - var span = document.createElement('span'); + let span = document.createElement('span'); span.className = 'option'; span.textContent = CM.ConfigData[config].label + ' '; div.appendChild(span); - var input = document.createElement('input'); + let input = document.createElement('input'); input.id = CM.ConfigPrefix + config; input.className = 'option'; input.type = 'text'; @@ -2094,34 +2093,34 @@ CM.Disp.CreatePrefOption = function(config) { input.style.width = '300px'; div.appendChild(input); div.appendChild(document.createTextNode(' ')); - var inputPrompt = document.createElement('input'); + let inputPrompt = document.createElement('input'); inputPrompt.id = CM.ConfigPrefix + config + 'Prompt'; inputPrompt.className = 'option'; inputPrompt.type = 'text'; inputPrompt.setAttribute('value', CM.Options[config]); - var a = document.createElement('a'); + let a = document.createElement('a'); a.className = 'option'; a.onclick = function() {Game.Prompt(inputPrompt.outerHTML, [['Save', 'CM.Options[\'' + config + '\'] = l(CM.ConfigPrefix + \'' + config + '\' + \'Prompt\').value; CM.Config.SaveConfig(); Game.ClosePrompt(); Game.UpdateMenu();'], 'Cancel']);}; a.textContent = 'Edit'; div.appendChild(a); - var label = document.createElement('label'); + let label = document.createElement('label'); label.textContent = CM.ConfigData[config].desc; div.appendChild(label); return div; } else if (CM.ConfigData[config].type == "color") { - var div = document.createElement('div'); - for (var i = 0; i < CM.Disp.colors.length; i++) { - var innerDiv = document.createElement('div'); + let div = document.createElement('div'); + for (let i = 0; i < CM.Disp.colors.length; i++) { + let innerDiv = document.createElement('div'); innerDiv.className = 'listing'; - var input = document.createElement('input'); + let input = document.createElement('input'); input.id = CM.Disp.colors[i]; input.style.width = '65px'; input.setAttribute('value', CM.Options.Colors[CM.Disp.colors[i]]); innerDiv.appendChild(input); let change = function() {CM.Options.Colors[this.targetElement.id] = this.toHEXString(); CM.Disp.UpdateColors(); CM.Config.SaveConfig(); Game.UpdateMenu();}; - let picker = new JSColor(input, {hash: true, position: "right", onInput: change}); - var label = document.createElement('label'); + let = new JSColor(input, {hash: true, position: "right", onInput: change}); + let label = document.createElement('label'); label.textContent = CM.ConfigData.Colors.desc[CM.Disp.colors[i]]; innerDiv.appendChild(label); div.appendChild(innerDiv); @@ -2129,13 +2128,13 @@ CM.Disp.CreatePrefOption = function(config) { return div; } else if (CM.ConfigData[config].type == "numscale") { - var div = document.createElement('div'); + let div = document.createElement('div'); div.className = 'listing'; - var span = document.createElement('span'); + let span = document.createElement('span'); span.className = 'option'; span.textContent = CM.ConfigData[config].label + ' '; div.appendChild(span); - var input = document.createElement('input'); + let input = document.createElement('input'); input.id = CM.ConfigPrefix + config; input.className = 'option'; input.type = 'number'; @@ -2143,13 +2142,13 @@ CM.Disp.CreatePrefOption = function(config) { input.min = CM.ConfigData[config].min; input.max = CM.ConfigData[config].max; input.oninput = function() {if (this.value > this.max) console.log("TEST"); - CM.Options[config] = this.value; - CM.Config.SaveConfig(); - CM.Disp.RefreshScale(); - }; + CM.Options[config] = this.value; + CM.Config.SaveConfig(); + CM.Disp.RefreshScale(); + }; div.appendChild(input); div.appendChild(document.createTextNode(' ')); - var label = document.createElement('label'); + let label = document.createElement('label'); label.textContent = CM.ConfigData[config].desc; div.appendChild(label); return div; @@ -2184,14 +2183,14 @@ CM.Disp.RefreshScale = function() { * The function is therefore called by a change in CM.Options.Colors */ CM.Disp.UpdateColors = function() { - var str = ''; - for (var i = 0; i < CM.Disp.colors.length; i++) { + let str = ''; + for (let i = 0; i < CM.Disp.colors.length; i++) { str += '.' + CM.Disp.colorTextPre + CM.Disp.colors[i] + ' { color: ' + CM.Options.Colors[CM.Disp.colors[i]] + '; }\n'; } - for (var i = 0; i < CM.Disp.colors.length; i++) { + for (let i = 0; i < CM.Disp.colors.length; i++) { str += '.' + CM.Disp.colorBackPre + CM.Disp.colors[i] + ' { background-color: ' + CM.Options.Colors[CM.Disp.colors[i]] + '; }\n'; } - for (var i = 0; i < CM.Disp.colors.length; i++) { + for (let i = 0; i < CM.Disp.colors.length; i++) { str += '.' + CM.Disp.colorBorderPre + CM.Disp.colors[i] + ' { border: 1px solid ' + CM.Options.Colors[CM.Disp.colors[i]] + '; }\n'; } CM.Disp.Css.textContent = str; @@ -2224,7 +2223,7 @@ CM.Disp.AddMenuStats = function(title) { stats.appendChild(CM.Disp.CreateStatsHeader('Spells', 'Spells')); if (CM.Options.Header.Spells) { stats.appendChild(CM.Disp.CreateStatsSpellsSection()); - } + } stats.appendChild(CM.Disp.CreateStatsHeader('Prestige', 'Prestige')); if (CM.Options.Header.Prestige) { @@ -2360,14 +2359,14 @@ CM.Disp.AddMenuStats = function(title) { * @returns {object} div The header object */ CM.Disp.CreateStatsHeader = function(text, config) { - var div = document.createElement('div'); + let div = document.createElement('div'); div.className = 'listing'; div.style.padding = '5px 16px'; div.style.opacity = '0.7'; div.style.fontSize = '17px'; - div.style.fontFamily = '\"Kavoon\", Georgia, serif'; + div.style.fontFamily = '"Kavoon", Georgia, serif'; div.appendChild(document.createTextNode(text + ' ')); - var span = document.createElement('span'); + let span = document.createElement('span'); span.style.cursor = 'pointer'; span.style.display = 'inline-block'; span.style.height = '14px'; @@ -2394,7 +2393,7 @@ CM.Disp.CreateStatsHeader = function(text, config) { * @returns {object} div The option object */ CM.Disp.CreateStatsListing = function(type, name, text, placeholder) { - var div = document.createElement('div'); + let div = document.createElement('div'); div.className = 'listing'; var listingName = document.createElement('b'); @@ -2433,20 +2432,20 @@ CM.Disp.CreateStatsListing = function(type, name, text, placeholder) { CM.Disp.CreateStatsMissDisp = function(theMissDisp) { var frag = document.createDocumentFragment(); frag.appendChild(document.createTextNode(theMissDisp.length + ' ')); - var span = document.createElement('span'); + let span = document.createElement('span'); span.onmouseout = function() { Game.tooltip.hide(); }; var placeholder = document.createElement('div'); var missing = document.createElement('div'); missing.style.minWidth = '140px'; missing.style.marginBottom = '4px'; - var title = document.createElement('div'); + let title = document.createElement('div'); title.className = 'name'; title.style.marginBottom = '4px'; title.style.textAlign = 'center'; title.textContent = 'Missing'; missing.appendChild(title); for (let i of Object.keys(theMissDisp)) { - var div = document.createElement('div'); + let div = document.createElement('div'); div.style.textAlign = 'center'; div.appendChild(document.createTextNode(theMissDisp[i])); missing.appendChild(div); @@ -2492,7 +2491,7 @@ CM.Disp.CreateStatsLuckySection = function() { luckyReqSmall.textContent = ' (' + luckyTime + ')'; luckyReqFrag.appendChild(luckyReqSmall); } - section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Lucky!\" Cookies Required', luckyReqFrag, goldCookTooltip)); + section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '"Lucky!" Cookies Required', luckyReqFrag, goldCookTooltip)); var luckyColorFrenzy = ((Game.cookies + CM.Disp.GetWrinkConfigBank()) < CM.Cache.LuckyFrenzy) ? CM.Disp.colorRed : CM.Disp.colorGreen; @@ -2508,7 +2507,7 @@ CM.Disp.CreateStatsLuckySection = function() { luckyReqFrenSmall.textContent = ' (' + luckyTimeFrenzy + ')'; luckyReqFrenFrag.appendChild(luckyReqFrenSmall); } - section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Lucky!\" Cookies Required (Frenzy)', luckyReqFrenFrag, goldCookTooltip)); + section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '"Lucky!" Cookies Required (Frenzy)', luckyReqFrenFrag, goldCookTooltip)); var luckySplit = CM.Cache.LuckyReward != CM.Cache.LuckyWrathReward; @@ -2516,20 +2515,20 @@ CM.Disp.CreateStatsLuckySection = function() { luckyRewardMaxSpan.style.fontWeight = 'bold'; luckyRewardMaxSpan.className = CM.Disp.colorTextPre + CM.Cache.LuckyReward; luckyRewardMaxSpan.textContent = Beautify(CM.Cache.LuckyReward) + (luckySplit ? (' / ' + Beautify(CM.Cache.LuckyWrathReward)) : ''); - section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Lucky!\" Reward (MAX)' + (luckySplit ? ' (Golden / Wrath)' : ''), luckyRewardMaxSpan, goldCookTooltip)); + section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '"Lucky!" Reward (MAX)' + (luckySplit ? ' (Golden / Wrath)' : ''), luckyRewardMaxSpan, goldCookTooltip)); var luckyRewardFrenzyMaxSpan = document.createElement('span'); luckyRewardFrenzyMaxSpan.style.fontWeight = 'bold'; luckyRewardFrenzyMaxSpan.className = CM.Disp.colorTextPre + luckyRewardFrenzyMaxSpan; luckyRewardFrenzyMaxSpan.textContent = Beautify(CM.Cache.LuckyRewardFrenzy) + (luckySplit ? (' / ' + Beautify(CM.Cache.LuckyWrathRewardFrenzy)) : ''); - section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Lucky!\" Reward (MAX) (Frenzy)' + (luckySplit ? ' (Golden / Wrath)' : ''), luckyRewardFrenzyMaxSpan , goldCookTooltip)); + section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '"Lucky!" Reward (MAX) (Frenzy)' + (luckySplit ? ' (Golden / Wrath)' : ''), luckyRewardFrenzyMaxSpan , goldCookTooltip)); var luckyCurBase = Math.min((Game.cookies + CM.Disp.GetWrinkConfigBank()) * 0.15, CM.Cache.NoGoldSwitchCookiesPS * CM.Cache.DragonsFortuneMultAdjustment * 60 * 15) + 13; var luckyCurSpan = document.createElement('span'); luckyCurSpan.style.fontWeight = 'bold'; luckyCurSpan.className = CM.Disp.colorTextPre + luckyCurSpan; luckyCurSpan.textContent = Beautify(CM.Cache.GoldenCookiesMult * luckyCurBase) + (luckySplit ? (' / ' + Beautify(CM.Cache.WrathCookiesMult * luckyCurBase)) : ''); - section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Lucky!\" Reward (CUR)' + (luckySplit ? ' (Golden / Wrath)' : ''), luckyCurSpan, goldCookTooltip)); + section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '"Lucky!" Reward (CUR)' + (luckySplit ? ' (Golden / Wrath)' : ''), luckyCurSpan, goldCookTooltip)); return section; }; @@ -2557,7 +2556,7 @@ CM.Disp.CreateStatsChainSection = function() { chainReqSmall.textContent = ' (' + chainTime + ')'; chainReqFrag.appendChild(chainReqSmall); } - section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Chain\" Cookies Required', chainReqFrag, goldCookTooltip)); + section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '"Chain" Cookies Required', chainReqFrag, goldCookTooltip)); var chainWrathColor = ((Game.cookies + CM.Disp.GetWrinkConfigBank()) < CM.Cache.ChainWrath) ? CM.Disp.colorRed : CM.Disp.colorGreen; var chainWrathTime = ((Game.cookies + CM.Disp.GetWrinkConfigBank()) < CM.Cache.ChainWrath) ? CM.Disp.FormatTime((CM.Cache.ChainWrath - (Game.cookies + CM.Disp.GetWrinkConfigBank())) / CM.Disp.GetCPS()) : ''; @@ -2572,7 +2571,7 @@ CM.Disp.CreateStatsChainSection = function() { chainWrathReqSmall.textContent = ' (' + chainWrathTime + ')'; chainWrathReqFrag.appendChild(chainWrathReqSmall); } - section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Chain\" Cookies Required (Wrath)', chainWrathReqFrag, goldCookTooltip)); + section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '"Chain" Cookies Required (Wrath)', chainWrathReqFrag, goldCookTooltip)); var chainColorFrenzy = ((Game.cookies + CM.Disp.GetWrinkConfigBank()) < CM.Cache.ChainFrenzy) ? CM.Disp.colorRed : CM.Disp.colorGreen; var chainTimeFrenzy = ((Game.cookies + CM.Disp.GetWrinkConfigBank()) < CM.Cache.ChainFrenzy) ? CM.Disp.FormatTime((CM.Cache.ChainFrenzy - (Game.cookies + CM.Disp.GetWrinkConfigBank())) / CM.Disp.GetCPS()) : ''; @@ -2587,7 +2586,7 @@ CM.Disp.CreateStatsChainSection = function() { chainReqFrenSmall.textContent = ' (' + chainTimeFrenzy + ')'; chainReqFrenFrag.appendChild(chainReqFrenSmall); } - section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Chain\" Cookies Required (Frenzy)', chainReqFrenFrag, goldCookTooltip)); + section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '"Chain" Cookies Required (Frenzy)', chainReqFrenFrag, goldCookTooltip)); var chainWrathColorFrenzy = ((Game.cookies + CM.Disp.GetWrinkConfigBank()) < CM.Cache.ChainFrenzyWrath) ? CM.Disp.colorRed : CM.Disp.colorGreen; var chainWrathTimeFrenzy = ((Game.cookies + CM.Disp.GetWrinkConfigBank()) < CM.Cache.ChainFrenzyWrath) ? CM.Disp.FormatTime((CM.Cache.ChainFrenzyWrath - (Game.cookies + CM.Disp.GetWrinkConfigBank())) / CM.Disp.GetCPS()) : ''; @@ -2602,17 +2601,17 @@ CM.Disp.CreateStatsChainSection = function() { chainWrathReqFrenSmall.textContent = ' (' + chainWrathTimeFrenzy + ')'; chainWrathReqFrenFrag.appendChild(chainWrathReqFrenSmall); } - section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Chain\" Cookies Required (Frenzy) (Wrath)', chainWrathReqFrenFrag, goldCookTooltip)); + 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) + ' / ' + Beautify(CM.Cache.ChainWrathReward)), goldCookTooltip)); + section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '"Chain" Reward (MAX) (Golden / Wrath)', document.createTextNode(Beautify(CM.Cache.ChainReward) + ' / ' + Beautify(CM.Cache.ChainWrathReward)), goldCookTooltip)); - section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Chain\" Reward (MAX) (Frenzy) (Golden / Wrath)', document.createTextNode((Beautify(CM.Cache.ChainFrenzyReward) + ' / ' + Beautify(CM.Cache.ChainFrenzyWrathReward))), goldCookTooltip)); + section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '"Chain" Reward (MAX) (Frenzy) (Golden / Wrath)', document.createTextNode((Beautify(CM.Cache.ChainFrenzyReward) + ' / ' + Beautify(CM.Cache.ChainFrenzyWrathReward))), goldCookTooltip)); // TODO: Place MaxChainMoni function into CM.Cache.RemakeChain and create global variables to store it var chainCurMax = Math.min(CM.Cache.NoGoldSwitchCookiesPS * CM.Cache.DragonsFortuneMultAdjustment * 60 * 60 * 6, (Game.cookies + CM.Disp.GetWrinkConfigBank()) * 0.5); var chainCur = CM.Cache.MaxChainMoni(7, chainCurMax, CM.Cache.GoldenCookiesMult); var chainCurWrath = CM.Cache.MaxChainMoni(6, chainCurMax, CM.Cache.WrathCookiesMult); - section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Chain\" Reward (CUR) (Golden / Wrath)', document.createTextNode((Beautify(chainCur) + ' / ' + Beautify(chainCurWrath))), goldCookTooltip)); + section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '"Chain" Reward (CUR) (Golden / Wrath)', document.createTextNode((Beautify(chainCur) + ' / ' + Beautify(chainCurWrath))), goldCookTooltip)); return section; }; @@ -2625,7 +2624,6 @@ CM.Disp.CreateStatsSpellsSection = function() { section.className = 'CMStatsSpellsSection'; var conjureColor = ((Game.cookies + CM.Disp.GetWrinkConfigBank()) < CM.Cache.Conjure) ? CM.Disp.colorRed : CM.Disp.colorGreen; - var conjureCur = Math.min((Game.cookies + CM.Disp.GetWrinkConfigBank()) * 0.15, CM.Cache.NoGoldSwitchCookiesPS * 60 * 30); var conjureTime = ((Game.cookies + CM.Disp.GetWrinkConfigBank()) < CM.Cache.Conjure) ? CM.Disp.FormatTime((CM.Cache.Conjure - (Game.cookies + CM.Disp.GetWrinkConfigBank())) / CM.Disp.GetCPS()) : ''; var conjureReqFrag = document.createDocumentFragment(); @@ -2639,8 +2637,8 @@ CM.Disp.CreateStatsSpellsSection = function() { conjureReqSmall.textContent = ' (' + conjureTime + ')'; conjureReqFrag.appendChild(conjureReqSmall); } - section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Conjure Baked Goods\" Cookies Required', conjureReqFrag, 'GoldCookTooltipPlaceholder')); - section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Conjure Baked Goods\" Reward (MAX)', document.createTextNode(CM.Disp.Beautify(CM.Cache.ConjureReward)), 'GoldCookTooltipPlaceholder')); + section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '"Conjure Baked Goods" Cookies Required', conjureReqFrag, 'GoldCookTooltipPlaceholder')); + section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '"Conjure Baked Goods" Reward (MAX)', document.createTextNode(CM.Disp.Beautify(CM.Cache.ConjureReward)), 'GoldCookTooltipPlaceholder')); var conjureFrenzyColor = ((Game.cookies + CM.Disp.GetWrinkConfigBank()) < CM.Cache.Conjure * 7) ? CM.Disp.colorRed : CM.Disp.colorGreen; var conjureFrenzyCur = Math.min((Game.cookies + CM.Disp.GetWrinkConfigBank()) * 0.15, CM.Cache.NoGoldSwitchCookiesPS * 60 * 30); @@ -2657,11 +2655,11 @@ CM.Disp.CreateStatsSpellsSection = function() { conjureFrenzyReqSmall.textContent = ' (' + conjureFrenzyTime + ')'; conjureFrenzyReqFrag.appendChild(conjureFrenzyReqSmall); } - section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Conjure Baked Goods\" Cookies Required (Frenzy)', conjureFrenzyReqFrag, 'GoldCookTooltipPlaceholder')); - section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Conjure Baked Goods\" Reward (MAX) (Frenzy)', document.createTextNode(CM.Disp.Beautify(CM.Cache.ConjureReward * 7)), 'GoldCookTooltipPlaceholder')); - section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Conjure Baked Goods\" Reward (CUR)', document.createTextNode(CM.Disp.Beautify(conjureFrenzyCur)), 'GoldCookTooltipPlaceholder')); + section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '"Conjure Baked Goods" Cookies Required (Frenzy)', conjureFrenzyReqFrag, 'GoldCookTooltipPlaceholder')); + section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '"Conjure Baked Goods" Reward (MAX) (Frenzy)', document.createTextNode(CM.Disp.Beautify(CM.Cache.ConjureReward * 7)), 'GoldCookTooltipPlaceholder')); + section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '"Conjure Baked Goods" Reward (CUR)', document.createTextNode(CM.Disp.Beautify(conjureFrenzyCur)), 'GoldCookTooltipPlaceholder')); if (CM.Cache.Edifice) { - section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Spontaneous Edifice\" Cookies Required (most expensive building)', document.createTextNode(CM.Disp.Beautify(CM.Cache.Edifice) + ' (' + CM.Cache.EdificeBuilding + ")"), 'GoldCookTooltipPlaceholder')); + section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '"Spontaneous Edifice" Cookies Required (most expensive building)', document.createTextNode(CM.Disp.Beautify(CM.Cache.Edifice) + ' (' + CM.Cache.EdificeBuilding + ")"), 'GoldCookTooltipPlaceholder')); } return section; }; @@ -2692,7 +2690,7 @@ CM.Disp.CreateStatsPrestigeSection = function() { var resetBonus = CM.Sim.ResetBonus(possiblePresMax); var resetFrag = document.createDocumentFragment(); resetFrag.appendChild(document.createTextNode(Beautify(resetBonus))); - var increase = Math.round(resetBonus / Game.cookiesPs * 10000); + let increase = Math.round(resetBonus / Game.cookiesPs * 10000); if (isFinite(increase) && increase != 0) { var resetSmall = document.createElement('small'); resetSmall.textContent = ' (' + (increase / 100) + '% of income)'; @@ -2743,7 +2741,7 @@ CM.Disp.CreateStatsPrestigeSection = function() { CM.Disp.AddMissingUpgrades = function() { if (CM.Cache.MissingUpgradesPrestige) { var prestigeUpgradesOwned = Game.PrestigeUpgrades.length - l('menu').children[5].children[3].children.length; - var title = document.createElement('div'); + let title = document.createElement('div'); title.id = "CMMissingUpgradesPrestigeTitle"; title.className = "listing"; titlefrag = document.createElement('div'); @@ -2756,10 +2754,9 @@ CM.Disp.AddMissingUpgrades = function() { l('menu').children[5].appendChild(upgrades); } if (CM.Cache.MissingUpgrades) { - if (Game.UpgradesOwned) { - var normalUpgradesOwned = Game.UpgradesByPool[""].length + Game.UpgradesByPool.tech.length - l('menu').children[6].childNodes[2].children.length; - } else var normalUpgradesOwned = 0; - var title = document.createElement('div'); + let normalUpgradesOwned = 0; + if (Game.UpgradesOwned) normalUpgradesOwned = Game.UpgradesByPool[""].length + Game.UpgradesByPool.tech.length - l('menu').children[6].childNodes[2].children.length; + let title = document.createElement('div'); title.id = "CMMissingUpgradesTitle"; title.className = "listing"; titlefrag = document.createElement('div'); @@ -2773,7 +2770,7 @@ CM.Disp.AddMissingUpgrades = function() { } if (CM.Cache.MissingUpgradesCookies) { var cookieUpgradesOwned = Game.UpgradesByPool.cookie.length - l('menu').children[6].lastChild.children.length; - var title = document.createElement('div'); + let title = document.createElement('div'); title.id = "CMMissingUpgradesCookiesTitle"; title.className = "listing"; titlefrag = document.createElement('div'); @@ -2803,7 +2800,7 @@ CM.Disp.crateMissing = function(me) { if (!Game.prefs.crates) noFrame = 1; if (noFrame) classes += ' noFrame'; - var icon = me.icon; + let icon = me.icon; if (me.iconFunction) icon = me.iconFunction(); tooltip = `function() {return Game.crateTooltip(Game.UpgradesById[${me.id}], 'stats');}`; return `
{ + Array.from(l('gardenPlot').children).forEach((child) => { var coords = child.id.slice(-3,); child.onmouseover = function() {Game.tooltip.dynamic=1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip('p', [`${coords[0]}`,`${coords[2]}`]);}, 'this'); Game.tooltip.wobble();}; }); @@ -349,7 +348,7 @@ CM.Main.ReplaceTooltipGarden = function() { CM.Main.FindShimmer = function() { CM.Main.currSpawnedGoldenCookieState = 0; CM.Cache.goldenShimmersByID = {}; - for (var i in Game.shimmers) { + for (let i of Object.keys(Game.shimmers)) { CM.Cache.goldenShimmersByID[Game.shimmers[i].id] = Game.shimmers[i]; if (Game.shimmers[i].spawnLead && Game.shimmers[i].type == 'golden') { CM.Cache.spawnedGoldenShimmer = Game.shimmers[i]; @@ -365,7 +364,7 @@ CM.Main.FindShimmer = function() { */ CM.Main.CheckGoldenCookie = function() { CM.Main.FindShimmer(); - for (var i in CM.Disp.GCTimers) { + for (let i of Object.keys(CM.Disp.GCTimers)) { if (typeof CM.Cache.goldenShimmersByID[i] == "undefined") { CM.Disp.GCTimers[i].parentNode.removeChild(CM.Disp.GCTimers[i]); // TODO remove delete here @@ -381,7 +380,7 @@ CM.Main.CheckGoldenCookie = function() { CM.Disp.Notification('GCNotification', "Golden Cookie Spawned", "A Golden Cookie has spawned. Click it now!"); } - for (var i in Game.shimmers) { + for (let i of Object.keys(Game.shimmers)) { if (typeof CM.Disp.GCTimers[Game.shimmers[i].id] == "undefined") { CM.Disp.CreateGCTimer(Game.shimmers[i]); } @@ -392,7 +391,7 @@ CM.Main.CheckGoldenCookie = function() { if (CM.Main.currSpawnedGoldenCookieState == 0) CM.Cache.spawnedGoldenShimmer = 0; } else if (CM.Options.GCTimer == 1 && CM.Main.lastGoldenCookieState) { - for (var i in CM.Disp.GCTimers) { + for (let i of Object.keys(CM.Disp.GCTimers)) { CM.Disp.GCTimers[i].style.opacity = CM.Cache.goldenShimmersByID[i].l.style.opacity; CM.Disp.GCTimers[i].style.transform = CM.Cache.goldenShimmersByID[i].l.style.transform; CM.Disp.GCTimers[i].textContent = Math.ceil(CM.Cache.goldenShimmersByID[i].life / Game.fps); @@ -407,7 +406,7 @@ CM.Main.CheckGoldenCookie = function() { CM.Main.CheckSeasonPopup = function() { if (CM.Main.lastSeasonPopupState != Game.shimmerTypes.reindeer.spawned) { CM.Main.lastSeasonPopupState = Game.shimmerTypes.reindeer.spawned; - for (var i in Game.shimmers) { + for (let i of Object.keys(Game.shimmers)) { if (Game.shimmers[i].spawnLead && Game.shimmers[i].type == 'reindeer') { CM.Cache.seasonPopShimmer = Game.shimmers[i]; break; @@ -472,7 +471,7 @@ CM.Main.CheckMagicMeter = function() { CM.Main.CheckWrinklerCount = function() { if (Game.elderWrath > 0) { var CurrentWrinklers = 0; - for (var i in Game.wrinklers) { + for (let i in Game.wrinklers) { if (Game.wrinklers[i].phase == 2) CurrentWrinklers++; } if (CurrentWrinklers > CM.Main.lastWrinklerCount) { @@ -509,7 +508,7 @@ CM.Main.AddWrinklerAreaDetect = function() { l('backgroundLeftCanvas').onmouseout = function() { CM.Disp.TooltipWrinklerArea = 0; Game.tooltip.hide(); - for (var i in Game.wrinklers) { + for (let i of Object.keys(Game.wrinklers)) { CM.Disp.TooltipWrinklerBeingShown[i] = 0; } }; @@ -540,7 +539,6 @@ CM.HasReplaceNativeGrimoireDraw = false; CM.Main.lastGoldenCookieState = 0; CM.Main.lastSpawnedGoldenCookieState = 0; -CM.Main.currSpawnedGoldenCookieState; CM.Main.lastTickerFortuneState = 0; CM.Main.lastSeasonPopupState = 0; CM.Main.lastGardenNextStep = 0; diff --git a/src/Sim.js b/src/Sim.js index 3e52aa9..014db87 100644 --- a/src/Sim.js +++ b/src/Sim.js @@ -3,8 +3,8 @@ *******/ CM.Sim.BuildingGetPrice = function(build, basePrice, start, free, increase) { - /*var price=0; - for (var i = Math.max(0 , start); i < Math.max(0, start + increase); i++) { + /*let price=0; + for (let i = Math.max(0 , start); i < Math.max(0, start + increase); i++) { price += basePrice * Math.pow(Game.priceIncrease, Math.max(0, i - free)); } if (Game.Has('Season savings')) price *= 0.99; @@ -15,8 +15,8 @@ CM.Sim.BuildingGetPrice = function(build, basePrice, start, free, increase) { return Math.ceil(price);*/ var moni = 0; - for (var i = 0; i < increase; i++) { - var price = basePrice * Math.pow(Game.priceIncrease, Math.max(0, start - free)); + for (let i = 0; i < increase; i++) { + let price = basePrice * Math.pow(Game.priceIncrease, Math.max(0, start - free)); price = Game.modifyBuildingPrice(build, price); price = Math.ceil(price); moni += price; @@ -26,8 +26,8 @@ CM.Sim.BuildingGetPrice = function(build, basePrice, start, free, increase) { }; CM.Sim.BuildingSell = function(build, basePrice, start, free, amount, noSim) { - /*var price=0; - for (var i = Math.max(0, start - amount); i < Math.max(0, start); i++) { + /*let price=0; + for (let i = Math.max(0, start - amount); i < Math.max(0, start); i++) { price += basePrice * Math.pow(Game.priceIncrease, Math.max(0, i - free)); } if (Game.Has('Season savings')) price*=0.99; @@ -49,8 +49,8 @@ CM.Sim.BuildingSell = function(build, basePrice, start, free, amount, noSim) { var moni = 0; if (amount == -1) amount = start; if (!amount) amount = Game.buyBulk; - for (var i = 0; i < amount; i++) { - var price = basePrice * Math.pow(Game.priceIncrease, Math.max(0, start - free)); + for (let i = 0; i < amount; i++) { + let price = basePrice * Math.pow(Game.priceIncrease, Math.max(0, start - free)); price = noSim ? Game.modifyBuildingPrice(build, price) : CM.Sim.modifyBuildingPrice(build, price); price = Math.ceil(price); var giveBack = noSim ? build.getSellMultiplier() : CM.Sim.getSellMultiplier(); @@ -64,7 +64,7 @@ CM.Sim.BuildingSell = function(build, basePrice, start, free, amount, noSim) { }; CM.Sim.Has = function(what) { - var it = CM.Sim.Upgrades[what]; + let it = CM.Sim.Upgrades[what]; if (Game.ascensionMode == 1 && (it.pool == 'prestige' || it.tier == 'fortune')) return 0; return (it ? it.bought : 0); }; @@ -108,7 +108,7 @@ CM.Sim.hasGod=function(what) { } var possibleGods = CM.Sim.Objects.Temple.minigame.gods; var god=possibleGods[what]; - for (var i=0;i<3;i++) + for (let i=0;i<3;i++) { if (CM.Sim.Objects.Temple.minigame.slot[i]==god.id) return (i+1); } @@ -139,7 +139,7 @@ eval('CM.Sim.GetTieredCpsMult = ' + Game.GetTieredCpsMult.toString() CM.Sim.getCPSBuffMult = function() { var mult = 1; - for (var i in Game.buffs) { + for (let i of Object.keys(Game.buffs)) { if (typeof Game.buffs[i].multCpS != 'undefined') mult *= Game.buffs[i].multCpS; } return mult; @@ -155,8 +155,8 @@ CM.Sim.getCPSBuffMult = function() { * are set by CM.Sim.CopyData. */ CM.Sim.InitialBuildingData = function(buildingName) { - var me = Game.Objects[buildingName]; - var you = {}; + let me = Game.Objects[buildingName]; + let you = {}; eval('you.cps = ' + me.cps.toString() .split('Game.Has').join('CM.Sim.Has') .split('Game.hasAura').join('CM.Sim.hasAura') @@ -176,8 +176,8 @@ CM.Sim.InitialBuildingData = function(buildingName) { * so this function just returns an empty object. */ CM.Sim.InitUpgrade = function(upgradeName) { - var me = Game.Upgrades[upgradeName]; - var you = {}; + let me = Game.Upgrades[upgradeName]; + let you = {}; you.pool = me.pool; you.name = me.name; return you; @@ -189,28 +189,31 @@ CM.Sim.InitUpgrade = function(upgradeName) { * so this function just returns an empty object. */ CM.Sim.InitAchievement = function(achievementName) { + let me = Game.Achievements[achievementName]; + let you = {}; + you.name = me.name; return {}; }; CM.Sim.InitData = function() { // Buildings CM.Sim.Objects = []; - for (var i in Game.Objects) { + for (let i of Object.keys(Game.Objects)) { CM.Sim.Objects[i] = CM.Sim.InitialBuildingData(i); } // Upgrades CM.Sim.Upgrades = []; - for (var i in Game.Upgrades) { + for (let i of Object.keys(Game.Upgrades)) { CM.Sim.Upgrades[i] = CM.Sim.InitUpgrade(i); } // Achievements CM.Sim.Achievements = []; - for (var i in Game.Achievements) { + for (let i of Object.keys(Game.Achievements)) { CM.Sim.Achievements[i] = CM.Sim.InitAchievement(i); } - CM.Sim.CopyData; + CM.Sim.CopyData(); }; CM.Sim.CopyData = function() { @@ -222,9 +225,9 @@ CM.Sim.CopyData = function() { CM.Sim.prestige = Game.prestige; // Buildings - for (var i in Game.Objects) { - var me = Game.Objects[i]; - var you = CM.Sim.Objects[i]; + for (let i of Object.keys(Game.Objects)) { + let me = Game.Objects[i]; + let you = CM.Sim.Objects[i]; if (you == undefined) { // New building! you = CM.Sim.Objects[i] = CM.Sim.InitialBuildingData(i); CM.Disp.CreateBotBarBuildingColumn(i); // Add new building to the bottom bar @@ -238,9 +241,9 @@ CM.Sim.CopyData = function() { } // Upgrades - for (var i in Game.Upgrades) { - var me = Game.Upgrades[i]; - var you = CM.Sim.Upgrades[i]; + for (let i of Object.keys(Game.Upgrades)) { + let me = Game.Upgrades[i]; + let you = CM.Sim.Upgrades[i]; if (you == undefined) { you = CM.Sim.Upgrades[i] = CM.Sim.InitUpgrade(i); } @@ -248,9 +251,9 @@ CM.Sim.CopyData = function() { } // Achievements - for (var i in Game.Achievements) { - var me = Game.Achievements[i]; - var you = CM.Sim.Achievements[i]; + for (let i of Object.keys(Game.Achievements)) { + let me = Game.Achievements[i]; + let you = CM.Sim.Achievements[i]; if (you == undefined) { you = CM.Sim.Achievements[i] = CM.Sim.InitAchievement(i); } @@ -268,12 +271,12 @@ CM.Sim.CalculateGains = function() { var mult = 1; // Include minigame effects var effs={}; - for (var i in Game.Objects) { + for (let i of Object.keys(Game.Objects)) { // TODO Store minigames and effects in Cache // Include possibility of new/modded building and new/modded minigames if (CM.Sim.Objects[i].minigameLoaded && CM.Sim.Objects[i].minigame.effs) { var myEffs = CM.Sim.Objects[i].minigame.effs; - for (var ii in myEffs) { + for (let ii in myEffs) { if (effs[ii]) effs[ii]*=myEffs[ii]; else effs[ii]=myEffs[ii]; } @@ -289,8 +292,8 @@ CM.Sim.CalculateGains = function() { // TODO: Make function call cached function where Game.Has is replaced with CM.Has // Related to valentine cookies - for (var i in Game.cookieUpgrades) { - var me = Game.cookieUpgrades[i]; + for (let i of Object.keys(Game.cookieUpgrades)) { + let me = Game.cookieUpgrades[i]; if (CM.Sim.Has(me.name)) { mult *= (1 + (typeof(me.power) == 'function' ? me.power(me) : me.power) * 0.01); } @@ -316,28 +319,28 @@ CM.Sim.CalculateGains = function() { // Check effect of chosen Gods var buildMult = 1; if (CM.Sim.Objects.Temple.minigameLoaded) { - var godLvl = CM.Sim.hasGod('asceticism'); + let godLvl = CM.Sim.hasGod('asceticism'); if (godLvl == 1) mult *= 1.15; else if (godLvl == 2) mult *= 1.1; else if (godLvl == 3) mult *= 1.05; // TODO: What does DateAges do? - var godLvl = CM.Sim.hasGod('ages'); + godLvl = CM.Sim.hasGod('ages'); if (godLvl == 1) mult *= 1 + 0.15 * Math.sin((CM.Sim.DateAges / 1000 / (60 * 60 * 3)) * Math.PI * 2); else if (godLvl == 2) mult *= 1 + 0.15 * Math.sin((CM.Sim.DateAges / 1000 / (60 * 60 * 12)) * Math.PI*2); else if (godLvl == 3) mult *= 1 + 0.15 * Math.sin((CM.Sim.DateAges / 1000 / (60 * 60 * 24)) * Math.PI*2); - var godLvl = CM.Sim.hasGod('decadence'); + godLvl = CM.Sim.hasGod('decadence'); if (godLvl == 1) buildMult *= 0.93; else if (godLvl == 2) buildMult *= 0.95; else if (godLvl == 3) buildMult *= 0.98; - var godLvl = CM.Sim.hasGod('industry'); + godLvl = CM.Sim.hasGod('industry'); if (godLvl == 1) buildMult *= 1.1; else if (godLvl == 2) buildMult *= 1.06; else if (godLvl == 3) buildMult *= 1.03; - var godLvl = CM.Sim.hasGod('labor'); + godLvl = CM.Sim.hasGod('labor'); if (godLvl == 1) buildMult *= 0.97; else if (godLvl == 2) buildMult *= 0.98; else if (godLvl == 3) buildMult *= 0.99; @@ -351,7 +354,7 @@ CM.Sim.CalculateGains = function() { //if (CM.Sim.hasAura('Breath of Milk')) milkMult *= 1.05; milkMult *= 1 + CM.Sim.auraMult('Breath of Milk') * 0.05; if (CM.Sim.Objects.Temple.minigameLoaded) { - var godLvl = CM.Sim.hasGod('mother'); + let godLvl = CM.Sim.hasGod('mother'); if (godLvl == 1) milkMult *= 1.1; else if (godLvl == 2) milkMult *= 1.05; else if (godLvl == 3) milkMult *= 1.03; @@ -377,8 +380,8 @@ CM.Sim.CalculateGains = function() { if (CM.Sim.Has('Kitten angels')) catMult *= (1 + milkProgress * 0.1 * milkMult); if (CM.Sim.Has('Fortune #103')) catMult *= (1 + milkProgress * 0.05 * milkMult); - for (var i in CM.Sim.Objects) { - var me = CM.Sim.Objects[i]; + for (let i of Object.keys(CM.Sim.Objects)) { + let me = CM.Sim.Objects[i]; var storedCps = (typeof(me.cps) == 'function' ? me.cps(me) : me.cps); if (Game.ascensionMode != 1) storedCps *= (1 + me.level * 0.01) * buildMult; if (me.name == "Grandma" && CM.Sim.Has('Milkhelp® lactose intolerance relief tablets')) storedCps *= 1 + 0.05 * milkProgress * milkMult; @@ -418,7 +421,7 @@ CM.Sim.CalculateGains = function() { mult *= 1 + CM.Sim.auraMult('Radiant Appetite'); var rawCookiesPs = CM.Sim.cookiesPs * mult; - for (var i in Game.CpsAchievements) { + for (let i of Object.keys(Game.CpsAchievements)) { if (rawCookiesPs >= Game.CpsAchievements[i].threshold) CM.Sim.Win(Game.CpsAchievements[i].name); } @@ -426,7 +429,7 @@ CM.Sim.CalculateGains = function() { var n = Game.shimmerTypes.golden.n; var auraMult = CM.Sim.auraMult('Dragon\'s Fortune'); - for (var i = 0; i < n; i++){ + for (let i = 0; i < n; i++){ mult *= 1 + auraMult * 1.23; } @@ -442,7 +445,7 @@ CM.Sim.CalculateGains = function() { var goldenSwitchMult = 1.5; if (CM.Sim.Has('Residual luck')) { var upgrades = Game.goldenCookieUpgrades; - for (var i in upgrades) { + for (let i of Object.keys(upgrades)) { if (CM.Sim.Has(upgrades[i])) goldenSwitchMult += 0.1; } } @@ -468,7 +471,7 @@ CM.Sim.CalculateGains = function() { CM.Sim.CheckOtherAchiev = function() { var grandmas = 0; - for (var i in Game.GrandmaSynergies) { + for (let i of Object.keys(Game.GrandmaSynergies)) { if (CM.Sim.Has(Game.GrandmaSynergies[i])) grandmas++; } if (!CM.Sim.HasAchiev('Elder') && grandmas >= 7) CM.Sim.Win('Elder'); @@ -478,7 +481,7 @@ CM.Sim.CheckOtherAchiev = function() { var mathematician = 1; var base10 = 1; var minAmount = 100000; - for (var i in CM.Sim.Objects) { + for (let i of Object.keys(CM.Sim.Objects)) { buildingsOwned += CM.Sim.Objects[i].amount; minAmount = Math.min(CM.Sim.Objects[i].amount, minAmount); if (!CM.Sim.HasAchiev('Mathematician')) { @@ -523,13 +526,13 @@ CM.Sim.CheckOtherAchiev = function() { if (CM.Sim.Objects.Cursor.amount + CM.Sim.Objects.Grandma.amount >= 777) CM.Sim.Win('The elder scrolls'); var hasAllHalloCook = true; - for (var i in CM.Data.HalloCookies) { + for (let i of Object.keys(CM.Data.HalloCookies)) { if (!CM.Sim.Has(CM.Data.HalloCookies[i])) hasAllHalloCook = false; } if (hasAllHalloCook) CM.Sim.Win('Spooky cookies'); var hasAllChristCook = true; - for (var i in CM.Data.ChristCookies) { + for (let i of Object.keys(CM.Data.ChristCookies)) { if (!CM.Sim.Has(CM.Data.ChristCookies[i])) hasAllChristCook = false; } if (hasAllChristCook) CM.Sim.Win('Let it snow'); @@ -537,7 +540,7 @@ CM.Sim.CheckOtherAchiev = function() { if (CM.Sim.Has('Fortune cookies')) { var list = Game.Tiers.fortune.upgrades; var fortunes = 0; - for (var i in list) { + for (let i of Object.keys(list)) { if (CM.Sim.Has(list[i].name)) fortunes++; } if (fortunes >= list.length) CM.Sim.Win('O Fortuna'); @@ -546,9 +549,9 @@ CM.Sim.CheckOtherAchiev = function() { CM.Sim.BuyBuildings = function(amount, target) { CM.Cache[target] = []; - for (var i in Game.Objects) { + for (let i of Object.keys(Game.Objects)) { CM.Sim.CopyData(); - var me = CM.Sim.Objects[i]; + let me = CM.Sim.Objects[i]; me.amount += amount; if (i == 'Cursor') { @@ -591,10 +594,10 @@ CM.Sim.BuyBuildings = function(amount, target) { CM.Sim.BuyUpgrades = function() { CM.Cache.Upgrades = []; - for (var i in Game.Upgrades) { + for (let i of Object.keys(Game.Upgrades)) { if (Game.Upgrades[i].pool == 'toggle' || (Game.Upgrades[i].bought == 0 && Game.Upgrades[i].unlocked && Game.Upgrades[i].pool != 'prestige')) { CM.Sim.CopyData(); - var me = CM.Sim.Upgrades[i]; + let me = CM.Sim.Upgrades[i]; me.bought = 1; if (Game.CountsAsUpgradeOwned(Game.Upgrades[i].pool)) CM.Sim.UpgradesOwned++; @@ -647,20 +650,22 @@ CM.Sim.CalculateChangeAura = function(aura) { else CM.Sim.dragonAura = aura; // Sell highest building but only if aura is different + let price = 0; if (CM.Sim.dragonAura != CM.Cache.dragonAura || CM.Sim.dragonAura2 != CM.Cache.dragonAura2) { - for (var i = Game.ObjectsById.length; i > -1, --i;) { + for (let i = Game.ObjectsById.length; i > -1, --i;) { if (Game.ObjectsById[i].amount > 0) { var highestBuilding = CM.Sim.Objects[Game.ObjectsById[i].name].name; CM.Sim.Objects[highestBuilding].amount -=1; CM.Sim.buildingsOwned -= 1; + price = CM.Sim.Objects[highestBuilding].basePrice * Math.pow(Game.priceIncrease, Math.max(0, CM.Sim.Objects[highestBuilding].amount - 1 -CM.Sim.Objects[highestBuilding].free)); + price = Game.modifyBuildingPrice(CM.Sim.Objects[highestBuilding], price); + price = Math.ceil(price); break; } } // This calculates price of highest building - var price = CM.Sim.Objects[highestBuilding].basePrice * Math.pow(Game.priceIncrease, Math.max(0, CM.Sim.Objects[highestBuilding].amount - 1 -CM.Sim.Objects[highestBuilding].free)); - price = Game.modifyBuildingPrice(CM.Sim.Objects[highestBuilding], price); - price = Math.ceil(price); - } else var price = 0; + + } var lastAchievementsOwned = CM.Sim.AchievementsOwned; CM.Sim.CalculateGains(); @@ -768,7 +773,7 @@ CM.Sim.modifyBuildingPrice = function(building,price) { if (building.fortune && CM.Sim.Has(building.fortune.name)) price *= 0.93; price *= CM.Sim.eff('buildingCost'); if (CM.Sim.Objects.Temple.minigameLoaded) { - var godLvl = CM.Sim.hasGod('creation'); + let godLvl = CM.Sim.hasGod('creation'); if (godLvl == 1) price *= 0.93; else if (godLvl == 2) price *= 0.95; else if (godLvl == 3) price *= 0.98; @@ -792,7 +797,7 @@ CM.Sim.SellBuildingsForChoEgg = function() { CM.Sim.dragonAura = 5; CM.Sim.dragonAura2 = 18; // Sacrifice highest buildings for the aura switch - for (var i = 0; i < buildingsToSacrifice; ++i) { + for (let i = 0; i < buildingsToSacrifice; ++i) { var highestBuilding = 0; for (var j in CM.Sim.Objects) { if (CM.Sim.Objects[j].amount > 0) { @@ -804,8 +809,8 @@ CM.Sim.SellBuildingsForChoEgg = function() { } // Get money made by selling all remaining buildings - for (var i in CM.Sim.Objects) { - var me = CM.Sim.Objects[i]; + for (let i of Object.keys(CM.Sim.Objects)) { + let me = CM.Sim.Objects[i]; sellTotal += CM.Sim.BuildingSell(Game.Objects[me.name], Game.Objects[i].basePrice, me.amount, Game.Objects[i].free, me.amount); } @@ -842,7 +847,7 @@ CM.Sim.mouseCps = function() { if (CM.Sim.Has('Octillion fingers')) add *= 20; if (CM.Sim.Has('Nonillion fingers')) add *= 20; var num=0; - for (var i in CM.Sim.Objects) {num+=CM.Sim.Objects[i].amount;} + for (let i of Object.keys(CM.Sim.Objects)) {num+=CM.Sim.Objects[i].amount;} num -= CM.Sim.Objects.Cursor.amount; add = add * num; @@ -886,7 +891,7 @@ CM.Sim.mouseCps = function() { } } - for (var i in Game.buffs) + for (let i of Object.keys(Game.buffs)) { if (typeof Game.buffs[i].multClick != 'undefined') mult*=Game.buffs[i].multClick; } From 4dd640ef4b6b9c4baf9acf34e48b6e7bfe426818 Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Sun, 31 Jan 2021 13:54:31 +0100 Subject: [PATCH 5/6] Installed ESLint --- .eslintrc.js | 24 +++++++++++++++++++++ CookieMonster.js | 55 ++++++++++++++++++++++++------------------------ src/Config.js | 6 +++--- src/Disp.js | 46 ++++++++++++++++++++-------------------- src/Header.js | 3 ++- 5 files changed, 80 insertions(+), 54 deletions(-) create mode 100644 .eslintrc.js diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..dfbdfa3 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,24 @@ +module.exports = { + "env": { + "browser": true, + "es2021": true + }, + "globals": { + "CM": "writable", + "Game": "writable", + "l": "readonly", + "b64_to_utf8": "readonly", + "utf8_to_b64": "readonly", + "Beautify": "writable", + "realAudio": "readonly", + "JSColor": "readonly", + "jscolor": "readonly", + "BeautifyAll": "readonly", + }, + "extends": "eslint:recommended", + "parserOptions": { + "ecmaVersion": 12 + }, + "rules": { + } +}; diff --git a/CookieMonster.js b/CookieMonster.js index cc7eb4e..f98a297 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -1,7 +1,8 @@ /********** * Header * **********/ -RunCookieMonsterHeader = function() { + +var RunCookieMonsterHeader = function() { CM = {}; CM.Backup = {}; @@ -717,9 +718,9 @@ CM.Cache.spawnedGoldenShimmer = 0; */ CM.Config.SaveConfig = function() { let saveString = b64_to_utf8(unescape(localStorage.getItem('CookieClickerGame')).split('!END!')[0]); - CookieMonsterSave = saveString.match(/CookieMonster.*(;|$)/); + let CookieMonsterSave = saveString.match(/CookieMonster.*(;|$)/); if (CookieMonsterSave != null) { - newSaveString = saveString.replace(CookieMonsterSave[0], "CookieMonster:" + CM.save()); + let newSaveString = saveString.replace(CookieMonsterSave[0], "CookieMonster:" + CM.save()); localStorage.setItem('CookieClickerGame', escape(utf8_to_b64(newSaveString)+'!END!')); } }; @@ -858,7 +859,7 @@ CM.Config.ToggleHeader = function(config) { CM.Config.CheckNotificationPermissions = function(ToggleOnOff) { if (ToggleOnOff == 1) { // Check if browser support Promise version of Notification Permissions - checkNotificationPromise = function () { + let checkNotificationPromise = function () { try { Notification.requestPermission().then(); } catch(e) { @@ -1419,8 +1420,8 @@ CM.Disp.Beautify = function(num, floats, forced) { answer = num.toExponential(decimals).toString().replace("e", "E"); } else { - exponential = num.toExponential().toString(); - AmountOfTenPowerThree = Math.floor(exponential.slice(exponential.indexOf("e") + 1) / 3); + let exponential = num.toExponential().toString(); + let AmountOfTenPowerThree = Math.floor(exponential.slice(exponential.indexOf("e") + 1) / 3); answer = (num / Number("1e" + (AmountOfTenPowerThree * 3))).toFixed(decimals); // answer is now "xxx.xx" (e.g., 123456789 would be 123.46) if (CM.Options.Scale == 1 && !forced || forced == 1) { // Metric scale, 123456789 => 123.457 M @@ -1694,7 +1695,7 @@ CM.Disp.CreateTimerBar = function() { * @param [{{string}, {string}}, ...] bars ([id, color]) The id and colours of individual parts of the timer */ CM.Disp.TimerBarCreateBar = function(id, name, bars) { - timerBar = document.createElement('div'); + let timerBar = document.createElement('div'); timerBar.id = 'CMTimerBar'; timerBar.style.height = '12px'; timerBar.style.margin = '0px 10px'; @@ -1805,7 +1806,7 @@ CM.Disp.UpdateTimerBar = function() { CM.Disp.BuffTimerBars = {}; for (let i of Object.keys(Game.buffs)) { if (Game.buffs[i]) { - timer = CM.Disp.TimerBarCreateBar(Game.buffs[i].name, Game.buffs[i].name, [{id: Game.buffs[i].name + 'Bar'}]); + let timer = CM.Disp.TimerBarCreateBar(Game.buffs[i].name, Game.buffs[i].name, [{id: Game.buffs[i].name + 'Bar'}]); timer.style.display = ''; var classColor = ''; // Gives specific timers specific colors @@ -2233,7 +2234,7 @@ CM.Disp.Notification = function(notifyConfig, title, message) { // The arguments check makes the sound not play upon initialization of the mod if (CM.Options[notifyConfig] == 1 && document.visibilityState == 'hidden' && CM.Disp.Notification.caller.caller.caller.caller == null) { var CookieIcon = 'https://orteil.dashnet.org/cookieclicker/favicon.ico'; - notification = new Notification(title, {body: message, badge: CookieIcon}); + new Notification(title, {body: message, badge: CookieIcon}); } }; @@ -2341,7 +2342,7 @@ CM.Disp.UpdateTitle = function() { * @param {object} cookie A Golden Cookie object */ CM.Disp.CreateGCTimer = function(cookie) { - GCTimer = document.createElement('div'); + let GCTimer = document.createElement('div'); GCTimer.id = 'GCTimer' + cookie.id; GCTimer.style.width = '96px'; GCTimer.style.height = '96px'; @@ -2609,7 +2610,7 @@ CM.Disp.UpdateTooltip = function() { CM.Sim.CopyData(); if (l('tooltipAnchor').style.display != 'none' && l('CMTooltipArea')) { l('CMTooltipArea').innerHTML = ''; - tooltipBox = CM.Disp.TooltipCreateTooltipBox(); + let tooltipBox = CM.Disp.TooltipCreateTooltipBox(); l('CMTooltipArea').appendChild(tooltipBox); if (CM.Disp.tooltipType == 'b') { @@ -2645,7 +2646,7 @@ CM.Disp.UpdateTooltip = function() { */ CM.Disp.UpdateTooltipBuilding = function() { if (CM.Options.TooltipBuildUpgrade == 1 && Game.buyMode == 1) { - tooltipBox = l('CMTooltipBorder'); + let tooltipBox = l('CMTooltipBorder'); CM.Disp.TooltipCreateCalculationSection(tooltipBox); var target = ''; @@ -2700,7 +2701,7 @@ CM.Disp.UpdateTooltipBuilding = function() { * It is called when Upgrade tooltips are created or refreshed by CM.Disp.UpdateTooltip() */ CM.Disp.UpdateTooltipUpgrade = function() { - tooltipBox = l('CMTooltipBorder'); + let tooltipBox = l('CMTooltipBorder'); CM.Disp.TooltipCreateCalculationSection(tooltipBox); CM.Disp.TooltipBonusIncome = CM.Cache.Upgrades[Game.UpgradesInStore[CM.Disp.tooltipName].name].bonus; @@ -2757,7 +2758,7 @@ CM.Disp.UpdateTooltipUpgrade = function() { */ CM.Disp.UpdateTooltipSugarLump = function() { if (CM.Options.TooltipLump === 1) { - tooltipBox = l('CMTooltipBorder'); + let tooltipBox = l('CMTooltipBorder'); tooltipBox.appendChild(CM.Disp.TooltipCreateHeader('Current Sugar Lump')); @@ -2781,7 +2782,7 @@ CM.Disp.UpdateTooltipGrimoire = function() { var spellCost = minigame.getSpellCost(minigame.spellsById[CM.Disp.tooltipName]); if (CM.Options.TooltipGrim == 1 && spellCost <= minigame.magicM) { - tooltipBox = l('CMTooltipBorder'); + let tooltipBox = l('CMTooltipBorder'); // Time left till enough magic for spell tooltipBox.appendChild(CM.Disp.TooltipCreateHeader('Time Left')); @@ -2907,7 +2908,7 @@ CM.Disp.UpdateTooltipHarvestAll = function() { CM.Disp.UpdateTooltipWarnings = function() { if (CM.Disp.tooltipType == "b" || CM.Disp.tooltipType == "u") { if (document.getElementById("CMDispTooltipWarningParent") == null) { - warningTooltip = CM.Disp.TooltipCreateWarningSection(); + let warningTooltip = CM.Disp.TooltipCreateWarningSection(); l('tooltipAnchor').appendChild(warningTooltip); CM.Disp.ToggleToolWarnPos(); } @@ -2934,7 +2935,7 @@ CM.Disp.UpdateTooltipWarnings = function() { else l('CMDispTooltipWarnLucky').style.display = 'none'; if (CM.Options.ToolWarnLuckyFrenzy == 1) { - limitLuckyFrenzy = limitLucky * 7; + let limitLuckyFrenzy = limitLucky * 7; if (amount < limitLuckyFrenzy && (CM.Disp.tooltipType != 'b' || Game.buyMode == 1)) { l('CMDispTooltipWarnLuckyFrenzy').style.display = ''; l('CMDispTooltipWarnLuckyFrenzyText').textContent = Beautify(limitLuckyFrenzy - amount) + ' (' + CM.Disp.FormatTime((limitLuckyFrenzy - amount) / (CM.Disp.GetCPS() + CM.Disp.TooltipBonusIncome)) + ')'; @@ -3167,13 +3168,13 @@ CM.Disp.AddMenuPref = function(title) { frag.appendChild(title()); for (let group of Object.keys(CM.ConfigGroups)) { - groupObject = CM.Disp.CreatePrefHeader(group, CM.ConfigGroups[group]); // (group, display-name of group) + let groupObject = CM.Disp.CreatePrefHeader(group, CM.ConfigGroups[group]); // (group, display-name of group) frag.appendChild(groupObject); if (CM.Options.Header[group]) { // 0 is show, 1 is collapsed // Make sub-sections of Notification section if (group == "Notification") { for (let subGroup of Object.keys(CM.ConfigGroupsNotification)) { - subGroupObject = CM.Disp.CreatePrefHeader(subGroup, CM.ConfigGroupsNotification[subGroup]); // (group, display-name of group) + let subGroupObject = CM.Disp.CreatePrefHeader(subGroup, CM.ConfigGroupsNotification[subGroup]); // (group, display-name of group) subGroupObject.style.fontSize = "15px"; subGroupObject.style.opacity = "0.5"; frag.appendChild(subGroupObject); @@ -3331,7 +3332,7 @@ CM.Disp.CreatePrefOption = function(config) { input.setAttribute('value', CM.Options.Colors[CM.Disp.colors[i]]); innerDiv.appendChild(input); let change = function() {CM.Options.Colors[this.targetElement.id] = this.toHEXString(); CM.Disp.UpdateColors(); CM.Config.SaveConfig(); Game.UpdateMenu();}; - let = new JSColor(input, {hash: true, position: "right", onInput: change}); + new JSColor(input, {hash: true, position: "right", onInput: change}); let label = document.createElement('label'); label.textContent = CM.ConfigData.Colors.desc[CM.Disp.colors[i]]; innerDiv.appendChild(label); @@ -3956,11 +3957,11 @@ CM.Disp.AddMissingUpgrades = function() { let title = document.createElement('div'); title.id = "CMMissingUpgradesPrestigeTitle"; title.className = "listing"; - titlefrag = document.createElement('div'); + let titlefrag = document.createElement('div'); titlefrag.innerHTML = 'Missing Prestige upgrades: '+ prestigeUpgradesOwned + '/' + Game.PrestigeUpgrades.length + ' (' + Math.floor((prestigeUpgradesOwned / Game.PrestigeUpgrades.length) * 100) + '%)'; title.appendChild(titlefrag); l('menu').children[5].appendChild(title); - upgrades = document.createElement('div'); + let upgrades = document.createElement('div'); upgrades.className = "listing crateBox"; upgrades.innerHTML = CM.Cache.MissingUpgradesPrestige; l('menu').children[5].appendChild(upgrades); @@ -3971,11 +3972,11 @@ CM.Disp.AddMissingUpgrades = function() { let title = document.createElement('div'); title.id = "CMMissingUpgradesTitle"; title.className = "listing"; - titlefrag = document.createElement('div'); + let titlefrag = document.createElement('div'); titlefrag.innerHTML = 'Missing normal upgrades: '+ normalUpgradesOwned + '/' + (Game.UpgradesByPool[""].length + Game.UpgradesByPool.tech.length) + ' (' + Math.floor((normalUpgradesOwned / ( Game.UpgradesByPool[""].length + Game.UpgradesByPool.tech.length)) * 100) + '%)'; title.appendChild(titlefrag); l('menu').children[6].insertBefore(title, l('menu').children[6].childNodes[3]); - upgrades = document.createElement('div'); + let upgrades = document.createElement('div'); upgrades.className = "listing crateBox"; upgrades.innerHTML = CM.Cache.MissingUpgrades; l('menu').children[6].insertBefore(upgrades, document.getElementById("CMMissingUpgradesTitle").nextSibling); @@ -3985,11 +3986,11 @@ CM.Disp.AddMissingUpgrades = function() { let title = document.createElement('div'); title.id = "CMMissingUpgradesCookiesTitle"; title.className = "listing"; - titlefrag = document.createElement('div'); + let titlefrag = document.createElement('div'); titlefrag.innerHTML = 'Missing Cookie upgrades: '+ cookieUpgradesOwned + '/' + Game.UpgradesByPool.cookie.length + ' (' + Math.floor((cookieUpgradesOwned / Game.UpgradesByPool.cookie.length) * 100) + '%)'; title.appendChild(titlefrag); l('menu').children[6].appendChild(title); - upgrades = document.createElement('div'); + let upgrades = document.createElement('div'); upgrades.className = "listing crateBox"; upgrades.innerHTML = CM.Cache.MissingUpgradesCookies; l('menu').children[6].appendChild(upgrades); @@ -4014,7 +4015,7 @@ CM.Disp.crateMissing = function(me) { let icon = me.icon; if (me.iconFunction) icon = me.iconFunction(); - tooltip = `function() {return Game.crateTooltip(Game.UpgradesById[${me.id}], 'stats');}`; + let tooltip = `function() {return Game.crateTooltip(Game.UpgradesById[${me.id}], 'stats');}`; return `
diff --git a/src/Config.js b/src/Config.js index 5fce331..6f7f879 100644 --- a/src/Config.js +++ b/src/Config.js @@ -13,9 +13,9 @@ */ CM.Config.SaveConfig = function() { let saveString = b64_to_utf8(unescape(localStorage.getItem('CookieClickerGame')).split('!END!')[0]); - CookieMonsterSave = saveString.match(/CookieMonster.*(;|$)/); + let CookieMonsterSave = saveString.match(/CookieMonster.*(;|$)/); if (CookieMonsterSave != null) { - newSaveString = saveString.replace(CookieMonsterSave[0], "CookieMonster:" + CM.save()); + let newSaveString = saveString.replace(CookieMonsterSave[0], "CookieMonster:" + CM.save()); localStorage.setItem('CookieClickerGame', escape(utf8_to_b64(newSaveString)+'!END!')); } }; @@ -154,7 +154,7 @@ CM.Config.ToggleHeader = function(config) { CM.Config.CheckNotificationPermissions = function(ToggleOnOff) { if (ToggleOnOff == 1) { // Check if browser support Promise version of Notification Permissions - checkNotificationPromise = function () { + let checkNotificationPromise = function () { try { Notification.requestPermission().then(); } catch(e) { diff --git a/src/Disp.js b/src/Disp.js index a6c10cf..510fced 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -207,8 +207,8 @@ CM.Disp.Beautify = function(num, floats, forced) { answer = num.toExponential(decimals).toString().replace("e", "E"); } else { - exponential = num.toExponential().toString(); - AmountOfTenPowerThree = Math.floor(exponential.slice(exponential.indexOf("e") + 1) / 3); + let exponential = num.toExponential().toString(); + let AmountOfTenPowerThree = Math.floor(exponential.slice(exponential.indexOf("e") + 1) / 3); answer = (num / Number("1e" + (AmountOfTenPowerThree * 3))).toFixed(decimals); // answer is now "xxx.xx" (e.g., 123456789 would be 123.46) if (CM.Options.Scale == 1 && !forced || forced == 1) { // Metric scale, 123456789 => 123.457 M @@ -482,7 +482,7 @@ CM.Disp.CreateTimerBar = function() { * @param [{{string}, {string}}, ...] bars ([id, color]) The id and colours of individual parts of the timer */ CM.Disp.TimerBarCreateBar = function(id, name, bars) { - timerBar = document.createElement('div'); + let timerBar = document.createElement('div'); timerBar.id = 'CMTimerBar'; timerBar.style.height = '12px'; timerBar.style.margin = '0px 10px'; @@ -593,7 +593,7 @@ CM.Disp.UpdateTimerBar = function() { CM.Disp.BuffTimerBars = {}; for (let i of Object.keys(Game.buffs)) { if (Game.buffs[i]) { - timer = CM.Disp.TimerBarCreateBar(Game.buffs[i].name, Game.buffs[i].name, [{id: Game.buffs[i].name + 'Bar'}]); + let timer = CM.Disp.TimerBarCreateBar(Game.buffs[i].name, Game.buffs[i].name, [{id: Game.buffs[i].name + 'Bar'}]); timer.style.display = ''; var classColor = ''; // Gives specific timers specific colors @@ -1021,7 +1021,7 @@ CM.Disp.Notification = function(notifyConfig, title, message) { // The arguments check makes the sound not play upon initialization of the mod if (CM.Options[notifyConfig] == 1 && document.visibilityState == 'hidden' && CM.Disp.Notification.caller.caller.caller.caller == null) { var CookieIcon = 'https://orteil.dashnet.org/cookieclicker/favicon.ico'; - notification = new Notification(title, {body: message, badge: CookieIcon}); + new Notification(title, {body: message, badge: CookieIcon}); } }; @@ -1129,7 +1129,7 @@ CM.Disp.UpdateTitle = function() { * @param {object} cookie A Golden Cookie object */ CM.Disp.CreateGCTimer = function(cookie) { - GCTimer = document.createElement('div'); + let GCTimer = document.createElement('div'); GCTimer.id = 'GCTimer' + cookie.id; GCTimer.style.width = '96px'; GCTimer.style.height = '96px'; @@ -1397,7 +1397,7 @@ CM.Disp.UpdateTooltip = function() { CM.Sim.CopyData(); if (l('tooltipAnchor').style.display != 'none' && l('CMTooltipArea')) { l('CMTooltipArea').innerHTML = ''; - tooltipBox = CM.Disp.TooltipCreateTooltipBox(); + let tooltipBox = CM.Disp.TooltipCreateTooltipBox(); l('CMTooltipArea').appendChild(tooltipBox); if (CM.Disp.tooltipType == 'b') { @@ -1433,7 +1433,7 @@ CM.Disp.UpdateTooltip = function() { */ CM.Disp.UpdateTooltipBuilding = function() { if (CM.Options.TooltipBuildUpgrade == 1 && Game.buyMode == 1) { - tooltipBox = l('CMTooltipBorder'); + let tooltipBox = l('CMTooltipBorder'); CM.Disp.TooltipCreateCalculationSection(tooltipBox); var target = ''; @@ -1488,7 +1488,7 @@ CM.Disp.UpdateTooltipBuilding = function() { * It is called when Upgrade tooltips are created or refreshed by CM.Disp.UpdateTooltip() */ CM.Disp.UpdateTooltipUpgrade = function() { - tooltipBox = l('CMTooltipBorder'); + let tooltipBox = l('CMTooltipBorder'); CM.Disp.TooltipCreateCalculationSection(tooltipBox); CM.Disp.TooltipBonusIncome = CM.Cache.Upgrades[Game.UpgradesInStore[CM.Disp.tooltipName].name].bonus; @@ -1545,7 +1545,7 @@ CM.Disp.UpdateTooltipUpgrade = function() { */ CM.Disp.UpdateTooltipSugarLump = function() { if (CM.Options.TooltipLump === 1) { - tooltipBox = l('CMTooltipBorder'); + let tooltipBox = l('CMTooltipBorder'); tooltipBox.appendChild(CM.Disp.TooltipCreateHeader('Current Sugar Lump')); @@ -1569,7 +1569,7 @@ CM.Disp.UpdateTooltipGrimoire = function() { var spellCost = minigame.getSpellCost(minigame.spellsById[CM.Disp.tooltipName]); if (CM.Options.TooltipGrim == 1 && spellCost <= minigame.magicM) { - tooltipBox = l('CMTooltipBorder'); + let tooltipBox = l('CMTooltipBorder'); // Time left till enough magic for spell tooltipBox.appendChild(CM.Disp.TooltipCreateHeader('Time Left')); @@ -1695,7 +1695,7 @@ CM.Disp.UpdateTooltipHarvestAll = function() { CM.Disp.UpdateTooltipWarnings = function() { if (CM.Disp.tooltipType == "b" || CM.Disp.tooltipType == "u") { if (document.getElementById("CMDispTooltipWarningParent") == null) { - warningTooltip = CM.Disp.TooltipCreateWarningSection(); + let warningTooltip = CM.Disp.TooltipCreateWarningSection(); l('tooltipAnchor').appendChild(warningTooltip); CM.Disp.ToggleToolWarnPos(); } @@ -1722,7 +1722,7 @@ CM.Disp.UpdateTooltipWarnings = function() { else l('CMDispTooltipWarnLucky').style.display = 'none'; if (CM.Options.ToolWarnLuckyFrenzy == 1) { - limitLuckyFrenzy = limitLucky * 7; + let limitLuckyFrenzy = limitLucky * 7; if (amount < limitLuckyFrenzy && (CM.Disp.tooltipType != 'b' || Game.buyMode == 1)) { l('CMDispTooltipWarnLuckyFrenzy').style.display = ''; l('CMDispTooltipWarnLuckyFrenzyText').textContent = Beautify(limitLuckyFrenzy - amount) + ' (' + CM.Disp.FormatTime((limitLuckyFrenzy - amount) / (CM.Disp.GetCPS() + CM.Disp.TooltipBonusIncome)) + ')'; @@ -1955,13 +1955,13 @@ CM.Disp.AddMenuPref = function(title) { frag.appendChild(title()); for (let group of Object.keys(CM.ConfigGroups)) { - groupObject = CM.Disp.CreatePrefHeader(group, CM.ConfigGroups[group]); // (group, display-name of group) + let groupObject = CM.Disp.CreatePrefHeader(group, CM.ConfigGroups[group]); // (group, display-name of group) frag.appendChild(groupObject); if (CM.Options.Header[group]) { // 0 is show, 1 is collapsed // Make sub-sections of Notification section if (group == "Notification") { for (let subGroup of Object.keys(CM.ConfigGroupsNotification)) { - subGroupObject = CM.Disp.CreatePrefHeader(subGroup, CM.ConfigGroupsNotification[subGroup]); // (group, display-name of group) + let subGroupObject = CM.Disp.CreatePrefHeader(subGroup, CM.ConfigGroupsNotification[subGroup]); // (group, display-name of group) subGroupObject.style.fontSize = "15px"; subGroupObject.style.opacity = "0.5"; frag.appendChild(subGroupObject); @@ -2119,7 +2119,7 @@ CM.Disp.CreatePrefOption = function(config) { input.setAttribute('value', CM.Options.Colors[CM.Disp.colors[i]]); innerDiv.appendChild(input); let change = function() {CM.Options.Colors[this.targetElement.id] = this.toHEXString(); CM.Disp.UpdateColors(); CM.Config.SaveConfig(); Game.UpdateMenu();}; - let = new JSColor(input, {hash: true, position: "right", onInput: change}); + new JSColor(input, {hash: true, position: "right", onInput: change}); let label = document.createElement('label'); label.textContent = CM.ConfigData.Colors.desc[CM.Disp.colors[i]]; innerDiv.appendChild(label); @@ -2744,11 +2744,11 @@ CM.Disp.AddMissingUpgrades = function() { let title = document.createElement('div'); title.id = "CMMissingUpgradesPrestigeTitle"; title.className = "listing"; - titlefrag = document.createElement('div'); + let titlefrag = document.createElement('div'); titlefrag.innerHTML = 'Missing Prestige upgrades: '+ prestigeUpgradesOwned + '/' + Game.PrestigeUpgrades.length + ' (' + Math.floor((prestigeUpgradesOwned / Game.PrestigeUpgrades.length) * 100) + '%)'; title.appendChild(titlefrag); l('menu').children[5].appendChild(title); - upgrades = document.createElement('div'); + let upgrades = document.createElement('div'); upgrades.className = "listing crateBox"; upgrades.innerHTML = CM.Cache.MissingUpgradesPrestige; l('menu').children[5].appendChild(upgrades); @@ -2759,11 +2759,11 @@ CM.Disp.AddMissingUpgrades = function() { let title = document.createElement('div'); title.id = "CMMissingUpgradesTitle"; title.className = "listing"; - titlefrag = document.createElement('div'); + let titlefrag = document.createElement('div'); titlefrag.innerHTML = 'Missing normal upgrades: '+ normalUpgradesOwned + '/' + (Game.UpgradesByPool[""].length + Game.UpgradesByPool.tech.length) + ' (' + Math.floor((normalUpgradesOwned / ( Game.UpgradesByPool[""].length + Game.UpgradesByPool.tech.length)) * 100) + '%)'; title.appendChild(titlefrag); l('menu').children[6].insertBefore(title, l('menu').children[6].childNodes[3]); - upgrades = document.createElement('div'); + let upgrades = document.createElement('div'); upgrades.className = "listing crateBox"; upgrades.innerHTML = CM.Cache.MissingUpgrades; l('menu').children[6].insertBefore(upgrades, document.getElementById("CMMissingUpgradesTitle").nextSibling); @@ -2773,11 +2773,11 @@ CM.Disp.AddMissingUpgrades = function() { let title = document.createElement('div'); title.id = "CMMissingUpgradesCookiesTitle"; title.className = "listing"; - titlefrag = document.createElement('div'); + let titlefrag = document.createElement('div'); titlefrag.innerHTML = 'Missing Cookie upgrades: '+ cookieUpgradesOwned + '/' + Game.UpgradesByPool.cookie.length + ' (' + Math.floor((cookieUpgradesOwned / Game.UpgradesByPool.cookie.length) * 100) + '%)'; title.appendChild(titlefrag); l('menu').children[6].appendChild(title); - upgrades = document.createElement('div'); + let upgrades = document.createElement('div'); upgrades.className = "listing crateBox"; upgrades.innerHTML = CM.Cache.MissingUpgradesCookies; l('menu').children[6].appendChild(upgrades); @@ -2802,7 +2802,7 @@ CM.Disp.crateMissing = function(me) { let icon = me.icon; if (me.iconFunction) icon = me.iconFunction(); - tooltip = `function() {return Game.crateTooltip(Game.UpgradesById[${me.id}], 'stats');}`; + let tooltip = `function() {return Game.crateTooltip(Game.UpgradesById[${me.id}], 'stats');}`; return `
diff --git a/src/Header.js b/src/Header.js index f08c907..8f0379e 100644 --- a/src/Header.js +++ b/src/Header.js @@ -1,7 +1,8 @@ /********** * Header * **********/ -RunCookieMonsterHeader = function() { + +var RunCookieMonsterHeader = function() { CM = {}; CM.Backup = {}; From 6519497ffcb5316b3cb7516baa502b712021f366 Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Sun, 31 Jan 2021 13:55:47 +0100 Subject: [PATCH 6/6] Fixed ESLint install --- .eslintrc.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.eslintrc.js b/.eslintrc.js index dfbdfa3..8570858 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -4,6 +4,7 @@ module.exports = { "es2021": true }, "globals": { + "module": "readonly", "CM": "writable", "Game": "writable", "l": "readonly", @@ -14,6 +15,7 @@ module.exports = { "JSColor": "readonly", "jscolor": "readonly", "BeautifyAll": "readonly", + }, "extends": "eslint:recommended", "parserOptions": {