diff --git a/CookieMonster.js b/CookieMonster.js index b9f99be..3b037d0 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -43,6 +43,7 @@ if (typeof CM == "undefined") { CM.Cache.InitCache = function() { CM.Cache.CacheDragonAuras(); CM.Cache.CacheWrinklers(); + CM.Cache.CacheStats(); } /******** @@ -94,6 +95,60 @@ CM.Cache.CacheWrinklers = function() { } } +/******** + * Section: Functions related to Cachining stats */ + +/** + * This functions caches variables related to the stats apge + * It is called by CM.Loop() upon changes to cps and CM.Cache.InitCache() + * @global {number} CM.Cache.Lucky Cookies required for max Lucky + * @global {number} CM.Cache.LuckyReward Reward for max normal Lucky + * @global {number} CM.Cache.LuckyWrathReward Reward for max normal Lucky from Wrath cookie + * @global {number} CM.Cache.LuckyFrenzy Cookies required for max Lucky Frenzy + * @global {number} CM.Cache.LuckyRewardFrenzy Reward for max Lucky Frenzy + * @global {number} CM.Cache.LuckyWrathRewardFrenzy Reward for max Lucky Frenzy from Wrath cookie + * @global {number} CM.Cache.Conjure Cookies required for max Conjure Baked Goods + * @global {number} CM.Cache.ConjureReward Reward for max Conjure Baked Goods + * @global {number} CM.Cache.Edifice Cookies required for most expensive building through Spontaneous Edifice + * @global {string} CM.Cache.EdificeBuilding Name of most expensive building possible with Spontaneous Edifice + */ +CM.Cache.CacheStats = 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.Edifice = 0; + var max = 0; + var n = 0; + for (var i in Game.Objects) { + if (Game.Objects[i].amount > max) max = Game.Objects[i].amount; + if (Game.Objects[i].amount > 0) n++; + } + for (var i in Game.Objects) { + if ((Game.Objects[i].amount < max || n == 1) && + Game.Objects[i].amount < 400 && + Game.Objects[i].price * 2 > CM.Cache.Edifice) { + CM.Cache.Edifice = Game.Objects[i].price * 2; + CM.Cache.EdificeBuilding = i; + } + } +} + /******** * Section: UNSORTED */ @@ -314,27 +369,6 @@ CM.Cache.RemakeGoldenAndWrathCookiesMults = function() { } } -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)); @@ -552,14 +586,6 @@ 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; @@ -1042,7 +1068,7 @@ CM.Data.ConfigDefault = { Colors: {Blue: '#4bb8f0', Green: '#00ff00', Yellow: '#ffff00', Orange: '#ff7f00', Red: '#ff0000', Purple: '#ff00ff', Gray: '#b3b3b3', Pink: '#ff1493', Brown: '#8b4513'}, SortBuildings: 0, SortUpgrades: 0, - Header: {BarsColors: 1, Calculation: 1, Notification: 1, Tooltip: 1, Statistics: 1, Notation: 1, Lucky: 1, Conjure: 1, Chain: 1, Prestige: 1, Wrink: 1, Sea: 1, Misc: 1}, + Header: {BarsColors: 1, Calculation: 1, Notification: 1, Tooltip: 1, Statistics: 1, Notation: 1, Lucky: 1, Spells: 1, Chain: 1, Prestige: 1, Wrink: 1, Sea: 1, Misc: 1}, }; /******** @@ -2722,23 +2748,9 @@ CM.Disp.UpdateTooltipWarnings = function() { else l('CMDispTooltipWarnConjure').style.display = 'none'; if (CM.Options.ToolWarnEdifice == 1) { - var limitEdifice = 0; - var max = 0; - var n = 0; - for (var i in Game.Objects) { - if (Game.Objects[i].amount > max) max = Game.Objects[i].amount; - if (Game.Objects[i].amount > 0) n++; - } - for (var i in Game.Objects) { - if ((Game.Objects[i].amount < max || n == 1) && - Game.Objects[i].amount < 400 && - Game.Objects[i].price * 2 > limitEdifice) { - limitEdifice = Game.Objects[i].price * 2; - } - } - if (limitEdifice && amount < limitEdifice && (CM.Disp.tooltipType != 'b' || Game.buyMode == 1)) { + if (CM.Cache.Edifice && amount < CM.Cache.Edifice && (CM.Disp.tooltipType != 'b' || Game.buyMode == 1)) { l('CMDispTooltipWarnEdifice').style.display = ''; - l('CMDispTooltipWarnEdificeText').textContent = Beautify(limitEdifice - amount) + ' (' + CM.Disp.FormatTime((limitEdifice - amount) / CM.Disp.GetCPS()) + ')'; + l('CMDispTooltipWarnEdificeText').textContent = Beautify(CM.Cache.Edifice - amount) + ' (' + CM.Disp.FormatTime((CM.Cache.Edifice - amount) / CM.Disp.GetCPS()) + ')'; } else l('CMDispTooltipWarnEdifice').style.display = 'none'; } else l('CMDispTooltipWarnEdifice').style.display = 'none'; @@ -3176,9 +3188,9 @@ CM.Disp.AddMenuStats = function(title) { stats.appendChild(CM.Disp.CreateStatsChainSection()); } - stats.appendChild(CM.Disp.CreateStatsHeader('Conjure Baked Goods', 'Conjure')); - if (CM.Options.Header.Conjure) { - stats.appendChild(CM.Disp.CreateStatsConjureSection()); + stats.appendChild(CM.Disp.CreateStatsHeader('Spells', 'Spells')); + if (CM.Options.Header.Spells) { + stats.appendChild(CM.Disp.CreateStatsSpellsSection()); } stats.appendChild(CM.Disp.CreateStatsHeader('Prestige', 'Prestige')); @@ -3572,12 +3584,12 @@ CM.Disp.CreateStatsChainSection = function() { } /** - * This function creates the "Conjure" section of the stats page - * @returns {object} section The object contating the Conjure section + * This function creates the "Spells" section of the stats page + * @returns {object} section The object contating the Spells section */ -CM.Disp.CreateStatsConjureSection = function() { +CM.Disp.CreateStatsSpellsSection = function() { var section = document.createElement('div'); - section.className = 'CMStatsConjureSection'; + section.className = 'CMStatsSpellsSection'; var conjureColor = ((Game.cookies + CM.Disp.GetWrinkConfigBank()) < CM.Cache.Conjure) ? CM.Disp.colorRed : CM.Disp.colorGreen; var conjureCur = Math.min((Game.cookies + CM.Disp.GetWrinkConfigBank()) * 0.15, CM.Cache.NoGoldSwitchCookiesPS * 60 * 30); @@ -3597,6 +3609,9 @@ CM.Disp.CreateStatsConjureSection = function() { section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Conjure Baked Goods\" Cookies Required', conjureReqFrag, 'GoldCookTooltipPlaceholder')); section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Conjure Baked Goods\" Reward (MAX)', document.createTextNode(CM.Disp.Beautify(CM.Cache.ConjureReward)), 'GoldCookTooltipPlaceholder')); section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Conjure Baked Goods\" Reward (CUR)', document.createTextNode(CM.Disp.Beautify(conjureCur)), 'GoldCookTooltipPlaceholder')); + if (CM.Cache.Edifice) { + section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Spontaneous Edifice\" Cookies Required (most expensive building)', document.createTextNode(CM.Disp.Beautify(CM.Cache.Edifice) + ' (' + CM.Cache.EdificeBuilding + ")"), 'GoldCookTooltipPlaceholder')); + } return section; } @@ -3962,12 +3977,13 @@ CM.Loop = function() { CM.Disp.UpdateAscendState(); } if (!Game.OnAscend && Game.AscendTimer == 0) { + // CM.Sim.DoSims is set whenever CPS has changed if (CM.Sim.DoSims) { CM.Cache.RemakeIncome(); CM.Sim.NoGoldSwitchCookiesPS(); // Needed first CM.Cache.RemakeGoldenAndWrathCookiesMults(); - CM.Cache.RemakeLucky(); + CM.Cache.CacheStats(); CM.Cache.RemakeChain(); CM.Cache.RemakeSeaSpec(); diff --git a/src/Cache.js b/src/Cache.js index c8377c9..e06a3cf 100644 --- a/src/Cache.js +++ b/src/Cache.js @@ -14,6 +14,7 @@ CM.Cache.InitCache = function() { CM.Cache.CacheDragonAuras(); CM.Cache.CacheWrinklers(); + CM.Cache.CacheStats(); } /******** @@ -65,6 +66,60 @@ CM.Cache.CacheWrinklers = function() { } } +/******** + * Section: Functions related to Cachining stats */ + +/** + * This functions caches variables related to the stats apge + * It is called by CM.Loop() upon changes to cps and CM.Cache.InitCache() + * @global {number} CM.Cache.Lucky Cookies required for max Lucky + * @global {number} CM.Cache.LuckyReward Reward for max normal Lucky + * @global {number} CM.Cache.LuckyWrathReward Reward for max normal Lucky from Wrath cookie + * @global {number} CM.Cache.LuckyFrenzy Cookies required for max Lucky Frenzy + * @global {number} CM.Cache.LuckyRewardFrenzy Reward for max Lucky Frenzy + * @global {number} CM.Cache.LuckyWrathRewardFrenzy Reward for max Lucky Frenzy from Wrath cookie + * @global {number} CM.Cache.Conjure Cookies required for max Conjure Baked Goods + * @global {number} CM.Cache.ConjureReward Reward for max Conjure Baked Goods + * @global {number} CM.Cache.Edifice Cookies required for most expensive building through Spontaneous Edifice + * @global {string} CM.Cache.EdificeBuilding Name of most expensive building possible with Spontaneous Edifice + */ +CM.Cache.CacheStats = 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.Edifice = 0; + var max = 0; + var n = 0; + for (var i in Game.Objects) { + if (Game.Objects[i].amount > max) max = Game.Objects[i].amount; + if (Game.Objects[i].amount > 0) n++; + } + for (var i in Game.Objects) { + if ((Game.Objects[i].amount < max || n == 1) && + Game.Objects[i].amount < 400 && + Game.Objects[i].price * 2 > CM.Cache.Edifice) { + CM.Cache.Edifice = Game.Objects[i].price * 2; + CM.Cache.EdificeBuilding = i; + } + } +} + /******** * Section: UNSORTED */ @@ -285,27 +340,6 @@ CM.Cache.RemakeGoldenAndWrathCookiesMults = function() { } } -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)); @@ -523,14 +557,6 @@ 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; diff --git a/src/Data.js b/src/Data.js index 5bb518e..4f24aaf 100644 --- a/src/Data.js +++ b/src/Data.js @@ -275,6 +275,6 @@ CM.Data.ConfigDefault = { Colors: {Blue: '#4bb8f0', Green: '#00ff00', Yellow: '#ffff00', Orange: '#ff7f00', Red: '#ff0000', Purple: '#ff00ff', Gray: '#b3b3b3', Pink: '#ff1493', Brown: '#8b4513'}, SortBuildings: 0, SortUpgrades: 0, - Header: {BarsColors: 1, Calculation: 1, Notification: 1, Tooltip: 1, Statistics: 1, Notation: 1, Lucky: 1, Conjure: 1, Chain: 1, Prestige: 1, Wrink: 1, Sea: 1, Misc: 1}, + Header: {BarsColors: 1, Calculation: 1, Notification: 1, Tooltip: 1, Statistics: 1, Notation: 1, Lucky: 1, Spells: 1, Chain: 1, Prestige: 1, Wrink: 1, Sea: 1, Misc: 1}, }; diff --git a/src/Disp.js b/src/Disp.js index 4993eec..4dd1c0f 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -1675,23 +1675,9 @@ CM.Disp.UpdateTooltipWarnings = function() { else l('CMDispTooltipWarnConjure').style.display = 'none'; if (CM.Options.ToolWarnEdifice == 1) { - var limitEdifice = 0; - var max = 0; - var n = 0; - for (var i in Game.Objects) { - if (Game.Objects[i].amount > max) max = Game.Objects[i].amount; - if (Game.Objects[i].amount > 0) n++; - } - for (var i in Game.Objects) { - if ((Game.Objects[i].amount < max || n == 1) && - Game.Objects[i].amount < 400 && - Game.Objects[i].price * 2 > limitEdifice) { - limitEdifice = Game.Objects[i].price * 2; - } - } - if (limitEdifice && amount < limitEdifice && (CM.Disp.tooltipType != 'b' || Game.buyMode == 1)) { + if (CM.Cache.Edifice && amount < CM.Cache.Edifice && (CM.Disp.tooltipType != 'b' || Game.buyMode == 1)) { l('CMDispTooltipWarnEdifice').style.display = ''; - l('CMDispTooltipWarnEdificeText').textContent = Beautify(limitEdifice - amount) + ' (' + CM.Disp.FormatTime((limitEdifice - amount) / CM.Disp.GetCPS()) + ')'; + l('CMDispTooltipWarnEdificeText').textContent = Beautify(CM.Cache.Edifice - amount) + ' (' + CM.Disp.FormatTime((CM.Cache.Edifice - amount) / CM.Disp.GetCPS()) + ')'; } else l('CMDispTooltipWarnEdifice').style.display = 'none'; } else l('CMDispTooltipWarnEdifice').style.display = 'none'; @@ -2129,9 +2115,9 @@ CM.Disp.AddMenuStats = function(title) { stats.appendChild(CM.Disp.CreateStatsChainSection()); } - stats.appendChild(CM.Disp.CreateStatsHeader('Conjure Baked Goods', 'Conjure')); - if (CM.Options.Header.Conjure) { - stats.appendChild(CM.Disp.CreateStatsConjureSection()); + stats.appendChild(CM.Disp.CreateStatsHeader('Spells', 'Spells')); + if (CM.Options.Header.Spells) { + stats.appendChild(CM.Disp.CreateStatsSpellsSection()); } stats.appendChild(CM.Disp.CreateStatsHeader('Prestige', 'Prestige')); @@ -2525,12 +2511,12 @@ CM.Disp.CreateStatsChainSection = function() { } /** - * This function creates the "Conjure" section of the stats page - * @returns {object} section The object contating the Conjure section + * This function creates the "Spells" section of the stats page + * @returns {object} section The object contating the Spells section */ -CM.Disp.CreateStatsConjureSection = function() { +CM.Disp.CreateStatsSpellsSection = function() { var section = document.createElement('div'); - section.className = 'CMStatsConjureSection'; + section.className = 'CMStatsSpellsSection'; var conjureColor = ((Game.cookies + CM.Disp.GetWrinkConfigBank()) < CM.Cache.Conjure) ? CM.Disp.colorRed : CM.Disp.colorGreen; var conjureCur = Math.min((Game.cookies + CM.Disp.GetWrinkConfigBank()) * 0.15, CM.Cache.NoGoldSwitchCookiesPS * 60 * 30); @@ -2550,6 +2536,9 @@ CM.Disp.CreateStatsConjureSection = function() { section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Conjure Baked Goods\" Cookies Required', conjureReqFrag, 'GoldCookTooltipPlaceholder')); section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Conjure Baked Goods\" Reward (MAX)', document.createTextNode(CM.Disp.Beautify(CM.Cache.ConjureReward)), 'GoldCookTooltipPlaceholder')); section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Conjure Baked Goods\" Reward (CUR)', document.createTextNode(CM.Disp.Beautify(conjureCur)), 'GoldCookTooltipPlaceholder')); + if (CM.Cache.Edifice) { + section.appendChild(CM.Disp.CreateStatsListing("withTooltip", '\"Spontaneous Edifice\" Cookies Required (most expensive building)', document.createTextNode(CM.Disp.Beautify(CM.Cache.Edifice) + ' (' + CM.Cache.EdificeBuilding + ")"), 'GoldCookTooltipPlaceholder')); + } return section; } diff --git a/src/Main.js b/src/Main.js index ff447e1..9af3d1b 100644 --- a/src/Main.js +++ b/src/Main.js @@ -140,12 +140,13 @@ CM.Loop = function() { CM.Disp.UpdateAscendState(); } if (!Game.OnAscend && Game.AscendTimer == 0) { + // CM.Sim.DoSims is set whenever CPS has changed if (CM.Sim.DoSims) { CM.Cache.RemakeIncome(); CM.Sim.NoGoldSwitchCookiesPS(); // Needed first CM.Cache.RemakeGoldenAndWrathCookiesMults(); - CM.Cache.RemakeLucky(); + CM.Cache.CacheStats(); CM.Cache.RemakeChain(); CM.Cache.RemakeSeaSpec();