/********** * Header * **********/ RunCookieMonsterHeader = function() { CM = {}; CM.Backup = {}; CM.Cache = {}; CM.Config = {}; CM.ConfigData = {}; CM.Data = {}; CM.Disp = {}; CM.Sim = {}; } if (typeof CM == "undefined") { RunCookieMonsterHeader(); } /********* * Cache * *********/ CM.Cache.AddQueue = function() { CM.Cache.Queue = document.createElement('script'); CM.Cache.Queue.type = 'text/javascript'; CM.Cache.Queue.setAttribute('src', 'https://aktanusa.github.io/CookieMonster/queue/queue.js'); document.head.appendChild(CM.Cache.Queue); } CM.Cache.NextNumber = function(base) { var count = base > Math.pow(2, 53) ? Math.pow(2, Math.floor(Math.log(base) / Math.log(2)) - 53) : 1; while (base == base + count) { count = CM.Cache.NextNumber(count); } return (base + count); } CM.Cache.RemakeBuildingsPrices = function() { for (var i in 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); } } CM.Cache.RemakeIncome = function() { // Simulate Building Buys for 1 amount CM.Sim.BuyBuildings(1, 'Objects'); // Simulate Upgrade Buys CM.Sim.BuyUpgrades(); // Simulate Building Buys for 10 amount CM.Sim.BuyBuildings(10, 'Objects10'); // Simulate Building Buys for 100 amount CM.Sim.BuyBuildings(100, 'Objects100'); } CM.Cache.RemakeWrinkBank = function() { var totalSucked = 0; for (var i in Game.wrinklers) { var sucked = Game.wrinklers[i].sucked; var toSuck = 1.1; if (Game.Has('Sacrilegious corruption')) toSuck *= 1.05; if (Game.wrinklers[i].type==1) toSuck *= 3; // Shiny wrinklers sucked *= toSuck; if (Game.Has('Wrinklerspawn')) sucked *= 1.05; if (CM.Sim.Objects.Temple.minigameLoaded) { var godLvl = CM.Sim.hasGod('scorn'); if (godLvl == 1) sucked *= 1.15; else if (godLvl == 2) sucked *= 1.1; else if (godLvl == 3) sucked *= 1.05; } totalSucked += sucked; } CM.Cache.WrinkBank = totalSucked; CM.Cache.WrinkGodBank = totalSucked; if (CM.Sim.Objects.Temple.minigameLoaded) { var godLvl = CM.Sim.hasGod('scorn'); if (godLvl == 2) CM.Cache.WrinkGodBank = CM.Cache.WrinkGodBank * 1.15 / 1.1; else if (godLvl == 3) CM.Cache.WrinkGodBank = CM.Cache.WrinkGodBank * 1.15 / 1.05; else if (godLvl != 1) CM.Cache.WrinkGodBank *= 1.15; } } CM.Cache.RemakeBuildingsPP = function() { CM.Cache.min = -1; CM.Cache.max = -1; CM.Cache.mid = -1; // Calculate PP and colors when compared to purchase of single optimal building if (CM.Config.ColorPPBulkMode == 0) { for (var i in 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); } else { CM.Cache.Objects[i].pp = (Game.Objects[i].getPrice() / CM.Cache.Objects[i].bonus); } if (CM.Cache.min == -1 || CM.Cache.Objects[i].pp < CM.Cache.min) CM.Cache.min = CM.Cache.Objects[i].pp; 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) { var 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; else color = CM.Disp.colorYellow; CM.Cache.Objects[i].color = color; } // Buildings for 10 amount CM.Cache.RemakeBuildingsOtherPP(10, 'Objects10'); // Buildings for 100 amount CM.Cache.RemakeBuildingsOtherPP(100, 'Objects100'); } // Calculate PP and colors when compared to purchase of selected bulk mode else { if (Game.buyBulk == 1) { for (var i in 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); } else { CM.Cache.Objects[i].pp = (Game.Objects[i].getPrice() / CM.Cache.Objects[i].bonus); } if (CM.Cache.min == -1 || CM.Cache.Objects[i].pp < CM.Cache.min) CM.Cache.min = CM.Cache.Objects[i].pp; 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) { var 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; else color = CM.Disp.colorYellow; CM.Cache.Objects[i].color = color; } CM.Cache.RemakeBuildingsOtherPP(10, 'Objects10'); CM.Cache.RemakeBuildingsOtherPP(100, 'Objects100'); } else if (Game.buyBulk == 10) { for (var i in 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 { CM.Cache.Objects10[i].pp = (Game.Objects[i].bulkPrice / CM.Cache.Objects10[i].bonus); } if (CM.Cache.min == -1 || CM.Cache.Objects10[i].pp < CM.Cache.min) CM.Cache.min = CM.Cache.Objects10[i].pp; if (CM.Cache.max == -1 || CM.Cache.Objects10[i].pp > CM.Cache.max) CM.Cache.max = CM.Cache.Objects10[i].pp; } CM.Cache.mid = ((CM.Cache.max - CM.Cache.min) / 2) + CM.Cache.min; for (var i in CM.Cache.Objects) { var color = ''; if (CM.Cache.Objects10[i].pp == CM.Cache.min) color = CM.Disp.colorGreen; else if (CM.Cache.Objects10[i].pp == CM.Cache.max) color = CM.Disp.colorRed; else if (CM.Cache.Objects10[i].pp > CM.Cache.mid) color = CM.Disp.colorOrange; else color = CM.Disp.colorYellow; CM.Cache.Objects10[i].color = color; } CM.Cache.RemakeBuildingsOtherPP(1, 'Objects'); CM.Cache.RemakeBuildingsOtherPP(100, 'Objects100'); } else if (Game.buyBulk == 100) { for (var i in 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 { CM.Cache.Objects100[i].pp = (Game.Objects[i].bulkPrice / CM.Cache.Objects100[i].bonus); } if (CM.Cache.min == -1 || CM.Cache.Objects100[i].pp < CM.Cache.min) CM.Cache.min = CM.Cache.Objects100[i].pp; if (CM.Cache.max == -1 || CM.Cache.Objects100[i].pp > CM.Cache.max) CM.Cache.max = CM.Cache.Objects100[i].pp; } CM.Cache.mid = ((CM.Cache.max - CM.Cache.min) / 2) + CM.Cache.min; for (var i in CM.Cache.Objects) { var color = ''; if (CM.Cache.Objects100[i].pp == CM.Cache.min) color = CM.Disp.colorGreen; else if (CM.Cache.Objects100[i].pp == CM.Cache.max) color = CM.Disp.colorRed; else if (CM.Cache.Objects100[i].pp > CM.Cache.mid) color = CM.Disp.colorOrange; else color = CM.Disp.colorYellow; CM.Cache.Objects100[i].color = color; } CM.Cache.RemakeBuildingsOtherPP(1, 'Objects'); CM.Cache.RemakeBuildingsOtherPP(10, 'Objects10'); } } } CM.Cache.RemakeUpgradePP = function() { for (var i in CM.Cache.Upgrades) { //CM.Cache.Upgrades[i].pp = Game.Upgrades[i].getPrice() / CM.Cache.Upgrades[i].bonus; if (Game.cookiesPs) { CM.Cache.Upgrades[i].pp = (Math.max(Game.Upgrades[i].getPrice() - (Game.cookies + CM.Disp.GetWrinkConfigBank()), 0) / Game.cookiesPs) + (Game.Upgrades[i].getPrice() / CM.Cache.Upgrades[i].bonus); } else { CM.Cache.Upgrades[i].pp = (Game.Upgrades[i].getPrice() / CM.Cache.Upgrades[i].bonus); } if (isNaN(CM.Cache.Upgrades[i].pp)) CM.Cache.Upgrades[i].pp = Infinity; var 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; else if (CM.Cache.Upgrades[i].pp == CM.Cache.max) color = CM.Disp.colorRed; else if (CM.Cache.Upgrades[i].pp > CM.Cache.max) color = CM.Disp.colorPurple; else if (CM.Cache.Upgrades[i].pp > CM.Cache.mid) color = CM.Disp.colorOrange; else color = CM.Disp.colorYellow; CM.Cache.Upgrades[i].color = color; } } CM.Cache.RemakeBuildingsOtherPP = function(amount, target) { for (var i in CM.Cache[target]) { //CM.Cache[target][i].pp = CM.Cache[target][i].price / CM.Cache[target][i].bonus; if (Game.cookiesPs) { CM.Cache[target][i].pp = (Math.max(CM.Cache[target][i].price - (Game.cookies + CM.Disp.GetWrinkConfigBank()), 0) / Game.cookiesPs) + (CM.Cache[target][i].price / CM.Cache[target][i].bonus); } else { CM.Cache[target][i].pp = (CM.Cache[target][i].price / CM.Cache[target][i].bonus); } var color = ''; if (CM.Cache[target][i].pp <= 0 || CM.Cache[target][i].pp == Infinity) color = CM.Disp.colorGray; else if (CM.Cache[target][i].pp < CM.Cache.min) color = CM.Disp.colorBlue; else if (CM.Cache[target][i].pp == CM.Cache.min) color = CM.Disp.colorGreen; else if (CM.Cache[target][i].pp == CM.Cache.max) color = CM.Disp.colorRed; else if (CM.Cache[target][i].pp > CM.Cache.max) color = CM.Disp.colorPurple; else if (CM.Cache[target][i].pp > CM.Cache.mid) color = CM.Disp.colorOrange; else color = CM.Disp.colorYellow; CM.Cache[target][i].color = color; } } CM.Cache.RemakePP = function() { // Buildings CM.Cache.RemakeBuildingsPP(); // Upgrades CM.Cache.RemakeUpgradePP(); } CM.Cache.RemakeGoldenAndWrathCookiesMults = function() { var goldenMult = 1; var wrathMult = 1; var mult = 1; // Factor auras and upgrade in mults if (CM.Sim.Has('Green yeast digestives')) mult *= 1.01; if (CM.Sim.Has('Dragon fang')) mult *= 1.03; goldenMult *= 1 + CM.Sim.auraMult('Ancestral Metamorphosis') * 0.1; goldenMult *= CM.Sim.eff('goldenCookieGain'); wrathMult *= 1 + CM.Sim.auraMult('Unholy Dominion') * 0.1; wrathMult *= CM.Sim.eff('wrathCookieGain'); // Calculate final golden and wrath multipliers CM.Cache.GoldenCookiesMult = mult * goldenMult; CM.Cache.WrathCookiesMult = mult * wrathMult; // Calculate Dragon's Fortune multiplier adjustment: // If Dragon's Fortune (or Reality Bending) aura is active and there are currently no golden cookies, // compute a multiplier adjustment to apply on the current CPS to simulate 1 golden cookie on screen. // Otherwise, the aura effect will be factored in the base CPS making the multiplier not requiring adjustment. CM.Cache.DragonsFortuneMultAdjustment = 1; if (Game.shimmerTypes.golden.n === 0) { CM.Cache.DragonsFortuneMultAdjustment *= 1 + CM.Sim.auraMult('Dragon\'s Fortune') * 1.23; } } CM.Cache.RemakeLucky = function() { var goldenMult = CM.Cache.GoldenCookiesMult; var wrathMult = CM.Cache.WrathCookiesMult; CM.Cache.Lucky = (CM.Cache.NoGoldSwitchCookiesPS * 900) / 0.15; CM.Cache.Lucky *= CM.Cache.DragonsFortuneMultAdjustment; var cpsBuffMult = CM.Sim.getCPSBuffMult(); if (cpsBuffMult > 0) { CM.Cache.Lucky /= cpsBuffMult; } else { CM.Cache.Lucky = 0; } CM.Cache.LuckyReward = goldenMult * (CM.Cache.Lucky * 0.15) + 13; CM.Cache.LuckyWrathReward = wrathMult * (CM.Cache.Lucky * 0.15) + 13; CM.Cache.LuckyFrenzy = CM.Cache.Lucky * 7; CM.Cache.LuckyRewardFrenzy = goldenMult * (CM.Cache.LuckyFrenzy * 0.15) + 13; 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.MaxChainMoni = function(digit, maxPayout, mult) { var chain = 1 + Math.max(0, Math.ceil(Math.log(Game.cookies) / Math.LN10) - 10); var moni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain) * digit * mult), maxPayout)); var nextMoni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain + 1) * digit * mult), maxPayout)); while (nextMoni < maxPayout) { chain++; moni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain) * digit * mult), maxPayout)); nextMoni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain + 1) * digit * mult), maxPayout)); } return moni; } CM.Cache.RemakeChain = function() { var maxPayout = CM.Cache.NoGoldSwitchCookiesPS * 60 * 60 * 6; maxPayout *= CM.Cache.DragonsFortuneMultAdjustment; var cpsBuffMult = CM.Sim.getCPSBuffMult(); if (cpsBuffMult > 0) { maxPayout /= cpsBuffMult; } else { maxPayout = 0; } var goldenMult = CM.Cache.GoldenCookiesMult; var wrathMult = CM.Cache.WrathCookiesMult; CM.Cache.ChainReward = CM.Cache.MaxChainMoni(7, maxPayout, goldenMult); CM.Cache.ChainWrathReward = CM.Cache.MaxChainMoni(6, maxPayout, wrathMult); if (maxPayout < CM.Cache.ChainReward) { CM.Cache.Chain = 0; } else { CM.Cache.Chain = CM.Cache.NextNumber(CM.Cache.ChainReward) / 0.5; } if (maxPayout < CM.Cache.ChainWrathReward) { CM.Cache.ChainWrath = 0; } else { CM.Cache.ChainWrath = CM.Cache.NextNumber(CM.Cache.ChainWrathReward) / 0.5; } CM.Cache.ChainFrenzyReward = CM.Cache.MaxChainMoni(7, maxPayout * 7, goldenMult); CM.Cache.ChainFrenzyWrathReward = CM.Cache.MaxChainMoni(6, maxPayout * 7, wrathMult); if ((maxPayout * 7) < CM.Cache.ChainFrenzyReward) { CM.Cache.ChainFrenzy = 0; } else { CM.Cache.ChainFrenzy = CM.Cache.NextNumber(CM.Cache.ChainFrenzyReward) / 0.5; } if ((maxPayout * 7) < CM.Cache.ChainFrenzyWrathReward) { CM.Cache.ChainFrenzyWrath = 0; } else { CM.Cache.ChainFrenzyWrath = CM.Cache.NextNumber(CM.Cache.ChainFrenzyWrathReward) / 0.5; } } CM.Cache.RemakeSeaSpec = function() { if (Game.season == 'christmas') { var val = Game.cookiesPs * 60; if (Game.hasBuff('Elder frenzy')) val *= 0.5; // very sorry if (Game.hasBuff('Frenzy')) val *= 0.75; // I sincerely apologize CM.Cache.SeaSpec = Math.max(25, val); if (Game.Has('Ho ho ho-flavored frosting')) CM.Cache.SeaSpec *= 2; } } CM.Cache.RemakeSellForChoEgg = function() { var sellTotal = 0; // Compute cookies earned by selling stock market goods if (Game.Objects.Bank.minigameLoaded) { var marketGoods = Game.Objects.Bank.minigame.goods; var goodsVal = 0; for (var i in marketGoods) { var marketGood = marketGoods[i]; goodsVal += marketGood.stock * marketGood.val; } sellTotal += goodsVal * Game.cookiesPsRawHighest; } // Compute cookies earned by selling all buildings with optimal auras (ES + RB) sellTotal += CM.Sim.SellBuildingsForChoEgg(); CM.Cache.SellForChoEgg = sellTotal; } CM.Cache.InitCookiesDiff = function() { CM.Cache.CookiesDiff = new Queue(); CM.Cache.WrinkDiff = new Queue(); CM.Cache.ChoEggDiff = new Queue(); CM.Cache.ClicksDiff = new Queue(); } CM.Cache.UpdateAvgCPS = function() { var currDate = Math.floor(Date.now() / 1000); if (CM.Cache.lastDate != currDate) { var choEggTotal = Game.cookies + CM.Cache.SellForChoEgg; if (Game.cpsSucked > 0) { choEggTotal += CM.Cache.WrinkGodBank; } CM.Cache.RealCookiesEarned = Math.max(Game.cookiesEarned, choEggTotal); choEggTotal *= 0.05; if (CM.Cache.lastDate != -1) { var timeDiff = currDate - CM.Cache.lastDate var bankDiffAvg = Math.max(0, (Game.cookies - CM.Cache.lastCookies)) / timeDiff; var wrinkDiffAvg = Math.max(0, (CM.Cache.WrinkBank - CM.Cache.lastWrinkCookies)) / 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++) { CM.Cache.CookiesDiff.enqueue(bankDiffAvg); CM.Cache.WrinkDiff.enqueue(wrinkDiffAvg); CM.Cache.ChoEggDiff.enqueue(choEggDiffAvg); CM.Cache.ClicksDiff.enqueue(clicksDiffAvg); } // Assumes the queues are the same length while (CM.Cache.CookiesDiff.getLength() > 1800) { CM.Cache.CookiesDiff.dequeue(); CM.Cache.WrinkDiff.dequeue(); CM.Cache.ClicksDiff.dequeue(); } while (CM.Cache.ClicksDiff.getLength() > 30) { CM.Cache.ClicksDiff.dequeue(); } } CM.Cache.lastDate = currDate; CM.Cache.lastCookies = Game.cookies; CM.Cache.lastWrinkCookies = CM.Cache.WrinkBank; CM.Cache.lastChoEgg = choEggTotal; CM.Cache.lastClicks = Game.cookieClicks; var sortedGainBank = new Array(); var sortedGainWrink = new Array(); var sortedGainChoEgg = new Array(); var cpsLength = Math.min(CM.Cache.CookiesDiff.getLength(), CM.Disp.cookieTimes[CM.Config.AvgCPSHist]); // Assumes the queues are the same length for (var i = CM.Cache.CookiesDiff.getLength() - cpsLength; i < CM.Cache.CookiesDiff.getLength(); i++) { sortedGainBank.push(CM.Cache.CookiesDiff.get(i)); sortedGainWrink.push(CM.Cache.WrinkDiff.get(i)); sortedGainChoEgg.push(CM.Cache.ChoEggDiff.get(i)); } sortedGainBank.sort(function(a, b) { return a - b; }); sortedGainWrink.sort(function(a, b) { return a - b; }); sortedGainChoEgg.sort(function(a, b) { return a - b; }); var cut = Math.round(sortedGainBank.length / 10); while (cut > 0) { sortedGainBank.shift(); sortedGainBank.pop(); sortedGainWrink.shift(); sortedGainWrink.pop(); sortedGainChoEgg.shift(); sortedGainChoEgg.pop(); cut--; } var totalGainBank = 0; var totalGainWrink = 0; var totalGainChoEgg = 0; for (var i = 0; i < sortedGainBank.length; i++) { totalGainBank += sortedGainBank[i]; totalGainWrink += sortedGainWrink[i]; totalGainChoEgg += sortedGainChoEgg[i]; } CM.Cache.AvgCPS = (totalGainBank + (CM.Config.CalcWrink ? totalGainWrink : 0)) / sortedGainBank.length; var choEgg = (Game.HasUnlocked('Chocolate egg') && !Game.Has('Chocolate egg')); if (choEgg || CM.Config.CalcWrink == 0) { CM.Cache.AvgCPSChoEgg = (totalGainBank + totalGainWrink + (choEgg ? totalGainChoEgg : 0)) / sortedGainBank.length; } else { CM.Cache.AvgCPSChoEgg = CM.Cache.AvgCPS; } var totalClicks = 0; var clicksLength = Math.min(CM.Cache.ClicksDiff.getLength(), CM.Disp.clickTimes[CM.Config.AvgClicksHist]); for (var i = CM.Cache.ClicksDiff.getLength() - clicksLength; i < CM.Cache.ClicksDiff.getLength(); i++) { totalClicks += CM.Cache.ClicksDiff.get(i); } CM.Cache.AvgClicks = totalClicks / clicksLength; } } CM.Cache.CalcMissingUpgrades = function() { var currentMissingUpgrades = [] for (var i in CM.Cache.MissingUpgrades) { if ((CM.Cache.MissingUpgrades[i].pool == "" || CM.Cache.MissingUpgrades[i].pool == "tech") && CM.Cache.MissingUpgrades[i].bought != 1) { currentMissingUpgrades.push(CM.Cache.MissingUpgrades[i]) } } CM.Cache.MissingUpgrades = currentMissingUpgrades var currentMissingCookies = [] for (var i in CM.Cache.MissingCookies) { if (CM.Cache.MissingCookies[i].pool == "cookie" && CM.Cache.MissingCookies[i].bought != 1) { currentMissingCookies.push(CM.Cache.MissingCookies[i]) } } CM.Cache.MissingCookies = currentMissingCookies } CM.Cache.min = -1; CM.Cache.max = -1; CM.Cache.mid = -1; CM.Cache.WrinkBank = -1; CM.Cache.WrinkGodBank = -1; CM.Cache.GoldenCookiesMult = 1; CM.Cache.WrathCookiesMult = 1; CM.Cache.DragonsFortuneMultAdjustment = 1; CM.Cache.NoGoldSwitchCookiesPS = 0; CM.Cache.Lucky = 0; CM.Cache.LuckyReward = 0; CM.Cache.LuckyWrathReward = 0; CM.Cache.LuckyFrenzy = 0; CM.Cache.LuckyRewardFrenzy = 0; CM.Cache.LuckyWrathRewardFrenzy = 0; CM.Cache.Conjure = 0; CM.Cache.ConjureReward = 0; CM.Cache.SeaSpec = 0; CM.Cache.Chain = 0; CM.Cache.ChainWrath = 0; CM.Cache.ChainReward = 0; CM.Cache.ChainWrathReward = 0; CM.Cache.ChainFrenzy = 0; CM.Cache.ChainFrenzyWrath = 0; CM.Cache.ChainFrenzyReward = 0; CM.Cache.ChainFrenzyWrathReward = 0; CM.Cache.CentEgg = 0; CM.Cache.SellForChoEgg = 0; CM.Cache.Title = ''; CM.Cache.HadBuildAura = false; CM.Cache.RealCookiesEarned = -1; CM.Cache.lastDate = -1; CM.Cache.lastCookies = -1; CM.Cache.lastWrinkCookies = -1; CM.Cache.lastChoEgg = -1; CM.Cache.lastClicks = -1; CM.Cache.CookiesDiff; CM.Cache.WrinkDiff; CM.Cache.ChoEggDiff; CM.Cache.ClicksDiff; CM.Cache.AvgCPS = -1; CM.Cache.AvgCPSChoEgg = -1; CM.Cache.AvgClicks = -1; CM.Cache.MissingUpgrades = Game.Upgrades; CM.Cache.MissingCookies = Game.Upgrades; CM.Cache.UpgradesOwned = -1; CM.Cache.MissingUpgradesString = null; CM.Cache.MissingCookiesString = null; /********** * Config * **********/ CM.SaveConfig = function(config) { localStorage.setItem(CM.ConfigPrefix, JSON.stringify(config)); } CM.LoadConfig = function() { if (localStorage.getItem(CM.ConfigPrefix) != null) { CM.Config = JSON.parse(localStorage.getItem(CM.ConfigPrefix)); // Check values var mod = false; for (var i in CM.ConfigDefault) { if (typeof CM.Config[i] === 'undefined') { mod = true; CM.Config[i] = CM.ConfigDefault[i]; } else if (i != 'StatsPref' && i != 'Colors') { if (i.indexOf('SoundURL') == -1) { if (!(CM.Config[i] > -1 && CM.Config[i] < CM.ConfigData[i].label.length)) { mod = true; CM.Config[i] = CM.ConfigDefault[i]; } } else { // Sound URLs if (typeof CM.Config[i] != 'string') { mod = true; CM.Config[i] = CM.ConfigDefault[i]; } } } else if (i == 'StatsPref') { for (var j in CM.ConfigDefault.StatsPref) { if (typeof CM.Config[i][j] === 'undefined' || !(CM.Config[i][j] > -1 && CM.Config[i][j] < 2)) { mod = true; CM.Config[i][j] = CM.ConfigDefault[i][j]; } } } else { // Colors for (var j in CM.ConfigDefault.Colors) { if (typeof CM.Config[i][j] === 'undefined' || typeof CM.Config[i][j] != 'string') { mod = true; CM.Config[i][j] = CM.ConfigDefault[i][j]; } } } } if (mod) CM.SaveConfig(CM.Config); CM.Loop(); // Do loop once for (var i in CM.ConfigDefault) { if (i != 'StatsPref' && i != 'MenuPref' && typeof CM.ConfigData[i].func !== 'undefined') { CM.ConfigData[i].func(); } } } else { // Default values CM.RestoreDefault(); } } CM.RestoreDefault = function() { CM.Config = {}; CM.SaveConfig(CM.ConfigDefault); CM.LoadConfig(); Game.UpdateMenu(); } CM.ToggleConfig = function(config) { CM.ToggleConfigUp(config); if (CM.ConfigData[config].toggle) { if (CM.Config[config] == 0) { l(CM.ConfigPrefix + config).className = 'option off'; } else { l(CM.ConfigPrefix + config).className = 'option'; } } } CM.ToggleConfigUp = function(config) { CM.Config[config]++; if (CM.Config[config] == CM.ConfigData[config].label.length) { CM.Config[config] = 0; } if (typeof CM.ConfigData[config].func !== 'undefined') { CM.ConfigData[config].func(); } l(CM.ConfigPrefix + config).innerHTML = CM.Disp.GetConfigDisplay(config); CM.SaveConfig(CM.Config); } CM.ToggleConfigDown = function(config) { CM.Config[config]--; if (CM.Config[config] < 0) { CM.Config[config] = CM.ConfigData[config].label.length - 1; } if (typeof CM.ConfigData[config].func !== 'undefined') { CM.ConfigData[config].func(); } l(CM.ConfigPrefix + config).innerHTML = CM.Disp.GetConfigDisplay(config); CM.SaveConfig(CM.Config); } CM.ToggleStatsConfig = function(config) { if (CM.Config.StatsPref[config] == 0) { CM.Config.StatsPref[config]++; } else { CM.Config.StatsPref[config]--; } CM.SaveConfig(CM.Config); } CM.ToggleMenuConfig = function(config) { if (CM.Config.MenuPref[config] == 0) { CM.Config.MenuPref[config]++; } else { CM.Config.MenuPref[config]--; } CM.SaveConfig(CM.Config); } // Checks if the browsers has permissions to produce notifications // Should be triggered when Config related to Notifications is toggled on CM.CheckNotificationPermissions = function(ToggleOnOff) { if (ToggleOnOff == 1) { // Check if browser support Promise version of Notification Permissions function checkNotificationPromise() { try { Notification.requestPermission().then(); } catch(e) { return false; } return true; } // Check if the browser supports notifications and which type if (!('Notification' in window)) { console.log("This browser does not support notifications."); } else { if(checkNotificationPromise()) { Notification.requestPermission().then(); } else { Notification.requestPermission(); } } } } CM.ConfigData.BotBar = {label: ['Bottom Bar OFF', 'Bottom Bar ON'], desc: 'Building Information', toggle: true, func: function() {CM.Disp.ToggleBotBar();}}; CM.ConfigData.TimerBar = {label: ['Timer Bar OFF', 'Timer Bar ON'], desc: 'Timers of Golden Cookie, Season Popup, Frenzy (Normal, Clot, Elder), Click Frenzy', toggle: true, func: function() {CM.Disp.ToggleTimerBar();}}; CM.ConfigData.TimerBarPos = {label: ['Timer Bar Position (Top Left)', 'Timer Bar Position (Bottom)'], desc: 'Placement of the Timer Bar', toggle: false, func: function() {CM.Disp.ToggleTimerBarPos();}}; CM.ConfigData.BuildColor = {label: ['Building Colors OFF', 'Building Colors ON'], desc: 'Color code buildings', toggle: true, func: function() {CM.Disp.UpdateBuildings();}}; CM.ConfigData.BulkBuildColor = {label: ['Bulk Building Colors (Single Building Color)', 'Bulk Building Colors (Calculated Bulk Color)'], desc: 'Color code bulk buildings based on single buildings color or calculated bulk value color', toggle: false, func: function() {CM.Disp.UpdateBuildings();}}; CM.ConfigData.ColorPPBulkMode = {label: ['Color of PP (Compared to Single)', 'Color of PP (Compared to Bulk)'], desc: 'Color PP-values based on comparison with single purchase or with selected bulk-buy mode', toggle: false}; CM.ConfigData.UpBarColor = {label: ['Upgrade Colors/Bar OFF', 'Upgrade Colors with Bar ON', 'Upgrade Colors without Bar ON'], desc: 'Color code upgrades and optionally add a counter bar', toggle: false, func: function() {CM.Disp.ToggleUpBarColor();}}; CM.ConfigData.Colors = { desc: { Blue: 'Color Blue. Used to show better than best PP building, for Click Frenzy bar, and for various labels', Green: 'Color Green. Used to show best PP building, for Blood Frenzy bar, and for various labels', Yellow: 'Color Yellow. Used to show between best and worst PP buildings closer to best, for Frenzy bar, and for various labels', Orange: 'Color Orange. Used to show between best and worst PP buildings closer to worst, for Next Reindeer bar, and for various labels', Red: 'Color Red. Used to show worst PP building, for Clot bar, and for various labels', Purple: 'Color Purple. Used to show worse than worst PP building, for Next Cookie bar, and for various labels', Gray: 'Color Gray. Used to show negative or infinity PP, and for Next Cookie/Next Reindeer bar', Pink: 'Color Pink. Used for Dragonflight bar', Brown: 'Color Brown. Used for Dragon Harvest bar' }, func: function() {CM.Disp.UpdateColors();} }; CM.ConfigData.UpgradeBarFixedPos = {label: ['Upgrade Bar Fixed Position OFF', 'Upgrade Bar Fixed Position ON'], desc: 'Lock the upgrade bar at top of the screen to prevent it from moving ofscreen when scrolling', toggle: true, func: function() {CM.Disp.ToggleUpgradeBarFixedPos();}}; CM.ConfigData.CalcWrink = {label: ['Calculate with Wrinklers OFF', 'Calculate with Wrinklers ON'], desc: 'Calculate times and average Cookies Per Second with Wrinklers', toggle: true}; CM.ConfigData.CPSMode = {label: ['Current Cookies Per Second', 'Average Cookies Per Second'], desc: 'Calculate times using current Cookies Per Second or average Cookies Per Second', toggle: false}; CM.ConfigData.AvgCPSHist = {label: ['Average CPS for past 10s', 'Average CPS for past 15s', 'Average CPS for past 30s', 'Average CPS for past 1m', 'Average CPS for past 5m', 'Average CPS for past 10m', 'Average CPS for past 15m', 'Average CPS for past 30m'], desc: 'How much time average Cookies Per Second should consider', toggle: false}; CM.ConfigData.AvgClicksHist = {label: ['Average Cookie Clicks for past 1s', 'Average Cookie Clicks for past 5s', 'Average Cookie Clicks for past 10s', 'Average Cookie Clicks for past 15s', 'Average Cookie Clicks for past 30s'], desc: 'How much time average Cookie Clicks should consider', toggle: false}; CM.ConfigData.ToolWarnBon = {label: ['Calculate Tooltip Warning With Bonus CPS OFF', 'Calculate Tooltip Warning With Bonus CPS ON'], desc: 'Calculate the warning with or without the bonus CPS you get from buying', toggle: true}; CM.ConfigData.GCNotification = {label: ['Golden Cookie Notification OFF', 'Golden Cookie Notification ON'], desc: 'Create a notification when Golden Cookie spawns', toggle: true, func: function () {CM.CheckNotificationPermissions(CM.Config.GCNotification);}}; CM.ConfigData.GCFlash = {label: ['Golden Cookie Flash OFF', 'Golden Cookie Flash ON'], desc: 'Flash screen on Golden Cookie', toggle: true}; CM.ConfigData.GCSound = {label: ['Golden Cookie Sound OFF', 'Golden Cookie Sound ON'], desc: 'Play a sound on Golden Cookie', toggle: true}; CM.ConfigData.GCVolume = {label: [], desc: 'Volume of the Golden Cookie sound'}; for (var i = 0; i < 101; i++) { CM.ConfigData.GCVolume.label[i] = i + '%'; } CM.ConfigData.GCSoundURL = {label: 'Golden Cookie Sound URL:', desc: 'URL of the sound to be played when a Golden Cookie spawns'}; CM.ConfigData.GCTimer = {label: ['Golden Cookie Timer OFF', 'Golden Cookie Timer ON'], desc: 'A timer on the Golden Cookie when it has been spawned', toggle: true, func: function() {CM.Disp.ToggleGCTimer();}}; CM.ConfigData.Favicon = {label: ['Favicon OFF', 'Favicon ON'], desc: 'Update favicon with Golden/Wrath Cookie', toggle: true, func: function() {CM.Disp.UpdateFavicon();}}; CM.ConfigData.FortuneNotification = {label: ['Fortune Cookie Notification OFF', 'Fortune Cookie Notification ON'], desc: 'Create a notification when Fortune Cookie is on the Ticker', toggle: true, func: function () {CM.CheckNotificationPermissions(CM.Config.FortuneNotification);}}; CM.ConfigData.FortuneFlash = {label: ['Fortune Cookie Flash OFF', 'Fortune Cookie Flash ON'], desc: 'Flash screen on Fortune Cookie', toggle: true}; CM.ConfigData.FortuneSound = {label: ['Fortune Cookie Sound OFF', 'Fortune Cookie Sound ON'], desc: 'Play a sound on Fortune Cookie', toggle: true}; CM.ConfigData.FortuneVolume = {label: [], desc: 'Volume of the Fortune Cookie sound'}; for (var i = 0; i < 101; i++) { CM.ConfigData.FortuneVolume.label[i] = i + '%'; } CM.ConfigData.FortuneSoundURL = {label: 'Fortune Cookie Sound URL:', desc: 'URL of the sound to be played when the Ticker has a Fortune Cookie'}; CM.ConfigData.SeaNotification = {label: ['Season Special Notification OFF', 'Season Special Notification ON'], desc: 'Create a notification on Season Popup', toggle: true, func: function () {CM.CheckNotificationPermissions(CM.Config.SeaNotification);}}; CM.ConfigData.SeaFlash = {label: ['Season Special Flash OFF', 'Season Special Flash ON'], desc: 'Flash screen on Season Popup', toggle: true}; CM.ConfigData.SeaSound = {label: ['Season Special Sound OFF', 'Season Special Sound ON'], desc: 'Play a sound on Season Popup', toggle: true}; CM.ConfigData.SeaVolume = {label: [], desc: 'Volume of the Season Special sound'}; for (var i = 0; i < 101; i++) { CM.ConfigData.SeaVolume.label[i] = i + '%'; } CM.ConfigData.SeaSoundURL = {label: 'Season Special Sound URL:', desc: 'URL of the sound to be played when a Season Special spawns'}; CM.ConfigData.GardFlash = {label: ['Garden Tick Flash OFF', 'Garden Tick Flash ON'], desc: 'Flash screen on Garden Tick', toggle: true}; CM.ConfigData.GardSound = {label: ['Garden Tick Sound OFF', 'Garden Tick Sound ON'], desc: 'Play a sound on Garden Tick', toggle: true}; CM.ConfigData.GardVolume = {label: [], desc: 'Volume of the Garden Tick sound'}; for (var i = 0; i < 101; i++) { CM.ConfigData.GardVolume.label[i] = i + '%'; } CM.ConfigData.GardSoundURL = {label: 'Garden Tick Sound URL:', desc: 'URL of the sound to be played when the garden ticks'}; CM.ConfigData.MagicNotification = {label: ['Magic Max Notification OFF', 'Magic Max Notification ON'], desc: 'Create a notification when magic reaches maximum', toggle: true, func: function () {CM.CheckNotificationPermissions(CM.Config.MagicNotification);}}; CM.ConfigData.MagicFlash = {label: ['Magic Max Flash OFF', 'Magic Max Flash ON'], desc: 'Flash screen when magic reaches maximum', toggle: true}; CM.ConfigData.MagicSound = {label: ['Magic Max Sound OFF', 'Magic Max Sound ON'], desc: 'Play a sound when magic reaches maximum', toggle: true}; CM.ConfigData.MagicVolume = {label: [], desc: 'Volume of the Max Magic sound'}; for (var i = 0; i < 101; i++) { CM.ConfigData.MagicVolume.label[i] = i + '%'; } CM.ConfigData.MagicSoundURL = {label: 'Magic Max Sound URL:', desc: 'URL of the sound to be played when magic reaches maxium'}; CM.ConfigData.WrinklerNotification = {label: ['Wrinkler Notification OFF', 'Wrinkler Notification ON'], desc: 'Create a notification when a Wrinkler appears', toggle: true, func: function () {CM.CheckNotificationPermissions(CM.Config.WrinklerNotification);}}; CM.ConfigData.WrinklerFlash = {label: ['Wrinkler Flash OFF', 'Wrinkler Flash ON'], desc: 'Flash screen when a Wrinkler appears', toggle: true}; CM.ConfigData.WrinklerSound = {label: ['Wrinkler Sound OFF', 'Wrinkler Sound ON'], desc: 'Play a sound when a Wrinkler appears', toggle: true}; CM.ConfigData.WrinklerVolume = {label: [], desc: 'Volume of the Wrinkler sound'}; for (var i = 0; i < 101; i++) { CM.ConfigData.WrinklerVolume.label[i] = i + '%'; } CM.ConfigData.WrinklerSoundURL = {label: 'Wrinkler Sound URL:', desc: 'URL of the sound to be played when a Wrinkler appears'}; CM.ConfigData.WrinklerMaxNotification = {label: ['Wrinkler Max Notification OFF', 'Wrinkler Max Notification ON'], desc: 'Create a notification when the maximum amount of Wrinklers has appeared', toggle: true, func: function () {CM.CheckNotificationPermissions(CM.Config.WrinklerMaxNotification);}}; CM.ConfigData.WrinklerMaxFlash = {label: ['Wrinkler Max Flash OFF', 'Wrinkler Max Flash ON'], desc: 'Flash screen when the maximum amount of Wrinklers has appeared', toggle: true}; CM.ConfigData.WrinklerMaxSound = {label: ['Wrinkler Max Sound OFF', 'Wrinkler Max Sound ON'], desc: 'Play a sound when the maximum amount of Wrinklers has appeared', toggle: true}; CM.ConfigData.WrinklerMaxVolume = {label: [], desc: 'Volume of the Wrinkler Max sound'}; for (var i = 0; i < 101; i++) { CM.ConfigData.WrinklerMaxVolume.label[i] = i + '%'; } CM.ConfigData.WrinklerMaxSoundURL = {label: 'Wrinkler Max Sound URL:', desc: 'URL of the sound to be played when the maximum amount of Wrinklers has appeared'}; CM.ConfigData.Title = {label: ['Title OFF', 'Title ON', 'Title Pinned Tab Highlight'], desc: 'Update title with Golden Cookie/Season Popup timers; pinned tab highlight only changes the title when a Golden Cookie/Season Popup spawns', toggle: true}; CM.ConfigData.TooltipBuildUp = {label: ['Buildings/Upgrades Tooltip Information OFF', 'Buildings/Upgrades Tooltip Information ON'], desc: 'Extra information in tooltip for buildings/upgrades', toggle: true}; CM.ConfigData.TooltipAmor = {label: ['Buildings Tooltip Amortization Information OFF', 'Buildings Tooltip Amortization Information ON'], desc: 'Add amortization information to buildings tooltip', toggle: true}; CM.ConfigData.ToolWarnLucky = {label: ['Tooltip Lucky Warning OFF', 'Tooltip Lucky Warning ON'], desc: 'A warning when buying if it will put the bank under the amount needed for max "Lucky!"/"Lucky!" (Frenzy) rewards', toggle: true}; CM.ConfigData.ToolWarnConjure = {label: ['Tooltip Conjure Warning OFF', 'Tooltip Conjure Warning ON'], desc: 'A warning when buying if it will put the bank under the amount needed for max "Conjure Baked Goods" rewards', toggle: true}; CM.ConfigData.ToolWarnPos = {label: ['Tooltip Warning Position (Left)', 'Tooltip Warning Position (Bottom)'], desc: 'Placement of the warning boxes', toggle: false, func: function() {CM.Disp.ToggleToolWarnPos();}}; CM.ConfigData.TooltipGrim = {label: ['Grimoire Tooltip Information OFF', 'Grimoire Tooltip Information ON'], desc: 'Extra information in tooltip for grimoire', toggle: true}; CM.ConfigData.ToolWrink = {label: ['Wrinkler Tooltip OFF', 'Wrinkler Tooltip ON'], desc: 'Shows the amount of cookies a wrinkler will give when popping it', toggle: true}; CM.ConfigData.TooltipLump = {label: ['Sugar Lump Tooltip OFF', 'Sugar Lump Tooltip ON'], desc: 'Shows the current Sugar Lump type in Sugar lump tooltip.', toggle: true}; CM.ConfigData.Stats = {label: ['Statistics OFF', 'Statistics ON'], desc: 'Extra Cookie Monster statistics!', toggle: true}; CM.ConfigData.MissingUpgrades = {label: ['Missing Upgrades OFF', 'Missing Upgrades ON'], desc: 'Shows Missing upgrades in Stats Menu. This feature can be laggy for users with a low amount of unlocked achievements.', toggle: true}; CM.ConfigData.UpStats = {label: ['Statistics Update Rate (Default)', 'Statistics Update Rate (1s)'], desc: 'Default Game rate is once every 5 seconds', toggle: false}; CM.ConfigData.TimeFormat = {label: ['Time XXd, XXh, XXm, XXs', 'Time XX:XX:XX:XX:XX'], desc: 'Change the time format', toggle: false}; CM.ConfigData.SayTime = {label: ['Format Time OFF', 'Format Time ON'], desc: 'Change how time is displayed in statistics', toggle: true, func: function() {CM.Disp.ToggleSayTime();}}; CM.ConfigData.GrimoireBar = {label: ['Grimoire Magic Meter Timer OFF', 'Grimoire Magic Meter Timer ON'], desc: 'A timer on how long before the Grimoire magic meter is full', toggle: true}; CM.ConfigData.Scale = {label: ['Game\'s Setting Scale', 'Metric', 'Short Scale', 'Scientific Notation', 'Engineering Notation'], desc: 'Change how long numbers are handled', toggle: false, func: function() {CM.Disp.RefreshScale();}}; CM.ConfigData.SortBuildings = {label: ['Sort Buildings: Default', 'Sort Buildings: PP'], desc: 'Sort the display of buildings in either default order or by PP', toggle: false, func: function () { CM.Disp.UpdateBuildings();}}; CM.ConfigData.SortUpgrades = {label: ['Sort Upgrades: Default', 'Sort Upgrades: PP'], desc: 'Sort the display of upgrades in either default order or by PP', toggle: false, func: function () { CM.Disp.UpdateUpgrades();}}; /******** * Data * ********/ CM.Data.Fortunes = [ 'Fortune #001', 'Fortune #002', 'Fortune #003', 'Fortune #004', 'Fortune #005', 'Fortune #006', 'Fortune #007', 'Fortune #008', 'Fortune #009', 'Fortune #010', 'Fortune #011', 'Fortune #012', 'Fortune #013', 'Fortune #014', 'Fortune #015', 'Fortune #016', 'Fortune #017', 'Fortune #018', 'Fortune #100', 'Fortune #101', 'Fortune #102', 'Fortune #103', 'Fortune #104' ]; 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']; /******** * Disp * ********/ CM.Disp.FormatTime = function(time, format) { if (time == Infinity) return time; if (CM.Config.TimeFormat) { if (time > 3155760000) return 'XX:XX:XX:XX:XX'; time = Math.ceil(time); var y = Math.floor(time / 31557600); var d = Math.floor(time % 31557600 / 86400); var h = Math.floor(time % 86400 / 3600); var m = Math.floor(time % 3600 / 60); var s = Math.floor(time % 60); var str = ''; if (y < 10) { str += '0'; } str += y + ':'; if (d < 10) { str += '0'; } str += d + ':'; if (h < 10) { str += '0'; } str += h + ':'; if (m < 10) { str += '0'; } str += m + ':'; if (s < 10) { str += '0'; } str += s; } else { if (time > 777600000) return format ? 'Over 9000 days!' : '>9000d'; time = Math.ceil(time); var d = Math.floor(time / 86400); var h = Math.floor(time % 86400 / 3600); var m = Math.floor(time % 3600 / 60); var s = Math.floor(time % 60); var str = ''; if (d > 0) { str += d + (format ? (d == 1 ? ' day' : ' days') : 'd') + ', '; } if (str.length > 0 || h > 0) { str += h + (format ? (h == 1 ? ' hour' : ' hours') : 'h') + ', '; } if (str.length > 0 || m > 0) { str += m + (format ? (m == 1 ? ' minute' : ' minutes') : 'm') + ', '; } str += s + (format ? (s == 1 ? ' second' : ' seconds') : 's'); } return str; } CM.Disp.GetTimeColor = function(price, bank, cps, time) { var color; var text; if (bank >= price) { color = CM.Disp.colorGreen; if (CM.Config.TimeFormat) { text = '00:00:00:00:00'; } else { text = 'Done!'; } } else { if (typeof time !== 'undefined') { var time = time; } else { var time = (price - bank) / cps; } text = CM.Disp.FormatTime(time); if (time > 300) { color = CM.Disp.colorRed; } else if (time > 60) { color = CM.Disp.colorOrange; } else { color = CM.Disp.colorYellow; } } return {text: text, color: color}; } /** * This function returns Name and Color as object for sugar lump type that is given as input param. * @param type Sugar Lump Type. * @returns {{text: string, color: string}} * @constructor */ CM.Disp.GetLumpColor = function(type) { var name = ""; var color = ""; switch (type) { case 0: name = "Normal"; color = CM.Disp.colorGray; break; case 1: name = "Bifurcated"; color = CM.Disp.colorGreen; break; case 2: name = "Golden"; color = CM.Disp.colorYellow; break; case 3: name = "Meaty"; color = CM.Disp.colorOrange; break; case 4: name = "Caramelized"; color = CM.Disp.colorPurple; break; default: name = "Unknown Sugar Lump"; color = CM.Disp.colorRed; break; } return {text: name, color: color}; }; CM.Disp.Beautify = function(num, frac) { if (CM.Config.Scale != 0 && isFinite(num)) { var answer = ''; var negative = false; if (num < 0) { num = Math.abs(num); negative = true; } if (CM.Config.Scale == 3) { if (num >= 999999) { var count = 0; while (num >= 10) { count++; num /= 10; } answer = +(Math.round(num + "e+2") + "e-2") + 'E+' + count; } else if (num < -999999 && num != 0) { var count = 0; while (num < 1) { count++; num *= 10; } answer = +(Math.round(num + "e+2") + "e-2") + 'E-' + count; } else { answer = CM.Backup.Beautify(num, frac); } } else if (CM.Config.Scale == 4) { if (num >= 999999) { var count = 0; while (num >= 1000) { count++; num /= 1000; } answer = +(Math.round(num + "e+2") + "e-2") + 'E+' + (count * 3); } else if (num < -999999 && num != 0) { var count = 0; while (num < 1) { count++; num *= 1000; } answer = +(Math.round(num + "e+2") + "e-2") + 'E-' + (count * 3); } else { answer = CM.Backup.Beautify(num, frac); } } else { for (var i = (CM.Disp.shortScale.length - 1); i >= 0; i--) { if (i < CM.Disp.metric.length && CM.Config.Scale == 1) { // Revert to Scientific Notation from e27 if (Math.log10(num) > 27) { if (num >= 999999) { var count = 0; while (num >= 10) { count++; num /= 10; } answer = +(Math.round(num + "e+2") + "e-2") + 'E+' + count; } else if (num < -999999 && num != 0) { var count = 0; while (num < 1) { count++; num *= 10; } answer = +(Math.round(num + "e+2") + "e-2") + 'E-' + count; } else { answer = CM.Backup.Beautify(num, frac); } } else if (num >= Math.pow(1000, i + 2)) { answer = (Math.round(num / Math.pow(1000, i + 1)) / 1000).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',') + ' ' + CM.Disp.metric[i]; break; } } else if (CM.Config.Scale == 2) { if (num >= Math.pow(1000, i + 2)) { answer = (Math.round(num / Math.pow(1000, i + 1)) / 1000) + ' ' + CM.Disp.shortScale[i]; break; } } } } if (answer == '') { answer = CM.Backup.Beautify(num, frac); } if (negative) { answer = '-' + answer; } return answer; } else { return CM.Backup.Beautify(num, frac); } } CM.Disp.GetWrinkConfigBank = function() { if (CM.Config.CalcWrink) return CM.Cache.WrinkBank; else return 0; } CM.Disp.GetCPS = function() { if (CM.Config.CPSMode) return CM.Cache.AvgCPS; else return (Game.cookiesPs * (1 - Game.cpsSucked)); } CM.Disp.UpdateBackground = function() { Game.Background.canvas.width = Game.Background.canvas.parentNode.offsetWidth; 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; } CM.Disp.GetConfigDisplay = function(config) { return CM.ConfigData[config].label[CM.Config[config]]; } CM.Disp.AddJscolor = function() { CM.Disp.Jscolor = document.createElement('script'); CM.Disp.Jscolor.type = 'text/javascript'; CM.Disp.Jscolor.setAttribute('src', 'https://aktanusa.github.io/CookieMonster/jscolor/jscolor.js'); document.head.appendChild(CM.Disp.Jscolor); } CM.Disp.CreateCssArea = function() { CM.Disp.Css = document.createElement('style'); CM.Disp.Css.type = 'text/css'; document.head.appendChild(CM.Disp.Css); // given the architecture of your code, you probably want these lines somewhere else, // but I stuck them here for convenience l("products").style.display = "grid"; l("storeBulk").style.gridRow = "1/1"; l("upgrades").style.display = "flex"; l("upgrades").style["flex-wrap"] = "wrap"; } /** * Extends the bottom bar (created by CM.Disp.CreateBotBar) with a column for the given building. * * This function is called by CM.Disp.CreateBotBar on initialization of Cookie Monster, * and also in CM.Sim.CopyData if a new building (added by another mod) is discovered. */ CM.Disp.CreateBotBarBuildingColumn = function(buildingName) { if(!CM.Disp.BotBar) { CM.Disp.CreateBotBar(); return; // CreateBotBar will call this function again } var type = CM.Disp.BotBar.firstChild.firstChild.childNodes[0]; var bonus = CM.Disp.BotBar.firstChild.firstChild.childNodes[1]; var pp = CM.Disp.BotBar.firstChild.firstChild.childNodes[2]; var time = CM.Disp.BotBar.firstChild.firstChild.childNodes[3]; var 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')); span.className = CM.Disp.colorTextPre + CM.Disp.colorBlue; header.appendChild(document.createTextNode(')')); bonus.appendChild(document.createElement('td')); pp.appendChild(document.createElement('td')); time.appendChild(document.createElement('td')); } CM.Disp.CreateBotBar = function() { CM.Disp.BotBar = document.createElement('div'); CM.Disp.BotBar.id = 'CMBotBar'; CM.Disp.BotBar.style.height = '69px'; CM.Disp.BotBar.style.width = '100%'; CM.Disp.BotBar.style.position = 'absolute'; CM.Disp.BotBar.style.display = 'none'; CM.Disp.BotBar.style.backgroundColor = '#262224'; CM.Disp.BotBar.style.backgroundImage = '-moz-linear-gradient(top, #4d4548, #000000)'; CM.Disp.BotBar.style.backgroundImage = '-o-linear-gradient(top, #4d4548, #000000)'; CM.Disp.BotBar.style.backgroundImage = '-webkit-linear-gradient(top, #4d4548, #000000)'; CM.Disp.BotBar.style.backgroundImage = 'linear-gradient(to bottom, #4d4548, #000000)'; CM.Disp.BotBar.style.borderTop = '1px solid black'; CM.Disp.BotBar.style.overflow = 'auto'; CM.Disp.BotBar.style.textShadow = '-1px 0 black, 0 1px black, 1px 0 black, 0 -1px black'; var table = CM.Disp.BotBar.appendChild(document.createElement('table')); table.style.width = '100%'; table.style.textAlign = 'center'; table.style.whiteSpace = 'nowrap'; // TODO figure a better way //table.style.tableLayout = 'fixed'; //table.style.overflow = 'hidden'; var tbody = table.appendChild(document.createElement('tbody')); var firstCol = function(text, color) { var td = document.createElement('td'); td.style.textAlign = 'right'; 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.VersionMajor + '.' + CM.VersionMinor, CM.Disp.colorYellow)); var bonus = tbody.appendChild(document.createElement('tr')); bonus.appendChild(firstCol('Bonus Income', CM.Disp.colorBlue)); var pp = tbody.appendChild(document.createElement('tr')); pp.appendChild(firstCol('Payback Period', CM.Disp.colorBlue)); var time = tbody.appendChild(document.createElement('tr')); time.appendChild(firstCol('Time Left', CM.Disp.colorBlue)); for (var i in Game.Objects) { CM.Disp.CreateBotBarBuildingColumn(i); } l('wrapper').appendChild(CM.Disp.BotBar); } CM.Disp.ToggleBotBar = function() { if (CM.Config.BotBar == 1) { CM.Disp.BotBar.style.display = ''; CM.Disp.UpdateBotBarOther(); } else { CM.Disp.BotBar.style.display = 'none'; } CM.Disp.UpdateBotTimerBarDisplay(); } CM.Disp.UpdateBotBarOther = function() { if (CM.Config.BotBar == 1) { var count = 0; for (var i in CM.Cache.Objects) { var target = 'Objects'; if (Game.buyBulk == 10) {target = 'Objects10';} if (Game.buyBulk == 100) {target = 'Objects100';} count++; CM.Disp.BotBar.firstChild.firstChild.childNodes[0].childNodes[count].childNodes[1].textContent = Game.Objects[i].amount; CM.Disp.BotBar.firstChild.firstChild.childNodes[1].childNodes[count].textContent = Beautify(CM.Cache[target][i].bonus, 2); CM.Disp.BotBar.firstChild.firstChild.childNodes[2].childNodes[count].className = CM.Disp.colorTextPre + CM.Cache[target][i].color; CM.Disp.BotBar.firstChild.firstChild.childNodes[2].childNodes[count].textContent = Beautify(CM.Cache[target][i].pp, 2); } } } CM.Disp.UpdateBotBarTime = function() { if (CM.Config.BotBar == 1) { var count = 0; for (var i in CM.Cache.Objects) { count++; var timeColor = CM.Disp.GetTimeColor(Game.Objects[i].getPrice(), (Game.cookies + CM.Disp.GetWrinkConfigBank()), CM.Disp.GetCPS()); CM.Disp.BotBar.firstChild.firstChild.childNodes[3].childNodes[count].className = CM.Disp.colorTextPre + timeColor.color; CM.Disp.BotBar.firstChild.firstChild.childNodes[3].childNodes[count].textContent = timeColor.text; } } } CM.Disp.CreateTimerBar = function() { CM.Disp.TimerBar = document.createElement('div'); CM.Disp.TimerBar.id = 'CMTimerBar'; CM.Disp.TimerBar.style.position = 'absolute'; CM.Disp.TimerBar.style.display = 'none'; CM.Disp.TimerBar.style.height = '48px'; CM.Disp.TimerBar.style.fontSize = '10px'; CM.Disp.TimerBar.style.fontWeight = 'bold'; CM.Disp.TimerBar.style.backgroundColor = 'black'; var bar = function(name, bars, time) { var div = document.createElement('div'); div.style.width = '100%'; div.style.height = '10px'; div.style.margin = 'auto'; div.style.position = 'absolute'; div.style.left = '0px'; div.style.top = '0px'; div.style.right = '0px'; div.style.bottom = '0px'; var type = document.createElement('span'); type.style.display = 'inline-block'; type.style.textAlign = 'right'; type.style.width = '108px'; type.style.marginRight = '5px'; type.style.verticalAlign = 'text-top'; type.textContent = name; div.appendChild(type); for (var i = 0; i < bars.length; i++) { var colorBar = document.createElement('span'); colorBar.id = bars[i].id colorBar.style.display = 'inline-block'; colorBar.style.height = '10px'; if (bars.length - 1 == i) { colorBar.style.borderTopRightRadius = '10px'; colorBar.style.borderBottomRightRadius = '10px'; } if (typeof bars[i].color !== 'undefined') { colorBar.className = CM.Disp.colorBackPre + bars[i].color; } div.appendChild(colorBar); } var timer = document.createElement('span'); timer.id = time; timer.style.marginLeft = '5px'; timer.style.verticalAlign = 'text-top'; div.appendChild(timer); return div } CM.Disp.TimerBarGC = document.createElement('div'); CM.Disp.TimerBarGC.id = 'CMTimerBarGC'; CM.Disp.TimerBarGC.style.height = '12px'; CM.Disp.TimerBarGC.style.margin = '0px 10px'; CM.Disp.TimerBarGC.style.position = 'relative'; CM.Disp.TimerBarGC.appendChild(bar('Next Cookie', [{id: 'CMTimerBarGCMinBar', color: CM.Disp.colorGray}, {id: 'CMTimerBarGCBar', color: CM.Disp.colorPurple}], 'CMTimerBarGCTime')); CM.Disp.TimerBar.appendChild(CM.Disp.TimerBarGC); CM.Disp.TimerBarRen = document.createElement('div'); CM.Disp.TimerBarRen.id = 'CMTimerBarRen'; CM.Disp.TimerBarRen.style.height = '12px'; CM.Disp.TimerBarRen.style.margin = '0px 10px'; CM.Disp.TimerBarRen.style.position = 'relative'; CM.Disp.TimerBarRen.appendChild(bar('Next Reindeer', [{id: 'CMTimerBarRenMinBar', color: CM.Disp.colorGray}, {id: 'CMTimerBarRenBar', color: CM.Disp.colorOrange}], 'CMTimerBarRenTime')); CM.Disp.TimerBar.appendChild(CM.Disp.TimerBarRen); CM.Disp.TimerBarBuff1 = document.createElement('div'); CM.Disp.TimerBarBuff1.id = 'CMTimerBarBuff1'; CM.Disp.TimerBarBuff1.style.height = '12px'; CM.Disp.TimerBarBuff1.style.margin = '0px 10px'; CM.Disp.TimerBarBuff1.style.position = 'relative'; CM.Disp.TimerBarBuff1.appendChild(bar('', [{id: 'CMTimerBarBuff1Bar'}], 'CMTimerBarBuff1Time')); CM.Disp.TimerBarBuff1.firstChild.firstChild.id = 'CMTimerBarBuff1Type'; CM.Disp.TimerBar.appendChild(CM.Disp.TimerBarBuff1); CM.Disp.TimerBarBuff2 = document.createElement('div'); CM.Disp.TimerBarBuff2.id = 'CMTimerBarBuff2'; CM.Disp.TimerBarBuff2.style.height = '12px'; CM.Disp.TimerBarBuff2.style.margin = '0px 10px'; CM.Disp.TimerBarBuff2.style.position = 'relative'; CM.Disp.TimerBarBuff2.appendChild(bar('', [{id: 'CMTimerBarBuff2Bar'}], 'CMTimerBarBuff2Time')); CM.Disp.TimerBarBuff2.firstChild.firstChild.id = 'CMTimerBarBuff2Type'; CM.Disp.TimerBar.appendChild(CM.Disp.TimerBarBuff2); l('wrapper').appendChild(CM.Disp.TimerBar); } CM.Disp.ToggleTimerBar = function() { if (CM.Config.TimerBar == 1) { CM.Disp.TimerBar.style.display = ''; } else { CM.Disp.TimerBar.style.display = 'none'; } CM.Disp.UpdateBotTimerBarDisplay(); } CM.Disp.ToggleTimerBarPos = function() { if (CM.Config.TimerBarPos == 0) { CM.Disp.TimerBar.style.width = '30%'; CM.Disp.TimerBar.style.bottom = ''; l('game').insertBefore(CM.Disp.TimerBar, l('sectionLeft')); } else { CM.Disp.TimerBar.style.width = '100%'; CM.Disp.TimerBar.style.bottom = '0px'; l('wrapper').appendChild(CM.Disp.TimerBar); } CM.Disp.UpdateBotTimerBarDisplay(); } CM.Disp.UpdateTimerBar = function() { if (CM.Config.TimerBar == 1) { // label width: 113, timer width: 26, div margin: 20 var maxWidth = CM.Disp.TimerBar.offsetWidth - 159; var count = 0; if (Game.shimmerTypes['golden'].spawned == 0 && !Game.Has('Golden switch [off]')) { CM.Disp.TimerBarGC.style.display = ''; l('CMTimerBarGCMinBar').style.width = Math.round(Math.max(0, Game.shimmerTypes['golden'].minTime - Game.shimmerTypes['golden'].time) * maxWidth / Game.shimmerTypes['golden'].maxTime) + 'px'; if (Game.shimmerTypes['golden'].minTime == Game.shimmerTypes['golden'].maxTime) { l('CMTimerBarGCMinBar').style.borderTopRightRadius = '10px'; l('CMTimerBarGCMinBar').style.borderBottomRightRadius = '10px'; } else { 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) * maxWidth / Game.shimmerTypes['golden'].maxTime) + 'px'; l('CMTimerBarGCTime').textContent = Math.ceil((Game.shimmerTypes['golden'].maxTime - Game.shimmerTypes['golden'].time) / Game.fps); count++; } else { CM.Disp.TimerBarGC.style.display = 'none'; } if (Game.season == 'christmas' && Game.shimmerTypes['reindeer'].spawned == 0) { CM.Disp.TimerBarRen.style.display = ''; l('CMTimerBarRenMinBar').style.width = Math.round(Math.max(0, Game.shimmerTypes['reindeer'].minTime - Game.shimmerTypes['reindeer'].time) * maxWidth / Game.shimmerTypes['reindeer'].maxTime) + 'px'; l('CMTimerBarRenBar').style.width = Math.round(Math.min(Game.shimmerTypes['reindeer'].maxTime - Game.shimmerTypes['reindeer'].minTime, Game.shimmerTypes['reindeer'].maxTime - Game.shimmerTypes['reindeer'].time) * maxWidth / Game.shimmerTypes['reindeer'].maxTime) + 'px'; l('CMTimerBarRenTime').textContent = Math.ceil((Game.shimmerTypes['reindeer'].maxTime - Game.shimmerTypes['reindeer'].time) / Game.fps); count++; } else { CM.Disp.TimerBarRen.style.display = 'none'; } var buffCount = 0; for (var i in Game.buffs) { if (Game.buffs[i]) { buffCount++; CM.Disp['TimerBarBuff' + buffCount].style.display = ''; l('CMTimerBarBuff' + buffCount + 'Type').textContent = Game.buffs[i].name; var classColor = ''; if (typeof CM.Disp.buffColors[Game.buffs[i].name] !== 'undefined') { classColor = CM.Disp.buffColors[Game.buffs[i].name]; } else { classColor = CM.Disp.colorPurple; } l('CMTimerBarBuff' + buffCount + 'Bar').className = CM.Disp.colorBackPre + classColor; l('CMTimerBarBuff' + buffCount + 'Bar').style.width = Math.round(Game.buffs[i].time * maxWidth / Game.buffs[i].maxTime) + 'px'; l('CMTimerBarBuff' + buffCount + 'Time').textContent = Math.ceil(Game.buffs[i].time / Game.fps); count++; if (buffCount == 2) { break; } } } if (buffCount < 2) { CM.Disp.TimerBarBuff2.style.display = 'none'; if (buffCount < 1) { CM.Disp.TimerBarBuff1.style.display = 'none'; } } /*if (Game.frenzy > 0) { CM.Disp.TimerBarBuff1.style.display = ''; if (Game.frenzyPower == 7) { l('CMTimerBarBuff1Type').textContent = 'Frenzy'; l('CMTimerBarBuff1Bar').className = CM.Disp.colorBackPre + CM.Disp.colorYellow; } else if (Game.frenzyPower == 0.5) { l('CMTimerBarBuff1Type').textContent = 'Clot'; l('CMTimerBarBuff1Bar').className = CM.Disp.colorBackPre + CM.Disp.colorRed; } else if (Game.frenzyPower == 15) { l('CMTimerBarBuff1Type').textContent = 'Dragon Harvest'; l('CMTimerBarBuff1Bar').className = CM.Disp.colorBackPre + CM.Disp.colorBrown; } else { l('CMTimerBarBuff1Type').textContent = 'Blood Frenzy'; l('CMTimerBarBuff1Bar').className = CM.Disp.colorBackPre + CM.Disp.colorGreen; } l('CMTimerBarBuff1Bar').style.width = Math.round(Game.frenzy * maxWidth / Game.frenzyMax) + 'px'; l('CMTimerBarBuff1Time').textContent = Math.ceil(Game.frenzy / Game.fps); count++; } else { CM.Disp.TimerBarBuff1.style.display = 'none'; } if (Game.clickFrenzy > 0) { CM.Disp.TimerBarBuff2.style.display = ''; if (Game.clickFrenzyPower == 777) { l('CMTimerBarBuff2Type').textContent = 'Click Frenzy'; l('CMTimerBarBuff2Bar').className = CM.Disp.colorBackPre + CM.Disp.colorBlue; } else { l('CMTimerBarBuff2Type').textContent = 'Dragonflight'; l('CMTimerBarBuff2Bar').className = CM.Disp.colorBackPre + CM.Disp.colorPink; } l('CMTimerBarBuff2Bar').style.width = Math.round(Game.clickFrenzy * maxWidth / Game.clickFrenzyMax) + 'px'; l('CMTimerBarBuff2Time').textContent = Math.ceil(Game.clickFrenzy / Game.fps); count++; } else { CM.Disp.TimerBarBuff2.style.display = 'none'; }*/ if (count != 0) { var height = 48 / count; CM.Disp.TimerBarGC.style.height = height + 'px'; CM.Disp.TimerBarRen.style.height = height + 'px'; CM.Disp.TimerBarBuff1.style.height = height + 'px'; CM.Disp.TimerBarBuff2.style.height = height + 'px'; } } } CM.Disp.UpdateBotTimerBarDisplay = function() { if (CM.Config.BotBar == 1 && CM.Config.TimerBar == 1 && CM.Config.TimerBarPos == 1) { CM.Disp.BotBar.style.bottom = '48px'; l('game').style.bottom = '118px'; } else if (CM.Config.BotBar == 1) { CM.Disp.BotBar.style.bottom = '0px'; l('game').style.bottom = '70px'; } else if (CM.Config.TimerBar == 1 && CM.Config.TimerBarPos == 1) { l('game').style.bottom = '48px'; } else { // No bars l('game').style.bottom = '0px'; } if (CM.Config.TimerBar == 1 && CM.Config.TimerBarPos == 0) { l('sectionLeft').style.top = '48px'; } else { l('sectionLeft').style.top = ''; } CM.Disp.UpdateBackground(); } CM.Disp.UpdateBuildings = function() { if (CM.Config.BuildColor == 1 && Game.buyMode == 1) { var target = ''; if (Game.buyBulk == 10 && CM.Config.BulkBuildColor == 1) { target = 'Objects10'; } else if (Game.buyBulk == 100 && CM.Config.BulkBuildColor == 1) { target = 'Objects100'; } else { target = 'Objects'; } for (var i in CM.Cache[target]) { l('productPrice' + Game.Objects[i].id).style.color = CM.Config.Colors[CM.Cache[target][i].color]; } } else { for (var i in CM.Cache.Objects) { var o = Game.Objects[i]; l('productPrice' + o.id).style.color = ''; /* * Fix sell price displayed in the object in the store. * * The buildings sell price displayed by the game itself (without any mod) is incorrect. * The following line of code fixes this issue, and can be safely removed when the game gets fixed. * * This issue is extensively detailed here: https://github.com/Aktanusa/CookieMonster/issues/359#issuecomment-735658262 */ l('productPrice' + o.id).innerHTML = Beautify(CM.Sim.BuildingSell(o, o.basePrice, o.amount, o.free, Game.buyBulk, 1)); } } // Build array of pointers, sort by pp, use array index (+2) as the grid row number // (grid rows are 1-based indexing, and row 1 is the bulk buy/sell options) if (Game.buyMode == 1 && CM.Config.SortBuildings) { var arr = Object.keys(CM.Cache[target]).map(k => { var o = CM.Cache[target][k]; o.name = k; o.id = Game.Objects[k].id; return o; }); 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); } } else { var arr = Object.keys(CM.Cache.Objects).map(k => { var o = CM.Cache.Objects[k]; o.name = k; o.id = Game.Objects[k].id; return o; }); arr.sort((a, b) => a.id - b.id); for (var x = 0; x < arr.length; x++) { Game.Objects[arr[x].name].l.style.gridRow = (x + 2) + "/" + (x + 2); } } } CM.Disp.CreateUpgradeBar = function() { CM.Disp.UpgradeBar = document.createElement('div'); CM.Disp.UpgradeBar.id = 'CMUpgradeBar'; CM.Disp.UpgradeBar.style.width = '100%'; CM.Disp.UpgradeBar.style.backgroundColor = 'black'; 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.onmouseout = function() { Game.tooltip.hide(); }; var placeholder = document.createElement('div'); var legend = document.createElement('div'); legend.style.minWidth = '330px'; legend.style.marginBottom = '4px'; var 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'); div.style.verticalAlign = 'middle'; var span = document.createElement('span'); span.className = CM.Disp.colorBackPre + color; span.style.display = 'inline-block'; span.style.height = '10px'; span.style.width = '10px'; span.style.marginRight = '4px'; 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')); legend.appendChild(legendLine(CM.Disp.colorYellow, 'Between best and worst PP buildings closer to best')); legend.appendChild(legendLine(CM.Disp.colorOrange, 'Between best and worst PP buildings closer to worst')); legend.appendChild(legendLine(CM.Disp.colorRed, 'Same as worst PP building')); legend.appendChild(legendLine(CM.Disp.colorPurple, 'Worse than worst PP building')); legend.appendChild(legendLine(CM.Disp.colorGray, 'Negative or infinity PP')); placeholder.appendChild(legend); CM.Disp.UpgradeBar.onmouseover = function() {Game.tooltip.draw(this, escape(placeholder.innerHTML), 'store');}; var upgradeNumber = function(id, color) { var span = document.createElement('span'); span.id = id; span.className = CM.Disp.colorTextPre + color; span.style.width = '14.28571428571429%'; 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)); CM.Disp.UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarOrange', CM.Disp.colorOrange)); CM.Disp.UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarRed', CM.Disp.colorRed)); CM.Disp.UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarPurple', CM.Disp.colorPurple)); CM.Disp.UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarGray', CM.Disp.colorGray)); l('upgrades').parentNode.insertBefore(CM.Disp.UpgradeBar, l('upgrades').parentNode.childNodes[3]); } CM.Disp.ToggleUpBarColor = function() { if (CM.Config.UpBarColor == 1) { CM.Disp.UpgradeBar.style.display = ''; CM.Disp.UpdateUpgrades(); } else if (CM.Config.UpBarColor == 2) { CM.Disp.UpgradeBar.style.display = 'none'; CM.Disp.UpdateUpgrades(); } else { CM.Disp.UpgradeBar.style.display = 'none'; Game.RebuildUpgrades(); } } CM.Disp.UpdateUpgrades = function() { if (CM.Config.UpBarColor > 0) { var blue = 0; var green = 0; var yellow = 0; var orange = 0; var red = 0; var purple = 0; var gray = 0; for (var i in Game.UpgradesInStore) { var me = Game.UpgradesInStore[i]; var addedColor = false; for (var 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; break; } } if (!addedColor) { var div = document.createElement('div'); div.style.width = '10px'; div.style.height = '10px'; div.className = CM.Disp.colorBackPre + CM.Cache.Upgrades[me.name].color; l('upgrade' + i).appendChild(div); } if (CM.Cache.Upgrades[me.name].color == CM.Disp.colorBlue) blue++; else if (CM.Cache.Upgrades[me.name].color == CM.Disp.colorGreen) green++; else if (CM.Cache.Upgrades[me.name].color == CM.Disp.colorYellow) yellow++; else if (CM.Cache.Upgrades[me.name].color == CM.Disp.colorOrange) orange++; else if (CM.Cache.Upgrades[me.name].color == CM.Disp.colorRed) red++; else if (CM.Cache.Upgrades[me.name].color == CM.Disp.colorPurple) purple++; else if (CM.Cache.Upgrades[me.name].color == CM.Disp.colorGray) gray++; } l('CMUpgradeBarBlue').textContent = blue; l('CMUpgradeBarGreen').textContent = green; l('CMUpgradeBarYellow').textContent = yellow; l('CMUpgradeBarOrange').textContent = orange; l('CMUpgradeBarRed').textContent = red; l('CMUpgradeBarPurple').textContent = purple; l('CMUpgradeBarGray').textContent = gray; } // Build array of pointers, sort by pp, set flex positions var arr = []; for (var x = 0; x < Game.UpgradesInStore.length; x++){ var o = {}; o.name = Game.UpgradesInStore[x].name; o.price = Game.UpgradesInStore[x].basePrice; o.pp = CM.Cache.Upgrades[o.name].pp; arr.push(o); } if (CM.Config.SortUpgrades) arr.sort((a, b) => a.pp - b.pp); 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 } } CM.Disp.UpdateColors = function() { var str = ''; for (var i = 0; i < CM.Disp.colors.length; i++) { str += '.' + CM.Disp.colorTextPre + CM.Disp.colors[i] + ' { color: ' + CM.Config.Colors[CM.Disp.colors[i]] + '; }\n'; } for (var i = 0; i < CM.Disp.colors.length; i++) { str += '.' + CM.Disp.colorBackPre + CM.Disp.colors[i] + ' { background-color: ' + CM.Config.Colors[CM.Disp.colors[i]] + '; }\n'; } for (var i = 0; i < CM.Disp.colors.length; i++) { str += '.' + CM.Disp.colorBorderPre + CM.Disp.colors[i] + ' { border: 1px solid ' + CM.Config.Colors[CM.Disp.colors[i]] + '; }\n'; } CM.Disp.Css.textContent = str; CM.Disp.UpdateBuildings(); // Class has been already set } CM.Disp.ToggleUpgradeBarFixedPos = function() { if (CM.Config.UpgradeBarFixedPos == 1) { CM.Disp.UpgradeBar.style.position = 'sticky'; CM.Disp.UpgradeBar.style.top = '0px'; } else { CM.Disp.UpgradeBar.style.position = ''; } } CM.Disp.CreateWhiteScreen = function() { CM.Disp.WhiteScreen = document.createElement('div'); CM.Disp.WhiteScreen.id = 'CMWhiteScreen'; CM.Disp.WhiteScreen.style.width = '100%'; CM.Disp.WhiteScreen.style.height = '100%'; CM.Disp.WhiteScreen.style.backgroundColor = 'white'; CM.Disp.WhiteScreen.style.display = 'none'; CM.Disp.WhiteScreen.style.zIndex = '9999999999'; CM.Disp.WhiteScreen.style.position = 'absolute'; l('wrapper').appendChild(CM.Disp.WhiteScreen); } CM.Disp.Flash = function(mode, config) { if ((CM.Config[config] == 1 && mode == 3) || mode == 1) { CM.Disp.WhiteScreen.style.opacity = '0.5'; if (mode == 3) { CM.Disp.WhiteScreen.style.display = 'inline'; setTimeout(function() {CM.Disp.Flash(2, config);}, 1000/Game.fps); } else { setTimeout(function() {CM.Disp.Flash(0, config);}, 1000/Game.fps); } } else if (mode == 2) { CM.Disp.WhiteScreen.style.opacity = '1'; setTimeout(function() {CM.Disp.Flash(1, config);}, 1000/Game.fps); } else if (mode == 0) { CM.Disp.WhiteScreen.style.display = 'none'; } } CM.Disp.PlaySound = function(url, sndConfig, volConfig) { if (CM.Config[sndConfig] == 1) { var sound = new realAudio(url); sound.volume = CM.Config[volConfig] / 100; sound.play(); } } CM.Disp.Notification = function(notifyConfig, title, message) { if (CM.Config[notifyConfig] == 1 && document.visibilityState == 'hidden') { var CookieIcon = 'https://orteil.dashnet.org/cookieclicker/favicon.ico' var notification = new Notification(title, {body: message, badge: CookieIcon}); } } CM.Disp.FindShimmer = function() { CM.Disp.currSpawnedGoldenCookieState = 0 CM.Disp.goldenShimmersByID = {} for (var i in Game.shimmers) { CM.Disp.goldenShimmersByID[Game.shimmers[i].id] = Game.shimmers[i] if (Game.shimmers[i].spawnLead && Game.shimmers[i].type == 'golden') { CM.Disp.spawnedGoldenShimmer = Game.shimmers[i]; CM.Disp.currSpawnedGoldenCookieState += 1; } } } CM.Disp.CreateFavicon = function() { CM.Disp.Favicon = document.createElement('link'); CM.Disp.Favicon.id = 'CMFavicon'; 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); } CM.Disp.UpdateFavicon = function() { if (CM.Config.Favicon == 1) { if (CM.Disp.spawnedGoldenShimmer.wrath) { CM.Disp.Favicon.href = 'https://aktanusa.github.io/CookieMonster/favicon/wrathCookie.ico'; } 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'; } } CM.Disp.CreateGCTimer = function(cookie) { GCTimer = document.createElement('div'); GCTimer.id = 'GCTimer' + cookie.id GCTimer.style.width = '96px'; GCTimer.style.height = '96px'; GCTimer.style.position = 'absolute'; GCTimer.style.zIndex = '10000000001'; GCTimer.style.textAlign = 'center'; GCTimer.style.lineHeight = '96px'; GCTimer.style.fontFamily = '\"Kavoon\", Georgia, serif'; GCTimer.style.fontSize = '35px'; GCTimer.style.cursor = 'pointer'; GCTimer.style.display = 'block'; GCTimer.style.left = cookie.l.style.left; GCTimer.style.top = cookie.l.style.top; GCTimer.onclick = function () {cookie.pop();}; GCTimer.onmouseover = function() {cookie.l.style.filter = 'brightness(125%) drop-shadow(0px 0px 3px rgba(255,255,255,1))'; cookie.l.style.webkitFilter = 'brightness(125%) drop-shadow(0px 0px 3px rgba(255,255,255,1))';}; GCTimer.onmouseout = function() {cookie.l.style.filter = ''; cookie.l.style.webkitFilter = '';}; CM.Disp.GCTimers[cookie.id] = GCTimer; l('shimmers').appendChild(GCTimer); } CM.Disp.ToggleGCTimer = function() { if (CM.Config.GCTimer == 1) { if (CM.Disp.lastGoldenCookieState) { for (var i in CM.Disp.GCTimers) { CM.Disp.GCTimers[i].style.display = 'block'; CM.Disp.GCTimers[i].style.left = CM.Disp.goldenShimmersByID[i].l.style.left; CM.Disp.GCTimers[i].style.top = CM.Disp.goldenShimmersByID[i].l.style.top; } } } else { for (var i in CM.Disp.GCTimers) { CM.Disp.GCTimers[i].style.display = 'none'; } } } CM.Disp.CheckGoldenCookie = function() { CM.Disp.FindShimmer(); for (var i in CM.Disp.GCTimers) { if (typeof CM.Disp.goldenShimmersByID[i] == "undefined") { CM.Disp.GCTimers[i].parentNode.removeChild(CM.Disp.GCTimers[i]); // TODO remove delete here delete CM.Disp.GCTimers[i]; } } if (CM.Disp.lastGoldenCookieState != Game.shimmerTypes['golden'].n) { CM.Disp.lastGoldenCookieState = Game.shimmerTypes['golden'].n; if (CM.Disp.lastGoldenCookieState) { if (CM.Disp.lastSpawnedGoldenCookieState < CM.Disp.currSpawnedGoldenCookieState) { CM.Disp.Flash(3, 'GCFlash'); CM.Disp.PlaySound(CM.Config.GCSoundURL, 'GCSound', 'GCVolume'); CM.Disp.Notification('GCNotification', "Golden Cookie Spawned", "A Golden Cookie has spawned. Click it now!") } CM.Disp.lastSpawnedGoldenCookieState = CM.Disp.currSpawnedGoldenCookieState CM.Disp.UpdateFavicon(); if (CM.Config.GCTimer == 1) { for (var i in Game.shimmers) { if (typeof CM.Disp.GCTimers[Game.shimmers[i].id] == "undefined") { CM.Disp.CreateGCTimer(Game.shimmers[i]); } } } } else if (CM.Config.GCTimer == 1) { for (var i in CM.Disp.GCTimers) { CM.Disp.GCTimers[i].style.display = 'none'; } } } else if (CM.Config.GCTimer == 1 && CM.Disp.lastGoldenCookieState) { for (var i in CM.Disp.GCTimers) { CM.Disp.GCTimers[i].style.opacity = CM.Disp.goldenShimmersByID[i].l.style.opacity; CM.Disp.GCTimers[i].style.transform = CM.Disp.goldenShimmersByID[i].l.style.transform; CM.Disp.GCTimers[i].textContent = Math.ceil(CM.Disp.goldenShimmersByID[i].life / Game.fps); } } } CM.Disp.CheckTickerFortune = function() { if (CM.Disp.lastTickerFortuneState != (Game.TickerEffect && Game.TickerEffect.type == 'fortune')) { CM.Disp.lastTickerFortuneState = (Game.TickerEffect && Game.TickerEffect.type == 'fortune'); if (CM.Disp.lastTickerFortuneState) { CM.Disp.Flash(3, 'FortuneFlash'); CM.Disp.PlaySound(CM.Config.FortuneSoundURL, 'FortuneSound', 'FortuneVolume'); CM.Disp.Notification('FortuneNotification', "Fortune Cookie found", "A Fortune Cookie has appeared on the Ticker.") } } } CM.Disp.CheckSeasonPopup = function() { if (CM.Disp.lastSeasonPopupState != Game.shimmerTypes['reindeer'].spawned) { CM.Disp.lastSeasonPopupState = Game.shimmerTypes['reindeer'].spawned; if (CM.Disp.lastSeasonPopupState && Game.season=='christmas') { // Needed for some of the functions to use the right object for (var i in Game.shimmers) { if (Game.shimmers[i].spawnLead && Game.shimmers[i].type == 'reindeer') { CM.Disp.seasonPopShimmer = Game.shimmers[i]; break; } } CM.Disp.Flash(3, 'SeaFlash'); CM.Disp.PlaySound(CM.Config.SeaSoundURL, 'SeaSound', 'SeaVolume'); CM.Disp.Notification('SeaNotification',"Reindeer sighted!", "A Reindeer has spawned. Click it now!") } } } CM.Disp.CheckGardenTick = function() { if (Game.Objects['Farm'].minigameLoaded && CM.Disp.lastGardenNextStep != Game.Objects['Farm'].minigame.nextStep) { if (CM.Disp.lastGardenNextStep != 0 && CM.Disp.lastGardenNextStep < Date.now()) { CM.Disp.Flash(3, 'GardFlash'); CM.Disp.PlaySound(CM.Config.GardSoundURL, 'GardSound', 'GardVolume'); } CM.Disp.lastGardenNextStep = Game.Objects['Farm'].minigame.nextStep; } } CM.Disp.CheckMagicMeter = function() { if (Game.Objects['Wizard tower'].minigameLoaded && CM.Config.GrimoireBar == 1) { var minigame = Game.Objects['Wizard tower'].minigame; if (minigame.magic < minigame.magicM) { CM.Disp.lastMagicBarFull = false; } else if (!CM.Disp.lastMagicBarFull) { CM.Disp.lastMagicBarFull = true; CM.Disp.Flash(3, 'MagicFlash'); CM.Disp.PlaySound(CM.Config.MagicSoundURL, 'MagicSound', 'MagicVolume'); CM.Disp.Notification('MagicNotification', "Magic Meter full", "Your Magic Meter is full. Cast a spell!") } } } CM.Disp.CheckWrinklerCount = function() { if (Game.elderWrath > 0) { var CurrentWrinklers = 0; for (var i in Game.wrinklers) { if (Game.wrinklers[i].phase == 2) CurrentWrinklers++; } if (CurrentWrinklers > CM.Disp.lastWrinklerCount) { CM.Disp.lastWrinklerCount = CurrentWrinklers if (CurrentWrinklers == Game.getWrinklersMax() && CM.Config.WrinklerMaxFlash) { CM.Disp.Flash(3, 'WrinklerMaxFlash'); } else { CM.Disp.Flash(3, 'WrinklerFlash'); } if (CurrentWrinklers == Game.getWrinklersMax() && CM.Config.WrinklerMaxSound) { CM.Disp.PlaySound(CM.Config.WrinklerMaxSoundURL, 'WrinklerMaxSound', 'WrinklerMaxVolume'); } else { CM.Disp.PlaySound(CM.Config.WrinklerSoundURL, 'WrinklerSound', 'WrinklerVolume'); } if (CurrentWrinklers == Game.getWrinklersMax() && CM.Config.WrinklerMaxNotification) { 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") } } else { CM.Disp.lastWrinklerCount = CurrentWrinklers } } } CM.Disp.UpdateTitle = function() { if (Game.OnAscend || CM.Config.Title == 0) { document.title = CM.Cache.Title; } else if (CM.Config.Title == 1) { var addFC = false; var addSP = false; var titleGC; var titleFC; var titleSP; if (CM.Disp.lastGoldenCookieState) { if (CM.Disp.spawnedGoldenShimmer.wrath) { titleGC = '[W ' + Math.ceil(CM.Disp.spawnedGoldenShimmer.life / Game.fps) + ']'; } else { titleGC = '[G ' + Math.ceil(CM.Disp.spawnedGoldenShimmer.life / Game.fps) + ']'; } } else if (!Game.Has('Golden switch [off]')) { titleGC = '[' + Math.ceil((Game.shimmerTypes['golden'].maxTime - Game.shimmerTypes['golden'].time) / Game.fps) + ']'; } else { titleGC = '[GS]' } if (CM.Disp.lastTickerFortuneState) { addFC = true; titleFC = '[F]'; } if (Game.season == 'christmas') { addSP = true; if (CM.Disp.lastSeasonPopupState) { titleSP = '[R ' + Math.ceil(CM.Disp.seasonPopShimmer.life / Game.fps) + ']'; } else { titleSP = '[' + Math.ceil((Game.shimmerTypes['reindeer'].maxTime - Game.shimmerTypes['reindeer'].time) / Game.fps) + ']'; } } var 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.Config.Title == 2) { var str = ''; var spawn = false; if (CM.Disp.lastGoldenCookieState) { spawn = true; if (CM.Disp.spawnedGoldenShimmer.wrath) { str += '[W ' + Math.ceil(CM.Disp.spawnedGoldenShimmer.life / Game.fps) + ']'; } else { str += '[G ' + Math.ceil(CM.Disp.spawnedGoldenShimmer.life / Game.fps) + ']'; } } if (CM.Disp.lastTickerFortuneState) { spawn = true; str += '[F]'; } if (Game.season == 'christmas' && CM.Disp.lastSeasonPopupState) { str += '[R ' + Math.ceil(CM.Disp.seasonPopShimmer.life / Game.fps) + ']'; spawn = true; } if (spawn) str += ' - '; var title = 'Cookie Clicker'; if (Game.season == 'fools') title = 'Cookie Baker'; str += title; document.title = str; } } CM.Disp.CollectWrinklers = function() { for (var i in Game.wrinklers) { if (Game.wrinklers[i].sucked > 0 && Game.wrinklers[i].type == 0) { Game.wrinklers[i].hp = 0; } } } CM.Disp.CreateTooltip = function(placeholder, text, minWidth) { CM.Disp[placeholder] = document.createElement('div'); var desc = document.createElement('div'); desc.style.minWidth = minWidth; desc.style.marginBottom = '4px'; var div = document.createElement('div'); div.style.textAlign = 'left'; div.textContent = text; desc.appendChild(div); CM.Disp[placeholder].appendChild(desc); } CM.Disp.AddMenuPref = function(title) { var header = function(text, config) { var 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.appendChild(document.createTextNode(text + ' ')); var span = document.createElement('span'); span.style.cursor = 'pointer'; span.style.display = 'inline-block'; span.style.height = '14px'; span.style.width = '14px'; span.style.borderRadius = '7px'; span.style.textAlign = 'center'; span.style.backgroundColor = '#C0C0C0'; span.style.color = 'black'; span.style.fontSize = '13px'; span.style.verticalAlign = 'middle'; span.textContent = CM.Config.MenuPref[config] ? '-' : '+'; span.onclick = function() {CM.ToggleMenuConfig(config); Game.UpdateMenu();}; div.appendChild(span); return div; } var frag = document.createDocumentFragment(); frag.appendChild(title()); var listing = function(config) { var div = document.createElement('div'); div.className = 'listing'; var a = document.createElement('a'); if (CM.ConfigData[config].toggle && CM.Config[config] == 0) { a.className = 'option off'; } else { a.className = 'option'; } a.id = CM.ConfigPrefix + config; a.onclick = function() {CM.ToggleConfig(config);}; a.textContent = CM.Disp.GetConfigDisplay(config); div.appendChild(a); var label = document.createElement('label'); label.textContent = CM.ConfigData[config].desc; div.appendChild(label); return div; } var vol = function(config) { var volConfig = config; var volume = document.createElement('div'); volume.className = 'listing'; var minus = document.createElement('a'); minus.className = 'option'; minus.onclick = function() {CM.ToggleConfigDown(volConfig);}; minus.textContent = '-'; volume.appendChild(minus); var volText = document.createElement('span'); volText.id = CM.ConfigPrefix + volConfig; volText.textContent = CM.Disp.GetConfigDisplay(volConfig); volume.appendChild(volText); var plus = document.createElement('a'); plus.className = 'option'; plus.onclick = function() {CM.ToggleConfigUp(volConfig);}; plus.textContent = '+'; volume.appendChild(plus); var volLabel = document.createElement('label'); volLabel.textContent = CM.ConfigData[volConfig].desc; volume.appendChild(volLabel); return volume; } var url = function(config) { var div = document.createElement('div'); div.className = 'listing'; var span = document.createElement('span'); span.className = 'option'; span.textContent = CM.ConfigData[config].label + ' '; div.appendChild(span); var input = document.createElement('input'); input.id = CM.ConfigPrefix + config; input.className = 'option'; input.type = 'text'; input.readOnly = true; input.setAttribute('value', CM.Config[config]); input.style.width = '300px'; div.appendChild(input); div.appendChild(document.createTextNode(' ')); var inputPrompt = document.createElement('input'); inputPrompt.id = CM.ConfigPrefix + config + 'Prompt'; inputPrompt.className = 'option'; inputPrompt.type = 'text'; inputPrompt.setAttribute('value', CM.Config[config]); var a = document.createElement('a'); a.className = 'option'; a.onclick = function() {Game.Prompt(inputPrompt.outerHTML, [['Save', 'CM.Config[\'' + config + '\'] = l(CM.ConfigPrefix + \'' + config + '\' + \'Prompt\').value; CM.SaveConfig(CM.Config); Game.ClosePrompt(); Game.UpdateMenu();'], 'Cancel']);}; a.textContent = 'Edit'; div.appendChild(a); var label = document.createElement('label'); label.textContent = CM.ConfigData[config].desc; div.appendChild(label); return div; } frag.appendChild(header('Bars/Colors', 'BarsColors')); if (CM.Config.MenuPref.BarsColors) { frag.appendChild(listing('BotBar')); frag.appendChild(listing('TimerBar')); frag.appendChild(listing('TimerBarPos')); frag.appendChild(listing('SortBuildings')); frag.appendChild(listing('SortUpgrades')); frag.appendChild(listing('BuildColor')); frag.appendChild(listing('BulkBuildColor')); frag.appendChild(listing('ColorPPBulkMode')); frag.appendChild(listing('UpBarColor')); for (var i = 0; i < CM.Disp.colors.length; i++) { var div = document.createElement('div'); div.className = 'listing'; var input = document.createElement('input'); input.id = CM.ConfigPrefix + 'Color' + CM.Disp.colors[i]; input.className = 'option'; input.style.width = '65px'; input.setAttribute('value', CM.Config.Colors[CM.Disp.colors[i]]); div.appendChild(input); eval('var change = function() {CM.Config.Colors[\'' + CM.Disp.colors[i] + '\'] = l(CM.ConfigPrefix + \'Color\' + \'' + CM.Disp.colors[i] + '\').value; CM.Disp.UpdateColors(); CM.SaveConfig(CM.Config);}'); var jscolorpicker = new jscolor.color(input, {hash: true, caps: false, pickerZIndex: 1000000, pickerPosition: 'right', onImmediateChange: change}); var label = document.createElement('label'); label.textContent = CM.ConfigData.Colors.desc[CM.Disp.colors[i]]; div.appendChild(label); frag.appendChild(div); } frag.appendChild(listing('UpgradeBarFixedPos')); } frag.appendChild(header('Calculation', 'Calculation')); if (CM.Config.MenuPref.Calculation) { frag.appendChild(listing('CalcWrink')); frag.appendChild(listing('CPSMode')); frag.appendChild(listing('AvgCPSHist')); frag.appendChild(listing('AvgClicksHist')); frag.appendChild(listing('ToolWarnBon')); } frag.appendChild(header('Notification', 'Notification')); if (CM.Config.MenuPref.Notification) { frag.appendChild(listing('GCNotification')); frag.appendChild(listing('GCFlash')); frag.appendChild(listing('GCSound')); frag.appendChild(vol('GCVolume')); frag.appendChild(url('GCSoundURL')); frag.appendChild(listing('GCTimer')); frag.appendChild(listing('Favicon')); frag.appendChild(listing('FortuneNotification')); frag.appendChild(listing('FortuneFlash')); frag.appendChild(listing('FortuneSound')); frag.appendChild(vol('FortuneVolume')); frag.appendChild(url('FortuneSoundURL')); frag.appendChild(listing('SeaNotification')); frag.appendChild(listing('SeaFlash')); frag.appendChild(listing('SeaSound')); frag.appendChild(vol('SeaVolume')); frag.appendChild(url('SeaSoundURL')); frag.appendChild(listing('GardFlash')); frag.appendChild(listing('GardSound')); frag.appendChild(vol('GardVolume')); frag.appendChild(url('GardSoundURL')); frag.appendChild(listing('MagicNotification')); frag.appendChild(listing('MagicFlash')); frag.appendChild(listing('MagicSound')); frag.appendChild(vol('MagicVolume')); frag.appendChild(url('MagicSoundURL')); frag.appendChild(listing('WrinklerNotification')); frag.appendChild(listing('WrinklerFlash')); frag.appendChild(listing('WrinklerSound')); frag.appendChild(vol('WrinklerVolume')); frag.appendChild(url('WrinklerSoundURL')); frag.appendChild(listing('WrinklerMaxNotification')); frag.appendChild(listing('WrinklerMaxFlash')); frag.appendChild(listing('WrinklerMaxSound')); frag.appendChild(vol('WrinklerMaxVolume')); frag.appendChild(url('WrinklerMaxSoundURL')); frag.appendChild(listing('Title')); } frag.appendChild(header('Tooltip', 'Tooltip')); if (CM.Config.MenuPref.Tooltip) { frag.appendChild(listing('TooltipBuildUp')); frag.appendChild(listing('TooltipAmor')); frag.appendChild(listing('ToolWarnLucky')); frag.appendChild(listing('ToolWarnConjure')); frag.appendChild(listing('ToolWarnPos')); frag.appendChild(listing('TooltipGrim')); frag.appendChild(listing('ToolWrink')); frag.appendChild(listing('TooltipLump')); } frag.appendChild(header('Statistics', 'Statistics')); if (CM.Config.MenuPref.Statistics) { frag.appendChild(listing('Stats')); frag.appendChild(listing('MissingUpgrades')); frag.appendChild(listing('UpStats')); frag.appendChild(listing('TimeFormat')); frag.appendChild(listing('SayTime')); frag.appendChild(listing('GrimoireBar')); } frag.appendChild(header('Other', 'Other')); if (CM.Config.MenuPref.Other) { frag.appendChild(listing('Scale')); var resDef = document.createElement('div'); resDef.className = 'listing'; var resDefBut = document.createElement('a'); resDefBut.className = 'option'; resDefBut.onclick = function() {CM.RestoreDefault();}; resDefBut.textContent = 'Restore Default'; resDef.appendChild(resDefBut); frag.appendChild(resDef); } l('menu').childNodes[2].insertBefore(frag, l('menu').childNodes[2].childNodes[l('menu').childNodes[2].childNodes.length - 1]); CM.Disp.FormatButtonOnClickBak = l('formatButton').onclick; eval('l(\'formatButton\').onclick = ' + l('formatButton').onclick.toString().split('mp3\');').join('mp3\'); CM.Disp.RefreshScale();')); //l('formatButton').onclick = function() {Game.Toggle('format', 'formatButton', 'Short numbers OFF', 'Short numbers ON', '1'); PlaySound('snd/tick.mp3'); CM.Disp.RefreshScale();}; } CM.Disp.AddMenuStats = function(title) { var header = function(text, config) { var 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.appendChild(document.createTextNode(text + ' ')); var span = document.createElement('span'); span.style.cursor = 'pointer'; span.style.display = 'inline-block'; span.style.height = '14px'; span.style.width = '14px'; span.style.borderRadius = '7px'; span.style.textAlign = 'center'; span.style.backgroundColor = '#C0C0C0'; span.style.color = 'black'; span.style.fontSize = '13px'; span.style.verticalAlign = 'middle'; span.textContent = CM.Config.StatsPref[config] ? '-' : '+'; span.onclick = function() {CM.ToggleStatsConfig(config); Game.UpdateMenu();}; div.appendChild(span); return div; } var stats = document.createElement('div'); stats.className = 'subsection'; stats.appendChild(title()); var listing = function(name, text) { var div = document.createElement('div'); div.className = 'listing'; var b = document.createElement('b'); if (typeof name == 'string') b.appendChild(document.createTextNode(name)); else b.appendChild(name); // fragment b.appendChild(document.createTextNode(' : ')); div.appendChild(b); div.appendChild(text); return div; } var listingQuest = function(text, placeholder) { var frag = document.createDocumentFragment(); frag.appendChild(document.createTextNode(text + ' ')); var span = document.createElement('span'); span.onmouseout = function() { Game.tooltip.hide(); }; span.onmouseover = function() {Game.tooltip.draw(this, escape(CM.Disp[placeholder].innerHTML));}; span.style.cursor = 'default'; span.style.display = 'inline-block'; span.style.height = '10px'; span.style.width = '10px'; span.style.borderRadius = '5px'; span.style.textAlign = 'center'; span.style.backgroundColor = '#C0C0C0'; span.style.color = 'black'; span.style.fontSize = '9px'; span.style.verticalAlign = 'bottom'; span.textContent = '?'; frag.appendChild(span); return frag; } var createMissDisp = function(theMissDisp) { var frag = document.createDocumentFragment(); frag.appendChild(document.createTextNode(theMissDisp.length + ' ')); var 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'); title.className = 'name'; title.style.marginBottom = '4px'; title.style.textAlign = 'center'; title.textContent = 'Missing'; missing.appendChild(title); for (var i in theMissDisp) { var div = document.createElement('div'); div.style.textAlign = 'center'; div.appendChild(document.createTextNode(theMissDisp[i])); missing.appendChild(div); } placeholder.appendChild(missing); span.onmouseover = function() {Game.tooltip.draw(this, escape(placeholder.innerHTML));}; span.style.cursor = 'default'; span.style.display = 'inline-block'; span.style.height = '10px'; span.style.width = '10px'; span.style.borderRadius = '5px'; span.style.textAlign = 'center'; span.style.backgroundColor = '#C0C0C0'; span.style.color = 'black'; span.style.fontSize = '9px'; span.style.verticalAlign = 'bottom'; span.textContent = '?'; frag.appendChild(span); return frag; } var goldCookTooltip = CM.Sim.auraMult('Dragon\'s Fortune') ? 'GoldCookDragonsFortuneTooltipPlaceholder' : 'GoldCookTooltipPlaceholder'; stats.appendChild(header('Lucky Cookies', 'Lucky')); if (CM.Config.StatsPref.Lucky) { var luckyColor = ((Game.cookies + CM.Disp.GetWrinkConfigBank()) < CM.Cache.Lucky) ? CM.Disp.colorRed : CM.Disp.colorGreen; var luckyTime = ((Game.cookies + CM.Disp.GetWrinkConfigBank()) < CM.Cache.Lucky) ? CM.Disp.FormatTime((CM.Cache.Lucky - (Game.cookies + CM.Disp.GetWrinkConfigBank())) / CM.Disp.GetCPS()) : ''; var luckyColorFrenzy = ((Game.cookies + CM.Disp.GetWrinkConfigBank()) < CM.Cache.LuckyFrenzy) ? CM.Disp.colorRed : CM.Disp.colorGreen; var luckyTimeFrenzy = ((Game.cookies + CM.Disp.GetWrinkConfigBank()) < CM.Cache.LuckyFrenzy) ? CM.Disp.FormatTime((CM.Cache.LuckyFrenzy - (Game.cookies + CM.Disp.GetWrinkConfigBank())) / CM.Disp.GetCPS()) : ''; var luckyCurBase = Math.min((Game.cookies + CM.Disp.GetWrinkConfigBank()) * 0.15, CM.Cache.NoGoldSwitchCookiesPS * CM.Cache.DragonsFortuneMultAdjustment * 60 * 15) + 13; var luckyRewardMax = CM.Cache.LuckyReward; var luckyRewardMaxWrath = CM.Cache.LuckyWrathReward; var luckyRewardFrenzyMax = CM.Cache.LuckyRewardFrenzy; var luckyRewardFrenzyMaxWrath = CM.Cache.LuckyWrathRewardFrenzy; var luckyCur = CM.Cache.GoldenCookiesMult * luckyCurBase; var luckyCurWrath = CM.Cache.WrathCookiesMult * luckyCurBase; var luckySplit = luckyRewardMax != luckyRewardMaxWrath; var luckyReqFrag = document.createDocumentFragment(); var luckyReqSpan = document.createElement('span'); luckyReqSpan.style.fontWeight = 'bold'; luckyReqSpan.className = CM.Disp.colorTextPre + luckyColor; luckyReqSpan.textContent = Beautify(CM.Cache.Lucky); luckyReqFrag.appendChild(luckyReqSpan); if (luckyTime != '') { var luckyReqSmall = document.createElement('small'); luckyReqSmall.textContent = ' (' + luckyTime + ')'; luckyReqFrag.appendChild(luckyReqSmall); } stats.appendChild(listing(listingQuest('\"Lucky!\" Cookies Required', goldCookTooltip), luckyReqFrag)); var luckyReqFrenFrag = document.createDocumentFragment(); var luckyReqFrenSpan = document.createElement('span'); luckyReqFrenSpan.style.fontWeight = 'bold'; luckyReqFrenSpan.className = CM.Disp.colorTextPre + luckyColorFrenzy; luckyReqFrenSpan.textContent = Beautify(CM.Cache.LuckyFrenzy); luckyReqFrenFrag.appendChild(luckyReqFrenSpan); if (luckyTimeFrenzy != '') { var luckyReqFrenSmall = document.createElement('small'); luckyReqFrenSmall.textContent = ' (' + luckyTimeFrenzy + ')'; luckyReqFrenFrag.appendChild(luckyReqFrenSmall); } stats.appendChild(listing(listingQuest('\"Lucky!\" Cookies Required (Frenzy)', goldCookTooltip), luckyReqFrenFrag)); stats.appendChild(listing(listingQuest('\"Lucky!\" Reward (MAX)' + (luckySplit ? ' (Golden / Wrath)' : ''), goldCookTooltip), document.createTextNode(Beautify(luckyRewardMax) + (luckySplit ? (' / ' + Beautify(luckyRewardMaxWrath)) : '')))); stats.appendChild(listing(listingQuest('\"Lucky!\" Reward (MAX) (Frenzy)' + (luckySplit ? ' (Golden / Wrath)' : ''), goldCookTooltip), document.createTextNode(Beautify(luckyRewardFrenzyMax) + (luckySplit ? (' / ' + Beautify(luckyRewardFrenzyMaxWrath)) : '')))); stats.appendChild(listing(listingQuest('\"Lucky!\" Reward (CUR)' + (luckySplit ? ' (Golden / Wrath)' : ''), goldCookTooltip), document.createTextNode(Beautify(luckyCur) + (luckySplit ? (' / ' + Beautify(luckyCurWrath)) : '')))); } stats.appendChild(header('Chain Cookies', 'Chain')); if (CM.Config.StatsPref.Chain) { var chainColor = ((Game.cookies + CM.Disp.GetWrinkConfigBank()) < CM.Cache.Chain) ? CM.Disp.colorRed : CM.Disp.colorGreen; var chainTime = ((Game.cookies + CM.Disp.GetWrinkConfigBank()) < CM.Cache.Chain) ? CM.Disp.FormatTime((CM.Cache.Chain - (Game.cookies + CM.Disp.GetWrinkConfigBank())) / CM.Disp.GetCPS()) : ''; 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()) : ''; 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()) : ''; 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()) : ''; var chainRewardMax = CM.Cache.ChainReward; var chainWrathRewardMax = CM.Cache.ChainWrathReward; var chainFrenzyRewardMax = CM.Cache.ChainFrenzyReward; var chainFrenzyWrathRewardMax = CM.Cache.ChainFrenzyWrathReward; 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); var chainReqFrag = document.createDocumentFragment(); var chainReqSpan = document.createElement('span'); chainReqSpan.style.fontWeight = 'bold'; chainReqSpan.className = CM.Disp.colorTextPre + chainColor; chainReqSpan.textContent = Beautify(CM.Cache.Chain); chainReqFrag.appendChild(chainReqSpan); if (chainTime != '') { var chainReqSmall = document.createElement('small'); chainReqSmall.textContent = ' (' + chainTime + ')'; chainReqFrag.appendChild(chainReqSmall); } stats.appendChild(listing(listingQuest('\"Chain\" Cookies Required', goldCookTooltip), chainReqFrag)); var chainWrathReqFrag = document.createDocumentFragment(); var chainWrathReqSpan = document.createElement('span'); chainWrathReqSpan.style.fontWeight = 'bold'; chainWrathReqSpan.className = CM.Disp.colorTextPre + chainWrathColor; chainWrathReqSpan.textContent = Beautify(CM.Cache.ChainWrath); chainWrathReqFrag.appendChild(chainWrathReqSpan); if (chainWrathTime != '') { var chainWrathReqSmall = document.createElement('small'); chainWrathReqSmall.textContent = ' (' + chainWrathTime + ')'; chainWrathReqFrag.appendChild(chainWrathReqSmall); } stats.appendChild(listing(listingQuest('\"Chain\" Cookies Required (Wrath)', goldCookTooltip), chainWrathReqFrag)); var chainReqFrenFrag = document.createDocumentFragment(); var chainReqFrenSpan = document.createElement('span'); chainReqFrenSpan.style.fontWeight = 'bold'; chainReqFrenSpan.className = CM.Disp.colorTextPre + chainColorFrenzy; chainReqFrenSpan.textContent = Beautify(CM.Cache.ChainFrenzy); chainReqFrenFrag.appendChild(chainReqFrenSpan); if (chainTimeFrenzy != '') { var chainReqFrenSmall = document.createElement('small'); chainReqFrenSmall.textContent = ' (' + chainTimeFrenzy + ')'; chainReqFrenFrag.appendChild(chainReqFrenSmall); } stats.appendChild(listing(listingQuest('\"Chain\" Cookies Required (Frenzy)', goldCookTooltip), chainReqFrenFrag)); var chainWrathReqFrenFrag = document.createDocumentFragment(); var chainWrathReqFrenFrag = document.createDocumentFragment(); var chainWrathReqFrenSpan = document.createElement('span'); chainWrathReqFrenSpan.style.fontWeight = 'bold'; chainWrathReqFrenSpan.className = CM.Disp.colorTextPre + chainWrathColorFrenzy; chainWrathReqFrenSpan.textContent = Beautify(CM.Cache.ChainFrenzyWrath); chainWrathReqFrenFrag.appendChild(chainWrathReqFrenSpan); if (chainWrathTimeFrenzy != '') { var chainWrathReqFrenSmall = document.createElement('small'); chainWrathReqFrenSmall.textContent = ' (' + chainWrathTimeFrenzy + ')'; chainWrathReqFrenFrag.appendChild(chainWrathReqFrenSmall); } stats.appendChild(listing(listingQuest('\"Chain\" Cookies Required (Frenzy) (Wrath)', goldCookTooltip), chainWrathReqFrenFrag)); stats.appendChild(listing(listingQuest('\"Chain\" Reward (MAX) (Golden / Wrath)', goldCookTooltip), document.createTextNode(Beautify(chainRewardMax) + ' / ' + Beautify(chainWrathRewardMax)))); stats.appendChild(listing(listingQuest('\"Chain\" Reward (MAX) (Frenzy) (Golden / Wrath)', goldCookTooltip), document.createTextNode(Beautify(chainFrenzyRewardMax) + ' / ' + Beautify(chainFrenzyWrathRewardMax)))); stats.appendChild(listing(listingQuest('\"Chain\" Reward (CUR) (Golden / Wrath)', goldCookTooltip), document.createTextNode(Beautify(chainCur) + ' / ' + Beautify(chainCurWrath)))); } stats.appendChild(header('Conjure Baked Goods', 'Conjure')); if (CM.Config.StatsPref.Conjure) { 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 conjureRewardMax = CM.Cache.ConjureReward; var conjureReqFrag = document.createDocumentFragment(); var conjureReqSpan = document.createElement('span'); conjureReqSpan.style.fontWeight = 'bold'; conjureReqSpan.className = CM.Disp.colorTextPre + conjureColor; conjureReqSpan.textContent = Beautify(CM.Cache.Conjure); conjureReqFrag.appendChild(conjureReqSpan); if (conjureTime != '') { var conjureReqSmall = document.createElement('small'); conjureReqSmall.textContent = ' (' + conjureTime + ')'; conjureReqFrag.appendChild(conjureReqSmall); } stats.appendChild(listing(listingQuest('\"Conjure Baked Goods\" Cookies Required', 'GoldCookTooltipPlaceholder'), conjureReqFrag)); stats.appendChild(listing(listingQuest('\"Conjure Baked Goods\" Reward (MAX)', 'GoldCookTooltipPlaceholder'), document.createTextNode(Beautify(conjureRewardMax)))); stats.appendChild(listing(listingQuest('\"Conjure Baked Goods\" Reward (CUR)', 'GoldCookTooltipPlaceholder'), document.createTextNode(Beautify(conjureCur)))); } var choEgg = (Game.HasUnlocked('Chocolate egg') && !Game.Has('Chocolate egg')); // Needs to be done for the checking below stats.appendChild(header('Prestige', 'Prestige')); if (CM.Config.StatsPref.Prestige) { var possiblePresMax = Math.floor(Game.HowMuchPrestige(CM.Cache.RealCookiesEarned + Game.cookiesReset + CM.Cache.WrinkGodBank + (choEgg ? CM.Cache.lastChoEgg : 0))); var neededCook = Game.HowManyCookiesReset(possiblePresMax + 1) - (CM.Cache.RealCookiesEarned + Game.cookiesReset + CM.Cache.WrinkGodBank + (choEgg ? CM.Cache.lastChoEgg : 0)); stats.appendChild(listing(listingQuest('Prestige Level (CUR / MAX)', 'PrestMaxTooltipPlaceholder'), document.createTextNode(Beautify(Game.prestige) + ' / ' + Beautify(possiblePresMax)))); var cookiesNextFrag = document.createDocumentFragment(); cookiesNextFrag.appendChild(document.createTextNode(Beautify(neededCook))); var cookiesNextSmall = document.createElement('small'); cookiesNextSmall.textContent = ' (' + (CM.Disp.FormatTime(neededCook / CM.Cache.AvgCPSChoEgg, 1)) + ')'; cookiesNextFrag.appendChild(cookiesNextSmall); stats.appendChild(listing(listingQuest('Cookies To Next Level', 'NextPrestTooltipPlaceholder'), cookiesNextFrag)); stats.appendChild(listing(listingQuest('Heavenly Chips (CUR / MAX)', 'HeavenChipMaxTooltipPlaceholder'), document.createTextNode(Beautify(Game.heavenlyChips) + ' / ' + Beautify((possiblePresMax - Game.prestige) + Game.heavenlyChips)))); var resetBonus = CM.Sim.ResetBonus(possiblePresMax); var resetFrag = document.createDocumentFragment(); resetFrag.appendChild(document.createTextNode(Beautify(resetBonus))); var increase = Math.round(resetBonus / Game.cookiesPs * 10000); if (isFinite(increase) && increase != 0) { var resetSmall = document.createElement('small'); resetSmall.textContent = ' (' + (increase / 100) + '% of income)'; resetFrag.appendChild(resetSmall); } stats.appendChild(listing(listingQuest('Reset Bonus Income', 'ResetTooltipPlaceholder'), resetFrag)); var currentPrestige = Math.floor(Game.HowMuchPrestige(Game.cookiesReset)); var willHave = Math.floor(Game.HowMuchPrestige(Game.cookiesReset + Game.cookiesEarned)); var willGet = willHave - currentPrestige; var addCommas = (n) => { var s1 = n.toString(); var s2 = ''; for (var i in s1) { if ((s1.length - i) % 3 == 0 && i > 0) s2 += ','; s2 += s1[i]; } return s2; }; if (!Game.Has('Lucky digit')) { var delta7 = 7 - (willHave % 10); if (delta7 < 0) delta7 += 10; var next7Reset = willGet + delta7; var next7Total = willHave + delta7; var frag7 = document.createDocumentFragment(); frag7.appendChild(document.createTextNode(addCommas(next7Total) + " / " + addCommas(next7Reset) + " (+" + delta7 + ")")); stats.appendChild(listing('Next "Lucky Digit" (total / reset)', frag7)); } if (!Game.Has('Lucky number')) { var delta777 = 777 - (willHave % 1000); if (delta777 < 0) delta777 += 1000; var next777Reset = willGet + delta777; var next777Total = willHave + delta777; var frag777 = document.createDocumentFragment(); frag777.appendChild(document.createTextNode(addCommas(next777Total) + " / " + addCommas(next777Reset) + " (+" + delta777 + ")")); stats.appendChild(listing('Next "Lucky Number" (total / reset)', frag777)); } if (!Game.Has('Lucky payout')) { var delta777777 = 777777 - (willHave % 1000000); if (delta777777 < 0) delta777777 += 1000000; var next777777Reset = willGet + delta777777; var next777777Total = willHave + delta777777; var frag777777 = document.createDocumentFragment(); frag777777.appendChild(document.createTextNode(addCommas(next777777Total) + " / " + addCommas(next777777Reset) + " (+" + delta777777 + ")")); stats.appendChild(listing('Next "Lucky Payout" (total / reset)', frag777777)); } } if (Game.cpsSucked > 0) { stats.appendChild(header('Wrinklers', 'Wrink')); if (CM.Config.StatsPref.Wrink) { var popAllFrag = document.createDocumentFragment(); popAllFrag.appendChild(document.createTextNode(Beautify(CM.Cache.WrinkBank) + ' ')); var popAllA = document.createElement('a'); popAllA.textContent = 'Pop All Normal'; popAllA.className = 'option'; popAllA.onclick = function() { CM.Disp.CollectWrinklers(); }; popAllFrag.appendChild(popAllA); stats.appendChild(listing('Rewards of Popping', popAllFrag)); } } var specDisp = false; var halloCook = []; for (var i in CM.Data.HalloCookies) { if (!Game.Has(CM.Data.HalloCookies[i])) { halloCook.push(CM.Data.HalloCookies[i]); specDisp = true; } } var christCook = []; for (var i in CM.Data.ChristCookies) { if (!Game.Has(CM.Data.ChristCookies[i])) { christCook.push(CM.Data.ChristCookies[i]); specDisp = true; } } var valCook = []; for (var i in CM.Data.ValCookies) { if (!Game.Has(CM.Data.ValCookies[i])) { valCook.push(CM.Data.ValCookies[i]); specDisp = true; } } var normEggs = []; for (var i in Game.eggDrops) { if (!Game.HasUnlocked(Game.eggDrops[i])) { normEggs.push(Game.eggDrops[i]); specDisp = true; } } var rareEggs = []; for (var i in Game.rareEggDrops) { if (!Game.HasUnlocked(Game.rareEggDrops[i])) { rareEggs.push(Game.rareEggDrops[i]); specDisp = true; } } var centEgg = Game.Has('Century egg'); if (Game.season == 'christmas' || specDisp || choEgg || centEgg) { stats.appendChild(header('Season Specials', 'Sea')); if (CM.Config.StatsPref.Sea) { if (specDisp) { if (halloCook.length != 0) stats.appendChild(listing('Halloween Cookies Left to Buy', createMissDisp(halloCook))); if (christCook.length != 0) stats.appendChild(listing('Christmas Cookies Left to Buy', createMissDisp(christCook))); if (valCook.length != 0) stats.appendChild(listing('Valentine Cookies Left to Buy', createMissDisp(valCook))); if (normEggs.length != 0) stats.appendChild(listing('Normal Easter Eggs Left to Unlock', createMissDisp(normEggs))); if (rareEggs.length != 0) stats.appendChild(listing('Rare Easter Eggs Left to Unlock', createMissDisp(rareEggs))); } if (Game.season == 'christmas') stats.appendChild(listing('Reindeer Reward', document.createTextNode(Beautify(CM.Cache.SeaSpec)))); if (choEgg) { stats.appendChild(listing(listingQuest('Chocolate Egg Cookies', 'ChoEggTooltipPlaceholder'), document.createTextNode(Beautify(CM.Cache.lastChoEgg)))); } if (centEgg) { stats.appendChild(listing('Century Egg Multiplier', document.createTextNode((Math.round((CM.Cache.CentEgg - 1) * 10000) / 100) + '%'))); } } } stats.appendChild(header('Miscellaneous', 'Misc')); if (CM.Config.StatsPref.Misc) { stats.appendChild(listing( 'Average Cookies Per Second (Past ' + (CM.Disp.cookieTimes[CM.Config.AvgCPSHist] < 60 ? (CM.Disp.cookieTimes[CM.Config.AvgCPSHist] + ' seconds') : ((CM.Disp.cookieTimes[CM.Config.AvgCPSHist] / 60) + (CM.Config.AvgCPSHist == 3 ? ' minute' : ' minutes'))) + ')', document.createTextNode(Beautify(CM.Cache.AvgCPS, 3)) )); stats.appendChild(listing('Average Cookie Clicks Per Second (Past ' + CM.Disp.clickTimes[CM.Config.AvgClicksHist] + (CM.Config.AvgClicksHist == 0 ? ' second' : ' seconds') + ')', document.createTextNode(Beautify(CM.Cache.AvgClicks, 1)))); if (Game.Has('Fortune cookies')) { var fortunes = []; for (var i in CM.Data.Fortunes) { if (!Game.Has(CM.Data.Fortunes[i])) { fortunes.push(CM.Data.Fortunes[i]); } } if (fortunes.length != 0) stats.appendChild(listing('Fortune Upgrades Left to Buy', createMissDisp(fortunes))); } stats.appendChild(listing('Missed Golden Cookies', document.createTextNode(Beautify(Game.missedGoldenClicks)))); if (Game.prefs.autosave) { var timeTillAutosave = Math.min((Game.fps*60 - (Game.T%(Game.fps*60))) / Game.fps, !Game.OnAscend * 60) stats.appendChild(listing('Seconds till autosave', document.createTextNode(Math.floor(timeTillAutosave)))); } } l('menu').insertBefore(stats, l('menu').childNodes[2]); } CM.Disp.AddMissingUpgrades = function() { if (CM.Cache.UpgradesOwned != Game.UpgradesOwned) { CM.Cache.CalcMissingUpgrades(); CM.Cache.MissingUpgradesString = null; CM.Cache.MissingCookiesString = null; } // Sort the lists of missing cookies & upgrades var sortMap = function(a,b) { if (a.order > b.order) return 1; else if (a.order < b.order) return -1; else return 0; } CM.Cache.MissingUpgrades.sort(sortMap); CM.Cache.MissingCookies.sort(sortMap);; // Find Upgrades-section of stats menu var upgradesMenu = null; for (var i = 0; i < l("menu").getElementsByClassName("subsection").length && upgradesMenu == null; i++) { if (l("menu").getElementsByClassName("subsection")[i].getElementsByClassName("title")[0].textContent === "Upgrades") { upgradesMenu = l("menu").getElementsByClassName("subsection")[i]; } } // This function creates div element from given object. It also adds tooltip for it. var createUpgradeElement = function (me) { return '