From 706fb7231e14edd33159be91ac7a785702dd32ac Mon Sep 17 00:00:00 2001 From: steven nguyen <58114641+icecream17@users.noreply.github.com> Date: Sun, 5 Jul 2020 10:50:19 -0500 Subject: [PATCH 01/49] Window.eval()? Var? --- README.md | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index c142a8f..efba84a 100644 --- a/README.md +++ b/README.md @@ -82,16 +82,14 @@ If you'd rather use the addon as a script via per example *Greasemonkey* or *Tam // @grant none // ==/UserScript== -var code = "(" + (function() { - var checkReady = setInterval(function() { - if (typeof Game.ready !== 'undefined' && Game.ready) { - Game.LoadMod('https://aktanusa.github.io/CookieMonster/CookieMonster.js'); - clearInterval(checkReady); - } - }, 1000); -}).toString() + ")()"; +'use strict'; -window.eval(code); +let checkReady = setInterval(function() { + if (typeof Game.ready !== 'undefined' && Game.ready) { + Game.LoadMod('https://aktanusa.github.io/CookieMonster/CookieMonster.js'); + clearInterval(checkReady); + } +}, 1000); ``` If you are using the beta, use this instead: @@ -105,16 +103,14 @@ If you are using the beta, use this instead: // @grant none // ==/UserScript== -var code = "(" + (function() { - var checkReady = setInterval(function() { - if (typeof Game.ready !== 'undefined' && Game.ready) { - Game.LoadMod('https://aktanusa.github.io/CookieMonster/CookieMonsterBeta.js'); - clearInterval(checkReady); - } - }, 1000); -}).toString() + ")()"; +'use strict'; -window.eval(code); +let checkReady = setInterval(function() { + if (typeof Game.ready !== 'undefined' && Game.ready) { + Game.LoadMod('https://aktanusa.github.io/CookieMonster/CookieMonsterBeta.js'); + clearInterval(checkReady); + } +}, 1000); ``` # Bugs and suggestions From dc6d643f7d9aa12e42bc24d184d612430885bae1 Mon Sep 17 00:00:00 2001 From: steven nguyen <58114641+icecream17@users.noreply.github.com> Date: Sun, 5 Jul 2020 10:58:17 -0500 Subject: [PATCH 02/49] scoping of variables. --- README.md | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index efba84a..570bff9 100644 --- a/README.md +++ b/README.md @@ -82,14 +82,14 @@ If you'd rather use the addon as a script via per example *Greasemonkey* or *Tam // @grant none // ==/UserScript== -'use strict'; - -let checkReady = setInterval(function() { - if (typeof Game.ready !== 'undefined' && Game.ready) { - Game.LoadMod('https://aktanusa.github.io/CookieMonster/CookieMonster.js'); - clearInterval(checkReady); - } -}, 1000); +(function() { + const checkReady = setInterval(function() { + if (typeof Game.ready !== 'undefined' && Game.ready) { + Game.LoadMod('https://aktanusa.github.io/CookieMonster/CookieMonster.js'); + clearInterval(checkReady); + } + }, 1000); +})(); ``` If you are using the beta, use this instead: @@ -103,14 +103,14 @@ If you are using the beta, use this instead: // @grant none // ==/UserScript== -'use strict'; - -let checkReady = setInterval(function() { - if (typeof Game.ready !== 'undefined' && Game.ready) { - Game.LoadMod('https://aktanusa.github.io/CookieMonster/CookieMonsterBeta.js'); - clearInterval(checkReady); - } -}, 1000); +(function() { + const checkReady = setInterval(function() { + if (typeof Game.ready !== 'undefined' && Game.ready) { + Game.LoadMod('https://aktanusa.github.io/CookieMonster/CookieMonsterBeta.js'); + clearInterval(checkReady); + } + }, 1000); +})(); ``` # Bugs and suggestions From 3721052cc3533d4db45a96c242e405a1cd688151 Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Mon, 23 Nov 2020 21:46:18 +0100 Subject: [PATCH 03/49] Removed all mentiones of warn/caut --- CookieMonster.js | 104 +++++++++++++++++++++++------------------------ src/Config.js | 6 +-- src/Disp.js | 86 +++++++++++++++++++-------------------- src/Main.js | 12 +++--- 4 files changed, 104 insertions(+), 104 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 1e05231..066921b 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -545,7 +545,7 @@ CM.ConfigData.CalcWrink = {label: ['Calculate with Wrinklers OFF', 'Calculate wi 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.ToolWarnCautBon = {label: ['Calculate Tooltip Warning/Caution With Bonus CPS OFF', 'Calculate Tooltip Warning/Caution With Bonus CPS ON'], desc: 'Calculate the warning/caution with or without the bonus CPS you get from buying', toggle: true}; +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.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'}; @@ -579,8 +579,8 @@ CM.ConfigData.GardSoundURL = {label: 'Garden Tick Sound URL:', desc: 'URL of the 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.ToolWarnCaut = {label: ['Tooltip Warning/Caution OFF', 'Tooltip Warning/Caution ON'], desc: 'A warning/caution when buying if it will put the bank under the amount needed for max "Lucky!"/"Lucky!" (Frenzy) rewards', toggle: true, func: function() {CM.Disp.ToggleToolWarnCaut();}}; -CM.ConfigData.ToolWarnCautPos = {label: ['Tooltip Warning/Caution Position (Left)', 'Tooltip Warning/Caution Position (Bottom)'], desc: 'Placement of the warning/caution boxes', toggle: false, func: function() {CM.Disp.ToggleToolWarnCautPos();}}; +CM.ConfigData.ToolWarn = {label: ['Tooltip Warning OFF', 'Tooltip 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, func: function() {CM.Disp.ToggleToolWarn();}}; +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}; @@ -1848,7 +1848,7 @@ CM.Disp.AddMenuPref = function(title) { frag.appendChild(listing('CPSMode')); frag.appendChild(listing('AvgCPSHist')); frag.appendChild(listing('AvgClicksHist')); - frag.appendChild(listing('ToolWarnCautBon')); + frag.appendChild(listing('ToolWarnBon')); frag.appendChild(header('Notification')); frag.appendChild(listing('GCFlash')); @@ -1874,8 +1874,8 @@ CM.Disp.AddMenuPref = function(title) { frag.appendChild(header('Tooltip')); frag.appendChild(listing('TooltipBuildUp')); frag.appendChild(listing('TooltipAmor')); - frag.appendChild(listing('ToolWarnCaut')); - frag.appendChild(listing('ToolWarnCautPos')); + frag.appendChild(listing('ToolWarn')); + frag.appendChild(listing('ToolWarnPos')); frag.appendChild(listing('TooltipGrim')); frag.appendChild(listing('ToolWrink')); frag.appendChild(listing('TooltipLump')); @@ -2359,9 +2359,9 @@ CM.Disp.FixMouseY = function(target) { CM.Disp.UpdateTooltipLocation = function() { if (Game.tooltip.origin == 'store') { - var warnCautOffset = 0; - if (CM.Config.ToolWarnCaut == 1 && CM.Config.ToolWarnCautPos == 1) warnCautOffset = CM.Disp.TooltipWarnCaut.clientHeight - 4; - Game.tooltip.tta.style.top = Math.min(parseInt(Game.tooltip.tta.style.top), (l('game').clientHeight + l('topBar').clientHeight) - Game.tooltip.tt.clientHeight - warnCautOffset - 46) + 'px'; + var warnOffset = 0; + if (CM.Config.ToolWarn == 1 && CM.Config.ToolWarnPos == 1) warnOffset = CM.Disp.TooltipWarn.clientHeight - 4; + Game.tooltip.tta.style.top = Math.min(parseInt(Game.tooltip.tta.style.top), (l('game').clientHeight + l('topBar').clientHeight) - Game.tooltip.tt.clientHeight - warnOffset - 46) + 'px'; } // Kept for future possible use if the code changes again /*else if (!Game.onCrate && !Game.OnAscend && CM.Config.TimerBar == 1 && CM.Config.TimerBarPos == 0) { @@ -2369,12 +2369,12 @@ CM.Disp.UpdateTooltipLocation = function() { }*/ } -CM.Disp.CreateTooltipWarnCaut = function() { - CM.Disp.TooltipWarnCaut = document.createElement('div'); - CM.Disp.TooltipWarnCaut.style.position = 'absolute'; - CM.Disp.TooltipWarnCaut.style.display = 'none'; - CM.Disp.TooltipWarnCaut.style.left = 'auto'; - CM.Disp.TooltipWarnCaut.style.bottom = 'auto'; +CM.Disp.CreateTooltipWarn = function() { + CM.Disp.TooltipWarn = document.createElement('div'); + CM.Disp.TooltipWarn.style.position = 'absolute'; + CM.Disp.TooltipWarn.style.display = 'none'; + CM.Disp.TooltipWarn.style.left = 'auto'; + CM.Disp.TooltipWarn.style.bottom = 'auto'; var create = function(boxId, color, labelTextFront, labelTextBack, deficitId) { var box = document.createElement('div'); @@ -2404,32 +2404,32 @@ CM.Disp.CreateTooltipWarnCaut = function() { deficitDiv.appendChild(deficitSpan); return box; } - CM.Disp.TooltipWarnCaut.appendChild(create('CMDispTooltipWarn', CM.Disp.colorRed, 'Warning: ', 'Purchase of this item will put you under the number of Cookies required for "Lucky!"', 'CMDispTooltipWarnText')); - CM.Disp.TooltipWarnCaut.firstChild.style.marginBottom = '4px'; - CM.Disp.TooltipWarnCaut.appendChild(create('CMDispTooltipCaut', CM.Disp.colorYellow, 'Caution: ', 'Purchase of this item will put you under the number of Cookies required for "Lucky!" (Frenzy)', 'CMDispTooltipCautText')); + CM.Disp.TooltipWarn.appendChild(create('CMDispTooltipWarn', CM.Disp.colorRed, 'Warning: ', 'Purchase of this item will put you under the number of Cookies required for "Lucky!"', 'CMDispTooltipWarnText')); + CM.Disp.TooltipWarn.firstChild.style.marginBottom = '4px'; + CM.Disp.TooltipWarn.appendChild(create('CMDispTooltipCaut', CM.Disp.colorYellow, 'Caution: ', 'Purchase of this item will put you under the number of Cookies required for "Lucky!" (Frenzy)', 'CMDispTooltipCautText')); - l('tooltipAnchor').appendChild(CM.Disp.TooltipWarnCaut); + l('tooltipAnchor').appendChild(CM.Disp.TooltipWarn); } -CM.Disp.ToggleToolWarnCaut = function() { // Pointless? - if (CM.Config.ToolWarnCaut == 1) { - CM.Disp.TooltipWarnCaut.style.display = 'block'; +CM.Disp.ToggleToolWarn = function() { // Pointless? + if (CM.Config.ToolWarn == 1) { + CM.Disp.TooltipWarn.style.display = 'block'; } else { - CM.Disp.TooltipWarnCaut.style.display = 'none'; + CM.Disp.TooltipWarn.style.display = 'none'; } } -CM.Disp.ToggleToolWarnCautPos = function() { - if (CM.Config.ToolWarnCautPos == 0) { - CM.Disp.TooltipWarnCaut.style.top = 'auto'; - CM.Disp.TooltipWarnCaut.style.margin = '4px -4px'; - CM.Disp.TooltipWarnCaut.style.padding = '3px 4px'; +CM.Disp.ToggleToolWarnPos = function() { + if (CM.Config.ToolWarnPos == 0) { + CM.Disp.TooltipWarn.style.top = 'auto'; + CM.Disp.TooltipWarn.style.margin = '4px -4px'; + CM.Disp.TooltipWarn.style.padding = '3px 4px'; } else { - CM.Disp.TooltipWarnCaut.style.right = 'auto'; - CM.Disp.TooltipWarnCaut.style.margin = '4px'; - CM.Disp.TooltipWarnCaut.style.padding = '4px 3px'; + CM.Disp.TooltipWarn.style.right = 'auto'; + CM.Disp.TooltipWarn.style.margin = '4px'; + CM.Disp.TooltipWarn.style.padding = '4px 3px'; } } @@ -2636,10 +2636,10 @@ CM.Disp.UpdateTooltip = function() { l('CMTooltipTime').className = CM.Disp.colorTextPre + timeColor.color; } - if (CM.Config.ToolWarnCaut == 1) { - CM.Disp.TooltipWarnCaut.style.display = 'block'; + if (CM.Config.ToolWarn == 1) { + CM.Disp.TooltipWarn.style.display = 'block'; var warn = CM.Cache.Lucky; - if (CM.Config.ToolWarnCautBon == 1) { + if (CM.Config.ToolWarnBon == 1) { var bonusNoFren = bonus; bonusNoFren /= CM.Sim.getCPSBuffMult(); warn += ((bonusNoFren * 60 * 15) / 0.15); @@ -2647,13 +2647,13 @@ CM.Disp.UpdateTooltip = function() { var caut = warn * 7; var amount = (Game.cookies + CM.Disp.GetWrinkConfigBank()) - price; if ((amount < warn || amount < caut) && (CM.Disp.tooltipType != 'b' || Game.buyMode == 1)) { - if (CM.Config.ToolWarnCautPos == 0) { - CM.Disp.TooltipWarnCaut.style.right = '0px'; + if (CM.Config.ToolWarnPos == 0) { + CM.Disp.TooltipWarn.style.right = '0px'; } else { - CM.Disp.TooltipWarnCaut.style.top = (l('tooltip').offsetHeight) + 'px'; + CM.Disp.TooltipWarn.style.top = (l('tooltip').offsetHeight) + 'px'; } - CM.Disp.TooltipWarnCaut.style.width = (l('tooltip').offsetWidth - 6) + 'px'; + CM.Disp.TooltipWarn.style.width = (l('tooltip').offsetWidth - 6) + 'px'; if (amount < warn) { l('CMDispTooltipWarn').style.display = ''; @@ -2677,13 +2677,13 @@ CM.Disp.UpdateTooltip = function() { } } else { - CM.Disp.TooltipWarnCaut.style.display = 'none'; + CM.Disp.TooltipWarn.style.display = 'none'; } } else if (CM.Disp.tooltipType === 's') { // Adding information about Sugar Lumps. - CM.Disp.TooltipWarnCaut.style.display = 'none'; + CM.Disp.TooltipWarn.style.display = 'none'; l('CMDispTooltipWarn').style.display = 'none'; l('CMDispTooltipCaut').style.display = 'none'; @@ -2715,7 +2715,7 @@ CM.Disp.UpdateTooltip = function() { } } else { // Grimoire - CM.Disp.TooltipWarnCaut.style.display = 'none'; + CM.Disp.TooltipWarn.style.display = 'none'; l('CMDispTooltipWarn').style.display = 'none'; l('CMDispTooltipCaut').style.display = 'none'; @@ -2764,20 +2764,20 @@ CM.Disp.UpdateTooltip = function() { } } else { - CM.Disp.TooltipWarnCaut.style.display = 'none'; + CM.Disp.TooltipWarn.style.display = 'none'; } } } -CM.Disp.DrawTooltipWarnCaut = function() { - if (CM.Config.ToolWarnCaut == 1) { +CM.Disp.DrawTooltipWarn = function() { + if (CM.Config.ToolWarn == 1) { l('CMDispTooltipWarn').style.opacity = '0'; l('CMDispTooltipCaut').style.opacity = '0'; } } -CM.Disp.UpdateTooltipWarnCaut = function() { - if (CM.Config.ToolWarnCaut == 1 && l('tooltipAnchor').style.display != 'none' && l('CMTooltipArea') != null) { +CM.Disp.UpdateTooltipWarn = function() { + if (CM.Config.ToolWarn == 1 && l('tooltipAnchor').style.display != 'none' && l('CMTooltipArea') != null) { l('CMDispTooltipWarn').style.opacity = '1'; l('CMDispTooltipCaut').style.opacity = '1'; } @@ -2942,14 +2942,14 @@ CM.ReplaceNative = function() { eval('CM.Backup.tooltip.drawMod = ' + Game.tooltip.draw.toString().split('this').join('Game.tooltip')); Game.tooltip.draw = function(from, text, origin) { CM.Backup.tooltip.drawMod(from, text, origin); - CM.Disp.DrawTooltipWarnCaut(); + CM.Disp.DrawTooltipWarn(); } CM.Backup.tooltip.update = Game.tooltip.update; eval('CM.Backup.tooltip.updateMod = ' + Game.tooltip.update.toString().split('this.').join('Game.tooltip.')); Game.tooltip.update = function() { CM.Backup.tooltip.updateMod(); - CM.Disp.UpdateTooltipWarnCaut(); + CM.Disp.UpdateTooltipWarn(); CM.Disp.UpdateTooltipLocation(); } @@ -3153,7 +3153,7 @@ CM.DelayInit = function() { for (var i in CM.Disp.TooltipText) { CM.Disp.CreateTooltip(CM.Disp.TooltipText[i][0], CM.Disp.TooltipText[i][1], CM.Disp.TooltipText[i][2]); } - CM.Disp.CreateTooltipWarnCaut(); + CM.Disp.CreateTooltipWarn(); CM.Disp.AddTooltipBuild(); CM.Disp.AddTooltipGrimoire(); CM.Disp.AddTooltipLump(); @@ -3188,7 +3188,7 @@ CM.ConfigDefault = { CPSMode: 1, AvgCPSHist: 3, AvgClicksHist: 0, - ToolWarnCautBon: 0, + ToolWarnBon: 0, GCFlash: 1, GCSound: 1, GCVolume: 100, @@ -3210,8 +3210,8 @@ CM.ConfigDefault = { Title: 1, TooltipBuildUp: 1, TooltipAmor: 0, - ToolWarnCaut: 1, - ToolWarnCautPos: 1, + ToolWarn: 1, + ToolWarnPos: 1, TooltipGrim:1, ToolWrink: 1, TooltipLump: 1, diff --git a/src/Config.js b/src/Config.js index 79d8613..7f32216 100644 --- a/src/Config.js +++ b/src/Config.js @@ -139,7 +139,7 @@ CM.ConfigData.CalcWrink = {label: ['Calculate with Wrinklers OFF', 'Calculate wi 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.ToolWarnCautBon = {label: ['Calculate Tooltip Warning/Caution With Bonus CPS OFF', 'Calculate Tooltip Warning/Caution With Bonus CPS ON'], desc: 'Calculate the warning/caution with or without the bonus CPS you get from buying', toggle: true}; +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.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'}; @@ -173,8 +173,8 @@ CM.ConfigData.GardSoundURL = {label: 'Garden Tick Sound URL:', desc: 'URL of the 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.ToolWarnCaut = {label: ['Tooltip Warning/Caution OFF', 'Tooltip Warning/Caution ON'], desc: 'A warning/caution when buying if it will put the bank under the amount needed for max "Lucky!"/"Lucky!" (Frenzy) rewards', toggle: true, func: function() {CM.Disp.ToggleToolWarnCaut();}}; -CM.ConfigData.ToolWarnCautPos = {label: ['Tooltip Warning/Caution Position (Left)', 'Tooltip Warning/Caution Position (Bottom)'], desc: 'Placement of the warning/caution boxes', toggle: false, func: function() {CM.Disp.ToggleToolWarnCautPos();}}; +CM.ConfigData.ToolWarn = {label: ['Tooltip Warning OFF', 'Tooltip 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, func: function() {CM.Disp.ToggleToolWarn();}}; +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}; diff --git a/src/Disp.js b/src/Disp.js index 60d6920..9609e44 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -1221,7 +1221,7 @@ CM.Disp.AddMenuPref = function(title) { frag.appendChild(listing('CPSMode')); frag.appendChild(listing('AvgCPSHist')); frag.appendChild(listing('AvgClicksHist')); - frag.appendChild(listing('ToolWarnCautBon')); + frag.appendChild(listing('ToolWarnBon')); frag.appendChild(header('Notification')); frag.appendChild(listing('GCFlash')); @@ -1247,8 +1247,8 @@ CM.Disp.AddMenuPref = function(title) { frag.appendChild(header('Tooltip')); frag.appendChild(listing('TooltipBuildUp')); frag.appendChild(listing('TooltipAmor')); - frag.appendChild(listing('ToolWarnCaut')); - frag.appendChild(listing('ToolWarnCautPos')); + frag.appendChild(listing('ToolWarn')); + frag.appendChild(listing('ToolWarnPos')); frag.appendChild(listing('TooltipGrim')); frag.appendChild(listing('ToolWrink')); frag.appendChild(listing('TooltipLump')); @@ -1732,9 +1732,9 @@ CM.Disp.FixMouseY = function(target) { CM.Disp.UpdateTooltipLocation = function() { if (Game.tooltip.origin == 'store') { - var warnCautOffset = 0; - if (CM.Config.ToolWarnCaut == 1 && CM.Config.ToolWarnCautPos == 1) warnCautOffset = CM.Disp.TooltipWarnCaut.clientHeight - 4; - Game.tooltip.tta.style.top = Math.min(parseInt(Game.tooltip.tta.style.top), (l('game').clientHeight + l('topBar').clientHeight) - Game.tooltip.tt.clientHeight - warnCautOffset - 46) + 'px'; + var warnOffset = 0; + if (CM.Config.ToolWarn == 1 && CM.Config.ToolWarnPos == 1) warnOffset = CM.Disp.TooltipWarn.clientHeight - 4; + Game.tooltip.tta.style.top = Math.min(parseInt(Game.tooltip.tta.style.top), (l('game').clientHeight + l('topBar').clientHeight) - Game.tooltip.tt.clientHeight - warnOffset - 46) + 'px'; } // Kept for future possible use if the code changes again /*else if (!Game.onCrate && !Game.OnAscend && CM.Config.TimerBar == 1 && CM.Config.TimerBarPos == 0) { @@ -1742,12 +1742,12 @@ CM.Disp.UpdateTooltipLocation = function() { }*/ } -CM.Disp.CreateTooltipWarnCaut = function() { - CM.Disp.TooltipWarnCaut = document.createElement('div'); - CM.Disp.TooltipWarnCaut.style.position = 'absolute'; - CM.Disp.TooltipWarnCaut.style.display = 'none'; - CM.Disp.TooltipWarnCaut.style.left = 'auto'; - CM.Disp.TooltipWarnCaut.style.bottom = 'auto'; +CM.Disp.CreateTooltipWarn = function() { + CM.Disp.TooltipWarn = document.createElement('div'); + CM.Disp.TooltipWarn.style.position = 'absolute'; + CM.Disp.TooltipWarn.style.display = 'none'; + CM.Disp.TooltipWarn.style.left = 'auto'; + CM.Disp.TooltipWarn.style.bottom = 'auto'; var create = function(boxId, color, labelTextFront, labelTextBack, deficitId) { var box = document.createElement('div'); @@ -1777,32 +1777,32 @@ CM.Disp.CreateTooltipWarnCaut = function() { deficitDiv.appendChild(deficitSpan); return box; } - CM.Disp.TooltipWarnCaut.appendChild(create('CMDispTooltipWarn', CM.Disp.colorRed, 'Warning: ', 'Purchase of this item will put you under the number of Cookies required for "Lucky!"', 'CMDispTooltipWarnText')); - CM.Disp.TooltipWarnCaut.firstChild.style.marginBottom = '4px'; - CM.Disp.TooltipWarnCaut.appendChild(create('CMDispTooltipCaut', CM.Disp.colorYellow, 'Caution: ', 'Purchase of this item will put you under the number of Cookies required for "Lucky!" (Frenzy)', 'CMDispTooltipCautText')); + CM.Disp.TooltipWarn.appendChild(create('CMDispTooltipWarn', CM.Disp.colorRed, 'Warning: ', 'Purchase of this item will put you under the number of Cookies required for "Lucky!"', 'CMDispTooltipWarnText')); + CM.Disp.TooltipWarn.firstChild.style.marginBottom = '4px'; + CM.Disp.TooltipWarn.appendChild(create('CMDispTooltipCaut', CM.Disp.colorYellow, 'Caution: ', 'Purchase of this item will put you under the number of Cookies required for "Lucky!" (Frenzy)', 'CMDispTooltipCautText')); - l('tooltipAnchor').appendChild(CM.Disp.TooltipWarnCaut); + l('tooltipAnchor').appendChild(CM.Disp.TooltipWarn); } -CM.Disp.ToggleToolWarnCaut = function() { // Pointless? - if (CM.Config.ToolWarnCaut == 1) { - CM.Disp.TooltipWarnCaut.style.display = 'block'; +CM.Disp.ToggleToolWarn = function() { // Pointless? + if (CM.Config.ToolWarn == 1) { + CM.Disp.TooltipWarn.style.display = 'block'; } else { - CM.Disp.TooltipWarnCaut.style.display = 'none'; + CM.Disp.TooltipWarn.style.display = 'none'; } } -CM.Disp.ToggleToolWarnCautPos = function() { - if (CM.Config.ToolWarnCautPos == 0) { - CM.Disp.TooltipWarnCaut.style.top = 'auto'; - CM.Disp.TooltipWarnCaut.style.margin = '4px -4px'; - CM.Disp.TooltipWarnCaut.style.padding = '3px 4px'; +CM.Disp.ToggleToolWarnPos = function() { + if (CM.Config.ToolWarnPos == 0) { + CM.Disp.TooltipWarn.style.top = 'auto'; + CM.Disp.TooltipWarn.style.margin = '4px -4px'; + CM.Disp.TooltipWarn.style.padding = '3px 4px'; } else { - CM.Disp.TooltipWarnCaut.style.right = 'auto'; - CM.Disp.TooltipWarnCaut.style.margin = '4px'; - CM.Disp.TooltipWarnCaut.style.padding = '4px 3px'; + CM.Disp.TooltipWarn.style.right = 'auto'; + CM.Disp.TooltipWarn.style.margin = '4px'; + CM.Disp.TooltipWarn.style.padding = '4px 3px'; } } @@ -2009,10 +2009,10 @@ CM.Disp.UpdateTooltip = function() { l('CMTooltipTime').className = CM.Disp.colorTextPre + timeColor.color; } - if (CM.Config.ToolWarnCaut == 1) { - CM.Disp.TooltipWarnCaut.style.display = 'block'; + if (CM.Config.ToolWarn == 1) { + CM.Disp.TooltipWarn.style.display = 'block'; var warn = CM.Cache.Lucky; - if (CM.Config.ToolWarnCautBon == 1) { + if (CM.Config.ToolWarnBon == 1) { var bonusNoFren = bonus; bonusNoFren /= CM.Sim.getCPSBuffMult(); warn += ((bonusNoFren * 60 * 15) / 0.15); @@ -2020,13 +2020,13 @@ CM.Disp.UpdateTooltip = function() { var caut = warn * 7; var amount = (Game.cookies + CM.Disp.GetWrinkConfigBank()) - price; if ((amount < warn || amount < caut) && (CM.Disp.tooltipType != 'b' || Game.buyMode == 1)) { - if (CM.Config.ToolWarnCautPos == 0) { - CM.Disp.TooltipWarnCaut.style.right = '0px'; + if (CM.Config.ToolWarnPos == 0) { + CM.Disp.TooltipWarn.style.right = '0px'; } else { - CM.Disp.TooltipWarnCaut.style.top = (l('tooltip').offsetHeight) + 'px'; + CM.Disp.TooltipWarn.style.top = (l('tooltip').offsetHeight) + 'px'; } - CM.Disp.TooltipWarnCaut.style.width = (l('tooltip').offsetWidth - 6) + 'px'; + CM.Disp.TooltipWarn.style.width = (l('tooltip').offsetWidth - 6) + 'px'; if (amount < warn) { l('CMDispTooltipWarn').style.display = ''; @@ -2050,13 +2050,13 @@ CM.Disp.UpdateTooltip = function() { } } else { - CM.Disp.TooltipWarnCaut.style.display = 'none'; + CM.Disp.TooltipWarn.style.display = 'none'; } } else if (CM.Disp.tooltipType === 's') { // Adding information about Sugar Lumps. - CM.Disp.TooltipWarnCaut.style.display = 'none'; + CM.Disp.TooltipWarn.style.display = 'none'; l('CMDispTooltipWarn').style.display = 'none'; l('CMDispTooltipCaut').style.display = 'none'; @@ -2088,7 +2088,7 @@ CM.Disp.UpdateTooltip = function() { } } else { // Grimoire - CM.Disp.TooltipWarnCaut.style.display = 'none'; + CM.Disp.TooltipWarn.style.display = 'none'; l('CMDispTooltipWarn').style.display = 'none'; l('CMDispTooltipCaut').style.display = 'none'; @@ -2137,20 +2137,20 @@ CM.Disp.UpdateTooltip = function() { } } else { - CM.Disp.TooltipWarnCaut.style.display = 'none'; + CM.Disp.TooltipWarn.style.display = 'none'; } } } -CM.Disp.DrawTooltipWarnCaut = function() { - if (CM.Config.ToolWarnCaut == 1) { +CM.Disp.DrawTooltipWarn = function() { + if (CM.Config.ToolWarn == 1) { l('CMDispTooltipWarn').style.opacity = '0'; l('CMDispTooltipCaut').style.opacity = '0'; } } -CM.Disp.UpdateTooltipWarnCaut = function() { - if (CM.Config.ToolWarnCaut == 1 && l('tooltipAnchor').style.display != 'none' && l('CMTooltipArea') != null) { +CM.Disp.UpdateTooltipWarn = function() { + if (CM.Config.ToolWarn == 1 && l('tooltipAnchor').style.display != 'none' && l('CMTooltipArea') != null) { l('CMDispTooltipWarn').style.opacity = '1'; l('CMDispTooltipCaut').style.opacity = '1'; } diff --git a/src/Main.js b/src/Main.js index 3eb16e6..ffcbb99 100644 --- a/src/Main.js +++ b/src/Main.js @@ -18,14 +18,14 @@ CM.ReplaceNative = function() { eval('CM.Backup.tooltip.drawMod = ' + Game.tooltip.draw.toString().split('this').join('Game.tooltip')); Game.tooltip.draw = function(from, text, origin) { CM.Backup.tooltip.drawMod(from, text, origin); - CM.Disp.DrawTooltipWarnCaut(); + CM.Disp.DrawTooltipWarn(); } CM.Backup.tooltip.update = Game.tooltip.update; eval('CM.Backup.tooltip.updateMod = ' + Game.tooltip.update.toString().split('this.').join('Game.tooltip.')); Game.tooltip.update = function() { CM.Backup.tooltip.updateMod(); - CM.Disp.UpdateTooltipWarnCaut(); + CM.Disp.UpdateTooltipWarn(); CM.Disp.UpdateTooltipLocation(); } @@ -229,7 +229,7 @@ CM.DelayInit = function() { for (var i in CM.Disp.TooltipText) { CM.Disp.CreateTooltip(CM.Disp.TooltipText[i][0], CM.Disp.TooltipText[i][1], CM.Disp.TooltipText[i][2]); } - CM.Disp.CreateTooltipWarnCaut(); + CM.Disp.CreateTooltipWarn(); CM.Disp.AddTooltipBuild(); CM.Disp.AddTooltipGrimoire(); CM.Disp.AddTooltipLump(); @@ -264,7 +264,7 @@ CM.ConfigDefault = { CPSMode: 1, AvgCPSHist: 3, AvgClicksHist: 0, - ToolWarnCautBon: 0, + ToolWarnBon: 0, GCFlash: 1, GCSound: 1, GCVolume: 100, @@ -286,8 +286,8 @@ CM.ConfigDefault = { Title: 1, TooltipBuildUp: 1, TooltipAmor: 0, - ToolWarnCaut: 1, - ToolWarnCautPos: 1, + ToolWarn: 1, + ToolWarnPos: 1, TooltipGrim:1, ToolWrink: 1, TooltipLump: 1, From f8c1dd93086bcabee90236f6e9f3e452ad444fa4 Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Mon, 23 Nov 2020 22:23:09 +0100 Subject: [PATCH 04/49] Updated warning tooltip code --- CookieMonster.js | 64 ++++++++++++++++++++++++------------------------ src/Config.js | 2 +- src/Disp.js | 60 ++++++++++++++++++++++----------------------- src/Main.js | 2 +- 4 files changed, 64 insertions(+), 64 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 066921b..6bf30f1 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -579,7 +579,7 @@ CM.ConfigData.GardSoundURL = {label: 'Garden Tick Sound URL:', desc: 'URL of the 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.ToolWarn = {label: ['Tooltip Warning OFF', 'Tooltip 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, func: function() {CM.Disp.ToggleToolWarn();}}; +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.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}; @@ -1874,7 +1874,7 @@ CM.Disp.AddMenuPref = function(title) { frag.appendChild(header('Tooltip')); frag.appendChild(listing('TooltipBuildUp')); frag.appendChild(listing('TooltipAmor')); - frag.appendChild(listing('ToolWarn')); + frag.appendChild(listing('ToolWarnLucky')); frag.appendChild(listing('ToolWarnPos')); frag.appendChild(listing('TooltipGrim')); frag.appendChild(listing('ToolWrink')); @@ -2360,7 +2360,7 @@ CM.Disp.FixMouseY = function(target) { CM.Disp.UpdateTooltipLocation = function() { if (Game.tooltip.origin == 'store') { var warnOffset = 0; - if (CM.Config.ToolWarn == 1 && CM.Config.ToolWarnPos == 1) warnOffset = CM.Disp.TooltipWarn.clientHeight - 4; + if (CM.Config.ToolWarnLucky == 1 && CM.Config.ToolWarnPos == 1) warnOffset = CM.Disp.TooltipWarn.clientHeight - 4; Game.tooltip.tta.style.top = Math.min(parseInt(Game.tooltip.tta.style.top), (l('game').clientHeight + l('topBar').clientHeight) - Game.tooltip.tt.clientHeight - warnOffset - 46) + 'px'; } // Kept for future possible use if the code changes again @@ -2404,9 +2404,9 @@ CM.Disp.CreateTooltipWarn = function() { deficitDiv.appendChild(deficitSpan); return box; } - CM.Disp.TooltipWarn.appendChild(create('CMDispTooltipWarn', CM.Disp.colorRed, 'Warning: ', 'Purchase of this item will put you under the number of Cookies required for "Lucky!"', 'CMDispTooltipWarnText')); + CM.Disp.TooltipWarn.appendChild(create('CMDispTooltipWarnLucky', CM.Disp.colorRed, 'Warning: ', 'Purchase of this item will put you under the number of Cookies required for "Lucky!"', 'CMDispTooltipWarnLuckyText')); CM.Disp.TooltipWarn.firstChild.style.marginBottom = '4px'; - CM.Disp.TooltipWarn.appendChild(create('CMDispTooltipCaut', CM.Disp.colorYellow, 'Caution: ', 'Purchase of this item will put you under the number of Cookies required for "Lucky!" (Frenzy)', 'CMDispTooltipCautText')); + CM.Disp.TooltipWarn.appendChild(create('CMDispTooltipWarnLuckyFrenzy', CM.Disp.colorYellow, 'Warning: ', 'Purchase of this item will put you under the number of Cookies required for "Lucky!" (Frenzy)', 'CMDispTooltipWarnLuckyFrenzyText')); l('tooltipAnchor').appendChild(CM.Disp.TooltipWarn); } @@ -2636,17 +2636,17 @@ CM.Disp.UpdateTooltip = function() { l('CMTooltipTime').className = CM.Disp.colorTextPre + timeColor.color; } - if (CM.Config.ToolWarn == 1) { + if (CM.Config.ToolWarnLucky == 1) { CM.Disp.TooltipWarn.style.display = 'block'; - var warn = CM.Cache.Lucky; + var limitLucky = CM.Cache.Lucky; if (CM.Config.ToolWarnBon == 1) { var bonusNoFren = bonus; bonusNoFren /= CM.Sim.getCPSBuffMult(); - warn += ((bonusNoFren * 60 * 15) / 0.15); + limitLucky += ((bonusNoFren * 60 * 15) / 0.15); } - var caut = warn * 7; + var limitLuckyFrenzy = limitLucky * 7; var amount = (Game.cookies + CM.Disp.GetWrinkConfigBank()) - price; - if ((amount < warn || amount < caut) && (CM.Disp.tooltipType != 'b' || Game.buyMode == 1)) { + if ((amount < limitLucky || amount < limitLuckyFrenzy) && (CM.Disp.tooltipType != 'b' || Game.buyMode == 1)) { if (CM.Config.ToolWarnPos == 0) { CM.Disp.TooltipWarn.style.right = '0px'; } @@ -2655,25 +2655,25 @@ CM.Disp.UpdateTooltip = function() { } CM.Disp.TooltipWarn.style.width = (l('tooltip').offsetWidth - 6) + 'px'; - if (amount < warn) { - l('CMDispTooltipWarn').style.display = ''; - l('CMDispTooltipWarnText').textContent = Beautify(warn - amount) + ' (' + CM.Disp.FormatTime((warn - amount) / CM.Disp.GetCPS()) + ')'; - l('CMDispTooltipCaut').style.display = ''; - l('CMDispTooltipCautText').textContent = Beautify(caut - amount) + ' (' + CM.Disp.FormatTime((caut - amount) / CM.Disp.GetCPS()) + ')'; + if (amount < limitLucky) { + l('CMDispTooltipWarnLucky').style.display = ''; + l('CMDispTooltipWarnLuckyText').textContent = Beautify(limitLucky - amount) + ' (' + CM.Disp.FormatTime((limitLucky - amount) / CM.Disp.GetCPS()) + ')'; + l('CMDispTooltipWarnLuckyFrenzy').style.display = ''; + l('CMDispTooltipWarnLuckyFrenzyText').textContent = Beautify(limitLuckyFrenzy - amount) + ' (' + CM.Disp.FormatTime((limitLuckyFrenzy - amount) / CM.Disp.GetCPS()) + ')'; } - else if (amount < caut) { - l('CMDispTooltipCaut').style.display = ''; - l('CMDispTooltipCautText').textContent = Beautify(caut - amount) + ' (' + CM.Disp.FormatTime((caut - amount) / CM.Disp.GetCPS()) + ')'; - l('CMDispTooltipWarn').style.display = 'none'; + else if (amount < limitLuckyFrenzy) { + l('CMDispTooltipWarnLuckyFrenzy').style.display = ''; + l('CMDispTooltipWarnLuckyFrenzyText').textContent = Beautify(limitLuckyFrenzy - amount) + ' (' + CM.Disp.FormatTime((limitLuckyFrenzy - amount) / CM.Disp.GetCPS()) + ')'; + l('CMDispTooltipWarnLucky').style.display = 'none'; } else { - l('CMDispTooltipWarn').style.display = 'none'; - l('CMDispTooltipCaut').style.display = 'none'; + l('CMDispTooltipWarnLucky').style.display = 'none'; + l('CMDispTooltipWarnLuckyFrenzy').style.display = 'none'; } } else { - l('CMDispTooltipWarn').style.display = 'none'; - l('CMDispTooltipCaut').style.display = 'none'; + l('CMDispTooltipWarnLucky').style.display = 'none'; + l('CMDispTooltipWarnLuckyFrenzy').style.display = 'none'; } } else { @@ -2685,7 +2685,7 @@ CM.Disp.UpdateTooltip = function() { CM.Disp.TooltipWarn.style.display = 'none'; l('CMDispTooltipWarn').style.display = 'none'; - l('CMDispTooltipCaut').style.display = 'none'; + l('CMDispTooltipWarnLuckyFrenzy').style.display = 'none'; if (CM.Config.TooltipLump === 1) { l('CMTooltipArea').innerHTML = ''; @@ -2717,7 +2717,7 @@ CM.Disp.UpdateTooltip = function() { else { // Grimoire CM.Disp.TooltipWarn.style.display = 'none'; l('CMDispTooltipWarn').style.display = 'none'; - l('CMDispTooltipCaut').style.display = 'none'; + l('CMDispTooltipWarnLuckyFrenzy').style.display = 'none'; var minigame = Game.Objects['Wizard tower'].minigame; var spellCost = minigame.getSpellCost(minigame.spellsById[CM.Disp.tooltipName]); @@ -2770,16 +2770,16 @@ CM.Disp.UpdateTooltip = function() { } CM.Disp.DrawTooltipWarn = function() { - if (CM.Config.ToolWarn == 1) { - l('CMDispTooltipWarn').style.opacity = '0'; - l('CMDispTooltipCaut').style.opacity = '0'; + if (CM.Config.ToolWarnLucky == 1) { + l('CMDispTooltipWarnLucky').style.opacity = '0'; + l('CMDispTooltipWarnLuckyFrenzy').style.opacity = '0'; } } CM.Disp.UpdateTooltipWarn = function() { - if (CM.Config.ToolWarn == 1 && l('tooltipAnchor').style.display != 'none' && l('CMTooltipArea') != null) { - l('CMDispTooltipWarn').style.opacity = '1'; - l('CMDispTooltipCaut').style.opacity = '1'; + if (CM.Config.ToolWarnLucky == 1 && l('tooltipAnchor').style.display != 'none' && l('CMTooltipArea') != null) { + l('CMDispTooltipWarnLucky').style.opacity = '1'; + l('CMDispTooltipWarnLuckyFrenzy').style.opacity = '1'; } } @@ -3210,7 +3210,7 @@ CM.ConfigDefault = { Title: 1, TooltipBuildUp: 1, TooltipAmor: 0, - ToolWarn: 1, + ToolWarnLucky: 1, ToolWarnPos: 1, TooltipGrim:1, ToolWrink: 1, diff --git a/src/Config.js b/src/Config.js index 7f32216..599957c 100644 --- a/src/Config.js +++ b/src/Config.js @@ -173,7 +173,7 @@ CM.ConfigData.GardSoundURL = {label: 'Garden Tick Sound URL:', desc: 'URL of the 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.ToolWarn = {label: ['Tooltip Warning OFF', 'Tooltip 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, func: function() {CM.Disp.ToggleToolWarn();}}; +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.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}; diff --git a/src/Disp.js b/src/Disp.js index 9609e44..f96de92 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -1247,7 +1247,7 @@ CM.Disp.AddMenuPref = function(title) { frag.appendChild(header('Tooltip')); frag.appendChild(listing('TooltipBuildUp')); frag.appendChild(listing('TooltipAmor')); - frag.appendChild(listing('ToolWarn')); + frag.appendChild(listing('ToolWarnLucky')); frag.appendChild(listing('ToolWarnPos')); frag.appendChild(listing('TooltipGrim')); frag.appendChild(listing('ToolWrink')); @@ -1733,7 +1733,7 @@ CM.Disp.FixMouseY = function(target) { CM.Disp.UpdateTooltipLocation = function() { if (Game.tooltip.origin == 'store') { var warnOffset = 0; - if (CM.Config.ToolWarn == 1 && CM.Config.ToolWarnPos == 1) warnOffset = CM.Disp.TooltipWarn.clientHeight - 4; + if (CM.Config.ToolWarnLucky == 1 && CM.Config.ToolWarnPos == 1) warnOffset = CM.Disp.TooltipWarn.clientHeight - 4; Game.tooltip.tta.style.top = Math.min(parseInt(Game.tooltip.tta.style.top), (l('game').clientHeight + l('topBar').clientHeight) - Game.tooltip.tt.clientHeight - warnOffset - 46) + 'px'; } // Kept for future possible use if the code changes again @@ -1777,9 +1777,9 @@ CM.Disp.CreateTooltipWarn = function() { deficitDiv.appendChild(deficitSpan); return box; } - CM.Disp.TooltipWarn.appendChild(create('CMDispTooltipWarn', CM.Disp.colorRed, 'Warning: ', 'Purchase of this item will put you under the number of Cookies required for "Lucky!"', 'CMDispTooltipWarnText')); + CM.Disp.TooltipWarn.appendChild(create('CMDispTooltipWarnLucky', CM.Disp.colorRed, 'Warning: ', 'Purchase of this item will put you under the number of Cookies required for "Lucky!"', 'CMDispTooltipWarnLuckyText')); CM.Disp.TooltipWarn.firstChild.style.marginBottom = '4px'; - CM.Disp.TooltipWarn.appendChild(create('CMDispTooltipCaut', CM.Disp.colorYellow, 'Caution: ', 'Purchase of this item will put you under the number of Cookies required for "Lucky!" (Frenzy)', 'CMDispTooltipCautText')); + CM.Disp.TooltipWarn.appendChild(create('CMDispTooltipWarnLuckyFrenzy', CM.Disp.colorYellow, 'Warning: ', 'Purchase of this item will put you under the number of Cookies required for "Lucky!" (Frenzy)', 'CMDispTooltipWarnLuckyFrenzyText')); l('tooltipAnchor').appendChild(CM.Disp.TooltipWarn); } @@ -2009,17 +2009,17 @@ CM.Disp.UpdateTooltip = function() { l('CMTooltipTime').className = CM.Disp.colorTextPre + timeColor.color; } - if (CM.Config.ToolWarn == 1) { + if (CM.Config.ToolWarnLucky == 1) { CM.Disp.TooltipWarn.style.display = 'block'; - var warn = CM.Cache.Lucky; + var limitLucky = CM.Cache.Lucky; if (CM.Config.ToolWarnBon == 1) { var bonusNoFren = bonus; bonusNoFren /= CM.Sim.getCPSBuffMult(); - warn += ((bonusNoFren * 60 * 15) / 0.15); + limitLucky += ((bonusNoFren * 60 * 15) / 0.15); } - var caut = warn * 7; + var limitLuckyFrenzy = limitLucky * 7; var amount = (Game.cookies + CM.Disp.GetWrinkConfigBank()) - price; - if ((amount < warn || amount < caut) && (CM.Disp.tooltipType != 'b' || Game.buyMode == 1)) { + if ((amount < limitLucky || amount < limitLuckyFrenzy) && (CM.Disp.tooltipType != 'b' || Game.buyMode == 1)) { if (CM.Config.ToolWarnPos == 0) { CM.Disp.TooltipWarn.style.right = '0px'; } @@ -2028,25 +2028,25 @@ CM.Disp.UpdateTooltip = function() { } CM.Disp.TooltipWarn.style.width = (l('tooltip').offsetWidth - 6) + 'px'; - if (amount < warn) { - l('CMDispTooltipWarn').style.display = ''; - l('CMDispTooltipWarnText').textContent = Beautify(warn - amount) + ' (' + CM.Disp.FormatTime((warn - amount) / CM.Disp.GetCPS()) + ')'; - l('CMDispTooltipCaut').style.display = ''; - l('CMDispTooltipCautText').textContent = Beautify(caut - amount) + ' (' + CM.Disp.FormatTime((caut - amount) / CM.Disp.GetCPS()) + ')'; + if (amount < limitLucky) { + l('CMDispTooltipWarnLucky').style.display = ''; + l('CMDispTooltipWarnLuckyText').textContent = Beautify(limitLucky - amount) + ' (' + CM.Disp.FormatTime((limitLucky - amount) / CM.Disp.GetCPS()) + ')'; + l('CMDispTooltipWarnLuckyFrenzy').style.display = ''; + l('CMDispTooltipWarnLuckyFrenzyText').textContent = Beautify(limitLuckyFrenzy - amount) + ' (' + CM.Disp.FormatTime((limitLuckyFrenzy - amount) / CM.Disp.GetCPS()) + ')'; } - else if (amount < caut) { - l('CMDispTooltipCaut').style.display = ''; - l('CMDispTooltipCautText').textContent = Beautify(caut - amount) + ' (' + CM.Disp.FormatTime((caut - amount) / CM.Disp.GetCPS()) + ')'; - l('CMDispTooltipWarn').style.display = 'none'; + else if (amount < limitLuckyFrenzy) { + l('CMDispTooltipWarnLuckyFrenzy').style.display = ''; + l('CMDispTooltipWarnLuckyFrenzyText').textContent = Beautify(limitLuckyFrenzy - amount) + ' (' + CM.Disp.FormatTime((limitLuckyFrenzy - amount) / CM.Disp.GetCPS()) + ')'; + l('CMDispTooltipWarnLucky').style.display = 'none'; } else { - l('CMDispTooltipWarn').style.display = 'none'; - l('CMDispTooltipCaut').style.display = 'none'; + l('CMDispTooltipWarnLucky').style.display = 'none'; + l('CMDispTooltipWarnLuckyFrenzy').style.display = 'none'; } } else { - l('CMDispTooltipWarn').style.display = 'none'; - l('CMDispTooltipCaut').style.display = 'none'; + l('CMDispTooltipWarnLucky').style.display = 'none'; + l('CMDispTooltipWarnLuckyFrenzy').style.display = 'none'; } } else { @@ -2058,7 +2058,7 @@ CM.Disp.UpdateTooltip = function() { CM.Disp.TooltipWarn.style.display = 'none'; l('CMDispTooltipWarn').style.display = 'none'; - l('CMDispTooltipCaut').style.display = 'none'; + l('CMDispTooltipWarnLuckyFrenzy').style.display = 'none'; if (CM.Config.TooltipLump === 1) { l('CMTooltipArea').innerHTML = ''; @@ -2090,7 +2090,7 @@ CM.Disp.UpdateTooltip = function() { else { // Grimoire CM.Disp.TooltipWarn.style.display = 'none'; l('CMDispTooltipWarn').style.display = 'none'; - l('CMDispTooltipCaut').style.display = 'none'; + l('CMDispTooltipWarnLuckyFrenzy').style.display = 'none'; var minigame = Game.Objects['Wizard tower'].minigame; var spellCost = minigame.getSpellCost(minigame.spellsById[CM.Disp.tooltipName]); @@ -2143,16 +2143,16 @@ CM.Disp.UpdateTooltip = function() { } CM.Disp.DrawTooltipWarn = function() { - if (CM.Config.ToolWarn == 1) { - l('CMDispTooltipWarn').style.opacity = '0'; - l('CMDispTooltipCaut').style.opacity = '0'; + if (CM.Config.ToolWarnLucky == 1) { + l('CMDispTooltipWarnLucky').style.opacity = '0'; + l('CMDispTooltipWarnLuckyFrenzy').style.opacity = '0'; } } CM.Disp.UpdateTooltipWarn = function() { - if (CM.Config.ToolWarn == 1 && l('tooltipAnchor').style.display != 'none' && l('CMTooltipArea') != null) { - l('CMDispTooltipWarn').style.opacity = '1'; - l('CMDispTooltipCaut').style.opacity = '1'; + if (CM.Config.ToolWarnLucky == 1 && l('tooltipAnchor').style.display != 'none' && l('CMTooltipArea') != null) { + l('CMDispTooltipWarnLucky').style.opacity = '1'; + l('CMDispTooltipWarnLuckyFrenzy').style.opacity = '1'; } } diff --git a/src/Main.js b/src/Main.js index ffcbb99..544c618 100644 --- a/src/Main.js +++ b/src/Main.js @@ -286,7 +286,7 @@ CM.ConfigDefault = { Title: 1, TooltipBuildUp: 1, TooltipAmor: 0, - ToolWarn: 1, + ToolWarnLucky: 1, ToolWarnPos: 1, TooltipGrim:1, ToolWrink: 1, From 3c28df38c8dc92e71a407508a0e258c934867194 Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Mon, 23 Nov 2020 23:20:48 +0100 Subject: [PATCH 05/49] Optional warning for Conjure Baked Goods --- CookieMonster.js | 71 +++++++++++++++++++++++++++++++----------------- src/Config.js | 1 + src/Disp.js | 67 +++++++++++++++++++++++++++++---------------- src/Main.js | 3 +- 4 files changed, 92 insertions(+), 50 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 6bf30f1..2ed1929 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -580,6 +580,7 @@ CM.ConfigData.Title = {label: ['Title OFF', 'Title ON', 'Title Pinned Tab Highli 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}; @@ -1875,6 +1876,7 @@ CM.Disp.AddMenuPref = function(title) { 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')); @@ -2407,19 +2409,13 @@ CM.Disp.CreateTooltipWarn = function() { CM.Disp.TooltipWarn.appendChild(create('CMDispTooltipWarnLucky', CM.Disp.colorRed, 'Warning: ', 'Purchase of this item will put you under the number of Cookies required for "Lucky!"', 'CMDispTooltipWarnLuckyText')); CM.Disp.TooltipWarn.firstChild.style.marginBottom = '4px'; CM.Disp.TooltipWarn.appendChild(create('CMDispTooltipWarnLuckyFrenzy', CM.Disp.colorYellow, 'Warning: ', 'Purchase of this item will put you under the number of Cookies required for "Lucky!" (Frenzy)', 'CMDispTooltipWarnLuckyFrenzyText')); + CM.Disp.TooltipWarn.lastChild.style.marginBottom = '4px'; + CM.Disp.TooltipWarn.appendChild(create('CMDispTooltipWarnConjure', CM.Disp.colorPurple, 'Warning: ', 'Purchase of this item will put you under the number of Cookies required for "Conjure Baked Goods"', 'CMDispTooltipWarnConjureText')); + l('tooltipAnchor').appendChild(CM.Disp.TooltipWarn); } -CM.Disp.ToggleToolWarn = function() { // Pointless? - if (CM.Config.ToolWarn == 1) { - CM.Disp.TooltipWarn.style.display = 'block'; - } - else { - CM.Disp.TooltipWarn.style.display = 'none'; - } -} - CM.Disp.ToggleToolWarnPos = function() { if (CM.Config.ToolWarnPos == 0) { CM.Disp.TooltipWarn.style.top = 'auto'; @@ -2636,6 +2632,14 @@ CM.Disp.UpdateTooltip = function() { l('CMTooltipTime').className = CM.Disp.colorTextPre + timeColor.color; } + if (CM.Config.ToolWarnPos == 0) { + CM.Disp.TooltipWarn.style.right = '0px'; + } + else { + CM.Disp.TooltipWarn.style.top = (l('tooltip').offsetHeight) + 'px'; + } + CM.Disp.TooltipWarn.style.width = (l('tooltip').offsetWidth - 6) + 'px'; + if (CM.Config.ToolWarnLucky == 1) { CM.Disp.TooltipWarn.style.display = 'block'; var limitLucky = CM.Cache.Lucky; @@ -2647,14 +2651,6 @@ CM.Disp.UpdateTooltip = function() { var limitLuckyFrenzy = limitLucky * 7; var amount = (Game.cookies + CM.Disp.GetWrinkConfigBank()) - price; if ((amount < limitLucky || amount < limitLuckyFrenzy) && (CM.Disp.tooltipType != 'b' || Game.buyMode == 1)) { - if (CM.Config.ToolWarnPos == 0) { - CM.Disp.TooltipWarn.style.right = '0px'; - } - else { - CM.Disp.TooltipWarn.style.top = (l('tooltip').offsetHeight) + 'px'; - } - CM.Disp.TooltipWarn.style.width = (l('tooltip').offsetWidth - 6) + 'px'; - if (amount < limitLucky) { l('CMDispTooltipWarnLucky').style.display = ''; l('CMDispTooltipWarnLuckyText').textContent = Beautify(limitLucky - amount) + ' (' + CM.Disp.FormatTime((limitLucky - amount) / CM.Disp.GetCPS()) + ')'; @@ -2671,21 +2667,38 @@ CM.Disp.UpdateTooltip = function() { l('CMDispTooltipWarnLuckyFrenzy').style.display = 'none'; } } - else { - l('CMDispTooltipWarnLucky').style.display = 'none'; - l('CMDispTooltipWarnLuckyFrenzy').style.display = 'none'; + } + else { + l('CMDispTooltipWarnLucky').style.display = 'none'; + l('CMDispTooltipWarnLuckyFrenzy').style.display = 'none'; + } + + if (CM.Config.ToolWarnConjure == 1) { + CM.Disp.TooltipWarn.style.display = 'block'; + var limitLucky = CM.Cache.Lucky; + if (CM.Config.ToolWarnBon == 1) { + var bonusNoFren = bonus; + bonusNoFren /= CM.Sim.getCPSBuffMult(); + limitLucky += ((bonusNoFren * 60 * 15) / 0.15); + } + var limitConjure = limitLucky * 2; + var amount = (Game.cookies + CM.Disp.GetWrinkConfigBank()) - price; + if ((amount < limitConjure) && (CM.Disp.tooltipType != 'b' || Game.buyMode == 1)) { + l('CMDispTooltipWarnConjure').style.display = ''; + l('CMDispTooltipWarnConjureText').textContent = Beautify(limitConjure - amount) + ' (' + CM.Disp.FormatTime((limitConjure - amount) / CM.Disp.GetCPS()) + ')'; } } else { - CM.Disp.TooltipWarn.style.display = 'none'; + l('CMDispTooltipWarnConjure').style.display = 'none'; } } else if (CM.Disp.tooltipType === 's') { // Adding information about Sugar Lumps. CM.Disp.TooltipWarn.style.display = 'none'; - l('CMDispTooltipWarn').style.display = 'none'; - l('CMDispTooltipWarnLuckyFrenzy').style.display = 'none'; + l('CMDispTooltipWarnLucky').style.display = 'none'; + l('CMDispTooltipWarnLuckyFrenzy').style.display = 'none'; + l('CMDispTooltipWarnConjure').style.display = 'none'; if (CM.Config.TooltipLump === 1) { l('CMTooltipArea').innerHTML = ''; @@ -2716,8 +2729,9 @@ CM.Disp.UpdateTooltip = function() { } else { // Grimoire CM.Disp.TooltipWarn.style.display = 'none'; - l('CMDispTooltipWarn').style.display = 'none'; + l('CMDispTooltipWarnLucky').style.display = 'none'; l('CMDispTooltipWarnLuckyFrenzy').style.display = 'none'; + l('CMDispTooltipWarnConjure').style.display = 'none'; var minigame = Game.Objects['Wizard tower'].minigame; var spellCost = minigame.getSpellCost(minigame.spellsById[CM.Disp.tooltipName]); @@ -2774,6 +2788,9 @@ CM.Disp.DrawTooltipWarn = function() { l('CMDispTooltipWarnLucky').style.opacity = '0'; l('CMDispTooltipWarnLuckyFrenzy').style.opacity = '0'; } + if (CM.Config.ToolWarnConjure == 1) { + l('CMDispTooltipWarnConjure').style.opacity = '0'; + } } CM.Disp.UpdateTooltipWarn = function() { @@ -2781,6 +2798,9 @@ CM.Disp.UpdateTooltipWarn = function() { l('CMDispTooltipWarnLucky').style.opacity = '1'; l('CMDispTooltipWarnLuckyFrenzy').style.opacity = '1'; } + if (CM.Config.ToolWarnConjure == 1 && l('tooltipAnchor').style.display != 'none' && l('CMTooltipArea') != null) { + l('CMDispTooltipWarnConjure').style.opacity = '1'; + } } CM.Disp.AddWrinklerAreaDetect = function() { @@ -3210,7 +3230,8 @@ CM.ConfigDefault = { Title: 1, TooltipBuildUp: 1, TooltipAmor: 0, - ToolWarnLucky: 1, + ToolWarnLucky: 1, + ToolWarnConjure: 1, ToolWarnPos: 1, TooltipGrim:1, ToolWrink: 1, diff --git a/src/Config.js b/src/Config.js index 599957c..6e8ad84 100644 --- a/src/Config.js +++ b/src/Config.js @@ -174,6 +174,7 @@ CM.ConfigData.Title = {label: ['Title OFF', 'Title ON', 'Title Pinned Tab Highli 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}; diff --git a/src/Disp.js b/src/Disp.js index f96de92..4efdc63 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -1248,6 +1248,7 @@ CM.Disp.AddMenuPref = function(title) { 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')); @@ -1780,19 +1781,13 @@ CM.Disp.CreateTooltipWarn = function() { CM.Disp.TooltipWarn.appendChild(create('CMDispTooltipWarnLucky', CM.Disp.colorRed, 'Warning: ', 'Purchase of this item will put you under the number of Cookies required for "Lucky!"', 'CMDispTooltipWarnLuckyText')); CM.Disp.TooltipWarn.firstChild.style.marginBottom = '4px'; CM.Disp.TooltipWarn.appendChild(create('CMDispTooltipWarnLuckyFrenzy', CM.Disp.colorYellow, 'Warning: ', 'Purchase of this item will put you under the number of Cookies required for "Lucky!" (Frenzy)', 'CMDispTooltipWarnLuckyFrenzyText')); + CM.Disp.TooltipWarn.lastChild.style.marginBottom = '4px'; + CM.Disp.TooltipWarn.appendChild(create('CMDispTooltipWarnConjure', CM.Disp.colorPurple, 'Warning: ', 'Purchase of this item will put you under the number of Cookies required for "Conjure Baked Goods"', 'CMDispTooltipWarnConjureText')); + l('tooltipAnchor').appendChild(CM.Disp.TooltipWarn); } -CM.Disp.ToggleToolWarn = function() { // Pointless? - if (CM.Config.ToolWarn == 1) { - CM.Disp.TooltipWarn.style.display = 'block'; - } - else { - CM.Disp.TooltipWarn.style.display = 'none'; - } -} - CM.Disp.ToggleToolWarnPos = function() { if (CM.Config.ToolWarnPos == 0) { CM.Disp.TooltipWarn.style.top = 'auto'; @@ -2009,6 +2004,14 @@ CM.Disp.UpdateTooltip = function() { l('CMTooltipTime').className = CM.Disp.colorTextPre + timeColor.color; } + if (CM.Config.ToolWarnPos == 0) { + CM.Disp.TooltipWarn.style.right = '0px'; + } + else { + CM.Disp.TooltipWarn.style.top = (l('tooltip').offsetHeight) + 'px'; + } + CM.Disp.TooltipWarn.style.width = (l('tooltip').offsetWidth - 6) + 'px'; + if (CM.Config.ToolWarnLucky == 1) { CM.Disp.TooltipWarn.style.display = 'block'; var limitLucky = CM.Cache.Lucky; @@ -2020,14 +2023,6 @@ CM.Disp.UpdateTooltip = function() { var limitLuckyFrenzy = limitLucky * 7; var amount = (Game.cookies + CM.Disp.GetWrinkConfigBank()) - price; if ((amount < limitLucky || amount < limitLuckyFrenzy) && (CM.Disp.tooltipType != 'b' || Game.buyMode == 1)) { - if (CM.Config.ToolWarnPos == 0) { - CM.Disp.TooltipWarn.style.right = '0px'; - } - else { - CM.Disp.TooltipWarn.style.top = (l('tooltip').offsetHeight) + 'px'; - } - CM.Disp.TooltipWarn.style.width = (l('tooltip').offsetWidth - 6) + 'px'; - if (amount < limitLucky) { l('CMDispTooltipWarnLucky').style.display = ''; l('CMDispTooltipWarnLuckyText').textContent = Beautify(limitLucky - amount) + ' (' + CM.Disp.FormatTime((limitLucky - amount) / CM.Disp.GetCPS()) + ')'; @@ -2044,21 +2039,38 @@ CM.Disp.UpdateTooltip = function() { l('CMDispTooltipWarnLuckyFrenzy').style.display = 'none'; } } - else { - l('CMDispTooltipWarnLucky').style.display = 'none'; - l('CMDispTooltipWarnLuckyFrenzy').style.display = 'none'; + } + else { + l('CMDispTooltipWarnLucky').style.display = 'none'; + l('CMDispTooltipWarnLuckyFrenzy').style.display = 'none'; + } + + if (CM.Config.ToolWarnConjure == 1) { + CM.Disp.TooltipWarn.style.display = 'block'; + var limitLucky = CM.Cache.Lucky; + if (CM.Config.ToolWarnBon == 1) { + var bonusNoFren = bonus; + bonusNoFren /= CM.Sim.getCPSBuffMult(); + limitLucky += ((bonusNoFren * 60 * 15) / 0.15); + } + var limitConjure = limitLucky * 2; + var amount = (Game.cookies + CM.Disp.GetWrinkConfigBank()) - price; + if ((amount < limitConjure) && (CM.Disp.tooltipType != 'b' || Game.buyMode == 1)) { + l('CMDispTooltipWarnConjure').style.display = ''; + l('CMDispTooltipWarnConjureText').textContent = Beautify(limitConjure - amount) + ' (' + CM.Disp.FormatTime((limitConjure - amount) / CM.Disp.GetCPS()) + ')'; } } else { - CM.Disp.TooltipWarn.style.display = 'none'; + l('CMDispTooltipWarnConjure').style.display = 'none'; } } else if (CM.Disp.tooltipType === 's') { // Adding information about Sugar Lumps. CM.Disp.TooltipWarn.style.display = 'none'; - l('CMDispTooltipWarn').style.display = 'none'; - l('CMDispTooltipWarnLuckyFrenzy').style.display = 'none'; + l('CMDispTooltipWarnLucky').style.display = 'none'; + l('CMDispTooltipWarnLuckyFrenzy').style.display = 'none'; + l('CMDispTooltipWarnConjure').style.display = 'none'; if (CM.Config.TooltipLump === 1) { l('CMTooltipArea').innerHTML = ''; @@ -2089,8 +2101,9 @@ CM.Disp.UpdateTooltip = function() { } else { // Grimoire CM.Disp.TooltipWarn.style.display = 'none'; - l('CMDispTooltipWarn').style.display = 'none'; + l('CMDispTooltipWarnLucky').style.display = 'none'; l('CMDispTooltipWarnLuckyFrenzy').style.display = 'none'; + l('CMDispTooltipWarnConjure').style.display = 'none'; var minigame = Game.Objects['Wizard tower'].minigame; var spellCost = minigame.getSpellCost(minigame.spellsById[CM.Disp.tooltipName]); @@ -2147,6 +2160,9 @@ CM.Disp.DrawTooltipWarn = function() { l('CMDispTooltipWarnLucky').style.opacity = '0'; l('CMDispTooltipWarnLuckyFrenzy').style.opacity = '0'; } + if (CM.Config.ToolWarnConjure == 1) { + l('CMDispTooltipWarnConjure').style.opacity = '0'; + } } CM.Disp.UpdateTooltipWarn = function() { @@ -2154,6 +2170,9 @@ CM.Disp.UpdateTooltipWarn = function() { l('CMDispTooltipWarnLucky').style.opacity = '1'; l('CMDispTooltipWarnLuckyFrenzy').style.opacity = '1'; } + if (CM.Config.ToolWarnConjure == 1 && l('tooltipAnchor').style.display != 'none' && l('CMTooltipArea') != null) { + l('CMDispTooltipWarnConjure').style.opacity = '1'; + } } CM.Disp.AddWrinklerAreaDetect = function() { diff --git a/src/Main.js b/src/Main.js index 544c618..5a8f828 100644 --- a/src/Main.js +++ b/src/Main.js @@ -286,7 +286,8 @@ CM.ConfigDefault = { Title: 1, TooltipBuildUp: 1, TooltipAmor: 0, - ToolWarnLucky: 1, + ToolWarnLucky: 1, + ToolWarnConjure: 1, ToolWarnPos: 1, TooltipGrim:1, ToolWrink: 1, From c68febd794f695932b3c689019a5f9af29264fe5 Mon Sep 17 00:00:00 2001 From: DanielNoord Date: Tue, 24 Nov 2020 11:23:52 +0100 Subject: [PATCH 06/49] Added stats for Conjure Baked Goods (#334) --- CookieMonster.js | 29 ++++++++++++++++++++++++++++- src/Cache.js | 4 ++++ src/Disp.js | 23 +++++++++++++++++++++++ src/Main.js | 2 +- 4 files changed, 56 insertions(+), 2 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 2ed1929..58c0a17 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -159,6 +159,8 @@ CM.Cache.RemakeLucky = function() { CM.Cache.LuckyReward = (CM.Cache.Lucky * 0.15) + 13; CM.Cache.LuckyFrenzy = CM.Cache.Lucky * 7; CM.Cache.LuckyRewardFrenzy = (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) { @@ -377,6 +379,8 @@ CM.Cache.Lucky = 0; CM.Cache.LuckyReward = 0; CM.Cache.LuckyFrenzy = 0; CM.Cache.LuckyRewardFrenzy = 0; +CM.Cache.Conjure = 0; +CM.Cache.ConjureReward = 0; CM.Cache.SeaSpec = 0; CM.Cache.Chain = 0; CM.Cache.ChainWrath = 0; @@ -2152,6 +2156,29 @@ CM.Disp.AddMenuStats = function(title) { stats.appendChild(listing(listingQuest('\"Chain\" Reward (CUR) (Golden / Wrath)', 'GoldCookTooltipPlaceholder'), 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')); @@ -3242,7 +3269,7 @@ CM.ConfigDefault = { SayTime: 1, GrimoireBar: 1, Scale: 2, - StatsPref: {Lucky: 1, Chain: 1, Prestige: 1, Wrink: 1, Sea: 1, Misc: 1}, + StatsPref: {Lucky: 1, Conjure: 1, Chain: 1, Prestige: 1, Wrink: 1, Sea: 1, Misc: 1}, Colors : {Blue: '#4bb8f0', Green: '#00ff00', Yellow: '#ffff00', Orange: '#ff7f00', Red: '#ff0000', Purple: '#ff00ff', Gray: '#b3b3b3', Pink: '#ff1493', Brown: '#8b4513'}, SortBuildings: 0, SortUpgrades: 0 diff --git a/src/Cache.js b/src/Cache.js index 1c31723..a27d678 100644 --- a/src/Cache.js +++ b/src/Cache.js @@ -139,6 +139,8 @@ CM.Cache.RemakeLucky = function() { CM.Cache.LuckyReward = (CM.Cache.Lucky * 0.15) + 13; CM.Cache.LuckyFrenzy = CM.Cache.Lucky * 7; CM.Cache.LuckyRewardFrenzy = (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) { @@ -357,6 +359,8 @@ CM.Cache.Lucky = 0; CM.Cache.LuckyReward = 0; CM.Cache.LuckyFrenzy = 0; CM.Cache.LuckyRewardFrenzy = 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/Disp.js b/src/Disp.js index 4efdc63..39a1213 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -1524,6 +1524,29 @@ CM.Disp.AddMenuStats = function(title) { stats.appendChild(listing(listingQuest('\"Chain\" Reward (CUR) (Golden / Wrath)', 'GoldCookTooltipPlaceholder'), 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')); diff --git a/src/Main.js b/src/Main.js index 5a8f828..4e1af4c 100644 --- a/src/Main.js +++ b/src/Main.js @@ -298,7 +298,7 @@ CM.ConfigDefault = { SayTime: 1, GrimoireBar: 1, Scale: 2, - StatsPref: {Lucky: 1, Chain: 1, Prestige: 1, Wrink: 1, Sea: 1, Misc: 1}, + StatsPref: {Lucky: 1, Conjure: 1, Chain: 1, Prestige: 1, Wrink: 1, Sea: 1, Misc: 1}, Colors : {Blue: '#4bb8f0', Green: '#00ff00', Yellow: '#ffff00', Orange: '#ff7f00', Red: '#ff0000', Purple: '#ff00ff', Gray: '#b3b3b3', Pink: '#ff1493', Brown: '#8b4513'}, SortBuildings: 0, SortUpgrades: 0 From 935ce42305c3a1e037d6a065bdff005ee4d4d768 Mon Sep 17 00:00:00 2001 From: DanielNoord Date: Tue, 24 Nov 2020 12:41:36 +0100 Subject: [PATCH 07/49] Support for Modded Objects/Upgrades/Achievs (#335) --- CookieMonster.js | 11 ++++++++++- src/Sim.js | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 58c0a17..2f7bc99 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -3447,6 +3447,9 @@ CM.Sim.CopyData = function() { for (var i in Game.Objects) { var me = Game.Objects[i]; var you = CM.Sim.Objects[i]; + if (you == undefined) { + CM.Sim.InitData(); + } you.amount = me.amount; you.level = me.level; } @@ -3455,6 +3458,9 @@ CM.Sim.CopyData = function() { for (var i in Game.Upgrades) { var me = Game.Upgrades[i]; var you = CM.Sim.Upgrades[i]; + if (you == undefined) { + CM.Sim.InitData(); + } you.bought = me.bought; } @@ -3462,6 +3468,9 @@ CM.Sim.CopyData = function() { for (var i in Game.Achievements) { var me = Game.Achievements[i]; var you = CM.Sim.Achievements[i]; + if (you == undefined) { + CM.Sim.InitData(); + } you.won = me.won; } }; @@ -3734,8 +3743,8 @@ CM.Sim.CheckOtherAchiev = function() { CM.Sim.BuyBuildings = function(amount, target) { CM.Cache[target] = []; + CM.Sim.CopyData(); for (var i in Game.Objects) { - CM.Sim.CopyData(); var me = CM.Sim.Objects[i]; me.amount += amount; diff --git a/src/Sim.js b/src/Sim.js index 1baab39..43e4d88 100644 --- a/src/Sim.js +++ b/src/Sim.js @@ -166,6 +166,9 @@ CM.Sim.CopyData = function() { for (var i in Game.Objects) { var me = Game.Objects[i]; var you = CM.Sim.Objects[i]; + if (you == undefined) { + CM.Sim.InitData(); + } you.amount = me.amount; you.level = me.level; } @@ -174,6 +177,9 @@ CM.Sim.CopyData = function() { for (var i in Game.Upgrades) { var me = Game.Upgrades[i]; var you = CM.Sim.Upgrades[i]; + if (you == undefined) { + CM.Sim.InitData(); + } you.bought = me.bought; } @@ -181,6 +187,9 @@ CM.Sim.CopyData = function() { for (var i in Game.Achievements) { var me = Game.Achievements[i]; var you = CM.Sim.Achievements[i]; + if (you == undefined) { + CM.Sim.InitData(); + } you.won = me.won; } }; @@ -453,8 +462,8 @@ CM.Sim.CheckOtherAchiev = function() { CM.Sim.BuyBuildings = function(amount, target) { CM.Cache[target] = []; + CM.Sim.CopyData(); for (var i in Game.Objects) { - CM.Sim.CopyData(); var me = CM.Sim.Objects[i]; me.amount += amount; From eda7514001f26cb0a7905566033c737429d123fa Mon Sep 17 00:00:00 2001 From: DanielNoord Date: Tue, 24 Nov 2020 13:29:02 +0100 Subject: [PATCH 08/49] Option to play sound at full Grimoire Meter (#337) --- CookieMonster.js | 33 +++++++++++++++++++++++++++++++++ src/Config.js | 7 +++++++ src/Disp.js | 19 +++++++++++++++++++ src/Main.js | 7 +++++++ 4 files changed, 66 insertions(+) diff --git a/CookieMonster.js b/CookieMonster.js index 2f7bc99..d482f64 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -580,6 +580,13 @@ 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.MagicFlash = {label: ['Magic Max Flash OFF', 'Magic Max Flash ON'], desc: 'Flash screen when magic reaches maxium', toggle: true}; +CM.ConfigData.MagicSound = {label: ['Magic Max Sound OFF', 'Magic Max Sound ON'], desc: 'Play a sound when magic reaches maxium', 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.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}; @@ -1635,6 +1642,20 @@ CM.Disp.CheckGardenTick = function() { } } +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.UpdateTitle = function() { if (Game.OnAscend || CM.Config.Title == 0) { document.title = CM.Cache.Title; @@ -1874,6 +1895,10 @@ CM.Disp.AddMenuPref = function(title) { frag.appendChild(listing('GardSound')); frag.appendChild(vol('GardVolume')); frag.appendChild(url('GardSoundURL')); + frag.appendChild(listing('MagicFlash')); + frag.appendChild(listing('MagicSound')); + frag.appendChild(vol('MagicVolume')); + frag.appendChild(url('MagicSoundURL')); frag.appendChild(listing('Title')); frag.appendChild(header('Tooltip')); @@ -2943,6 +2968,7 @@ CM.Disp.lastGoldenCookieState = 0; CM.Disp.lastTickerFortuneState = 0; CM.Disp.lastSeasonPopupState = 0; CM.Disp.lastGardenNextStep = 0; +CM.Disp.lastMagicBarFull = 0; CM.Disp.goldenShimmer; CM.Disp.seasonPopShimmer; CM.Disp.lastAscendState = -1; @@ -3166,6 +3192,9 @@ CM.Loop = function() { // Check Garden Tick CM.Disp.CheckGardenTick(); + // Check Grimoire Meter + CM.Disp.CheckMagicMeter(); + // Update Average CPS (might need to move) CM.Cache.UpdateAvgCPS() } @@ -3254,6 +3283,10 @@ CM.ConfigDefault = { GardSound: 1, GardVolume: 100, GardSoundURL: 'https://freesound.org/data/previews/103/103046_861714-lq.mp3', + MagicFlash: 1, + MagicSound: 1, + MagicVolume: 100, + MagicSoundURL: 'https://freesound.org/data/previews/221/221683_1015240-lq.mp3', Title: 1, TooltipBuildUp: 1, TooltipAmor: 0, diff --git a/src/Config.js b/src/Config.js index 6e8ad84..5aeba0b 100644 --- a/src/Config.js +++ b/src/Config.js @@ -170,6 +170,13 @@ 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.MagicFlash = {label: ['Magic Max Flash OFF', 'Magic Max Flash ON'], desc: 'Flash screen when magic reaches maxium', toggle: true}; +CM.ConfigData.MagicSound = {label: ['Magic Max Sound OFF', 'Magic Max Sound ON'], desc: 'Play a sound when magic reaches maxium', 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.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}; diff --git a/src/Disp.js b/src/Disp.js index 39a1213..2dbc5a9 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -1003,6 +1003,20 @@ CM.Disp.CheckGardenTick = function() { } } +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.UpdateTitle = function() { if (Game.OnAscend || CM.Config.Title == 0) { document.title = CM.Cache.Title; @@ -1242,6 +1256,10 @@ CM.Disp.AddMenuPref = function(title) { frag.appendChild(listing('GardSound')); frag.appendChild(vol('GardVolume')); frag.appendChild(url('GardSoundURL')); + frag.appendChild(listing('MagicFlash')); + frag.appendChild(listing('MagicSound')); + frag.appendChild(vol('MagicVolume')); + frag.appendChild(url('MagicSoundURL')); frag.appendChild(listing('Title')); frag.appendChild(header('Tooltip')); @@ -2311,6 +2329,7 @@ CM.Disp.lastGoldenCookieState = 0; CM.Disp.lastTickerFortuneState = 0; CM.Disp.lastSeasonPopupState = 0; CM.Disp.lastGardenNextStep = 0; +CM.Disp.lastMagicBarFull = 0; CM.Disp.goldenShimmer; CM.Disp.seasonPopShimmer; CM.Disp.lastAscendState = -1; diff --git a/src/Main.js b/src/Main.js index 4e1af4c..a1c4693 100644 --- a/src/Main.js +++ b/src/Main.js @@ -195,6 +195,9 @@ CM.Loop = function() { // Check Garden Tick CM.Disp.CheckGardenTick(); + // Check Grimoire Meter + CM.Disp.CheckMagicMeter(); + // Update Average CPS (might need to move) CM.Cache.UpdateAvgCPS() } @@ -283,6 +286,10 @@ CM.ConfigDefault = { GardSound: 1, GardVolume: 100, GardSoundURL: 'https://freesound.org/data/previews/103/103046_861714-lq.mp3', + MagicFlash: 1, + MagicSound: 1, + MagicVolume: 100, + MagicSoundURL: 'https://freesound.org/data/previews/221/221683_1015240-lq.mp3', Title: 1, TooltipBuildUp: 1, TooltipAmor: 0, From 8ea9400a07f66ff658aa2f658d84778c6eda74c6 Mon Sep 17 00:00:00 2001 From: DanielNoord Date: Tue, 24 Nov 2020 15:59:02 +0100 Subject: [PATCH 09/49] Fixed mistake with CopyData (#338) --- CookieMonster.js | 2 +- src/Sim.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index d482f64..a62aad5 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -3776,8 +3776,8 @@ CM.Sim.CheckOtherAchiev = function() { CM.Sim.BuyBuildings = function(amount, target) { CM.Cache[target] = []; - CM.Sim.CopyData(); for (var i in Game.Objects) { + CM.Sim.CopyData(); var me = CM.Sim.Objects[i]; me.amount += amount; diff --git a/src/Sim.js b/src/Sim.js index 43e4d88..f583dab 100644 --- a/src/Sim.js +++ b/src/Sim.js @@ -462,8 +462,8 @@ CM.Sim.CheckOtherAchiev = function() { CM.Sim.BuyBuildings = function(amount, target) { CM.Cache[target] = []; - CM.Sim.CopyData(); for (var i in Game.Objects) { + CM.Sim.CopyData(); var me = CM.Sim.Objects[i]; me.amount += amount; From d40f90d233e445624f0160502e8d8d2ae4e9209e Mon Sep 17 00:00:00 2001 From: DanielNoord Date: Tue, 24 Nov 2020 18:35:56 +0100 Subject: [PATCH 10/49] Sort Building list based on PP of selected buy mode (#340) --- CookieMonster.js | 4 ++-- src/Disp.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index a62aad5..517adc9 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -1283,9 +1283,9 @@ CM.Disp.UpdateBuildings = function() { // 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) - var arr = Object.keys(CM.Cache.Objects).map(k => + var arr = Object.keys(CM.Cache[target]).map(k => { - var o = CM.Cache.Objects[k]; + var o = CM.Cache[target][k]; o.name = k; o.id = Game.Objects[k].id; return o; diff --git a/src/Disp.js b/src/Disp.js index 2dbc5a9..ec26c81 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -644,9 +644,9 @@ CM.Disp.UpdateBuildings = function() { // 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) - var arr = Object.keys(CM.Cache.Objects).map(k => + var arr = Object.keys(CM.Cache[target]).map(k => { - var o = CM.Cache.Objects[k]; + var o = CM.Cache[target][k]; o.name = k; o.id = Game.Objects[k].id; return o; From 6922dd04653b8ebfaaf614f22dfda5b4d3fc0b96 Mon Sep 17 00:00:00 2001 From: DanielNoord Date: Tue, 24 Nov 2020 23:32:35 +0100 Subject: [PATCH 11/49] Option for notifications for Golden/Fortunes/Season Cookies & full Magic Bar (#341) --- CookieMonster.js | 57 +++++++++++++++++++++++++++++++++++++++++++++--- src/Config.js | 37 +++++++++++++++++++++++++++++-- src/Disp.js | 16 +++++++++++++- src/Main.js | 4 ++++ 4 files changed, 108 insertions(+), 6 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 517adc9..08dabe9 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -524,6 +524,35 @@ CM.ToggleStatsConfig = function(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();}}; @@ -550,6 +579,7 @@ CM.ConfigData.CPSMode = {label: ['Current Cookies Per Second', 'Average Cookies 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'}; @@ -559,6 +589,7 @@ for (var i = 0; i < 101; 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'}; @@ -566,6 +597,7 @@ 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'}; @@ -580,8 +612,9 @@ 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.MagicFlash = {label: ['Magic Max Flash OFF', 'Magic Max Flash ON'], desc: 'Flash screen when magic reaches maxium', toggle: true}; -CM.ConfigData.MagicSound = {label: ['Magic Max Sound OFF', 'Magic Max Sound ON'], desc: 'Play a sound when magic reaches maxium', toggle: true}; +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 + '%'; @@ -1512,6 +1545,13 @@ CM.Disp.PlaySound = function(url, sndConfig, volConfig) { } } +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}); + } +} + /** * Needed for some of the functions to use the right object */ @@ -1594,6 +1634,7 @@ CM.Disp.CheckGoldenCookie = function() { 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!") } else if (CM.Config.GCTimer == 1) CM.Disp.GCTimer.style.display = 'none'; } @@ -1610,6 +1651,7 @@ CM.Disp.CheckTickerFortune = function() { 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.") } } } @@ -1628,6 +1670,7 @@ CM.Disp.CheckSeasonPopup = function() { 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!") } } } @@ -1652,6 +1695,7 @@ CM.Disp.CheckMagicMeter = function() { 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!") } } } @@ -1877,16 +1921,19 @@ CM.Disp.AddMenuPref = function(title) { frag.appendChild(listing('ToolWarnBon')); frag.appendChild(header('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')); @@ -1895,6 +1942,7 @@ CM.Disp.AddMenuPref = function(title) { 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')); @@ -2994,7 +3042,6 @@ CM.Disp.TooltipText = [ ['ResetTooltipPlaceholder', 'The bonus income you would get from new prestige levels unlocked at 100% of its potential and from reset achievements if you have the same buildings/upgrades after reset', '370px'], ['ChoEggTooltipPlaceholder', 'The amount of cookies you would get from popping all wrinklers with Skruuia god in Diamond slot, selling all buildings with Earth Shatterer and Reality Bending auras, and then buying Chocolate egg', '300px'] ]; - /******** * Main * ********/ @@ -3265,16 +3312,19 @@ CM.ConfigDefault = { AvgCPSHist: 3, AvgClicksHist: 0, ToolWarnBon: 0, + GCNotification: 0, GCFlash: 1, GCSound: 1, GCVolume: 100, GCSoundURL: 'https://freesound.org/data/previews/66/66717_931655-lq.mp3', GCTimer: 1, Favicon: 1, + FortuneNotification: 0, FortuneFlash: 1, FortuneSound: 1, FortuneVolume: 100, FortuneSoundURL: 'https://freesound.org/data/previews/174/174027_3242494-lq.mp3', + SeaNotification: 0, SeaFlash: 1, SeaSound: 1, SeaVolume: 100, @@ -3283,6 +3333,7 @@ CM.ConfigDefault = { GardSound: 1, GardVolume: 100, GardSoundURL: 'https://freesound.org/data/previews/103/103046_861714-lq.mp3', + MagicNotification: 0, MagicFlash: 1, MagicSound: 1, MagicVolume: 100, diff --git a/src/Config.js b/src/Config.js index 5aeba0b..e978e57 100644 --- a/src/Config.js +++ b/src/Config.js @@ -114,6 +114,35 @@ CM.ToggleStatsConfig = function(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();}}; @@ -140,6 +169,7 @@ CM.ConfigData.CPSMode = {label: ['Current Cookies Per Second', 'Average Cookies 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'}; @@ -149,6 +179,7 @@ for (var i = 0; i < 101; 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'}; @@ -156,6 +187,7 @@ 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'}; @@ -170,8 +202,9 @@ 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.MagicFlash = {label: ['Magic Max Flash OFF', 'Magic Max Flash ON'], desc: 'Flash screen when magic reaches maxium', toggle: true}; -CM.ConfigData.MagicSound = {label: ['Magic Max Sound OFF', 'Magic Max Sound ON'], desc: 'Play a sound when magic reaches maxium', toggle: true}; +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 + '%'; diff --git a/src/Disp.js b/src/Disp.js index ec26c81..4593075 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -873,6 +873,13 @@ CM.Disp.PlaySound = function(url, sndConfig, volConfig) { } } +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}); + } +} + /** * Needed for some of the functions to use the right object */ @@ -955,6 +962,7 @@ CM.Disp.CheckGoldenCookie = function() { 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!") } else if (CM.Config.GCTimer == 1) CM.Disp.GCTimer.style.display = 'none'; } @@ -971,6 +979,7 @@ CM.Disp.CheckTickerFortune = function() { 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.") } } } @@ -989,6 +998,7 @@ CM.Disp.CheckSeasonPopup = function() { 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!") } } } @@ -1013,6 +1023,7 @@ CM.Disp.CheckMagicMeter = function() { 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!") } } } @@ -1238,16 +1249,19 @@ CM.Disp.AddMenuPref = function(title) { frag.appendChild(listing('ToolWarnBon')); frag.appendChild(header('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')); @@ -1256,6 +1270,7 @@ CM.Disp.AddMenuPref = function(title) { 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')); @@ -2355,4 +2370,3 @@ CM.Disp.TooltipText = [ ['ResetTooltipPlaceholder', 'The bonus income you would get from new prestige levels unlocked at 100% of its potential and from reset achievements if you have the same buildings/upgrades after reset', '370px'], ['ChoEggTooltipPlaceholder', 'The amount of cookies you would get from popping all wrinklers with Skruuia god in Diamond slot, selling all buildings with Earth Shatterer and Reality Bending auras, and then buying Chocolate egg', '300px'] ]; - diff --git a/src/Main.js b/src/Main.js index a1c4693..d2dafcc 100644 --- a/src/Main.js +++ b/src/Main.js @@ -268,16 +268,19 @@ CM.ConfigDefault = { AvgCPSHist: 3, AvgClicksHist: 0, ToolWarnBon: 0, + GCNotification: 0, GCFlash: 1, GCSound: 1, GCVolume: 100, GCSoundURL: 'https://freesound.org/data/previews/66/66717_931655-lq.mp3', GCTimer: 1, Favicon: 1, + FortuneNotification: 0, FortuneFlash: 1, FortuneSound: 1, FortuneVolume: 100, FortuneSoundURL: 'https://freesound.org/data/previews/174/174027_3242494-lq.mp3', + SeaNotification: 0, SeaFlash: 1, SeaSound: 1, SeaVolume: 100, @@ -286,6 +289,7 @@ CM.ConfigDefault = { GardSound: 1, GardVolume: 100, GardSoundURL: 'https://freesound.org/data/previews/103/103046_861714-lq.mp3', + MagicNotification: 0, MagicFlash: 1, MagicSound: 1, MagicVolume: 100, From 272f17be713f86942c3396c2d082c4197263d7f6 Mon Sep 17 00:00:00 2001 From: DanielNoord Date: Wed, 25 Nov 2020 11:25:56 +0100 Subject: [PATCH 12/49] Fixed warning tooltips not disappearing (#344) --- CookieMonster.js | 9 +++++---- src/Disp.js | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 08dabe9..5cfc967 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -2762,10 +2762,9 @@ CM.Disp.UpdateTooltip = function() { l('CMDispTooltipWarnLuckyFrenzyText').textContent = Beautify(limitLuckyFrenzy - amount) + ' (' + CM.Disp.FormatTime((limitLuckyFrenzy - amount) / CM.Disp.GetCPS()) + ')'; l('CMDispTooltipWarnLucky').style.display = 'none'; } - else { - l('CMDispTooltipWarnLucky').style.display = 'none'; - l('CMDispTooltipWarnLuckyFrenzy').style.display = 'none'; - } + } else { + l('CMDispTooltipWarnLucky').style.display = 'none'; + l('CMDispTooltipWarnLuckyFrenzy').style.display = 'none'; } } else { @@ -2786,6 +2785,8 @@ CM.Disp.UpdateTooltip = function() { if ((amount < limitConjure) && (CM.Disp.tooltipType != 'b' || Game.buyMode == 1)) { l('CMDispTooltipWarnConjure').style.display = ''; l('CMDispTooltipWarnConjureText').textContent = Beautify(limitConjure - amount) + ' (' + CM.Disp.FormatTime((limitConjure - amount) / CM.Disp.GetCPS()) + ')'; + } else { + l('CMDispTooltipWarnConjure').style.display = 'none'; } } else { diff --git a/src/Disp.js b/src/Disp.js index 4593075..dddd218 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -2090,10 +2090,9 @@ CM.Disp.UpdateTooltip = function() { l('CMDispTooltipWarnLuckyFrenzyText').textContent = Beautify(limitLuckyFrenzy - amount) + ' (' + CM.Disp.FormatTime((limitLuckyFrenzy - amount) / CM.Disp.GetCPS()) + ')'; l('CMDispTooltipWarnLucky').style.display = 'none'; } - else { - l('CMDispTooltipWarnLucky').style.display = 'none'; - l('CMDispTooltipWarnLuckyFrenzy').style.display = 'none'; - } + } else { + l('CMDispTooltipWarnLucky').style.display = 'none'; + l('CMDispTooltipWarnLuckyFrenzy').style.display = 'none'; } } else { @@ -2114,6 +2113,8 @@ CM.Disp.UpdateTooltip = function() { if ((amount < limitConjure) && (CM.Disp.tooltipType != 'b' || Game.buyMode == 1)) { l('CMDispTooltipWarnConjure').style.display = ''; l('CMDispTooltipWarnConjureText').textContent = Beautify(limitConjure - amount) + ' (' + CM.Disp.FormatTime((limitConjure - amount) / CM.Disp.GetCPS()) + ')'; + } else { + l('CMDispTooltipWarnConjure').style.display = 'none'; } } else { From 8a98c6f4db9ff8c37fa340b1ddad94679580be59 Mon Sep 17 00:00:00 2001 From: DanielNoord Date: Wed, 25 Nov 2020 12:46:47 +0100 Subject: [PATCH 13/49] Option to colour PP values based on the selected buy mode (#346) --- CookieMonster.js | 108 +++++++++++++++++++++++++++++++++++++---------- src/Cache.js | 103 +++++++++++++++++++++++++++++++++++--------- src/Config.js | 3 +- src/Disp.js | 1 + src/Main.js | 1 + 5 files changed, 172 insertions(+), 44 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 5cfc967..a320912 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -39,6 +39,7 @@ CM.Cache.NextNumber = function(base) { 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); } @@ -89,20 +90,86 @@ CM.Cache.RemakeBuildingsPP = function() { CM.Cache.min = -1; CM.Cache.max = -1; CM.Cache.mid = -1; - for (var i in CM.Cache.Objects) { - //CM.Cache.Objects[i].pp = Game.Objects[i].getPrice() / CM.Cache.Objects[i].bonus; - 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); - 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; + // 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; + 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); + 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; + 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); + 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) { + 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); + 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) { + 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); + 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'); + } } } @@ -140,17 +207,11 @@ CM.Cache.RemakeBuildingsOtherPP = function(amount, target) { } CM.Cache.RemakePP = function() { - // Buildings for 1 amount + // Buildings CM.Cache.RemakeBuildingsPP(); // Upgrades CM.Cache.RemakeUpgradePP(); - - // Buildings for 10 amount - CM.Cache.RemakeBuildingsOtherPP(10, 'Objects10'); - - // Buildings for 100 amount - CM.Cache.RemakeBuildingsOtherPP(100, 'Objects100'); } CM.Cache.RemakeLucky = function() { @@ -557,7 +618,8 @@ CM.ConfigData.BotBar = {label: ['Bottom Bar OFF', 'Bottom Bar ON'], desc: 'Build 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 Buildings Color)', 'Bulk Building Colors (Calculated 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.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 bul-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: { @@ -1894,6 +1956,7 @@ CM.Disp.AddMenuPref = function(title) { 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'); @@ -3306,6 +3369,7 @@ CM.ConfigDefault = { TimerBarPos: 0, BuildColor: 1, BulkBuildColor: 0, + ColorPPBulkMode: 0, UpBarColor: 1, UpgradeBarFixedPos: 1, CalcWrink: 0, diff --git a/src/Cache.js b/src/Cache.js index a27d678..57cc42b 100644 --- a/src/Cache.js +++ b/src/Cache.js @@ -19,6 +19,7 @@ CM.Cache.NextNumber = function(base) { 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); } @@ -69,20 +70,86 @@ CM.Cache.RemakeBuildingsPP = function() { CM.Cache.min = -1; CM.Cache.max = -1; CM.Cache.mid = -1; - for (var i in CM.Cache.Objects) { - //CM.Cache.Objects[i].pp = Game.Objects[i].getPrice() / CM.Cache.Objects[i].bonus; - 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); - 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; + // 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; + 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); + 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; + 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); + 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) { + 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); + 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) { + 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); + 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'); + } } } @@ -120,17 +187,11 @@ CM.Cache.RemakeBuildingsOtherPP = function(amount, target) { } CM.Cache.RemakePP = function() { - // Buildings for 1 amount + // Buildings CM.Cache.RemakeBuildingsPP(); // Upgrades CM.Cache.RemakeUpgradePP(); - - // Buildings for 10 amount - CM.Cache.RemakeBuildingsOtherPP(10, 'Objects10'); - - // Buildings for 100 amount - CM.Cache.RemakeBuildingsOtherPP(100, 'Objects100'); } CM.Cache.RemakeLucky = function() { diff --git a/src/Config.js b/src/Config.js index e978e57..b95e268 100644 --- a/src/Config.js +++ b/src/Config.js @@ -147,7 +147,8 @@ CM.ConfigData.BotBar = {label: ['Bottom Bar OFF', 'Bottom Bar ON'], desc: 'Build 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 Buildings Color)', 'Bulk Building Colors (Calculated 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.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 bul-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: { diff --git a/src/Disp.js b/src/Disp.js index dddd218..30deb56 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -1222,6 +1222,7 @@ CM.Disp.AddMenuPref = function(title) { 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'); diff --git a/src/Main.js b/src/Main.js index d2dafcc..5a65c9c 100644 --- a/src/Main.js +++ b/src/Main.js @@ -261,6 +261,7 @@ CM.ConfigDefault = { TimerBarPos: 0, BuildColor: 1, BulkBuildColor: 0, + ColorPPBulkMode: 0, UpBarColor: 1, UpgradeBarFixedPos: 1, CalcWrink: 0, From e05db88a72c9c1344eb0b1c0ee7e10792e45159d Mon Sep 17 00:00:00 2001 From: Chorizorro Date: Wed, 25 Nov 2020 14:06:55 +0100 Subject: [PATCH 14/49] Compute stock market in chocolate egg value (#345) --- CookieMonster.js | 12 +++++++++++- src/Cache.js | 10 ++++++++++ src/Disp.js | 2 +- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index a320912..d71a305 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -323,6 +323,16 @@ CM.Cache.RemakeSellForChoEgg = function() { sellTotal += CM.Sim.BuildingSell(me, me.basePrice, amount, me.free, amount, 1); } } + // 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; + } CM.Cache.SellForChoEgg = sellTotal; } @@ -3104,7 +3114,7 @@ CM.Disp.TooltipText = [ ['NextPrestTooltipPlaceholder', 'Calculated with cookies gained from wrinklers and Chocolate egg', '200px'], ['HeavenChipMaxTooltipPlaceholder', 'The MAX heavenly chips is calculated with the cookies gained from popping all wrinklers with Skruuia god in Diamond slot, selling all buildings with Earth Shatterer and Reality Bending auras, and buying Chocolate egg', '330px'], ['ResetTooltipPlaceholder', 'The bonus income you would get from new prestige levels unlocked at 100% of its potential and from reset achievements if you have the same buildings/upgrades after reset', '370px'], - ['ChoEggTooltipPlaceholder', 'The amount of cookies you would get from popping all wrinklers with Skruuia god in Diamond slot, selling all buildings with Earth Shatterer and Reality Bending auras, and then buying Chocolate egg', '300px'] + ['ChoEggTooltipPlaceholder', 'The amount of cookies you would get from popping all wrinklers with Skruuia god in Diamond slot, selling all buildings with Earth Shatterer and Reality Bending auras, selling all stock market goods, and then buying Chocolate egg', '300px'] ]; /******** * Main * diff --git a/src/Cache.js b/src/Cache.js index 57cc42b..09955fe 100644 --- a/src/Cache.js +++ b/src/Cache.js @@ -303,6 +303,16 @@ CM.Cache.RemakeSellForChoEgg = function() { sellTotal += CM.Sim.BuildingSell(me, me.basePrice, amount, me.free, amount, 1); } } + // 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; + } CM.Cache.SellForChoEgg = sellTotal; } diff --git a/src/Disp.js b/src/Disp.js index 30deb56..853c21c 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -2370,5 +2370,5 @@ CM.Disp.TooltipText = [ ['NextPrestTooltipPlaceholder', 'Calculated with cookies gained from wrinklers and Chocolate egg', '200px'], ['HeavenChipMaxTooltipPlaceholder', 'The MAX heavenly chips is calculated with the cookies gained from popping all wrinklers with Skruuia god in Diamond slot, selling all buildings with Earth Shatterer and Reality Bending auras, and buying Chocolate egg', '330px'], ['ResetTooltipPlaceholder', 'The bonus income you would get from new prestige levels unlocked at 100% of its potential and from reset achievements if you have the same buildings/upgrades after reset', '370px'], - ['ChoEggTooltipPlaceholder', 'The amount of cookies you would get from popping all wrinklers with Skruuia god in Diamond slot, selling all buildings with Earth Shatterer and Reality Bending auras, and then buying Chocolate egg', '300px'] + ['ChoEggTooltipPlaceholder', 'The amount of cookies you would get from popping all wrinklers with Skruuia god in Diamond slot, selling all buildings with Earth Shatterer and Reality Bending auras, selling all stock market goods, and then buying Chocolate egg', '300px'] ]; From 3d965943c0c0cce5df026ddc075912dbdf2faf28 Mon Sep 17 00:00:00 2001 From: DanielNoord Date: Wed, 25 Nov 2020 21:44:14 +0100 Subject: [PATCH 15/49] Optional Sound/Flash/Notif. for (Max) Wrinklers (#349) --- CookieMonster.js | 71 +++++++++++++++++++++++++++++++++++++++++++++++- src/Config.js | 16 +++++++++++ src/Disp.js | 40 +++++++++++++++++++++++++++ src/Main.js | 15 +++++++++- 4 files changed, 140 insertions(+), 2 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index d71a305..5aca795 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -692,6 +692,22 @@ 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}; @@ -1772,6 +1788,35 @@ CM.Disp.CheckMagicMeter = function() { } } +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; @@ -2020,6 +2065,16 @@ CM.Disp.AddMenuPref = function(title) { 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')); @@ -3091,6 +3146,7 @@ CM.Disp.lastTickerFortuneState = 0; CM.Disp.lastSeasonPopupState = 0; CM.Disp.lastGardenNextStep = 0; CM.Disp.lastMagicBarFull = 0; +CM.Disp.lastWrinklerCount = 0; CM.Disp.goldenShimmer; CM.Disp.seasonPopShimmer; CM.Disp.lastAscendState = -1; @@ -3316,6 +3372,9 @@ CM.Loop = function() { // Check Grimoire Meter CM.Disp.CheckMagicMeter(); + // Check Wrinklers + CM.Disp.CheckWrinklerCount(); + // Update Average CPS (might need to move) CM.Cache.UpdateAvgCPS() } @@ -3412,7 +3471,17 @@ CM.ConfigDefault = { MagicFlash: 1, MagicSound: 1, MagicVolume: 100, - MagicSoundURL: 'https://freesound.org/data/previews/221/221683_1015240-lq.mp3', + MagicSoundURL: 'https://freesound.org/data/previews/221/221683_1015240-lq.mp3', + WrinklerNotification: 0, + WrinklerFlash: 1, + WrinklerSound: 1, + WrinklerVolume: 100, + WrinklerSoundURL: 'https://freesound.org/data/previews/124/124186_8043-lq.mp3', + WrinklerMaxNotification: 0, + WrinklerMaxFlash: 1, + WrinklerMaxSound: 1, + WrinklerMaxVolume: 100, + WrinklerMaxSoundURL: 'https://freesound.org/data/previews/152/152743_15663-lq.mp3', Title: 1, TooltipBuildUp: 1, TooltipAmor: 0, diff --git a/src/Config.js b/src/Config.js index b95e268..34d369d 100644 --- a/src/Config.js +++ b/src/Config.js @@ -211,6 +211,22 @@ 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}; diff --git a/src/Disp.js b/src/Disp.js index 853c21c..0dd6e4f 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -1028,6 +1028,35 @@ CM.Disp.CheckMagicMeter = function() { } } +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; @@ -1276,6 +1305,16 @@ CM.Disp.AddMenuPref = function(title) { 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')); @@ -2347,6 +2386,7 @@ CM.Disp.lastTickerFortuneState = 0; CM.Disp.lastSeasonPopupState = 0; CM.Disp.lastGardenNextStep = 0; CM.Disp.lastMagicBarFull = 0; +CM.Disp.lastWrinklerCount = 0; CM.Disp.goldenShimmer; CM.Disp.seasonPopShimmer; CM.Disp.lastAscendState = -1; diff --git a/src/Main.js b/src/Main.js index 5a65c9c..01a961b 100644 --- a/src/Main.js +++ b/src/Main.js @@ -198,6 +198,9 @@ CM.Loop = function() { // Check Grimoire Meter CM.Disp.CheckMagicMeter(); + // Check Wrinklers + CM.Disp.CheckWrinklerCount(); + // Update Average CPS (might need to move) CM.Cache.UpdateAvgCPS() } @@ -294,7 +297,17 @@ CM.ConfigDefault = { MagicFlash: 1, MagicSound: 1, MagicVolume: 100, - MagicSoundURL: 'https://freesound.org/data/previews/221/221683_1015240-lq.mp3', + MagicSoundURL: 'https://freesound.org/data/previews/221/221683_1015240-lq.mp3', + WrinklerNotification: 0, + WrinklerFlash: 1, + WrinklerSound: 1, + WrinklerVolume: 100, + WrinklerSoundURL: 'https://freesound.org/data/previews/124/124186_8043-lq.mp3', + WrinklerMaxNotification: 0, + WrinklerMaxFlash: 1, + WrinklerMaxSound: 1, + WrinklerMaxVolume: 100, + WrinklerMaxSoundURL: 'https://freesound.org/data/previews/152/152743_15663-lq.mp3', Title: 1, TooltipBuildUp: 1, TooltipAmor: 0, From 66ac922ae24bd41ff67c3c56953c6271e9a17ed8 Mon Sep 17 00:00:00 2001 From: staticvariablejames <69834129+staticvariablejames@users.noreply.github.com> Date: Thu, 26 Nov 2020 11:01:06 -0600 Subject: [PATCH 16/49] Compatibility with content mods (#350) --- Combine.sh | 0 CookieMonster.js | 65 ++++++++++++++++++++++++++++++------------------ src/Disp.js | 61 +++++++++++++++++++++++++++------------------ src/Sim.js | 4 +++ 4 files changed, 82 insertions(+), 48 deletions(-) mode change 100644 => 100755 Combine.sh diff --git a/Combine.sh b/Combine.sh old mode 100644 new mode 100755 diff --git a/CookieMonster.js b/CookieMonster.js index 5aca795..d5f2e9b 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -1016,6 +1016,36 @@ CM.Disp.CreateCssArea = function() { 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'; @@ -1032,15 +1062,14 @@ CM.Disp.CreateBotBar = function() { 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 = document.createElement('table'); + 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 = document.createElement('tbody'); - table.appendChild(tbody); + var tbody = table.appendChild(document.createElement('tbody')); var firstCol = function(text, color) { var td = document.createElement('td'); @@ -1050,36 +1079,20 @@ CM.Disp.CreateBotBar = function() { return td; } - var type = document.createElement('tr'); + var type = tbody.appendChild(document.createElement('tr')); type.style.fontWeight = 'bold'; type.appendChild(firstCol(CM.VersionMajor + '.' + CM.VersionMinor, CM.Disp.colorYellow)); - tbody.appendChild(type); - var bonus = document.createElement('tr'); + var bonus = tbody.appendChild(document.createElement('tr')); bonus.appendChild(firstCol('Bonus Income', CM.Disp.colorBlue)); - tbody.appendChild(bonus); - var pp = document.createElement('tr'); + var pp = tbody.appendChild(document.createElement('tr')); pp.appendChild(firstCol('Payback Period', CM.Disp.colorBlue)); - tbody.appendChild(pp); - var time = document.createElement('tr'); + var time = tbody.appendChild(document.createElement('tr')); time.appendChild(firstCol('Time Left', CM.Disp.colorBlue)); - tbody.appendChild(time); for (var i in Game.Objects) { - var header = document.createElement('td'); - header.appendChild(document.createTextNode((i.indexOf(' ') != -1 ? i.substring(0, i.indexOf(' ')) : i) + ' (')); - var span = document.createElement('span'); - span.className = CM.Disp.colorTextPre + CM.Disp.colorBlue; - header.appendChild(span); - header.appendChild(document.createTextNode(')')); - type.appendChild(header); - bonus.appendChild(document.createElement('td')); - pp.appendChild(document.createElement('td')); - time.appendChild(document.createElement('td')); - + CM.Disp.CreateBotBarBuildingColumn(i); } - CM.Disp.BotBar.appendChild(table); - l('wrapper').appendChild(CM.Disp.BotBar); } @@ -3677,6 +3690,8 @@ CM.Sim.CopyData = function() { var you = CM.Sim.Objects[i]; if (you == undefined) { CM.Sim.InitData(); + you = CM.Sim.Objects[i]; // Not undefined anymore + CM.Disp.CreateBotBarBuildingColumn(i); // New building! Add it to the bottom bar } you.amount = me.amount; you.level = me.level; @@ -3688,6 +3703,7 @@ CM.Sim.CopyData = function() { var you = CM.Sim.Upgrades[i]; if (you == undefined) { CM.Sim.InitData(); + you = CM.Sim.Upgrades[i]; } you.bought = me.bought; } @@ -3698,6 +3714,7 @@ CM.Sim.CopyData = function() { var you = CM.Sim.Achievements[i]; if (you == undefined) { CM.Sim.InitData(); + you = CM.Sim.Achievements[i]; } you.won = me.won; } diff --git a/src/Disp.js b/src/Disp.js index 0dd6e4f..fee96e6 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -256,6 +256,36 @@ CM.Disp.CreateCssArea = function() { 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'; @@ -272,15 +302,14 @@ CM.Disp.CreateBotBar = function() { 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 = document.createElement('table'); + 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 = document.createElement('tbody'); - table.appendChild(tbody); + var tbody = table.appendChild(document.createElement('tbody')); var firstCol = function(text, color) { var td = document.createElement('td'); @@ -290,36 +319,20 @@ CM.Disp.CreateBotBar = function() { return td; } - var type = document.createElement('tr'); + var type = tbody.appendChild(document.createElement('tr')); type.style.fontWeight = 'bold'; type.appendChild(firstCol(CM.VersionMajor + '.' + CM.VersionMinor, CM.Disp.colorYellow)); - tbody.appendChild(type); - var bonus = document.createElement('tr'); + var bonus = tbody.appendChild(document.createElement('tr')); bonus.appendChild(firstCol('Bonus Income', CM.Disp.colorBlue)); - tbody.appendChild(bonus); - var pp = document.createElement('tr'); + var pp = tbody.appendChild(document.createElement('tr')); pp.appendChild(firstCol('Payback Period', CM.Disp.colorBlue)); - tbody.appendChild(pp); - var time = document.createElement('tr'); + var time = tbody.appendChild(document.createElement('tr')); time.appendChild(firstCol('Time Left', CM.Disp.colorBlue)); - tbody.appendChild(time); for (var i in Game.Objects) { - var header = document.createElement('td'); - header.appendChild(document.createTextNode((i.indexOf(' ') != -1 ? i.substring(0, i.indexOf(' ')) : i) + ' (')); - var span = document.createElement('span'); - span.className = CM.Disp.colorTextPre + CM.Disp.colorBlue; - header.appendChild(span); - header.appendChild(document.createTextNode(')')); - type.appendChild(header); - bonus.appendChild(document.createElement('td')); - pp.appendChild(document.createElement('td')); - time.appendChild(document.createElement('td')); - + CM.Disp.CreateBotBarBuildingColumn(i); } - CM.Disp.BotBar.appendChild(table); - l('wrapper').appendChild(CM.Disp.BotBar); } diff --git a/src/Sim.js b/src/Sim.js index f583dab..429fd68 100644 --- a/src/Sim.js +++ b/src/Sim.js @@ -168,6 +168,8 @@ CM.Sim.CopyData = function() { var you = CM.Sim.Objects[i]; if (you == undefined) { CM.Sim.InitData(); + you = CM.Sim.Objects[i]; // Not undefined anymore + CM.Disp.CreateBotBarBuildingColumn(i); // New building! Add it to the bottom bar } you.amount = me.amount; you.level = me.level; @@ -179,6 +181,7 @@ CM.Sim.CopyData = function() { var you = CM.Sim.Upgrades[i]; if (you == undefined) { CM.Sim.InitData(); + you = CM.Sim.Upgrades[i]; } you.bought = me.bought; } @@ -189,6 +192,7 @@ CM.Sim.CopyData = function() { var you = CM.Sim.Achievements[i]; if (you == undefined) { CM.Sim.InitData(); + you = CM.Sim.Achievements[i]; } you.won = me.won; } From 744ee0dc5eb71f53f2dcec630cddb8395bafe9db Mon Sep 17 00:00:00 2001 From: DanielNoord Date: Thu, 26 Nov 2020 18:56:34 +0100 Subject: [PATCH 17/49] Bottom bar now changes depending on bulk-mode and has a height that fits all info (#354) --- CookieMonster.js | 17 ++++++++++------- src/Config.js | 2 +- src/Disp.js | 15 +++++++++------ 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index d5f2e9b..86f7d10 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -629,7 +629,7 @@ CM.ConfigData.TimerBar = {label: ['Timer Bar OFF', 'Timer Bar ON'], desc: 'Timer 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 bul-buy mode', toggle: false}; +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: { @@ -1049,7 +1049,7 @@ CM.Disp.CreateBotBarBuildingColumn = function(buildingName) { CM.Disp.CreateBotBar = function() { CM.Disp.BotBar = document.createElement('div'); CM.Disp.BotBar.id = 'CMBotBar'; - CM.Disp.BotBar.style.height = '55px'; + CM.Disp.BotBar.style.height = '69px'; CM.Disp.BotBar.style.width = '100%'; CM.Disp.BotBar.style.position = 'absolute'; CM.Disp.BotBar.style.display = 'none'; @@ -1112,11 +1112,14 @@ CM.Disp.UpdateBotBarOther = function() { 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.Objects[i].bonus, 2); - CM.Disp.BotBar.firstChild.firstChild.childNodes[2].childNodes[count].className = CM.Disp.colorTextPre + CM.Cache.Objects[i].color; - CM.Disp.BotBar.firstChild.firstChild.childNodes[2].childNodes[count].textContent = Beautify(CM.Cache.Objects[i].pp, 2); + 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); } } } @@ -1370,11 +1373,11 @@ CM.Disp.UpdateTimerBar = function() { 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 = '104px'; + l('game').style.bottom = '118px'; } else if (CM.Config.BotBar == 1) { CM.Disp.BotBar.style.bottom = '0px'; - l('game').style.bottom = '56px'; + l('game').style.bottom = '70px'; } else if (CM.Config.TimerBar == 1 && CM.Config.TimerBarPos == 1) { l('game').style.bottom = '48px'; diff --git a/src/Config.js b/src/Config.js index 34d369d..8f8822a 100644 --- a/src/Config.js +++ b/src/Config.js @@ -148,7 +148,7 @@ CM.ConfigData.TimerBar = {label: ['Timer Bar OFF', 'Timer Bar ON'], desc: 'Timer 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 bul-buy mode', toggle: false}; +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: { diff --git a/src/Disp.js b/src/Disp.js index fee96e6..4128e47 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -289,7 +289,7 @@ CM.Disp.CreateBotBarBuildingColumn = function(buildingName) { CM.Disp.CreateBotBar = function() { CM.Disp.BotBar = document.createElement('div'); CM.Disp.BotBar.id = 'CMBotBar'; - CM.Disp.BotBar.style.height = '55px'; + CM.Disp.BotBar.style.height = '69px'; CM.Disp.BotBar.style.width = '100%'; CM.Disp.BotBar.style.position = 'absolute'; CM.Disp.BotBar.style.display = 'none'; @@ -352,11 +352,14 @@ CM.Disp.UpdateBotBarOther = function() { 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.Objects[i].bonus, 2); - CM.Disp.BotBar.firstChild.firstChild.childNodes[2].childNodes[count].className = CM.Disp.colorTextPre + CM.Cache.Objects[i].color; - CM.Disp.BotBar.firstChild.firstChild.childNodes[2].childNodes[count].textContent = Beautify(CM.Cache.Objects[i].pp, 2); + 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); } } } @@ -610,11 +613,11 @@ CM.Disp.UpdateTimerBar = function() { 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 = '104px'; + l('game').style.bottom = '118px'; } else if (CM.Config.BotBar == 1) { CM.Disp.BotBar.style.bottom = '0px'; - l('game').style.bottom = '56px'; + l('game').style.bottom = '70px'; } else if (CM.Config.TimerBar == 1 && CM.Config.TimerBarPos == 1) { l('game').style.bottom = '48px'; From 291ff1ae6abc1511d6ee22a4e70301eaa022a8a1 Mon Sep 17 00:00:00 2001 From: Chorizorro Date: Fri, 27 Nov 2020 17:58:49 +0100 Subject: [PATCH 18/49] Add sim for selling buildings for chocolate egg Add a simulation for selling all buildings with Earth Shatterer + Reality bending auras, and use it in chocolate egg value calculation --- CookieMonster.js | 133 ++++++++++++++++++++++++++++++----------------- src/Cache.js | 40 ++------------ src/Disp.js | 4 +- src/Sim.js | 88 +++++++++++++++++++++++++++---- 4 files changed, 167 insertions(+), 98 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 86f7d10..cd73bb0 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -286,43 +286,7 @@ CM.Cache.RemakeSeaSpec = function() { } CM.Cache.RemakeSellForChoEgg = function() { - if (Game.auraMult('Earth Shatterer') == 1.1) { - var sellTotal = 0; - for (var i in Game.Objects) { - var me = Game.Objects[i]; - sellTotal += CM.Sim.BuildingSell(me, me.basePrice, me.amount, me.free, me.amount, 0); - } - } - else { - var highestBuilding = ''; - for (var i in Game.Objects) { - if (Game.Objects[i].amount > 0) highestBuilding = i; - } - var secondHighBuild = ''; - if (Game.auraMult('Earth Shatterer') == 0 && highestBuilding != '') { - if (Game.Objects[highestBuilding].amount > 1) { - secondHighBuild = highestBuilding; - } - else { - for (var i in Game.Objects) { - if (i != highestBuilding && Game.Objects[i].amount > 0) secondHighBuild = i; - } - } - } - - var sellTotal = 0; - for (var i in Game.Objects) { - var me = Game.Objects[i]; - var amount = me.amount; - if (i == highestBuilding) { - amount -= 1; - } - if (i == secondHighBuild) { - amount -= 1; - } - sellTotal += CM.Sim.BuildingSell(me, me.basePrice, amount, me.free, amount, 1); - } - } + var sellTotal = 0; // Compute cookies earned by selling stock market goods if (Game.Objects.Bank.minigameLoaded) { var marketGoods = Game.Objects.Bank.minigame.goods; @@ -333,6 +297,8 @@ CM.Cache.RemakeSellForChoEgg = function() { } sellTotal += goodsVal * Game.cookiesPsRawHighest; } + // Compute cookies earned by selling all buildings with optimal auras (ES + RB) + sellTotal += CM.Sim.SellBuildingsForChoEgg(); CM.Cache.SellForChoEgg = sellTotal; } @@ -2756,10 +2722,10 @@ CM.Disp.Tooltip = function(type, name) { } else if (Game.buyMode == -1) { if (Game.buyBulk == -1) { - l('tooltip').innerHTML = l('tooltip').innerHTML.split(Beautify(Game.Objects[name].getPrice())).join('-' + Beautify(CM.Sim.BuildingSell(Game.Objects[name], Game.Objects[name].basePrice, Game.Objects[name].amount, Game.Objects[name].free, Game.Objects[name].amount, 0))); + l('tooltip').innerHTML = l('tooltip').innerHTML.split(Beautify(Game.Objects[name].getPrice())).join('-' + Beautify(CM.Sim.BuildingSell(Game.Objects[name], Game.Objects[name].basePrice, Game.Objects[name].amount, Game.Objects[name].free, Game.Objects[name].amount))); } else { - l('tooltip').innerHTML = l('tooltip').innerHTML.split(Beautify(Game.Objects[name].getPrice())).join('-' + Beautify(CM.Sim.BuildingSell(Game.Objects[name], Game.Objects[name].basePrice, Game.Objects[name].amount, Game.Objects[name].free, Game.buyBulk, 0))); + l('tooltip').innerHTML = l('tooltip').innerHTML.split(Beautify(Game.Objects[name].getPrice())).join('-' + Beautify(CM.Sim.BuildingSell(Game.Objects[name], Game.Objects[name].basePrice, Game.Objects[name].amount, Game.Objects[name].free, Game.buyBulk))); } } } @@ -3550,7 +3516,7 @@ CM.Sim.BuildingGetPrice = function(build, basePrice, start, free, increase) { return moni; } -CM.Sim.BuildingSell = function(build, basePrice, start, free, amount, emuAura) { +CM.Sim.BuildingSell = function(build, basePrice, start, free, amount) { /*var price=0; for (var i = Math.max(0, start - amount); i < Math.max(0, start); i++) { price += basePrice * Math.pow(Game.priceIncrease, Math.max(0, i - free)); @@ -3568,18 +3534,13 @@ CM.Sim.BuildingSell = function(build, basePrice, start, free, amount, emuAura) { } return Math.ceil(price);*/ - var moni=0; + // Calculate money gains from selling buildings + var moni = 0; for (var i = 0; i < amount; i++) { var price = basePrice * Math.pow(Game.priceIncrease, Math.max(0, start - free)); - price = Game.modifyBuildingPrice(build, price); + price = CM.Sim.modifyBuildingPrice(build, price); price = Math.ceil(price); - var giveBack = 0.25; - if (emuAura) { - giveBack = 0.5; - } - else { - giveBack *= 1 + Game.auraMult('Earth Shatterer'); - } + var giveBack = CM.Sim.getSellMultiplier(); price = Math.floor(price * giveBack); if (start > 0) { moni += price; @@ -4145,6 +4106,80 @@ CM.Sim.ResetBonus = function(possiblePresMax) { return (CM.Sim.cookiesPs - curCPS); } +CM.Sim.getSellMultiplier = function() { + var giveBack = 0.25; + giveBack *= 1 + CM.Sim.auraMult('Earth Shatterer'); + return giveBack; +} + +CM.Sim.modifyBuildingPrice = function(building,price) { + if (CM.Sim.Has('Season savings')) price *= 0.99; + if (CM.Sim.Has('Santa\'s dominion')) price *= 0.99; + if (CM.Sim.Has('Faberge egg')) price *= 0.99; + if (CM.Sim.Has('Divine discount')) price *= 0.99; + if (CM.Sim.Has('Fortune #100')) price *= 0.99; + //if (CM.Sim.hasAura('Fierce Hoarder')) price *= 0.98; + price *= 1 - CM.Sim.auraMult('Fierce Hoarder') * 0.02; + if (Game.hasBuff('Everything must go')) price *= 0.95; + if (Game.hasBuff('Crafty pixies')) price *= 0.98; + if (Game.hasBuff('Nasty goblins')) price *= 1.02; + if (building.fortune && CM.Sim.Has(building.fortune.name)) price *= 0.93; + price *= Game.eff('buildingCost'); + if (Game.hasGod) { + var godLvl = Game.hasGod('creation'); + if (godLvl == 1) price *= 0.93; + else if (godLvl == 2) price *= 0.95; + else if (godLvl == 3) price *= 0.98; + } + return price; +} + +CM.Sim.SellBuildingsForChoEgg = function() { + var sellTotal = 0; + + CM.Sim.CopyData(); + + // Change auras to Earth Shatterer + Reality bending to optimize money made by selling + var buildingsToSacrifice = 2; + if (CM.Sim.dragonAura === 5 || CM.Sim.dragonAura === 18) { + --buildingsToSacrifice; + } + if (CM.Sim.dragonAura2 === 5 || CM.Sim.dragonAura2 === 18) { + --buildingsToSacrifice; + } + CM.Sim.dragonAura = 5; + CM.Sim.dragonAura2 = 18; + // Sacrifice highest buildings for the aura switch + for (var i = 0; i < buildingsToSacrifice; ++i) { + var highestBuilding = 0; + for (var j in CM.Sim.Objects) { + if (CM.Sim.Objects[j].amount > 0) { + highestBuilding = CM.Sim.Objects[j]; + } + } + highestBuilding.amount--; + CM.Sim.buildingsOwned--; + } + + // Get money made by selling all remaining buildings + for (var i in CM.Sim.Objects) { + var me = CM.Sim.Objects[i]; + debug = CM.Sim.BuildingSell(Game.Objects[me.name], Game.Objects[i].basePrice, me.amount, Game.Objects[i].free, me.amount); + sellTotal += debug; + } + + // CM.Sim.CalculateGains(); + + // CM.Sim.CheckOtherAchiev(); + + // if (lastAchievementsOwned != CM.Sim.AchievementsOwned) { + // CM.Sim.CalculateGains(); + // } + + // CM.Cache.DoRemakeBuildPrices = 1; + + return sellTotal; +} /********** * Footer * **********/ diff --git a/src/Cache.js b/src/Cache.js index 09955fe..f5ed125 100644 --- a/src/Cache.js +++ b/src/Cache.js @@ -266,43 +266,7 @@ CM.Cache.RemakeSeaSpec = function() { } CM.Cache.RemakeSellForChoEgg = function() { - if (Game.auraMult('Earth Shatterer') == 1.1) { - var sellTotal = 0; - for (var i in Game.Objects) { - var me = Game.Objects[i]; - sellTotal += CM.Sim.BuildingSell(me, me.basePrice, me.amount, me.free, me.amount, 0); - } - } - else { - var highestBuilding = ''; - for (var i in Game.Objects) { - if (Game.Objects[i].amount > 0) highestBuilding = i; - } - var secondHighBuild = ''; - if (Game.auraMult('Earth Shatterer') == 0 && highestBuilding != '') { - if (Game.Objects[highestBuilding].amount > 1) { - secondHighBuild = highestBuilding; - } - else { - for (var i in Game.Objects) { - if (i != highestBuilding && Game.Objects[i].amount > 0) secondHighBuild = i; - } - } - } - - var sellTotal = 0; - for (var i in Game.Objects) { - var me = Game.Objects[i]; - var amount = me.amount; - if (i == highestBuilding) { - amount -= 1; - } - if (i == secondHighBuild) { - amount -= 1; - } - sellTotal += CM.Sim.BuildingSell(me, me.basePrice, amount, me.free, amount, 1); - } - } + var sellTotal = 0; // Compute cookies earned by selling stock market goods if (Game.Objects.Bank.minigameLoaded) { var marketGoods = Game.Objects.Bank.minigame.goods; @@ -313,6 +277,8 @@ CM.Cache.RemakeSellForChoEgg = function() { } sellTotal += goodsVal * Game.cookiesPsRawHighest; } + // Compute cookies earned by selling all buildings with optimal auras (ES + RB) + sellTotal += CM.Sim.SellBuildingsForChoEgg(); CM.Cache.SellForChoEgg = sellTotal; } diff --git a/src/Disp.js b/src/Disp.js index 4128e47..fd5cce1 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -1996,10 +1996,10 @@ CM.Disp.Tooltip = function(type, name) { } else if (Game.buyMode == -1) { if (Game.buyBulk == -1) { - l('tooltip').innerHTML = l('tooltip').innerHTML.split(Beautify(Game.Objects[name].getPrice())).join('-' + Beautify(CM.Sim.BuildingSell(Game.Objects[name], Game.Objects[name].basePrice, Game.Objects[name].amount, Game.Objects[name].free, Game.Objects[name].amount, 0))); + l('tooltip').innerHTML = l('tooltip').innerHTML.split(Beautify(Game.Objects[name].getPrice())).join('-' + Beautify(CM.Sim.BuildingSell(Game.Objects[name], Game.Objects[name].basePrice, Game.Objects[name].amount, Game.Objects[name].free, Game.Objects[name].amount))); } else { - l('tooltip').innerHTML = l('tooltip').innerHTML.split(Beautify(Game.Objects[name].getPrice())).join('-' + Beautify(CM.Sim.BuildingSell(Game.Objects[name], Game.Objects[name].basePrice, Game.Objects[name].amount, Game.Objects[name].free, Game.buyBulk, 0))); + l('tooltip').innerHTML = l('tooltip').innerHTML.split(Beautify(Game.Objects[name].getPrice())).join('-' + Beautify(CM.Sim.BuildingSell(Game.Objects[name], Game.Objects[name].basePrice, Game.Objects[name].amount, Game.Objects[name].free, Game.buyBulk))); } } } diff --git a/src/Sim.js b/src/Sim.js index 429fd68..72e03ea 100644 --- a/src/Sim.js +++ b/src/Sim.js @@ -25,7 +25,7 @@ CM.Sim.BuildingGetPrice = function(build, basePrice, start, free, increase) { return moni; } -CM.Sim.BuildingSell = function(build, basePrice, start, free, amount, emuAura) { +CM.Sim.BuildingSell = function(build, basePrice, start, free, amount) { /*var price=0; for (var i = Math.max(0, start - amount); i < Math.max(0, start); i++) { price += basePrice * Math.pow(Game.priceIncrease, Math.max(0, i - free)); @@ -43,18 +43,13 @@ CM.Sim.BuildingSell = function(build, basePrice, start, free, amount, emuAura) { } return Math.ceil(price);*/ - var moni=0; + // Calculate money gains from selling buildings + var moni = 0; for (var i = 0; i < amount; i++) { var price = basePrice * Math.pow(Game.priceIncrease, Math.max(0, start - free)); - price = Game.modifyBuildingPrice(build, price); + price = CM.Sim.modifyBuildingPrice(build, price); price = Math.ceil(price); - var giveBack = 0.25; - if (emuAura) { - giveBack = 0.5; - } - else { - giveBack *= 1 + Game.auraMult('Earth Shatterer'); - } + var giveBack = CM.Sim.getSellMultiplier(); price = Math.floor(price * giveBack); if (start > 0) { moni += price; @@ -620,3 +615,76 @@ CM.Sim.ResetBonus = function(possiblePresMax) { return (CM.Sim.cookiesPs - curCPS); } +CM.Sim.getSellMultiplier = function() { + var giveBack = 0.25; + giveBack *= 1 + CM.Sim.auraMult('Earth Shatterer'); + return giveBack; +} + +CM.Sim.modifyBuildingPrice = function(building,price) { + if (CM.Sim.Has('Season savings')) price *= 0.99; + if (CM.Sim.Has('Santa\'s dominion')) price *= 0.99; + if (CM.Sim.Has('Faberge egg')) price *= 0.99; + if (CM.Sim.Has('Divine discount')) price *= 0.99; + if (CM.Sim.Has('Fortune #100')) price *= 0.99; + //if (CM.Sim.hasAura('Fierce Hoarder')) price *= 0.98; + price *= 1 - CM.Sim.auraMult('Fierce Hoarder') * 0.02; + if (Game.hasBuff('Everything must go')) price *= 0.95; + if (Game.hasBuff('Crafty pixies')) price *= 0.98; + if (Game.hasBuff('Nasty goblins')) price *= 1.02; + if (building.fortune && CM.Sim.Has(building.fortune.name)) price *= 0.93; + price *= Game.eff('buildingCost'); + if (Game.hasGod) { + var godLvl = Game.hasGod('creation'); + if (godLvl == 1) price *= 0.93; + else if (godLvl == 2) price *= 0.95; + else if (godLvl == 3) price *= 0.98; + } + return price; +} + +CM.Sim.SellBuildingsForChoEgg = function() { + var sellTotal = 0; + + CM.Sim.CopyData(); + + // Change auras to Earth Shatterer + Reality bending to optimize money made by selling + var buildingsToSacrifice = 2; + if (CM.Sim.dragonAura === 5 || CM.Sim.dragonAura === 18) { + --buildingsToSacrifice; + } + if (CM.Sim.dragonAura2 === 5 || CM.Sim.dragonAura2 === 18) { + --buildingsToSacrifice; + } + CM.Sim.dragonAura = 5; + CM.Sim.dragonAura2 = 18; + // Sacrifice highest buildings for the aura switch + for (var i = 0; i < buildingsToSacrifice; ++i) { + var highestBuilding = 0; + for (var j in CM.Sim.Objects) { + if (CM.Sim.Objects[j].amount > 0) { + highestBuilding = CM.Sim.Objects[j]; + } + } + highestBuilding.amount--; + CM.Sim.buildingsOwned--; + } + + // Get money made by selling all remaining buildings + for (var i in CM.Sim.Objects) { + var me = CM.Sim.Objects[i]; + sellTotal += CM.Sim.BuildingSell(Game.Objects[me.name], Game.Objects[i].basePrice, me.amount, Game.Objects[i].free, me.amount); + } + + // CM.Sim.CalculateGains(); + + // CM.Sim.CheckOtherAchiev(); + + // if (lastAchievementsOwned != CM.Sim.AchievementsOwned) { + // CM.Sim.CalculateGains(); + // } + + // CM.Cache.DoRemakeBuildPrices = 1; + + return sellTotal; +} From 8f809cc0930c9a03f3196679cb7fe93b8f9544fa Mon Sep 17 00:00:00 2001 From: Static Variable James Date: Thu, 26 Nov 2020 20:49:06 -0600 Subject: [PATCH 19/49] Fix accidentally erasing data if a new building/upgrade/achievement is found. --- CookieMonster.js | 72 ++++++++++++++++++++++++++++++++---------------- src/Sim.js | 72 ++++++++++++++++++++++++++++++++---------------- 2 files changed, 96 insertions(+), 48 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 86f7d10..5f3941f 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -3645,35 +3645,63 @@ CM.Sim.getCPSBuffMult = function() { return mult; } +/* Constructs an object with the static properties of a building, + * but with a 'cps' method changed to use 'CM.Sim.Has' instead of 'Game.Has' + * (and similar to 'hasAura', 'Objects', 'GetTieredCpsMult' and 'auraMult'). + * + * The dynamic properties of the building, + * namely level and amount owned, + * are set by CM.Sim.CopyData. + */ +CM.Sim.InitialBuildingData = function(buildingName) { + var me = Game.Objects[buildingName]; + var you = {}; + eval('you.cps = ' + me.cps.toString() + .split('Game.Has').join('CM.Sim.Has') + .split('Game.hasAura').join('CM.Sim.hasAura') + .split('Game.Objects').join('CM.Sim.Objects') + .split('Game.GetTieredCpsMult').join('CM.Sim.GetTieredCpsMult') + .split('Game.auraMult').join('CM.Sim.auraMult') + ); + // Below is needed for above eval! + you.baseCps = me.baseCps; + you.name = me.name; + return you; +} + +/* Similar to the previous function, but for upgrades. + * Note: currently no static data is used by Cookie Monster, + * so this function just returns an empty object. + */ +CM.Sim.InitUpgrade = function(upgradeName) { + return {}; +} + +/* Similar to the previous function, but for achievements. + * Note: currently no static data is used by Cookie Monster, + * so this function just returns an empty object. + */ +CM.Sim.InitAchievement = function(achievementName) { + return {}; +} + CM.Sim.InitData = function() { // Buildings CM.Sim.Objects = []; for (var i in Game.Objects) { - CM.Sim.Objects[i] = {}; - var me = Game.Objects[i]; - var you = CM.Sim.Objects[i]; - eval('you.cps = ' + me.cps.toString() - .split('Game.Has').join('CM.Sim.Has') - .split('Game.hasAura').join('CM.Sim.hasAura') - .split('Game.Objects').join('CM.Sim.Objects') - .split('Game.GetTieredCpsMult').join('CM.Sim.GetTieredCpsMult') - .split('Game.auraMult').join('CM.Sim.auraMult') - ); - // Below is needed for above eval! - you.baseCps = me.baseCps; - you.name = me.name; + CM.Sim.Objects[i] = CM.Sim.InitialBuildingData(i); } // Upgrades CM.Sim.Upgrades = []; for (var i in Game.Upgrades) { - CM.Sim.Upgrades[i] = {}; + CM.Sim.Upgrades[i] = CM.Sim.InitUpgrade(i); } // Achievements CM.Sim.Achievements = []; for (var i in Game.Achievements) { - CM.Sim.Achievements[i] = {}; + CM.Sim.Achievements[i] = CM.Sim.InitAchievement(i); } } @@ -3691,10 +3719,9 @@ CM.Sim.CopyData = function() { for (var i in Game.Objects) { var me = Game.Objects[i]; var you = CM.Sim.Objects[i]; - if (you == undefined) { - CM.Sim.InitData(); - you = CM.Sim.Objects[i]; // Not undefined anymore - CM.Disp.CreateBotBarBuildingColumn(i); // New building! Add it to the bottom bar + if (you == undefined) { // New building! + you = CM.Sim.Objects[i] = CM.Sim.InitialBuildingData(i); + CM.Disp.CreateBotBarBuildingColumn(i); // Add new building to the bottom bar } you.amount = me.amount; you.level = me.level; @@ -3705,8 +3732,7 @@ CM.Sim.CopyData = function() { var me = Game.Upgrades[i]; var you = CM.Sim.Upgrades[i]; if (you == undefined) { - CM.Sim.InitData(); - you = CM.Sim.Upgrades[i]; + you = CM.Sim.Upgrades[i] = CM.Sim.InitUpgrade(i); } you.bought = me.bought; } @@ -3716,14 +3742,12 @@ CM.Sim.CopyData = function() { var me = Game.Achievements[i]; var you = CM.Sim.Achievements[i]; if (you == undefined) { - CM.Sim.InitData(); - you = CM.Sim.Achievements[i]; + you = CM.Sim.Achievements[i] = CM.Sim.InitAchievement(i); } you.won = me.won; } }; - CM.Sim.CalculateGains = function() { CM.Sim.cookiesPs = 0; var mult = 1; diff --git a/src/Sim.js b/src/Sim.js index 429fd68..2abed2f 100644 --- a/src/Sim.js +++ b/src/Sim.js @@ -120,35 +120,63 @@ CM.Sim.getCPSBuffMult = function() { return mult; } +/* Constructs an object with the static properties of a building, + * but with a 'cps' method changed to use 'CM.Sim.Has' instead of 'Game.Has' + * (and similar to 'hasAura', 'Objects', 'GetTieredCpsMult' and 'auraMult'). + * + * The dynamic properties of the building, + * namely level and amount owned, + * are set by CM.Sim.CopyData. + */ +CM.Sim.InitialBuildingData = function(buildingName) { + var me = Game.Objects[buildingName]; + var you = {}; + eval('you.cps = ' + me.cps.toString() + .split('Game.Has').join('CM.Sim.Has') + .split('Game.hasAura').join('CM.Sim.hasAura') + .split('Game.Objects').join('CM.Sim.Objects') + .split('Game.GetTieredCpsMult').join('CM.Sim.GetTieredCpsMult') + .split('Game.auraMult').join('CM.Sim.auraMult') + ); + // Below is needed for above eval! + you.baseCps = me.baseCps; + you.name = me.name; + return you; +} + +/* Similar to the previous function, but for upgrades. + * Note: currently no static data is used by Cookie Monster, + * so this function just returns an empty object. + */ +CM.Sim.InitUpgrade = function(upgradeName) { + return {}; +} + +/* Similar to the previous function, but for achievements. + * Note: currently no static data is used by Cookie Monster, + * so this function just returns an empty object. + */ +CM.Sim.InitAchievement = function(achievementName) { + return {}; +} + CM.Sim.InitData = function() { // Buildings CM.Sim.Objects = []; for (var i in Game.Objects) { - CM.Sim.Objects[i] = {}; - var me = Game.Objects[i]; - var you = CM.Sim.Objects[i]; - eval('you.cps = ' + me.cps.toString() - .split('Game.Has').join('CM.Sim.Has') - .split('Game.hasAura').join('CM.Sim.hasAura') - .split('Game.Objects').join('CM.Sim.Objects') - .split('Game.GetTieredCpsMult').join('CM.Sim.GetTieredCpsMult') - .split('Game.auraMult').join('CM.Sim.auraMult') - ); - // Below is needed for above eval! - you.baseCps = me.baseCps; - you.name = me.name; + CM.Sim.Objects[i] = CM.Sim.InitialBuildingData(i); } // Upgrades CM.Sim.Upgrades = []; for (var i in Game.Upgrades) { - CM.Sim.Upgrades[i] = {}; + CM.Sim.Upgrades[i] = CM.Sim.InitUpgrade(i); } // Achievements CM.Sim.Achievements = []; for (var i in Game.Achievements) { - CM.Sim.Achievements[i] = {}; + CM.Sim.Achievements[i] = CM.Sim.InitAchievement(i); } } @@ -166,10 +194,9 @@ CM.Sim.CopyData = function() { for (var i in Game.Objects) { var me = Game.Objects[i]; var you = CM.Sim.Objects[i]; - if (you == undefined) { - CM.Sim.InitData(); - you = CM.Sim.Objects[i]; // Not undefined anymore - CM.Disp.CreateBotBarBuildingColumn(i); // New building! Add it to the bottom bar + if (you == undefined) { // New building! + you = CM.Sim.Objects[i] = CM.Sim.InitialBuildingData(i); + CM.Disp.CreateBotBarBuildingColumn(i); // Add new building to the bottom bar } you.amount = me.amount; you.level = me.level; @@ -180,8 +207,7 @@ CM.Sim.CopyData = function() { var me = Game.Upgrades[i]; var you = CM.Sim.Upgrades[i]; if (you == undefined) { - CM.Sim.InitData(); - you = CM.Sim.Upgrades[i]; + you = CM.Sim.Upgrades[i] = CM.Sim.InitUpgrade(i); } you.bought = me.bought; } @@ -191,14 +217,12 @@ CM.Sim.CopyData = function() { var me = Game.Achievements[i]; var you = CM.Sim.Achievements[i]; if (you == undefined) { - CM.Sim.InitData(); - you = CM.Sim.Achievements[i]; + you = CM.Sim.Achievements[i] = CM.Sim.InitAchievement(i); } you.won = me.won; } }; - CM.Sim.CalculateGains = function() { CM.Sim.cookiesPs = 0; var mult = 1; From 44d532146b081a175c73df8f8ac035dbad376274 Mon Sep 17 00:00:00 2001 From: Chorizorro Date: Sat, 28 Nov 2020 10:44:53 +0100 Subject: [PATCH 20/49] Update ascension, heavenly chips and chocolate egg tooltips Update ascension, heavenly chips and chocolate egg tooltips --- CookieMonster.js | 10 +++++----- src/Disp.js | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 86f7d10..cec911d 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -3181,12 +3181,12 @@ for (var i in Game.wrinklers) { } CM.Disp.TooltipText = [ - ['GoldCookTooltipPlaceholder', 'Calculated with Golden Switch off', '200px'], - ['PrestMaxTooltipPlaceholder', 'The MAX prestige is calculated with the cookies gained from popping all wrinklers with Skruuia god in Diamond slot, selling all buildings with Earth Shatterer and Reality Bending auras, and buying Chocolate egg', '320px'], + ['GoldCookTooltipPlaceholder', 'Calculated with Golden Switch off', '200px'], + ['PrestMaxTooltipPlaceholder', 'The MAX prestige is calculated with the cookies gained from popping all wrinklers with Skruuia god in Diamond slot, selling all stock market goods, selling all buildings with Earth Shatterer and Reality Bending auras, and buying Chocolate egg', '320px'], ['NextPrestTooltipPlaceholder', 'Calculated with cookies gained from wrinklers and Chocolate egg', '200px'], - ['HeavenChipMaxTooltipPlaceholder', 'The MAX heavenly chips is calculated with the cookies gained from popping all wrinklers with Skruuia god in Diamond slot, selling all buildings with Earth Shatterer and Reality Bending auras, and buying Chocolate egg', '330px'], - ['ResetTooltipPlaceholder', 'The bonus income you would get from new prestige levels unlocked at 100% of its potential and from reset achievements if you have the same buildings/upgrades after reset', '370px'], - ['ChoEggTooltipPlaceholder', 'The amount of cookies you would get from popping all wrinklers with Skruuia god in Diamond slot, selling all buildings with Earth Shatterer and Reality Bending auras, selling all stock market goods, and then buying Chocolate egg', '300px'] + ['HeavenChipMaxTooltipPlaceholder', 'The MAX heavenly chips is calculated with the cookies gained from popping all wrinklers with Skruuia god in Diamond slot, selling all stock market goods, selling all buildings with Earth Shatterer and Reality Bending auras, and buying Chocolate egg', '330px'], + ['ResetTooltipPlaceholder', 'The bonus income you would get from new prestige levels unlocked at 100% of its potential and from ascension achievements if you have the same buildings/upgrades after reset', '370px'], + ['ChoEggTooltipPlaceholder', 'The amount of cookies you would get from popping all wrinklers with Skruuia god in Diamond slot, selling all stock market goods, selling all buildings with Earth Shatterer and Reality Bending auras, and then buying Chocolate egg', '300px'] ]; /******** * Main * diff --git a/src/Disp.js b/src/Disp.js index 4128e47..97c7219 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -2421,10 +2421,10 @@ for (var i in Game.wrinklers) { } CM.Disp.TooltipText = [ - ['GoldCookTooltipPlaceholder', 'Calculated with Golden Switch off', '200px'], - ['PrestMaxTooltipPlaceholder', 'The MAX prestige is calculated with the cookies gained from popping all wrinklers with Skruuia god in Diamond slot, selling all buildings with Earth Shatterer and Reality Bending auras, and buying Chocolate egg', '320px'], + ['GoldCookTooltipPlaceholder', 'Calculated with Golden Switch off', '200px'], + ['PrestMaxTooltipPlaceholder', 'The MAX prestige is calculated with the cookies gained from popping all wrinklers with Skruuia god in Diamond slot, selling all stock market goods, selling all buildings with Earth Shatterer and Reality Bending auras, and buying Chocolate egg', '320px'], ['NextPrestTooltipPlaceholder', 'Calculated with cookies gained from wrinklers and Chocolate egg', '200px'], - ['HeavenChipMaxTooltipPlaceholder', 'The MAX heavenly chips is calculated with the cookies gained from popping all wrinklers with Skruuia god in Diamond slot, selling all buildings with Earth Shatterer and Reality Bending auras, and buying Chocolate egg', '330px'], - ['ResetTooltipPlaceholder', 'The bonus income you would get from new prestige levels unlocked at 100% of its potential and from reset achievements if you have the same buildings/upgrades after reset', '370px'], - ['ChoEggTooltipPlaceholder', 'The amount of cookies you would get from popping all wrinklers with Skruuia god in Diamond slot, selling all buildings with Earth Shatterer and Reality Bending auras, selling all stock market goods, and then buying Chocolate egg', '300px'] + ['HeavenChipMaxTooltipPlaceholder', 'The MAX heavenly chips is calculated with the cookies gained from popping all wrinklers with Skruuia god in Diamond slot, selling all stock market goods, selling all buildings with Earth Shatterer and Reality Bending auras, and buying Chocolate egg', '330px'], + ['ResetTooltipPlaceholder', 'The bonus income you would get from new prestige levels unlocked at 100% of its potential and from ascension achievements if you have the same buildings/upgrades after reset', '370px'], + ['ChoEggTooltipPlaceholder', 'The amount of cookies you would get from popping all wrinklers with Skruuia god in Diamond slot, selling all stock market goods, selling all buildings with Earth Shatterer and Reality Bending auras, and then buying Chocolate egg', '300px'] ]; From 564d136df3c292276229b7f183f2c005d10a1dc0 Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Sat, 28 Nov 2020 12:41:26 +0100 Subject: [PATCH 21/49] Cleaned up CM.Sim.CalculateGains and added TODOs --- CookieMonster.js | 56 +++++++++++++++++++++++++++++------------------- src/Sim.js | 53 ++++++++++++++++++++++++++++----------------- 2 files changed, 67 insertions(+), 42 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 0587e53..b1bbd09 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -3577,6 +3577,8 @@ CM.Sim.hasAura = function(what) { return false; } +// Check if multiplier auras are present +// Used as CM.Sim.auraMult('Aura') * mult, i.e. CM.Sim.auraMult('Dragon God) * 0.05 CM.Sim.auraMult = function(what) { var n = 0; if (Game.dragonAuras[CM.Sim.dragonAura].name == what || Game.dragonAuras[CM.Sim.dragonAura2].name == what) @@ -3643,7 +3645,7 @@ CM.Sim.CopyData = function() { CM.Sim.UpgradesOwned = Game.UpgradesOwned; CM.Sim.pledges = Game.pledges; CM.Sim.AchievementsOwned = Game.AchievementsOwned; - CM.Sim.heavenlyPower = Game.heavenlyPower; // Unneeded? + CM.Sim.heavenlyPower = Game.heavenlyPower; // Unneeded? > Might be modded CM.Sim.prestige = Game.prestige; CM.Sim.dragonAura = Game.dragonAura; CM.Sim.dragonAura2 = Game.dragonAura2; @@ -3688,15 +3690,22 @@ CM.Sim.CopyData = function() { CM.Sim.CalculateGains = function() { CM.Sim.cookiesPs = 0; var mult = 1; - + // Include minigame effects + for (var i in CM.Cache.Objects) { + // TODO Store minigames and effects in Cache + // Include possibility of new/modded building and new/modded minigames + if (Game.Objects[i].minigameLoaded && Game.Objects[i].minigame.effs) { + } + } + if (Game.ascensionMode != 1) mult += parseFloat(CM.Sim.prestige) * 0.01 * CM.Sim.heavenlyPower * CM.Sim.GetHeavenlyMultiplier(); - // TODO Store minigame buffs? mult *= Game.eff('cps'); - + if (CM.Sim.Has('Heralds') && Game.ascensionMode != 1) mult *= 1 + 0.01 * Game.heralds; - var cookieMult = 0; + // TODO: Make function call cached function where Game.Has is replaced with CM.Has + // Related to valentine cookies for (var i in Game.cookieUpgrades) { var me = Game.cookieUpgrades[i]; if (CM.Sim.Has(me.name)) { @@ -3704,7 +3713,6 @@ CM.Sim.CalculateGains = function() { } } - mult *= (1 + 0.01 * cookieMult); if (CM.Sim.Has('Specialized chocolate chips')) mult *= 1.01; if (CM.Sim.Has('Designer cocoa beans')) mult *= 1.02; if (CM.Sim.Has('Underworld ovens')) mult *= 1.03; @@ -3722,6 +3730,8 @@ CM.Sim.CalculateGains = function() { if (CM.Sim.Has('Dragon scale')) mult *= 1.03; + // Cached and sim temple gods + // TODO: Caches chosen gods var buildMult = 1; if (Game.hasGod) { var godLvl = Game.hasGod('asceticism'); @@ -3729,6 +3739,7 @@ CM.Sim.CalculateGains = function() { else if (godLvl == 2) mult *= 1.1; else if (godLvl == 3) mult *= 1.05; + // TODO: What does DateAges do? var godLvl = Game.hasGod('ages'); if (godLvl == 1) mult *= 1 + 0.15 * Math.sin((CM.Sim.DateAges / 1000 / (60 * 60 * 3)) * Math.PI * 2); else if (godLvl == 2) mult *= 1 + 0.15 * Math.sin((CM.Sim.DateAges / 1000 / (60 * 60 * 12)) * Math.PI*2); @@ -3824,26 +3835,25 @@ CM.Sim.CalculateGains = function() { //if (CM.Sim.hasAura('Radiant Appetite')) mult *= 2; mult *= 1 + CM.Sim.auraMult('Radiant Appetite'); - if (true) { // || CM.Sim.hasAura('Dragon\'s Fortune')) { - var n = Game.shimmerTypes['golden'].n; - var auraMult = CM.Sim.auraMult('Dragon\'s Fortune'); - for (var i = 0; i < n; i++) { - mult *= 1 + auraMult * 1.23; - } - } - var rawCookiesPs = CM.Sim.cookiesPs * mult; - for (var i in Game.CpsAchievements) { if (rawCookiesPs >= Game.CpsAchievements[i].threshold) CM.Sim.Win(Game.CpsAchievements[i].name); } - mult *= CM.Sim.getCPSBuffMult(); + CM.Sim.cookiesPsRaw=rawCookiesPs; + + if (CM.Sim.hasAura('Dragon\'s Fortune')) { + var n = Game.shimmerTypes['golden'].n; + for (var i = 0; i < n; i++) { + mult *= 1.23; + } + } - // Pointless? var name = Game.bakeryName.toLowerCase(); if (name == 'orteil') mult *= 0.99; - else if (name == 'ortiel') mult *= 0.98; //or so help me + else if (name == 'ortiel') mult *= 0.98; + + // TODO: Move CalcWink option and calculation here from CM.Disp if (CM.Sim.Has('Elder Covenant')) mult *= 0.95; @@ -3862,13 +3872,15 @@ CM.Sim.CalculateGains = function() { if (CM.Sim.Has('Reinforced membrane')) veilMult += 0.1; mult *= 1 + veilMult; } + // Removed debug upgrades - // Removed buffs + mult *= CM.Sim.getCPSBuffMult(); + + // TODO: Handle ModHooks, see Game code CM.Sim.cookiesPs *= mult; - // TODO remove? // if (Game.hasBuff('Cursed finger')) Game.cookiesPs = 0; }; @@ -4091,6 +4103,7 @@ CM.Sim.ResetBonus = function(possiblePresMax) { CM.Sim.Upgrades['Heavenly confectionery'].bought = 1; CM.Sim.Upgrades['Heavenly key'].bought = 1; + // TODO: Fix this reseting. CM.Sim.prestige = possiblePresMax; lastAchievementsOwned = CM.Sim.AchievementsOwned; @@ -4164,8 +4177,7 @@ CM.Sim.SellBuildingsForChoEgg = function() { // Get money made by selling all remaining buildings for (var i in CM.Sim.Objects) { var me = CM.Sim.Objects[i]; - debug = CM.Sim.BuildingSell(Game.Objects[me.name], Game.Objects[i].basePrice, me.amount, Game.Objects[i].free, me.amount); - sellTotal += debug; + sellTotal += CM.Sim.BuildingSell(Game.Objects[me.name], Game.Objects[i].basePrice, me.amount, Game.Objects[i].free, me.amount); } // CM.Sim.CalculateGains(); diff --git a/src/Sim.js b/src/Sim.js index 72e03ea..0047faf 100644 --- a/src/Sim.js +++ b/src/Sim.js @@ -86,6 +86,8 @@ CM.Sim.hasAura = function(what) { return false; } +// Check if multiplier auras are present +// Used as CM.Sim.auraMult('Aura') * mult, i.e. CM.Sim.auraMult('Dragon God) * 0.05 CM.Sim.auraMult = function(what) { var n = 0; if (Game.dragonAuras[CM.Sim.dragonAura].name == what || Game.dragonAuras[CM.Sim.dragonAura2].name == what) @@ -152,7 +154,7 @@ CM.Sim.CopyData = function() { CM.Sim.UpgradesOwned = Game.UpgradesOwned; CM.Sim.pledges = Game.pledges; CM.Sim.AchievementsOwned = Game.AchievementsOwned; - CM.Sim.heavenlyPower = Game.heavenlyPower; // Unneeded? + CM.Sim.heavenlyPower = Game.heavenlyPower; // Unneeded? > Might be modded CM.Sim.prestige = Game.prestige; CM.Sim.dragonAura = Game.dragonAura; CM.Sim.dragonAura2 = Game.dragonAura2; @@ -197,15 +199,22 @@ CM.Sim.CopyData = function() { CM.Sim.CalculateGains = function() { CM.Sim.cookiesPs = 0; var mult = 1; - + // Include minigame effects + for (var i in CM.Cache.Objects) { + // TODO Store minigames and effects in Cache + // Include possibility of new/modded building and new/modded minigames + if (Game.Objects[i].minigameLoaded && Game.Objects[i].minigame.effs) { + } + } + if (Game.ascensionMode != 1) mult += parseFloat(CM.Sim.prestige) * 0.01 * CM.Sim.heavenlyPower * CM.Sim.GetHeavenlyMultiplier(); - // TODO Store minigame buffs? mult *= Game.eff('cps'); - + if (CM.Sim.Has('Heralds') && Game.ascensionMode != 1) mult *= 1 + 0.01 * Game.heralds; - var cookieMult = 0; + // TODO: Make function call cached function where Game.Has is replaced with CM.Has + // Related to valentine cookies for (var i in Game.cookieUpgrades) { var me = Game.cookieUpgrades[i]; if (CM.Sim.Has(me.name)) { @@ -213,7 +222,6 @@ CM.Sim.CalculateGains = function() { } } - mult *= (1 + 0.01 * cookieMult); if (CM.Sim.Has('Specialized chocolate chips')) mult *= 1.01; if (CM.Sim.Has('Designer cocoa beans')) mult *= 1.02; if (CM.Sim.Has('Underworld ovens')) mult *= 1.03; @@ -231,6 +239,8 @@ CM.Sim.CalculateGains = function() { if (CM.Sim.Has('Dragon scale')) mult *= 1.03; + // Cached and sim temple gods + // TODO: Caches chosen gods var buildMult = 1; if (Game.hasGod) { var godLvl = Game.hasGod('asceticism'); @@ -238,6 +248,7 @@ CM.Sim.CalculateGains = function() { else if (godLvl == 2) mult *= 1.1; else if (godLvl == 3) mult *= 1.05; + // TODO: What does DateAges do? var godLvl = Game.hasGod('ages'); if (godLvl == 1) mult *= 1 + 0.15 * Math.sin((CM.Sim.DateAges / 1000 / (60 * 60 * 3)) * Math.PI * 2); else if (godLvl == 2) mult *= 1 + 0.15 * Math.sin((CM.Sim.DateAges / 1000 / (60 * 60 * 12)) * Math.PI*2); @@ -333,26 +344,25 @@ CM.Sim.CalculateGains = function() { //if (CM.Sim.hasAura('Radiant Appetite')) mult *= 2; mult *= 1 + CM.Sim.auraMult('Radiant Appetite'); - if (true) { // || CM.Sim.hasAura('Dragon\'s Fortune')) { - var n = Game.shimmerTypes['golden'].n; - var auraMult = CM.Sim.auraMult('Dragon\'s Fortune'); - for (var i = 0; i < n; i++) { - mult *= 1 + auraMult * 1.23; - } - } - var rawCookiesPs = CM.Sim.cookiesPs * mult; - for (var i in Game.CpsAchievements) { if (rawCookiesPs >= Game.CpsAchievements[i].threshold) CM.Sim.Win(Game.CpsAchievements[i].name); } - mult *= CM.Sim.getCPSBuffMult(); + CM.Sim.cookiesPsRaw=rawCookiesPs; + + if (CM.Sim.hasAura('Dragon\'s Fortune')) { + var n = Game.shimmerTypes['golden'].n; + for (var i = 0; i < n; i++) { + mult *= 1.23; + } + } - // Pointless? var name = Game.bakeryName.toLowerCase(); if (name == 'orteil') mult *= 0.99; - else if (name == 'ortiel') mult *= 0.98; //or so help me + else if (name == 'ortiel') mult *= 0.98; + + // TODO: Move CalcWink option and calculation here from CM.Disp if (CM.Sim.Has('Elder Covenant')) mult *= 0.95; @@ -371,13 +381,15 @@ CM.Sim.CalculateGains = function() { if (CM.Sim.Has('Reinforced membrane')) veilMult += 0.1; mult *= 1 + veilMult; } + // Removed debug upgrades - // Removed buffs + mult *= CM.Sim.getCPSBuffMult(); + + // TODO: Handle ModHooks, see Game code CM.Sim.cookiesPs *= mult; - // TODO remove? // if (Game.hasBuff('Cursed finger')) Game.cookiesPs = 0; }; @@ -600,6 +612,7 @@ CM.Sim.ResetBonus = function(possiblePresMax) { CM.Sim.Upgrades['Heavenly confectionery'].bought = 1; CM.Sim.Upgrades['Heavenly key'].bought = 1; + // TODO: Fix this reseting. CM.Sim.prestige = possiblePresMax; lastAchievementsOwned = CM.Sim.AchievementsOwned; From 9de75915315d9431e24ef1347a96acd880e5be53 Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Sat, 28 Nov 2020 12:44:32 +0100 Subject: [PATCH 22/49] Fixed CM.Sim.prestige not resetting --- CookieMonster.js | 8 ++++++-- src/Sim.js | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index b1bbd09..939ea07 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -4103,7 +4103,6 @@ CM.Sim.ResetBonus = function(possiblePresMax) { CM.Sim.Upgrades['Heavenly confectionery'].bought = 1; CM.Sim.Upgrades['Heavenly key'].bought = 1; - // TODO: Fix this reseting. CM.Sim.prestige = possiblePresMax; lastAchievementsOwned = CM.Sim.AchievementsOwned; @@ -4116,7 +4115,12 @@ CM.Sim.ResetBonus = function(possiblePresMax) { CM.Sim.CalculateGains(); } - return (CM.Sim.cookiesPs - curCPS); + var ResetCPS = CM.Sim.cookiesPs - curCPS + + // Reset Pretige level after calculation + CM.Sim.prestige = Game.prestige; + + return (ResetCPS); } CM.Sim.getSellMultiplier = function() { diff --git a/src/Sim.js b/src/Sim.js index 0047faf..2f30ff7 100644 --- a/src/Sim.js +++ b/src/Sim.js @@ -612,7 +612,6 @@ CM.Sim.ResetBonus = function(possiblePresMax) { CM.Sim.Upgrades['Heavenly confectionery'].bought = 1; CM.Sim.Upgrades['Heavenly key'].bought = 1; - // TODO: Fix this reseting. CM.Sim.prestige = possiblePresMax; lastAchievementsOwned = CM.Sim.AchievementsOwned; @@ -625,7 +624,12 @@ CM.Sim.ResetBonus = function(possiblePresMax) { CM.Sim.CalculateGains(); } - return (CM.Sim.cookiesPs - curCPS); + var ResetCPS = CM.Sim.cookiesPs - curCPS + + // Reset Pretige level after calculation + CM.Sim.prestige = Game.prestige; + + return (ResetCPS); } CM.Sim.getSellMultiplier = function() { From c458d46d33aa84065a0eb8a186e0235d7f158dc4 Mon Sep 17 00:00:00 2001 From: Chorizorro Date: Sat, 28 Nov 2020 11:12:13 +0100 Subject: [PATCH 23/49] Fix Lucky/Chain cookies stats when CpS is zero --- CookieMonster.js | 17 +++++++++++++---- src/Cache.js | 14 ++++++++++++-- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 0587e53..9855d6e 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -216,7 +216,12 @@ CM.Cache.RemakePP = function() { CM.Cache.RemakeLucky = function() { CM.Cache.Lucky = (CM.Cache.NoGoldSwitchCookiesPS * 60 * 15) / 0.15; - CM.Cache.Lucky /= CM.Sim.getCPSBuffMult(); + var cpsBuffMult = CM.Sim.getCPSBuffMult(); + if (cpsBuffMult > 0) { + CM.Cache.Lucky /= cpsBuffMult; + } else { + CM.Cache.Lucky = 0; + } CM.Cache.LuckyReward = (CM.Cache.Lucky * 0.15) + 13; CM.Cache.LuckyFrenzy = CM.Cache.Lucky * 7; CM.Cache.LuckyRewardFrenzy = (CM.Cache.LuckyFrenzy * 0.15) + 13; @@ -238,7 +243,12 @@ CM.Cache.MaxChainMoni = function(digit, maxPayout) { CM.Cache.RemakeChain = function() { var maxPayout = CM.Cache.NoGoldSwitchCookiesPS * 60 * 60 * 6; - maxPayout /= CM.Sim.getCPSBuffMult(); + var cpsBuffMult = CM.Sim.getCPSBuffMult(); + if (cpsBuffMult > 0) { + maxPayout /= cpsBuffMult; + } else { + maxPayout = 0; + } CM.Cache.ChainReward = CM.Cache.MaxChainMoni(7, maxPayout); @@ -4164,8 +4174,7 @@ CM.Sim.SellBuildingsForChoEgg = function() { // Get money made by selling all remaining buildings for (var i in CM.Sim.Objects) { var me = CM.Sim.Objects[i]; - debug = CM.Sim.BuildingSell(Game.Objects[me.name], Game.Objects[i].basePrice, me.amount, Game.Objects[i].free, me.amount); - sellTotal += debug; + sellTotal += CM.Sim.BuildingSell(Game.Objects[me.name], Game.Objects[i].basePrice, me.amount, Game.Objects[i].free, me.amount); } // CM.Sim.CalculateGains(); diff --git a/src/Cache.js b/src/Cache.js index f5ed125..aa92ffd 100644 --- a/src/Cache.js +++ b/src/Cache.js @@ -196,7 +196,12 @@ CM.Cache.RemakePP = function() { CM.Cache.RemakeLucky = function() { CM.Cache.Lucky = (CM.Cache.NoGoldSwitchCookiesPS * 60 * 15) / 0.15; - CM.Cache.Lucky /= CM.Sim.getCPSBuffMult(); + var cpsBuffMult = CM.Sim.getCPSBuffMult(); + if (cpsBuffMult > 0) { + CM.Cache.Lucky /= cpsBuffMult; + } else { + CM.Cache.Lucky = 0; + } CM.Cache.LuckyReward = (CM.Cache.Lucky * 0.15) + 13; CM.Cache.LuckyFrenzy = CM.Cache.Lucky * 7; CM.Cache.LuckyRewardFrenzy = (CM.Cache.LuckyFrenzy * 0.15) + 13; @@ -218,7 +223,12 @@ CM.Cache.MaxChainMoni = function(digit, maxPayout) { CM.Cache.RemakeChain = function() { var maxPayout = CM.Cache.NoGoldSwitchCookiesPS * 60 * 60 * 6; - maxPayout /= CM.Sim.getCPSBuffMult(); + var cpsBuffMult = CM.Sim.getCPSBuffMult(); + if (cpsBuffMult > 0) { + maxPayout /= cpsBuffMult; + } else { + maxPayout = 0; + } CM.Cache.ChainReward = CM.Cache.MaxChainMoni(7, maxPayout); From d7883e72382b069cadf06f8a5559d11d27f165bd Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Sat, 28 Nov 2020 13:46:39 +0100 Subject: [PATCH 24/49] Cache gods and implement CM.Sim.hasGodI() --- CookieMonster.js | 47 +++++++++++++++++++++++++++++------------------ src/Cache.js | 8 ++++---- src/Disp.js | 4 ++-- src/Sim.js | 35 +++++++++++++++++++++++------------ 4 files changed, 58 insertions(+), 36 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 939ea07..7467a81 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -68,8 +68,8 @@ CM.Cache.RemakeWrinkBank = function() { if (Game.wrinklers[i].type==1) toSuck *= 3; // Shiny wrinklers sucked *= toSuck; if (Game.Has('Wrinklerspawn')) sucked *= 1.05; - if (Game.hasGod) { - var godLvl = Game.hasGod('scorn'); + 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; @@ -78,8 +78,8 @@ CM.Cache.RemakeWrinkBank = function() { } CM.Cache.WrinkBank = totalSucked; CM.Cache.WrinkGodBank = totalSucked; - if (Game.hasGod) { - var godLvl = Game.hasGod('scorn'); + 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; @@ -3066,8 +3066,8 @@ CM.Disp.UpdateWrinklerTooltip = function() { if (Game.wrinklers[CM.Disp.TooltipWrinkler].type == 1) toSuck *= 3; // Shiny wrinklers sucked *= toSuck; if (Game.Has('Wrinklerspawn')) sucked *= 1.05; - if (Game.hasGod) { - var godLvl = Game.hasGod('scorn'); + 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; @@ -3570,6 +3570,7 @@ eval('CM.Sim.HasAchiev = ' + Game.HasAchiev.toString().split('Game').join('CM.Si eval('CM.Sim.GetHeavenlyMultiplier = ' + Game.GetHeavenlyMultiplier.toString().split('Game.Has').join('CM.Sim.Has').split('Game.hasAura').join('CM.Sim.hasAura').split('Game.auraMult').join('CM.Sim.auraMult')); +// Check for Pantheon Auras CM.Sim.hasAura = function(what) { if (Game.dragonAuras[CM.Sim.dragonAura].name == what || Game.dragonAuras[CM.Sim.dragonAura2].name == what) return true; @@ -3588,6 +3589,16 @@ CM.Sim.auraMult = function(what) { return n; } +CM.Sim.hasGod=function(what) { + var possibleGods = CM.Sim.Objects.Temple.minigame.gods + var god=possibleGods[what]; + for (var i=0;i<3;i++) + { + if (CM.Sim.Objects.Temple.minigame.slot[i]==god.id) return (i+1); + } + return false; +} + eval('CM.Sim.GetTieredCpsMult = ' + Game.GetTieredCpsMult.toString() .split('Game.Has').join('CM.Sim.Has') .split('me.tieredUpgrades').join('Game.Objects[me.name].tieredUpgrades') @@ -3661,6 +3672,7 @@ CM.Sim.CopyData = function() { } you.amount = me.amount; you.level = me.level; + if (me.minigameLoaded) you.minigameLoaded = me.minigameLoaded; you.minigame = me.minigame; } // Upgrades @@ -3730,32 +3742,31 @@ CM.Sim.CalculateGains = function() { if (CM.Sim.Has('Dragon scale')) mult *= 1.03; - // Cached and sim temple gods - // TODO: Caches chosen gods + // Check effect of chosen Gods var buildMult = 1; - if (Game.hasGod) { - var godLvl = Game.hasGod('asceticism'); + if (CM.Sim.Objects.Temple.minigameLoaded) { + var godLvl = CM.Sim.hasGod('asceticism'); if (godLvl == 1) mult *= 1.15; else if (godLvl == 2) mult *= 1.1; else if (godLvl == 3) mult *= 1.05; // TODO: What does DateAges do? - var godLvl = Game.hasGod('ages'); + var godLvl = CM.Sim.hasGod('ages'); if (godLvl == 1) mult *= 1 + 0.15 * Math.sin((CM.Sim.DateAges / 1000 / (60 * 60 * 3)) * Math.PI * 2); else if (godLvl == 2) mult *= 1 + 0.15 * Math.sin((CM.Sim.DateAges / 1000 / (60 * 60 * 12)) * Math.PI*2); else if (godLvl == 3) mult *= 1 + 0.15 * Math.sin((CM.Sim.DateAges / 1000 / (60 * 60 * 24)) * Math.PI*2); - var godLvl = Game.hasGod('decadence'); + var godLvl = CM.Sim.hasGod('decadence'); if (godLvl == 1) buildMult *= 0.93; else if (godLvl == 2) buildMult *= 0.95; else if (godLvl == 3) buildMult *= 0.98; - var godLvl = Game.hasGod('industry'); + var godLvl = CM.Sim.hasGod('industry'); if (godLvl == 1) buildMult *= 1.1; else if (godLvl == 2) buildMult *= 1.06; else if (godLvl == 3) buildMult *= 1.03; - var godLvl = Game.hasGod('labor'); + var godLvl = CM.Sim.hasGod('labor'); if (godLvl == 1) buildMult *= 0.97; else if (godLvl == 2) buildMult *= 0.98; else if (godLvl == 3) buildMult *= 0.99; @@ -3768,8 +3779,8 @@ CM.Sim.CalculateGains = function() { if (CM.Sim.Has('Santa\'s milk and cookies')) milkMult *= 1.05; //if (CM.Sim.hasAura('Breath of Milk')) milkMult *= 1.05; milkMult *= 1 + CM.Sim.auraMult('Breath of Milk') * 0.05; - if (Game.hasGod) { - var godLvl = Game.hasGod('mother'); + if (CM.Sim.Objects.Temple.minigameLoaded) { + var godLvl = CM.Sim.hasGod('mother'); if (godLvl == 1) milkMult *= 1.1; else if (godLvl == 2) milkMult *= 1.05; else if (godLvl == 3) milkMult *= 1.03; @@ -4142,8 +4153,8 @@ CM.Sim.modifyBuildingPrice = function(building,price) { if (Game.hasBuff('Nasty goblins')) price *= 1.02; if (building.fortune && CM.Sim.Has(building.fortune.name)) price *= 0.93; price *= Game.eff('buildingCost'); - if (Game.hasGod) { - var godLvl = Game.hasGod('creation'); + if (CM.Sim.Objects.Temple.minigameLoaded) { + var godLvl = CM.Sim.hasGod('creation'); if (godLvl == 1) price *= 0.93; else if (godLvl == 2) price *= 0.95; else if (godLvl == 3) price *= 0.98; diff --git a/src/Cache.js b/src/Cache.js index f5ed125..0821025 100644 --- a/src/Cache.js +++ b/src/Cache.js @@ -48,8 +48,8 @@ CM.Cache.RemakeWrinkBank = function() { if (Game.wrinklers[i].type==1) toSuck *= 3; // Shiny wrinklers sucked *= toSuck; if (Game.Has('Wrinklerspawn')) sucked *= 1.05; - if (Game.hasGod) { - var godLvl = Game.hasGod('scorn'); + 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; @@ -58,8 +58,8 @@ CM.Cache.RemakeWrinkBank = function() { } CM.Cache.WrinkBank = totalSucked; CM.Cache.WrinkGodBank = totalSucked; - if (Game.hasGod) { - var godLvl = Game.hasGod('scorn'); + 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; diff --git a/src/Disp.js b/src/Disp.js index fdcc56e..990e638 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -2340,8 +2340,8 @@ CM.Disp.UpdateWrinklerTooltip = function() { if (Game.wrinklers[CM.Disp.TooltipWrinkler].type == 1) toSuck *= 3; // Shiny wrinklers sucked *= toSuck; if (Game.Has('Wrinklerspawn')) sucked *= 1.05; - if (Game.hasGod) { - var godLvl = Game.hasGod('scorn'); + 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; diff --git a/src/Sim.js b/src/Sim.js index 2f30ff7..96dc827 100644 --- a/src/Sim.js +++ b/src/Sim.js @@ -79,6 +79,7 @@ eval('CM.Sim.HasAchiev = ' + Game.HasAchiev.toString().split('Game').join('CM.Si eval('CM.Sim.GetHeavenlyMultiplier = ' + Game.GetHeavenlyMultiplier.toString().split('Game.Has').join('CM.Sim.Has').split('Game.hasAura').join('CM.Sim.hasAura').split('Game.auraMult').join('CM.Sim.auraMult')); +// Check for Pantheon Auras CM.Sim.hasAura = function(what) { if (Game.dragonAuras[CM.Sim.dragonAura].name == what || Game.dragonAuras[CM.Sim.dragonAura2].name == what) return true; @@ -97,6 +98,16 @@ CM.Sim.auraMult = function(what) { return n; } +CM.Sim.hasGod=function(what) { + var possibleGods = CM.Sim.Objects.Temple.minigame.gods + var god=possibleGods[what]; + for (var i=0;i<3;i++) + { + if (CM.Sim.Objects.Temple.minigame.slot[i]==god.id) return (i+1); + } + return false; +} + eval('CM.Sim.GetTieredCpsMult = ' + Game.GetTieredCpsMult.toString() .split('Game.Has').join('CM.Sim.Has') .split('me.tieredUpgrades').join('Game.Objects[me.name].tieredUpgrades') @@ -170,6 +181,7 @@ CM.Sim.CopyData = function() { } you.amount = me.amount; you.level = me.level; + if (me.minigameLoaded) you.minigameLoaded = me.minigameLoaded; you.minigame = me.minigame; } // Upgrades @@ -239,32 +251,31 @@ CM.Sim.CalculateGains = function() { if (CM.Sim.Has('Dragon scale')) mult *= 1.03; - // Cached and sim temple gods - // TODO: Caches chosen gods + // Check effect of chosen Gods var buildMult = 1; - if (Game.hasGod) { - var godLvl = Game.hasGod('asceticism'); + if (CM.Sim.Objects.Temple.minigameLoaded) { + var godLvl = CM.Sim.hasGod('asceticism'); if (godLvl == 1) mult *= 1.15; else if (godLvl == 2) mult *= 1.1; else if (godLvl == 3) mult *= 1.05; // TODO: What does DateAges do? - var godLvl = Game.hasGod('ages'); + var godLvl = CM.Sim.hasGod('ages'); if (godLvl == 1) mult *= 1 + 0.15 * Math.sin((CM.Sim.DateAges / 1000 / (60 * 60 * 3)) * Math.PI * 2); else if (godLvl == 2) mult *= 1 + 0.15 * Math.sin((CM.Sim.DateAges / 1000 / (60 * 60 * 12)) * Math.PI*2); else if (godLvl == 3) mult *= 1 + 0.15 * Math.sin((CM.Sim.DateAges / 1000 / (60 * 60 * 24)) * Math.PI*2); - var godLvl = Game.hasGod('decadence'); + var godLvl = CM.Sim.hasGod('decadence'); if (godLvl == 1) buildMult *= 0.93; else if (godLvl == 2) buildMult *= 0.95; else if (godLvl == 3) buildMult *= 0.98; - var godLvl = Game.hasGod('industry'); + var godLvl = CM.Sim.hasGod('industry'); if (godLvl == 1) buildMult *= 1.1; else if (godLvl == 2) buildMult *= 1.06; else if (godLvl == 3) buildMult *= 1.03; - var godLvl = Game.hasGod('labor'); + var godLvl = CM.Sim.hasGod('labor'); if (godLvl == 1) buildMult *= 0.97; else if (godLvl == 2) buildMult *= 0.98; else if (godLvl == 3) buildMult *= 0.99; @@ -277,8 +288,8 @@ CM.Sim.CalculateGains = function() { if (CM.Sim.Has('Santa\'s milk and cookies')) milkMult *= 1.05; //if (CM.Sim.hasAura('Breath of Milk')) milkMult *= 1.05; milkMult *= 1 + CM.Sim.auraMult('Breath of Milk') * 0.05; - if (Game.hasGod) { - var godLvl = Game.hasGod('mother'); + if (CM.Sim.Objects.Temple.minigameLoaded) { + var godLvl = CM.Sim.hasGod('mother'); if (godLvl == 1) milkMult *= 1.1; else if (godLvl == 2) milkMult *= 1.05; else if (godLvl == 3) milkMult *= 1.03; @@ -651,8 +662,8 @@ CM.Sim.modifyBuildingPrice = function(building,price) { if (Game.hasBuff('Nasty goblins')) price *= 1.02; if (building.fortune && CM.Sim.Has(building.fortune.name)) price *= 0.93; price *= Game.eff('buildingCost'); - if (Game.hasGod) { - var godLvl = Game.hasGod('creation'); + if (CM.Sim.Objects.Temple.minigameLoaded) { + var godLvl = CM.Sim.hasGod('creation'); if (godLvl == 1) price *= 0.93; else if (godLvl == 2) price *= 0.95; else if (godLvl == 3) price *= 0.98; From 57cfdad21573a3634062e8ddc154b92164d5449e Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Sat, 28 Nov 2020 15:36:41 +0100 Subject: [PATCH 25/49] Store minigame effects as Sim data --- CookieMonster.js | 31 +++++++++++++++++++++++-------- src/Sim.js | 27 ++++++++++++++++++++++----- 2 files changed, 45 insertions(+), 13 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 7467a81..e2054f9 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -3599,6 +3599,16 @@ CM.Sim.hasGod=function(what) { return false; } +CM.Sim.eff = function(name) { + if (typeof CM.Sim.effs[name]==='undefined') { + CM.Sim.effs[name] = 1 + return CM.Sim.effs[name] + } + else { + return Game.effs[name]; + } +} + eval('CM.Sim.GetTieredCpsMult = ' + Game.GetTieredCpsMult.toString() .split('Game.Has').join('CM.Sim.Has') .split('me.tieredUpgrades').join('Game.Objects[me.name].tieredUpgrades') @@ -3703,16 +3713,21 @@ CM.Sim.CalculateGains = function() { CM.Sim.cookiesPs = 0; var mult = 1; // Include minigame effects + var effs={}; for (var i in CM.Cache.Objects) { - // TODO Store minigames and effects in Cache - // Include possibility of new/modded building and new/modded minigames - if (Game.Objects[i].minigameLoaded && Game.Objects[i].minigame.effs) { + if (CM.Sim.Objects[i].minigameLoaded && CM.Sim.Objects[i].minigame.effs) { + var myEffs = CM.Sim.Objects[i].minigame.effs; + for (var ii in myEffs) { + if (effs[ii]) effs[ii]*=myEffs[ii]; + else effs[ii]=myEffs[ii]; + } } } - + CM.Sim.effs = effs; + if (Game.ascensionMode != 1) mult += parseFloat(CM.Sim.prestige) * 0.01 * CM.Sim.heavenlyPower * CM.Sim.GetHeavenlyMultiplier(); - mult *= Game.eff('cps'); + mult *= CM.Sim.eff('cps'); if (CM.Sim.Has('Heralds') && Game.ascensionMode != 1) mult *= 1 + 0.01 * Game.heralds; @@ -3785,8 +3800,8 @@ CM.Sim.CalculateGains = function() { else if (godLvl == 2) milkMult *= 1.05; else if (godLvl == 3) milkMult *= 1.03; } - // TODO Store minigame buffs? - milkMult *= Game.eff('milk'); + + milkMult *= CM.Sim.eff('milk'); var catMult = 1; @@ -4152,7 +4167,7 @@ CM.Sim.modifyBuildingPrice = function(building,price) { if (Game.hasBuff('Crafty pixies')) price *= 0.98; if (Game.hasBuff('Nasty goblins')) price *= 1.02; if (building.fortune && CM.Sim.Has(building.fortune.name)) price *= 0.93; - price *= Game.eff('buildingCost'); + price *= CM.Sim.eff('buildingCost'); if (CM.Sim.Objects.Temple.minigameLoaded) { var godLvl = CM.Sim.hasGod('creation'); if (godLvl == 1) price *= 0.93; diff --git a/src/Sim.js b/src/Sim.js index 96dc827..26d6484 100644 --- a/src/Sim.js +++ b/src/Sim.js @@ -108,6 +108,16 @@ CM.Sim.hasGod=function(what) { return false; } +CM.Sim.eff = function(name) { + if (typeof CM.Sim.effs[name]==='undefined') { + CM.Sim.effs[name] = 1 + return CM.Sim.effs[name] + } + else { + return Game.effs[name]; + } +} + eval('CM.Sim.GetTieredCpsMult = ' + Game.GetTieredCpsMult.toString() .split('Game.Has').join('CM.Sim.Has') .split('me.tieredUpgrades').join('Game.Objects[me.name].tieredUpgrades') @@ -212,16 +222,23 @@ CM.Sim.CalculateGains = function() { CM.Sim.cookiesPs = 0; var mult = 1; // Include minigame effects + var effs={}; for (var i in CM.Cache.Objects) { // TODO Store minigames and effects in Cache // Include possibility of new/modded building and new/modded minigames - if (Game.Objects[i].minigameLoaded && Game.Objects[i].minigame.effs) { + if (CM.Sim.Objects[i].minigameLoaded && CM.Sim.Objects[i].minigame.effs) { + var myEffs = CM.Sim.Objects[i].minigame.effs; + for (var ii in myEffs) { + if (effs[ii]) effs[ii]*=myEffs[ii]; + else effs[ii]=myEffs[ii]; + } } } - + CM.Sim.effs = effs; + if (Game.ascensionMode != 1) mult += parseFloat(CM.Sim.prestige) * 0.01 * CM.Sim.heavenlyPower * CM.Sim.GetHeavenlyMultiplier(); - mult *= Game.eff('cps'); + mult *= CM.Sim.eff('cps'); if (CM.Sim.Has('Heralds') && Game.ascensionMode != 1) mult *= 1 + 0.01 * Game.heralds; @@ -295,7 +312,7 @@ CM.Sim.CalculateGains = function() { else if (godLvl == 3) milkMult *= 1.03; } // TODO Store minigame buffs? - milkMult *= Game.eff('milk'); + milkMult *= CM.Sim.eff('milk'); var catMult = 1; @@ -661,7 +678,7 @@ CM.Sim.modifyBuildingPrice = function(building,price) { if (Game.hasBuff('Crafty pixies')) price *= 0.98; if (Game.hasBuff('Nasty goblins')) price *= 1.02; if (building.fortune && CM.Sim.Has(building.fortune.name)) price *= 0.93; - price *= Game.eff('buildingCost'); + price *= CM.Sim.eff('buildingCost'); if (CM.Sim.Objects.Temple.minigameLoaded) { var godLvl = CM.Sim.hasGod('creation'); if (godLvl == 1) price *= 0.93; From 78888e784c7718ef92aa3ac3fe898ba0819921a7 Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Sat, 28 Nov 2020 16:20:44 +0100 Subject: [PATCH 26/49] Fixed GC rewards not considering garden buffs --- CookieMonster.js | 20 ++++++++++++-------- src/Cache.js | 16 +++++++++------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 3672491..56c7f22 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -215,28 +215,30 @@ CM.Cache.RemakePP = function() { } CM.Cache.RemakeLucky = function() { - CM.Cache.Lucky = (CM.Cache.NoGoldSwitchCookiesPS * 60 * 15) / 0.15; + var GCmult = CM.Sim.eff('goldenCookieGain') + CM.Cache.Lucky = (CM.Cache.NoGoldSwitchCookiesPS * 900) / 0.15; var cpsBuffMult = CM.Sim.getCPSBuffMult(); if (cpsBuffMult > 0) { CM.Cache.Lucky /= cpsBuffMult; } else { CM.Cache.Lucky = 0; } - CM.Cache.LuckyReward = (CM.Cache.Lucky * 0.15) + 13; + CM.Cache.LuckyReward = GCmult * (CM.Cache.Lucky * 0.15) + 13; CM.Cache.LuckyFrenzy = CM.Cache.Lucky * 7; - CM.Cache.LuckyRewardFrenzy = (CM.Cache.LuckyFrenzy * 0.15) + 13; + CM.Cache.LuckyRewardFrenzy = GCmult * (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) { + var GCmult = CM.Sim.eff('goldenCookieGain') 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), maxPayout)); - var nextMoni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain + 1) * digit), maxPayout)); + var moni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain) * digit * GCmult), maxPayout)); + var nextMoni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain + 1) * digit * GCmult), maxPayout)); while (nextMoni < maxPayout) { chain++; - moni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain) * digit), maxPayout)); - nextMoni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain + 1) * digit), maxPayout)); + moni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain) * digit * GCmult), maxPayout)); + nextMoni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain + 1) * digit * GCmult), maxPayout)); } return moni; } @@ -3749,6 +3751,8 @@ CM.Sim.CalculateGains = function() { // Include minigame effects var effs={}; for (var i in CM.Cache.Objects) { + // TODO Store minigames and effects in Cache + // Include possibility of new/modded building and new/modded minigames if (CM.Sim.Objects[i].minigameLoaded && CM.Sim.Objects[i].minigame.effs) { var myEffs = CM.Sim.Objects[i].minigame.effs; for (var ii in myEffs) { @@ -3834,7 +3838,7 @@ CM.Sim.CalculateGains = function() { else if (godLvl == 2) milkMult *= 1.05; else if (godLvl == 3) milkMult *= 1.03; } - + // TODO Store minigame buffs? milkMult *= CM.Sim.eff('milk'); var catMult = 1; diff --git a/src/Cache.js b/src/Cache.js index 2ff2950..d3330f8 100644 --- a/src/Cache.js +++ b/src/Cache.js @@ -195,28 +195,30 @@ CM.Cache.RemakePP = function() { } CM.Cache.RemakeLucky = function() { - CM.Cache.Lucky = (CM.Cache.NoGoldSwitchCookiesPS * 60 * 15) / 0.15; + var GCmult = CM.Sim.eff('goldenCookieGain') + CM.Cache.Lucky = (CM.Cache.NoGoldSwitchCookiesPS * 900) / 0.15; var cpsBuffMult = CM.Sim.getCPSBuffMult(); if (cpsBuffMult > 0) { CM.Cache.Lucky /= cpsBuffMult; } else { CM.Cache.Lucky = 0; } - CM.Cache.LuckyReward = (CM.Cache.Lucky * 0.15) + 13; + CM.Cache.LuckyReward = GCmult * (CM.Cache.Lucky * 0.15) + 13; CM.Cache.LuckyFrenzy = CM.Cache.Lucky * 7; - CM.Cache.LuckyRewardFrenzy = (CM.Cache.LuckyFrenzy * 0.15) + 13; + CM.Cache.LuckyRewardFrenzy = GCmult * (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) { + var GCmult = CM.Sim.eff('goldenCookieGain') 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), maxPayout)); - var nextMoni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain + 1) * digit), maxPayout)); + var moni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain) * digit * GCmult), maxPayout)); + var nextMoni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain + 1) * digit * GCmult), maxPayout)); while (nextMoni < maxPayout) { chain++; - moni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain) * digit), maxPayout)); - nextMoni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain + 1) * digit), maxPayout)); + moni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain) * digit * GCmult), maxPayout)); + nextMoni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain + 1) * digit * GCmult), maxPayout)); } return moni; } From f7192d1e90e35e92c466eaf73f1f12bd6a826ab5 Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Sun, 29 Nov 2020 14:57:48 +0100 Subject: [PATCH 27/49] Fixed pp-sort breaking for sell-mode --- CookieMonster.js | 50 +++++++++++++++++++++++++++++++++++------------- src/Disp.js | 50 +++++++++++++++++++++++++++++++++++------------- 2 files changed, 74 insertions(+), 26 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 56c7f22..e577246 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -1398,21 +1398,32 @@ CM.Disp.UpdateBuildings = function() { // 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) - 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; - }); - - if (CM.Config.SortBuildings) + 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((a, b) => a.pp - b.pp); - else - 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); + 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() { @@ -3102,6 +3113,19 @@ CM.Disp.UpdateAscendState = function() { CM.Disp.UpdateBackground(); } +CM.Disp.UpdateAuraDescription = function() { + return "function(aura)\ + {\ + l('dragonAuraInfo').innerHTML=\ + '

'+Game.dragonAuras[aura].name+'

'+\ + '
'+\ + Game.dragonAuras[aura].desc+\ + '
'+\ + CM.\ + '
';\ + }" +} + CM.Disp.ToggleSayTime = function() { if (CM.Config.SayTime == 1) { Game.sayTime = CM.Disp.sayTime; diff --git a/src/Disp.js b/src/Disp.js index 990e638..5b5eb81 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -660,21 +660,32 @@ CM.Disp.UpdateBuildings = function() { // 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) - 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; - }); - - if (CM.Config.SortBuildings) + 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((a, b) => a.pp - b.pp); - else - 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); + 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() { @@ -2364,6 +2375,19 @@ CM.Disp.UpdateAscendState = function() { CM.Disp.UpdateBackground(); } +CM.Disp.UpdateAuraDescription = function() { + return "function(aura)\ + {\ + l('dragonAuraInfo').innerHTML=\ + '

'+Game.dragonAuras[aura].name+'

'+\ + '
'+\ + Game.dragonAuras[aura].desc+\ + '
'+\ + CM.\ + '
';\ + }" +} + CM.Disp.ToggleSayTime = function() { if (CM.Config.SayTime == 1) { Game.sayTime = CM.Disp.sayTime; From b91d0e1195efe72ef6995d8dbb902be0651caa40 Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Sun, 29 Nov 2020 16:42:14 +0100 Subject: [PATCH 28/49] Option sections are now collapsable --- CookieMonster.js | 233 +++++++++++++++++++++++++++-------------------- src/Config.js | 12 ++- src/Disp.js | 220 ++++++++++++++++++++++++-------------------- src/Main.js | 1 + 4 files changed, 270 insertions(+), 196 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index e577246..6d15255 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -510,7 +510,7 @@ CM.LoadConfig = function() { if (mod) CM.SaveConfig(CM.Config); CM.Loop(); // Do loop once for (var i in CM.ConfigDefault) { - if (i != 'StatsPref' && typeof CM.ConfigData[i].func !== 'undefined') { + if (i != 'StatsPref' && i != 'MenuPref' && typeof CM.ConfigData[i].func !== 'undefined') { CM.ConfigData[i].func(); } } @@ -573,6 +573,16 @@ CM.ToggleStatsConfig = function(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) { @@ -1917,14 +1927,28 @@ CM.Disp.CreateTooltip = function(placeholder, text, minWidth) { } CM.Disp.AddMenuPref = function(title) { - var header = function(text) { + 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.textContent = text; + 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; } @@ -2008,107 +2032,119 @@ CM.Disp.AddMenuPref = function(title) { return div; } - frag.appendChild(header('Bars/Colors')); - 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(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(listing('UpgradeBarFixedPos')); - frag.appendChild(header('Calculation')); - frag.appendChild(listing('CalcWrink')); - frag.appendChild(listing('CPSMode')); - frag.appendChild(listing('AvgCPSHist')); - frag.appendChild(listing('AvgClicksHist')); - frag.appendChild(listing('ToolWarnBon')); + 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')); - 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('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')); - 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('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')); - frag.appendChild(listing('Stats')); - frag.appendChild(listing('UpStats')); - frag.appendChild(listing('TimeFormat')); - frag.appendChild(listing('SayTime')); - frag.appendChild(listing('GrimoireBar')); + frag.appendChild(header('Statistics', 'Statistics')); + if (CM.Config.MenuPref.Statistics) { + frag.appendChild(listing('Stats')); + frag.appendChild(listing('UpStats')); + frag.appendChild(listing('TimeFormat')); + frag.appendChild(listing('SayTime')); + frag.appendChild(listing('GrimoireBar')); + } - frag.appendChild(header('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); + 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]); @@ -3515,6 +3551,7 @@ CM.ConfigDefault = { SayTime: 1, GrimoireBar: 1, Scale: 2, + MenuPref: {BarsColors: 1, Calculation: 1, Notification: 1, Tooltip: 1, Statistics: 1, Other: 1}, StatsPref: {Lucky: 1, Conjure: 1, Chain: 1, Prestige: 1, Wrink: 1, Sea: 1, Misc: 1}, Colors : {Blue: '#4bb8f0', Green: '#00ff00', Yellow: '#ffff00', Orange: '#ff7f00', Red: '#ff0000', Purple: '#ff00ff', Gray: '#b3b3b3', Pink: '#ff1493', Brown: '#8b4513'}, SortBuildings: 0, diff --git a/src/Config.js b/src/Config.js index 8f8822a..d7f531f 100644 --- a/src/Config.js +++ b/src/Config.js @@ -51,7 +51,7 @@ CM.LoadConfig = function() { if (mod) CM.SaveConfig(CM.Config); CM.Loop(); // Do loop once for (var i in CM.ConfigDefault) { - if (i != 'StatsPref' && typeof CM.ConfigData[i].func !== 'undefined') { + if (i != 'StatsPref' && i != 'MenuPref' && typeof CM.ConfigData[i].func !== 'undefined') { CM.ConfigData[i].func(); } } @@ -114,6 +114,16 @@ CM.ToggleStatsConfig = function(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) { diff --git a/src/Disp.js b/src/Disp.js index 5b5eb81..474e9af 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -1179,14 +1179,28 @@ CM.Disp.CreateTooltip = function(placeholder, text, minWidth) { } CM.Disp.AddMenuPref = function(title) { - var header = function(text) { + 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.textContent = text; + 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; } @@ -1270,107 +1284,119 @@ CM.Disp.AddMenuPref = function(title) { return div; } - frag.appendChild(header('Bars/Colors')); - 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(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(listing('UpgradeBarFixedPos')); - frag.appendChild(header('Calculation')); - frag.appendChild(listing('CalcWrink')); - frag.appendChild(listing('CPSMode')); - frag.appendChild(listing('AvgCPSHist')); - frag.appendChild(listing('AvgClicksHist')); - frag.appendChild(listing('ToolWarnBon')); + 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')); - 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('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')); - 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('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')); - frag.appendChild(listing('Stats')); - frag.appendChild(listing('UpStats')); - frag.appendChild(listing('TimeFormat')); - frag.appendChild(listing('SayTime')); - frag.appendChild(listing('GrimoireBar')); + frag.appendChild(header('Statistics', 'Statistics')); + if (CM.Config.MenuPref.Statistics) { + frag.appendChild(listing('Stats')); + frag.appendChild(listing('UpStats')); + frag.appendChild(listing('TimeFormat')); + frag.appendChild(listing('SayTime')); + frag.appendChild(listing('GrimoireBar')); + } - frag.appendChild(header('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); + 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]); diff --git a/src/Main.js b/src/Main.js index 01a961b..f4aa8d4 100644 --- a/src/Main.js +++ b/src/Main.js @@ -323,6 +323,7 @@ CM.ConfigDefault = { SayTime: 1, GrimoireBar: 1, Scale: 2, + MenuPref: {BarsColors: 1, Calculation: 1, Notification: 1, Tooltip: 1, Statistics: 1, Other: 1}, StatsPref: {Lucky: 1, Conjure: 1, Chain: 1, Prestige: 1, Wrink: 1, Sea: 1, Misc: 1}, Colors : {Blue: '#4bb8f0', Green: '#00ff00', Yellow: '#ffff00', Orange: '#ff7f00', Red: '#ff0000', Purple: '#ff00ff', Gray: '#b3b3b3', Pink: '#ff1493', Brown: '#8b4513'}, SortBuildings: 0, From 292a80b8072e8b1417fae1e4332a09c07ec85faf Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Sun, 29 Nov 2020 23:57:52 +0100 Subject: [PATCH 29/49] Rewrote GCTimer Code --- CookieMonster.js | 144 ++++++++++++++++++++++++++++------------------- src/Disp.js | 143 +++++++++++++++++++++++++++------------------- src/Main.js | 1 - 3 files changed, 172 insertions(+), 116 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 6d15255..a3f833a 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -1655,18 +1655,18 @@ CM.Disp.Notification = function(notifyConfig, title, message) { } } -/** - * Needed for some of the functions to use the right object - */ -CM.Disp.FindGoldenShimmer = function() { - if (CM.Disp.lastGoldenCookieState) { - for (var i in Game.shimmers) { - if (Game.shimmers[i].spawnLead && Game.shimmers[i].type == 'golden') { - CM.Disp.goldenShimmer = Game.shimmers[i]; - break; - } + +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() { @@ -1678,8 +1678,8 @@ CM.Disp.CreateFavicon = function() { } CM.Disp.UpdateFavicon = function() { - if (CM.Config.Favicon == 1 && CM.Disp.lastGoldenCookieState) { - if (CM.Disp.goldenShimmer.wrath) { + if (CM.Config.Favicon == 1) { + if (CM.Disp.spawnedGoldenShimmer.wrath) { CM.Disp.Favicon.href = 'https://aktanusa.github.io/CookieMonster/favicon/wrathCookie.ico'; } else { @@ -1691,60 +1691,85 @@ CM.Disp.UpdateFavicon = function() { } } -CM.Disp.CreateGCTimer = function() { - CM.Disp.GCTimer = document.createElement('div'); - CM.Disp.GCTimer.style.width = '96px'; - CM.Disp.GCTimer.style.height = '96px'; - CM.Disp.GCTimer.style.display = 'none'; - CM.Disp.GCTimer.style.position = 'absolute'; - CM.Disp.GCTimer.style.zIndex = '10000000001'; - CM.Disp.GCTimer.style.textAlign = 'center'; - CM.Disp.GCTimer.style.lineHeight = '96px'; - CM.Disp.GCTimer.style.fontFamily = '\"Kavoon\", Georgia, serif'; - CM.Disp.GCTimer.style.fontSize = '35px'; - CM.Disp.GCTimer.style.cursor = 'pointer'; - CM.Disp.GCTimer.onclick = function () {CM.Disp.goldenShimmer.pop(); CM.Disp.GCTimer.style.display = 'none';}; - CM.Disp.GCTimer.onmouseover = function() {CM.Disp.goldenShimmer.l.style.filter = 'brightness(125%) drop-shadow(0px 0px 3px rgba(255,255,255,1))'; CM.Disp.goldenShimmer.l.style.webkitFilter = 'brightness(125%) drop-shadow(0px 0px 3px rgba(255,255,255,1))';}; - CM.Disp.GCTimer.onmouseout = function() {CM.Disp.goldenShimmer.l.style.filter = ''; CM.Disp.goldenShimmer.l.style.webkitFilter = '';}; +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 = '';}; - l('game').appendChild(CM.Disp.GCTimer); + CM.Disp.GCTimers[cookie.id] = GCTimer; + l('shimmers').appendChild(GCTimer); } CM.Disp.ToggleGCTimer = function() { if (CM.Config.GCTimer == 1) { if (CM.Disp.lastGoldenCookieState) { - CM.Disp.GCTimer.style.display = 'block'; - CM.Disp.GCTimer.style.left = CM.Disp.goldenShimmer.l.style.left; - CM.Disp.GCTimer.style.top = CM.Disp.goldenShimmer.l.style.top; + 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 { - CM.Disp.GCTimer.style.display = 'none'; + for (var i in CM.Disp.GCTimers) { + CM.Disp.GCTimers[i].style.display = 'none'; + } } } CM.Disp.CheckGoldenCookie = function() { - if (CM.Disp.lastGoldenCookieState != Game.shimmerTypes['golden'].spawned) { - CM.Disp.lastGoldenCookieState = Game.shimmerTypes['golden'].spawned; - CM.Disp.FindGoldenShimmer(); - CM.Disp.UpdateFavicon(); - if (CM.Disp.lastGoldenCookieState) { - if (CM.Config.GCTimer == 1) { - CM.Disp.GCTimer.style.display = 'block'; - CM.Disp.GCTimer.style.left = CM.Disp.goldenShimmer.l.style.left; - CM.Disp.GCTimer.style.top = CM.Disp.goldenShimmer.l.style.top; - } - - 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.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]); + 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.GCTimer.style.display = 'none'; } else if (CM.Config.GCTimer == 1 && CM.Disp.lastGoldenCookieState) { - CM.Disp.GCTimer.style.opacity = CM.Disp.goldenShimmer.l.style.opacity; - CM.Disp.GCTimer.style.transform = CM.Disp.goldenShimmer.l.style.transform; - CM.Disp.GCTimer.textContent = Math.ceil(CM.Disp.goldenShimmer.life / Game.fps); + 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); + } } } @@ -1844,11 +1869,11 @@ CM.Disp.UpdateTitle = function() { var titleFC; var titleSP; if (CM.Disp.lastGoldenCookieState) { - if (CM.Disp.goldenShimmer.wrath) { - titleGC = '[W ' + Math.ceil(CM.Disp.goldenShimmer.life / Game.fps) + ']'; + if (CM.Disp.spawnedGoldenShimmer.wrath) { + titleGC = '[W ' + Math.ceil(CM.Disp.spawnedGoldenShimmer.life / Game.fps) + ']'; } else { - titleGC = '[G ' + Math.ceil(CM.Disp.goldenShimmer.life / Game.fps) + ']'; + titleGC = '[G ' + Math.ceil(CM.Disp.spawnedGoldenShimmer.life / Game.fps) + ']'; } } else if (!Game.Has('Golden switch [off]')) { @@ -1883,11 +1908,11 @@ CM.Disp.UpdateTitle = function() { var spawn = false; if (CM.Disp.lastGoldenCookieState) { spawn = true; - if (CM.Disp.goldenShimmer.wrath) { - str += '[W ' + Math.ceil(CM.Disp.goldenShimmer.life / Game.fps) + ']'; + if (CM.Disp.spawnedGoldenShimmer.wrath) { + str += '[W ' + Math.ceil(CM.Disp.spawnedGoldenShimmer.life / Game.fps) + ']'; } else { - str += '[G ' + Math.ceil(CM.Disp.goldenShimmer.life / Game.fps) + ']'; + str += '[G ' + Math.ceil(CM.Disp.spawnedGoldenShimmer.life / Game.fps) + ']'; } } if (CM.Disp.lastTickerFortuneState) { @@ -3196,12 +3221,16 @@ CM.Disp.colorBrown = 'Brown'; CM.Disp.colors = [CM.Disp.colorBlue, CM.Disp.colorGreen, CM.Disp.colorYellow, CM.Disp.colorOrange, CM.Disp.colorRed, CM.Disp.colorPurple, CM.Disp.colorGray, CM.Disp.colorPink, CM.Disp.colorBrown]; CM.Disp.buffColors = {'Frenzy': CM.Disp.colorYellow, 'Dragon Harvest': CM.Disp.colorBrown, 'Elder frenzy': CM.Disp.colorGreen, 'Clot': CM.Disp.colorRed, 'Click frenzy': CM.Disp.colorBlue, 'Dragonflight': CM.Disp.colorPink}; CM.Disp.lastGoldenCookieState = 0; +CM.Disp.lastSpawnedGoldenCookieState = 0; +CM.Disp.currSpawnedGoldenCookieState CM.Disp.lastTickerFortuneState = 0; CM.Disp.lastSeasonPopupState = 0; CM.Disp.lastGardenNextStep = 0; CM.Disp.lastMagicBarFull = 0; CM.Disp.lastWrinklerCount = 0; -CM.Disp.goldenShimmer; +CM.Disp.goldenShimmersByID = {}; +CM.Disp.spawnedGoldenShimmer = 0; +CM.Disp.GCTimers = {}; CM.Disp.seasonPopShimmer; CM.Disp.lastAscendState = -1; @@ -3459,7 +3488,6 @@ CM.DelayInit = function() { CM.Disp.CreateUpgradeBar(); CM.Disp.CreateWhiteScreen(); CM.Disp.CreateFavicon(); - CM.Disp.CreateGCTimer(); for (var i in CM.Disp.TooltipText) { CM.Disp.CreateTooltip(CM.Disp.TooltipText[i][0], CM.Disp.TooltipText[i][1], CM.Disp.TooltipText[i][2]); } diff --git a/src/Disp.js b/src/Disp.js index 474e9af..dcf085a 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -907,18 +907,18 @@ CM.Disp.Notification = function(notifyConfig, title, message) { } } -/** - * Needed for some of the functions to use the right object - */ -CM.Disp.FindGoldenShimmer = function() { - if (CM.Disp.lastGoldenCookieState) { - for (var i in Game.shimmers) { - if (Game.shimmers[i].spawnLead && Game.shimmers[i].type == 'golden') { - CM.Disp.goldenShimmer = Game.shimmers[i]; - break; - } + +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() { @@ -930,8 +930,8 @@ CM.Disp.CreateFavicon = function() { } CM.Disp.UpdateFavicon = function() { - if (CM.Config.Favicon == 1 && CM.Disp.lastGoldenCookieState) { - if (CM.Disp.goldenShimmer.wrath) { + if (CM.Config.Favicon == 1) { + if (CM.Disp.spawnedGoldenShimmer.wrath) { CM.Disp.Favicon.href = 'https://aktanusa.github.io/CookieMonster/favicon/wrathCookie.ico'; } else { @@ -943,60 +943,85 @@ CM.Disp.UpdateFavicon = function() { } } -CM.Disp.CreateGCTimer = function() { - CM.Disp.GCTimer = document.createElement('div'); - CM.Disp.GCTimer.style.width = '96px'; - CM.Disp.GCTimer.style.height = '96px'; - CM.Disp.GCTimer.style.display = 'none'; - CM.Disp.GCTimer.style.position = 'absolute'; - CM.Disp.GCTimer.style.zIndex = '10000000001'; - CM.Disp.GCTimer.style.textAlign = 'center'; - CM.Disp.GCTimer.style.lineHeight = '96px'; - CM.Disp.GCTimer.style.fontFamily = '\"Kavoon\", Georgia, serif'; - CM.Disp.GCTimer.style.fontSize = '35px'; - CM.Disp.GCTimer.style.cursor = 'pointer'; - CM.Disp.GCTimer.onclick = function () {CM.Disp.goldenShimmer.pop(); CM.Disp.GCTimer.style.display = 'none';}; - CM.Disp.GCTimer.onmouseover = function() {CM.Disp.goldenShimmer.l.style.filter = 'brightness(125%) drop-shadow(0px 0px 3px rgba(255,255,255,1))'; CM.Disp.goldenShimmer.l.style.webkitFilter = 'brightness(125%) drop-shadow(0px 0px 3px rgba(255,255,255,1))';}; - CM.Disp.GCTimer.onmouseout = function() {CM.Disp.goldenShimmer.l.style.filter = ''; CM.Disp.goldenShimmer.l.style.webkitFilter = '';}; +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 = '';}; - l('game').appendChild(CM.Disp.GCTimer); + CM.Disp.GCTimers[cookie.id] = GCTimer; + l('shimmers').appendChild(GCTimer); } CM.Disp.ToggleGCTimer = function() { if (CM.Config.GCTimer == 1) { if (CM.Disp.lastGoldenCookieState) { - CM.Disp.GCTimer.style.display = 'block'; - CM.Disp.GCTimer.style.left = CM.Disp.goldenShimmer.l.style.left; - CM.Disp.GCTimer.style.top = CM.Disp.goldenShimmer.l.style.top; + 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 { - CM.Disp.GCTimer.style.display = 'none'; + for (var i in CM.Disp.GCTimers) { + CM.Disp.GCTimers[i].style.display = 'none'; + } } } CM.Disp.CheckGoldenCookie = function() { - if (CM.Disp.lastGoldenCookieState != Game.shimmerTypes['golden'].spawned) { - CM.Disp.lastGoldenCookieState = Game.shimmerTypes['golden'].spawned; - CM.Disp.FindGoldenShimmer(); - CM.Disp.UpdateFavicon(); - if (CM.Disp.lastGoldenCookieState) { - if (CM.Config.GCTimer == 1) { - CM.Disp.GCTimer.style.display = 'block'; - CM.Disp.GCTimer.style.left = CM.Disp.goldenShimmer.l.style.left; - CM.Disp.GCTimer.style.top = CM.Disp.goldenShimmer.l.style.top; - } - - 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.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]); + 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.GCTimer.style.display = 'none'; } else if (CM.Config.GCTimer == 1 && CM.Disp.lastGoldenCookieState) { - CM.Disp.GCTimer.style.opacity = CM.Disp.goldenShimmer.l.style.opacity; - CM.Disp.GCTimer.style.transform = CM.Disp.goldenShimmer.l.style.transform; - CM.Disp.GCTimer.textContent = Math.ceil(CM.Disp.goldenShimmer.life / Game.fps); + 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); + } } } @@ -1096,11 +1121,11 @@ CM.Disp.UpdateTitle = function() { var titleFC; var titleSP; if (CM.Disp.lastGoldenCookieState) { - if (CM.Disp.goldenShimmer.wrath) { - titleGC = '[W ' + Math.ceil(CM.Disp.goldenShimmer.life / Game.fps) + ']'; + if (CM.Disp.spawnedGoldenShimmer.wrath) { + titleGC = '[W ' + Math.ceil(CM.Disp.spawnedGoldenShimmer.life / Game.fps) + ']'; } else { - titleGC = '[G ' + Math.ceil(CM.Disp.goldenShimmer.life / Game.fps) + ']'; + titleGC = '[G ' + Math.ceil(CM.Disp.spawnedGoldenShimmer.life / Game.fps) + ']'; } } else if (!Game.Has('Golden switch [off]')) { @@ -1135,11 +1160,11 @@ CM.Disp.UpdateTitle = function() { var spawn = false; if (CM.Disp.lastGoldenCookieState) { spawn = true; - if (CM.Disp.goldenShimmer.wrath) { - str += '[W ' + Math.ceil(CM.Disp.goldenShimmer.life / Game.fps) + ']'; + if (CM.Disp.spawnedGoldenShimmer.wrath) { + str += '[W ' + Math.ceil(CM.Disp.spawnedGoldenShimmer.life / Game.fps) + ']'; } else { - str += '[G ' + Math.ceil(CM.Disp.goldenShimmer.life / Game.fps) + ']'; + str += '[G ' + Math.ceil(CM.Disp.spawnedGoldenShimmer.life / Game.fps) + ']'; } } if (CM.Disp.lastTickerFortuneState) { @@ -2448,12 +2473,16 @@ CM.Disp.colorBrown = 'Brown'; CM.Disp.colors = [CM.Disp.colorBlue, CM.Disp.colorGreen, CM.Disp.colorYellow, CM.Disp.colorOrange, CM.Disp.colorRed, CM.Disp.colorPurple, CM.Disp.colorGray, CM.Disp.colorPink, CM.Disp.colorBrown]; CM.Disp.buffColors = {'Frenzy': CM.Disp.colorYellow, 'Dragon Harvest': CM.Disp.colorBrown, 'Elder frenzy': CM.Disp.colorGreen, 'Clot': CM.Disp.colorRed, 'Click frenzy': CM.Disp.colorBlue, 'Dragonflight': CM.Disp.colorPink}; CM.Disp.lastGoldenCookieState = 0; +CM.Disp.lastSpawnedGoldenCookieState = 0; +CM.Disp.currSpawnedGoldenCookieState CM.Disp.lastTickerFortuneState = 0; CM.Disp.lastSeasonPopupState = 0; CM.Disp.lastGardenNextStep = 0; CM.Disp.lastMagicBarFull = 0; CM.Disp.lastWrinklerCount = 0; -CM.Disp.goldenShimmer; +CM.Disp.goldenShimmersByID = {}; +CM.Disp.spawnedGoldenShimmer = 0; +CM.Disp.GCTimers = {}; CM.Disp.seasonPopShimmer; CM.Disp.lastAscendState = -1; diff --git a/src/Main.js b/src/Main.js index f4aa8d4..b8be047 100644 --- a/src/Main.js +++ b/src/Main.js @@ -231,7 +231,6 @@ CM.DelayInit = function() { CM.Disp.CreateUpgradeBar(); CM.Disp.CreateWhiteScreen(); CM.Disp.CreateFavicon(); - CM.Disp.CreateGCTimer(); for (var i in CM.Disp.TooltipText) { CM.Disp.CreateTooltip(CM.Disp.TooltipText[i][0], CM.Disp.TooltipText[i][1], CM.Disp.TooltipText[i][2]); } From 0ac966a9059846d55e758d1ed1fab9c70a73e782 Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Mon, 30 Nov 2020 08:47:29 +0100 Subject: [PATCH 30/49] Added Game.runModHookOnValue in CalcGains --- CookieMonster.js | 5 +++-- src/Sim.js | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index a3f833a..3b84447 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -4027,11 +4027,12 @@ CM.Sim.CalculateGains = function() { } // Removed debug upgrades + + // TODO: Check if this is handled correctly + CM.Sim.cookiesPs = Game.runModHookOnValue('cps', CM.Sim.cookiesPs); mult *= CM.Sim.getCPSBuffMult(); - // TODO: Handle ModHooks, see Game code - CM.Sim.cookiesPs *= mult; // if (Game.hasBuff('Cursed finger')) Game.cookiesPs = 0; diff --git a/src/Sim.js b/src/Sim.js index 4f996de..9ea54db 100644 --- a/src/Sim.js +++ b/src/Sim.js @@ -435,11 +435,12 @@ CM.Sim.CalculateGains = function() { } // Removed debug upgrades + + // TODO: Check if this is handled correctly + CM.Sim.cookiesPs = Game.runModHookOnValue('cps', CM.Sim.cookiesPs); mult *= CM.Sim.getCPSBuffMult(); - // TODO: Handle ModHooks, see Game code - CM.Sim.cookiesPs *= mult; // if (Game.hasBuff('Cursed finger')) Game.cookiesPs = 0; From a11f82fce4644a5cf6b5f4d07a583d95ab3da5a0 Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Mon, 30 Nov 2020 10:36:34 +0100 Subject: [PATCH 31/49] Fixed notations bugging out --- CookieMonster.js | 44 +++++++++++++++++++++++++++++++++----------- src/Disp.js | 44 +++++++++++++++++++++++++++++++++----------- 2 files changed, 66 insertions(+), 22 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 3b84447..3cfb74e 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -886,51 +886,73 @@ CM.Disp.Beautify = function(num, frac) { } if (CM.Config.Scale == 3) { - if (num >= 10) { + if (num >= 999999) { var count = 0; while (num >= 10) { count++; num /= 10; } - answer = Math.round(num * 1000) / 1000 + 'E+' + count; + answer = +(Math.round(num + "e+2") + "e-2") + 'E+' + count; } - else if (num < 1 && num != 0) { + else if (num < -999999 && num != 0) { var count = 0; while (num < 1) { count++; num *= 10; } - answer = Math.round(num * 1000) / 1000 + 'E-' + count; + answer = +(Math.round(num + "e+2") + "e-2") + 'E-' + count; } else { - answer = Math.round(num * 1000) / 1000 + 'E+0'; + answer = CM.Backup.Beautify(num, frac); } } else if (CM.Config.Scale == 4) { - if (num >= 1000) { + if (um >= 999999) { var count = 0; while (num >= 1000) { count++; num /= 1000; } - answer = Math.round(num * 1000) / 1000 + 'E+' + (count * 3); + answer = +(Math.round(num + "e+2") + "e-2") + 'E+' + (count * 3); } - else if (num < 1 && num != 0) { + else if (num < -999999 && num != 0) { var count = 0; while (num < 1) { count++; num *= 1000; } - answer = Math.round(num * 1000) / 1000 + 'E-' + (count * 3); + answer = +(Math.round(num + "e+2") + "e-2") + 'E-' + (count * 3); } else { - answer = Math.round(num * 1000) / 1000 + 'E+0'; + 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) { - if (num >= Math.pow(1000, i + 2)) { + // 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; } diff --git a/src/Disp.js b/src/Disp.js index dcf085a..6da56c6 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -138,51 +138,73 @@ CM.Disp.Beautify = function(num, frac) { } if (CM.Config.Scale == 3) { - if (num >= 10) { + if (num >= 999999) { var count = 0; while (num >= 10) { count++; num /= 10; } - answer = Math.round(num * 1000) / 1000 + 'E+' + count; + answer = +(Math.round(num + "e+2") + "e-2") + 'E+' + count; } - else if (num < 1 && num != 0) { + else if (num < -999999 && num != 0) { var count = 0; while (num < 1) { count++; num *= 10; } - answer = Math.round(num * 1000) / 1000 + 'E-' + count; + answer = +(Math.round(num + "e+2") + "e-2") + 'E-' + count; } else { - answer = Math.round(num * 1000) / 1000 + 'E+0'; + answer = CM.Backup.Beautify(num, frac); } } else if (CM.Config.Scale == 4) { - if (num >= 1000) { + if (um >= 999999) { var count = 0; while (num >= 1000) { count++; num /= 1000; } - answer = Math.round(num * 1000) / 1000 + 'E+' + (count * 3); + answer = +(Math.round(num + "e+2") + "e-2") + 'E+' + (count * 3); } - else if (num < 1 && num != 0) { + else if (num < -999999 && num != 0) { var count = 0; while (num < 1) { count++; num *= 1000; } - answer = Math.round(num * 1000) / 1000 + 'E-' + (count * 3); + answer = +(Math.round(num + "e+2") + "e-2") + 'E-' + (count * 3); } else { - answer = Math.round(num * 1000) / 1000 + 'E+0'; + 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) { - if (num >= Math.pow(1000, i + 2)) { + // 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; } From d257830de81b06d856da8914745bdc7a55ef016e Mon Sep 17 00:00:00 2001 From: Chorizorro Date: Sun, 29 Nov 2020 11:54:20 +0100 Subject: [PATCH 32/49] Fix building tooltip in sell mode (#359) --- CookieMonster.js | 25 ++++++++++++++++--------- src/Disp.js | 15 +++++++++------ src/Sim.js | 10 +++++++--- 3 files changed, 32 insertions(+), 18 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 3cfb74e..c945cf9 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -2827,12 +2827,15 @@ CM.Disp.Tooltip = function(type, name) { } } else if (Game.buyMode == -1) { - if (Game.buyBulk == -1) { - l('tooltip').innerHTML = l('tooltip').innerHTML.split(Beautify(Game.Objects[name].getPrice())).join('-' + Beautify(CM.Sim.BuildingSell(Game.Objects[name], Game.Objects[name].basePrice, Game.Objects[name].amount, Game.Objects[name].free, Game.Objects[name].amount))); - } - else { - l('tooltip').innerHTML = l('tooltip').innerHTML.split(Beautify(Game.Objects[name].getPrice())).join('-' + Beautify(CM.Sim.BuildingSell(Game.Objects[name], Game.Objects[name].basePrice, Game.Objects[name].amount, Game.Objects[name].free, Game.buyBulk))); - } + /* + * Fix sell price displayed in the object tooltip. + * + * 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('tooltip').innerHTML = l('tooltip').innerHTML.split(Beautify(Game.Objects[name].bulkPrice)).join(Beautify(CM.Sim.BuildingSell(Game.Objects[name], Game.Objects[name].basePrice, Game.Objects[name].amount, Game.Objects[name].free, Game.buyBulk, 1))); } } else if (type == 'u') { @@ -3639,7 +3642,7 @@ CM.Sim.BuildingGetPrice = function(build, basePrice, start, free, increase) { return moni; } -CM.Sim.BuildingSell = function(build, basePrice, start, free, amount) { +CM.Sim.BuildingSell = function(build, basePrice, start, free, amount, noSim) { /*var price=0; for (var i = Math.max(0, start - amount); i < Math.max(0, start); i++) { price += basePrice * Math.pow(Game.priceIncrease, Math.max(0, i - free)); @@ -3658,12 +3661,16 @@ CM.Sim.BuildingSell = function(build, basePrice, start, free, amount) { return Math.ceil(price);*/ // Calculate money gains from selling buildings + // If noSim is set, use Game methods to compute price instead of Sim ones. + noSim = typeof noSim === "undefined" ? 0 : noSim; var moni = 0; + if (amount == -1) amount = start; + if (!amount) amount = Game.buyBulk; for (var i = 0; i < amount; i++) { var price = basePrice * Math.pow(Game.priceIncrease, Math.max(0, start - free)); - price = CM.Sim.modifyBuildingPrice(build, price); + price = noSim ? Game.modifyBuildingPrice(build, price) : CM.Sim.modifyBuildingPrice(build, price); price = Math.ceil(price); - var giveBack = CM.Sim.getSellMultiplier(); + var giveBack = noSim ? build.getSellMultiplier() : CM.Sim.getSellMultiplier(); price = Math.floor(price * giveBack); if (start > 0) { moni += price; diff --git a/src/Disp.js b/src/Disp.js index 6da56c6..be7b31b 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -2079,12 +2079,15 @@ CM.Disp.Tooltip = function(type, name) { } } else if (Game.buyMode == -1) { - if (Game.buyBulk == -1) { - l('tooltip').innerHTML = l('tooltip').innerHTML.split(Beautify(Game.Objects[name].getPrice())).join('-' + Beautify(CM.Sim.BuildingSell(Game.Objects[name], Game.Objects[name].basePrice, Game.Objects[name].amount, Game.Objects[name].free, Game.Objects[name].amount))); - } - else { - l('tooltip').innerHTML = l('tooltip').innerHTML.split(Beautify(Game.Objects[name].getPrice())).join('-' + Beautify(CM.Sim.BuildingSell(Game.Objects[name], Game.Objects[name].basePrice, Game.Objects[name].amount, Game.Objects[name].free, Game.buyBulk))); - } + /* + * Fix sell price displayed in the object tooltip. + * + * 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('tooltip').innerHTML = l('tooltip').innerHTML.split(Beautify(Game.Objects[name].bulkPrice)).join(Beautify(CM.Sim.BuildingSell(Game.Objects[name], Game.Objects[name].basePrice, Game.Objects[name].amount, Game.Objects[name].free, Game.buyBulk, 1))); } } else if (type == 'u') { diff --git a/src/Sim.js b/src/Sim.js index 9ea54db..a8fba6f 100644 --- a/src/Sim.js +++ b/src/Sim.js @@ -25,7 +25,7 @@ CM.Sim.BuildingGetPrice = function(build, basePrice, start, free, increase) { return moni; } -CM.Sim.BuildingSell = function(build, basePrice, start, free, amount) { +CM.Sim.BuildingSell = function(build, basePrice, start, free, amount, noSim) { /*var price=0; for (var i = Math.max(0, start - amount); i < Math.max(0, start); i++) { price += basePrice * Math.pow(Game.priceIncrease, Math.max(0, i - free)); @@ -44,12 +44,16 @@ CM.Sim.BuildingSell = function(build, basePrice, start, free, amount) { return Math.ceil(price);*/ // Calculate money gains from selling buildings + // If noSim is set, use Game methods to compute price instead of Sim ones. + noSim = typeof noSim === "undefined" ? 0 : noSim; var moni = 0; + if (amount == -1) amount = start; + if (!amount) amount = Game.buyBulk; for (var i = 0; i < amount; i++) { var price = basePrice * Math.pow(Game.priceIncrease, Math.max(0, start - free)); - price = CM.Sim.modifyBuildingPrice(build, price); + price = noSim ? Game.modifyBuildingPrice(build, price) : CM.Sim.modifyBuildingPrice(build, price); price = Math.ceil(price); - var giveBack = CM.Sim.getSellMultiplier(); + var giveBack = noSim ? build.getSellMultiplier() : CM.Sim.getSellMultiplier(); price = Math.floor(price * giveBack); if (start > 0) { moni += price; From 17f13239ca4cf2218956f3b5680837589209882b Mon Sep 17 00:00:00 2001 From: Chorizorro Date: Mon, 30 Nov 2020 11:25:21 +0100 Subject: [PATCH 33/49] Fix building price in store in sell mode (#359) --- CookieMonster.js | 12 +++++++++++- src/Disp.js | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index c945cf9..f4b5c38 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -1424,7 +1424,17 @@ CM.Disp.UpdateBuildings = function() { } else { for (var i in CM.Cache.Objects) { - l('productPrice' + Game.Objects[i].id).style.color = ''; + 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)); } } diff --git a/src/Disp.js b/src/Disp.js index be7b31b..e32aab0 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -676,7 +676,17 @@ CM.Disp.UpdateBuildings = function() { } else { for (var i in CM.Cache.Objects) { - l('productPrice' + Game.Objects[i].id).style.color = ''; + 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)); } } From 42960d9780a8155b8a13169a566ecdc1298819fb Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Mon, 30 Nov 2020 22:07:47 +0100 Subject: [PATCH 34/49] Added 'seconds till autosave' to Misc. tats --- CookieMonster.js | 5 +++++ src/Disp.js | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/CookieMonster.js b/CookieMonster.js index f4b5c38..fba864b 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -2648,6 +2648,11 @@ CM.Disp.AddMenuStats = function(title) { 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) + console.log(timeTillAutosave) + stats.appendChild(listing('Seconds till autosave', document.createTextNode(Math.floor(timeTillAutosave)))); + } } l('menu').insertBefore(stats, l('menu').childNodes[2]); diff --git a/src/Disp.js b/src/Disp.js index e32aab0..ad25d23 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -1900,6 +1900,11 @@ CM.Disp.AddMenuStats = function(title) { 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) + console.log(timeTillAutosave) + stats.appendChild(listing('Seconds till autosave', document.createTextNode(Math.floor(timeTillAutosave)))); + } } l('menu').insertBefore(stats, l('menu').childNodes[2]); From a30f07be7781ebefb4aafc9c38cbc204293480b5 Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Mon, 30 Nov 2020 22:27:00 +0100 Subject: [PATCH 35/49] Removed console.log from debugging --- CookieMonster.js | 1 - src/Disp.js | 1 - 2 files changed, 2 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index fba864b..9521539 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -2650,7 +2650,6 @@ CM.Disp.AddMenuStats = function(title) { 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) - console.log(timeTillAutosave) stats.appendChild(listing('Seconds till autosave', document.createTextNode(Math.floor(timeTillAutosave)))); } } diff --git a/src/Disp.js b/src/Disp.js index ad25d23..754e2f6 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -1902,7 +1902,6 @@ CM.Disp.AddMenuStats = function(title) { 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) - console.log(timeTillAutosave) stats.appendChild(listing('Seconds till autosave', document.createTextNode(Math.floor(timeTillAutosave)))); } } From baf21e888f3621814f05ef902267271a5c386b84 Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Tue, 1 Dec 2020 08:44:23 +0100 Subject: [PATCH 36/49] Fixed PP calculation when CPS = 0 --- CookieMonster.js | 36 ++++++++++++++++++++++++++++++------ src/Cache.js | 36 ++++++++++++++++++++++++++++++------ 2 files changed, 60 insertions(+), 12 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 9521539..8c77b86 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -94,7 +94,11 @@ CM.Cache.RemakeBuildingsPP = function() { 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; - 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); + 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; } @@ -118,7 +122,11 @@ CM.Cache.RemakeBuildingsPP = function() { 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; - 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); + 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; } @@ -136,7 +144,11 @@ CM.Cache.RemakeBuildingsPP = function() { } else if (Game.buyBulk == 10) { for (var i in CM.Cache.Objects) { - 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); + 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; } @@ -154,7 +166,11 @@ CM.Cache.RemakeBuildingsPP = function() { } else if (Game.buyBulk == 100) { for (var i in CM.Cache.Objects) { - 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); + 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; } @@ -176,7 +192,11 @@ CM.Cache.RemakeBuildingsPP = function() { 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; - 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); + 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; @@ -193,7 +213,11 @@ CM.Cache.RemakeUpgradePP = function() { 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; - 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); + 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; diff --git a/src/Cache.js b/src/Cache.js index d3330f8..a2b69dd 100644 --- a/src/Cache.js +++ b/src/Cache.js @@ -74,7 +74,11 @@ CM.Cache.RemakeBuildingsPP = function() { 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; - 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); + 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; } @@ -98,7 +102,11 @@ CM.Cache.RemakeBuildingsPP = function() { 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; - 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); + 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; } @@ -116,7 +124,11 @@ CM.Cache.RemakeBuildingsPP = function() { } else if (Game.buyBulk == 10) { for (var i in CM.Cache.Objects) { - 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); + 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; } @@ -134,7 +146,11 @@ CM.Cache.RemakeBuildingsPP = function() { } else if (Game.buyBulk == 100) { for (var i in CM.Cache.Objects) { - 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); + 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; } @@ -156,7 +172,11 @@ CM.Cache.RemakeBuildingsPP = function() { 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; - 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); + 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; @@ -173,7 +193,11 @@ CM.Cache.RemakeUpgradePP = function() { 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; - 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); + 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; From f810c42b734915c147f5d21242f9d123072aae69 Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Tue, 1 Dec 2020 11:37:03 +0100 Subject: [PATCH 37/49] Optional display of missing upgrades to stats --- CookieMonster.js | 114 ++++++++++++++++++++++++++++++++++++++++++++++- src/Cache.js | 23 ++++++++++ src/Config.js | 1 + src/Disp.js | 89 +++++++++++++++++++++++++++++++++++- src/Main.js | 1 + 5 files changed, 224 insertions(+), 4 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 8c77b86..9282fff 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -442,6 +442,24 @@ CM.Cache.UpdateAvgCPS = function() { } } +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; @@ -480,6 +498,11 @@ 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 * @@ -730,6 +753,7 @@ CM.ConfigData.TooltipGrim = {label: ['Grimoire Tooltip Information OFF', 'Grimoi 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.', 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();}}; @@ -1792,6 +1816,7 @@ CM.Disp.CheckGoldenCookie = function() { 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]; } } @@ -2208,6 +2233,7 @@ CM.Disp.AddMenuPref = function(title) { 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')); @@ -2681,6 +2707,83 @@ CM.Disp.AddMenuStats = function(title) { 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 '
' + + '
' + + '
' + Beautify(Math.round(me.getPrice())) + '
' + + '
' + me.name + '
' + + '
' + me.desc + '
', + 'top', + true) + + ' style="background-position:' + (-me.icon[0] * 48) + 'px ' + (-me.icon[1] * 48) + 'px;">'; + }; + + // This function creates section of given elements and adds this elements to it. + var createElementBox = function (elements) { + var div = document.createElement('div'); + div.className = 'listing crateBox'; + elements.forEach(function (element) { + div.innerHTML += createUpgradeElement(element); + }); + return div; + }; + + // This function creates header element with given text. + var createHeader = function (text) { + var div = document.createElement('div'); + div.className = 'listing'; + var b = document.createElement('b'); + b.textContent = text; + div.appendChild(b); + return div; + }; + + if (CM.Cache.MissingUpgrades.length > 0) { + upgradesMenu.appendChild(createHeader("Missing Upgrades")); + if (CM.Cache.MissingUpgradesString == null) { + CM.Cache.MissingUpgradesString = createElementBox(CM.Cache.MissingUpgrades); + } + upgradesMenu.appendChild(CM.Cache.MissingUpgradesString); + } + + if (CM.Cache.MissingCookies.length > 0) { + upgradesMenu.appendChild(createHeader("Missing Cookies")); + if (CM.Cache.MissingCookiesString == null) { + CM.Cache.MissingCookiesString = createElementBox(CM.Cache.MissingCookies); + } + upgradesMenu.appendChild(CM.Cache.MissingCookiesString); + } +} + CM.Disp.AddMenu = function() { var title = function() { var div = document.createElement('div'); @@ -2692,8 +2795,14 @@ CM.Disp.AddMenu = function() { if (Game.onMenu == 'prefs') { CM.Disp.AddMenuPref(title); } - else if (CM.Config.Stats == 1 && Game.onMenu == 'stats') { - CM.Disp.AddMenuStats(title); + else if (Game.onMenu == 'stats') { + if (CM.Config.Stats) { + CM.Disp.AddMenuStats(title); + } + + if (CM.Config.MissingUpgrades) { + CM.Disp.AddMissingUpgrades(); + } } } @@ -3637,6 +3746,7 @@ CM.ConfigDefault = { ToolWrink: 1, TooltipLump: 1, Stats: 1, + MissingUpgrades: 0, UpStats: 1, TimeFormat: 0, SayTime: 1, diff --git a/src/Cache.js b/src/Cache.js index a2b69dd..e54b13a 100644 --- a/src/Cache.js +++ b/src/Cache.js @@ -422,6 +422,24 @@ CM.Cache.UpdateAvgCPS = function() { } } +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; @@ -460,4 +478,9 @@ 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; diff --git a/src/Config.js b/src/Config.js index d7f531f..aa04353 100644 --- a/src/Config.js +++ b/src/Config.js @@ -247,6 +247,7 @@ CM.ConfigData.TooltipGrim = {label: ['Grimoire Tooltip Information OFF', 'Grimoi 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.', 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();}}; diff --git a/src/Disp.js b/src/Disp.js index 754e2f6..84b37d9 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -1020,6 +1020,7 @@ CM.Disp.CheckGoldenCookie = function() { 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]; } } @@ -1436,6 +1437,7 @@ CM.Disp.AddMenuPref = function(title) { 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')); @@ -1909,6 +1911,83 @@ CM.Disp.AddMenuStats = function(title) { 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 '
' + + '
' + + '
' + Beautify(Math.round(me.getPrice())) + '
' + + '
' + me.name + '
' + + '
' + me.desc + '
', + 'top', + true) + + ' style="background-position:' + (-me.icon[0] * 48) + 'px ' + (-me.icon[1] * 48) + 'px;">'; + }; + + // This function creates section of given elements and adds this elements to it. + var createElementBox = function (elements) { + var div = document.createElement('div'); + div.className = 'listing crateBox'; + elements.forEach(function (element) { + div.innerHTML += createUpgradeElement(element); + }); + return div; + }; + + // This function creates header element with given text. + var createHeader = function (text) { + var div = document.createElement('div'); + div.className = 'listing'; + var b = document.createElement('b'); + b.textContent = text; + div.appendChild(b); + return div; + }; + + if (CM.Cache.MissingUpgrades.length > 0) { + upgradesMenu.appendChild(createHeader("Missing Upgrades")); + if (CM.Cache.MissingUpgradesString == null) { + CM.Cache.MissingUpgradesString = createElementBox(CM.Cache.MissingUpgrades); + } + upgradesMenu.appendChild(CM.Cache.MissingUpgradesString); + } + + if (CM.Cache.MissingCookies.length > 0) { + upgradesMenu.appendChild(createHeader("Missing Cookies")); + if (CM.Cache.MissingCookiesString == null) { + CM.Cache.MissingCookiesString = createElementBox(CM.Cache.MissingCookies); + } + upgradesMenu.appendChild(CM.Cache.MissingCookiesString); + } +} + CM.Disp.AddMenu = function() { var title = function() { var div = document.createElement('div'); @@ -1920,8 +1999,14 @@ CM.Disp.AddMenu = function() { if (Game.onMenu == 'prefs') { CM.Disp.AddMenuPref(title); } - else if (CM.Config.Stats == 1 && Game.onMenu == 'stats') { - CM.Disp.AddMenuStats(title); + else if (Game.onMenu == 'stats') { + if (CM.Config.Stats) { + CM.Disp.AddMenuStats(title); + } + + if (CM.Config.MissingUpgrades) { + CM.Disp.AddMissingUpgrades(); + } } } diff --git a/src/Main.js b/src/Main.js index b8be047..cfcfb66 100644 --- a/src/Main.js +++ b/src/Main.js @@ -317,6 +317,7 @@ CM.ConfigDefault = { ToolWrink: 1, TooltipLump: 1, Stats: 1, + MissingUpgrades: 0, UpStats: 1, TimeFormat: 0, SayTime: 1, From 810c5adfba2494e572ff5506f355d3c25f8f564f Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Tue, 1 Dec 2020 12:44:13 +0100 Subject: [PATCH 38/49] Fixed sorting when PP = Infinity --- CookieMonster.js | 3 ++- src/Disp.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 9282fff..8068ff5 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -1496,7 +1496,8 @@ CM.Disp.UpdateBuildings = function() { o.id = Game.Objects[k].id; return o; }); - arr.sort((a, b) => a.pp - b.pp); + + 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); diff --git a/src/Disp.js b/src/Disp.js index 84b37d9..d06238a 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -700,7 +700,8 @@ CM.Disp.UpdateBuildings = function() { o.id = Game.Objects[k].id; return o; }); - arr.sort((a, b) => a.pp - b.pp); + + 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); From 71a4407da8711a94d61e6ae3046436e0ac5485f1 Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Tue, 1 Dec 2020 13:38:49 +0100 Subject: [PATCH 39/49] Added cookies to be gained/lost to conjure tooltip --- CookieMonster.js | 22 +++++++++++++++++++++- src/Disp.js | 22 +++++++++++++++++++++- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 9282fff..b376bff 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -3194,7 +3194,8 @@ CM.Disp.UpdateTooltip = function() { l('CMTooltipArea').appendChild(lumpTooltip); } } - else { // Grimoire + else if (CM.Disp.tooltipType === 'g') { + // Grimoire CM.Disp.TooltipWarn.style.display = 'none'; l('CMDispTooltipWarnLucky').style.display = 'none'; l('CMDispTooltipWarnLuckyFrenzy').style.display = 'none'; @@ -3240,6 +3241,25 @@ CM.Disp.UpdateTooltip = function() { recover.className = CM.Disp.colorTextPre + recoverColor.color; } + // Extra information when spell is Conjure Baked Goods (Name == 0) + if (CM.Disp.tooltipName == 0) { + tooltip.appendChild(header('Cookies to be gained/lost')); + var conjure = document.createElement('div'); + conjure.id = 'CMTooltipConjure'; + tooltip.appendChild(conjure); + var reward = document.createElement('span'); + reward.style.color = "#33FF00" + reward.textContent = Beautify(Math.min((Game.cookies + CM.Disp.GetWrinkConfigBank()) * 0.15, CM.Cache.NoGoldSwitchCookiesPS * 60 * 30), 2) + conjure.appendChild(reward) + var seperator = document.createElement('span'); + seperator.textContent = ' / ' + conjure.appendChild(seperator) + var loss = document.createElement('span'); + loss.style.color = "red" + loss.textContent = Beautify((CM.Cache.NoGoldSwitchCookiesPS * 60 * 15), 2); + conjure.appendChild(loss) + } + l('CMTooltipArea').appendChild(tooltip); } } diff --git a/src/Disp.js b/src/Disp.js index 84b37d9..3676db4 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -2398,7 +2398,8 @@ CM.Disp.UpdateTooltip = function() { l('CMTooltipArea').appendChild(lumpTooltip); } } - else { // Grimoire + else if (CM.Disp.tooltipType === 'g') { + // Grimoire CM.Disp.TooltipWarn.style.display = 'none'; l('CMDispTooltipWarnLucky').style.display = 'none'; l('CMDispTooltipWarnLuckyFrenzy').style.display = 'none'; @@ -2444,6 +2445,25 @@ CM.Disp.UpdateTooltip = function() { recover.className = CM.Disp.colorTextPre + recoverColor.color; } + // Extra information when spell is Conjure Baked Goods (Name == 0) + if (CM.Disp.tooltipName == 0) { + tooltip.appendChild(header('Cookies to be gained/lost')); + var conjure = document.createElement('div'); + conjure.id = 'CMTooltipConjure'; + tooltip.appendChild(conjure); + var reward = document.createElement('span'); + reward.style.color = "#33FF00" + reward.textContent = Beautify(Math.min((Game.cookies + CM.Disp.GetWrinkConfigBank()) * 0.15, CM.Cache.NoGoldSwitchCookiesPS * 60 * 30), 2) + conjure.appendChild(reward) + var seperator = document.createElement('span'); + seperator.textContent = ' / ' + conjure.appendChild(seperator) + var loss = document.createElement('span'); + loss.style.color = "red" + loss.textContent = Beautify((CM.Cache.NoGoldSwitchCookiesPS * 60 * 15), 2); + conjure.appendChild(loss) + } + l('CMTooltipArea').appendChild(tooltip); } } From 8dc5d4b849b5abed695761402de14839f8d58e96 Mon Sep 17 00:00:00 2001 From: Chorizorro Date: Tue, 1 Dec 2020 12:23:42 +0100 Subject: [PATCH 40/49] Fix golden and wrath cookies multipliers (#379) --- CookieMonster.js | 88 +++++++++++++++++++++++++----------------------- src/Cache.js | 54 ++++++++++++++++++++++------- src/Disp.js | 33 +++--------------- src/Main.js | 1 + 4 files changed, 92 insertions(+), 84 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index e862e83..571c736 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -238,8 +238,29 @@ CM.Cache.RemakePP = function() { 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; +} + CM.Cache.RemakeLucky = function() { - var GCmult = CM.Sim.eff('goldenCookieGain') + var goldenMult = CM.Cache.GoldenCookiesMult; + // TODO wrathMult + CM.Cache.Lucky = (CM.Cache.NoGoldSwitchCookiesPS * 900) / 0.15; var cpsBuffMult = CM.Sim.getCPSBuffMult(); if (cpsBuffMult > 0) { @@ -247,22 +268,24 @@ CM.Cache.RemakeLucky = function() { } else { CM.Cache.Lucky = 0; } - CM.Cache.LuckyReward = GCmult * (CM.Cache.Lucky * 0.15) + 13; + CM.Cache.LuckyReward = goldenMult * (CM.Cache.Lucky * 0.15) + 13; + // TODO LuckyWrathReward CM.Cache.LuckyFrenzy = CM.Cache.Lucky * 7; - CM.Cache.LuckyRewardFrenzy = GCmult * (CM.Cache.LuckyFrenzy * 0.15) + 13; + CM.Cache.LuckyRewardFrenzy = goldenMult * (CM.Cache.LuckyFrenzy * 0.15) + 13; + // TODO LuckyWrathRewardFrenzy CM.Cache.Conjure = CM.Cache.Lucky * 2; CM.Cache.ConjureReward = CM.Cache.Conjure * 0.15; } -CM.Cache.MaxChainMoni = function(digit, maxPayout) { - var GCmult = CM.Sim.eff('goldenCookieGain') +CM.Cache.MaxChainMoni = function(digit, maxPayout, mult) { + // TODO wrathMult 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 * GCmult), maxPayout)); - var nextMoni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain + 1) * digit * GCmult), maxPayout)); + 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 * GCmult), maxPayout)); - nextMoni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain + 1) * digit * GCmult), maxPayout)); + 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; } @@ -276,9 +299,12 @@ CM.Cache.RemakeChain = function() { maxPayout = 0; } - CM.Cache.ChainReward = CM.Cache.MaxChainMoni(7, maxPayout); + var goldenMult = CM.Cache.GoldenCookiesMult; + var wrathMult = CM.Cache.WrathCookiesMult; - CM.Cache.ChainWrathReward = CM.Cache.MaxChainMoni(6, maxPayout); + 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; @@ -293,9 +319,9 @@ CM.Cache.RemakeChain = function() { CM.Cache.ChainWrath = CM.Cache.NextNumber(CM.Cache.ChainWrathReward) / 0.5; } - CM.Cache.ChainFrenzyReward = CM.Cache.MaxChainMoni(7, maxPayout * 7); + CM.Cache.ChainFrenzyReward = CM.Cache.MaxChainMoni(7, maxPayout * 7, goldenMult); - CM.Cache.ChainFrenzyWrathReward = CM.Cache.MaxChainMoni(6, maxPayout * 7); + CM.Cache.ChainFrenzyWrathReward = CM.Cache.MaxChainMoni(6, maxPayout * 7, wrathMult); if ((maxPayout * 7) < CM.Cache.ChainFrenzyReward) { CM.Cache.ChainFrenzy = 0; @@ -465,6 +491,8 @@ 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.NoGoldSwitchCookiesPS = 0; CM.Cache.Lucky = 0; CM.Cache.LuckyReward = 0; @@ -2375,23 +2403,8 @@ CM.Disp.AddMenuStats = function(title) { var luckyRewardMaxWrath = CM.Cache.LuckyReward; var luckyRewardFrenzyMax = CM.Cache.LuckyRewardFrenzy; var luckyRewardFrenzyMaxWrath = CM.Cache.LuckyRewardFrenzy; - var luckyCur = luckyCurBase; - var luckyCurWrath = luckyCurBase; - // Old way - if (Game.hasAura('Ancestral Metamorphosis')) { - luckyRewardMax *= 1.1; - luckyRewardFrenzyMax *= 1.1; - luckyCur *= 1.1; - } - /*luckyRewardMax *= 1 + Game.auraMult('Ancestral Metamorphosis') * 0.1; - luckyRewardFrenzyMax *= 1 + Game.auraMult('Ancestral Metamorphosis') * 0.1; - luckyCur *= 1 + Game.auraMult('Ancestral Metamorphosis') * 0.1;*/ - // Old way - if (Game.hasAura('Unholy Dominion')) { - luckyRewardMaxWrath *= 1.1; - luckyRewardFrenzyMaxWrath *= 1.1; - luckyCurWrath *= 1.1; - } + var luckyCur = CM.Cache.GoldenCookiesMult * luckyCurBase; + var luckyCurWrath = CM.Cache.WrathCookiesMult * luckyCurBase; var luckySplit = luckyRewardMax != luckyRewardMaxWrath; var luckyReqFrag = document.createDocumentFragment(); @@ -2439,18 +2452,8 @@ CM.Disp.AddMenuStats = function(title) { var chainFrenzyRewardMax = CM.Cache.ChainFrenzyReward; var chainFrenzyWrathRewardMax = CM.Cache.ChainFrenzyWrathReward; var chainCurMax = Math.min(CM.Cache.NoGoldSwitchCookiesPS * 60 * 60 * 6, (Game.cookies + CM.Disp.GetWrinkConfigBank()) * 0.5); - var chainCur = CM.Cache.MaxChainMoni(7, chainCurMax); - var chainCurWrath = CM.Cache.MaxChainMoni(6, chainCurMax); - if (Game.hasAura('Ancestral Metamorphosis')) { - chainRewardMax *= 1.1; - chainFrenzyRewardMax *= 1.1; - chainCur *= 1.1; - } - if (Game.hasAura('Unholy Dominion')) { - chainWrathRewardMax *= 1.1; - chainFrenzyWrathRewardMax *= 1.1; - chainCurWrath *= 1.1; - } + 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'); @@ -3582,6 +3585,7 @@ CM.Loop = function() { CM.Cache.RemakeIncome(); CM.Sim.NoGoldSwitchCookiesPS(); // Needed first + CM.Cache.RemakeGoldenAndWrathCookiesMults(); CM.Cache.RemakeLucky(); CM.Cache.RemakeChain(); diff --git a/src/Cache.js b/src/Cache.js index e54b13a..6bc7aad 100644 --- a/src/Cache.js +++ b/src/Cache.js @@ -218,8 +218,29 @@ CM.Cache.RemakePP = function() { 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; +} + CM.Cache.RemakeLucky = function() { - var GCmult = CM.Sim.eff('goldenCookieGain') + var goldenMult = CM.Cache.GoldenCookiesMult; + // TODO wrathMult + CM.Cache.Lucky = (CM.Cache.NoGoldSwitchCookiesPS * 900) / 0.15; var cpsBuffMult = CM.Sim.getCPSBuffMult(); if (cpsBuffMult > 0) { @@ -227,22 +248,24 @@ CM.Cache.RemakeLucky = function() { } else { CM.Cache.Lucky = 0; } - CM.Cache.LuckyReward = GCmult * (CM.Cache.Lucky * 0.15) + 13; + CM.Cache.LuckyReward = goldenMult * (CM.Cache.Lucky * 0.15) + 13; + // TODO LuckyWrathReward CM.Cache.LuckyFrenzy = CM.Cache.Lucky * 7; - CM.Cache.LuckyRewardFrenzy = GCmult * (CM.Cache.LuckyFrenzy * 0.15) + 13; + CM.Cache.LuckyRewardFrenzy = goldenMult * (CM.Cache.LuckyFrenzy * 0.15) + 13; + // TODO LuckyWrathRewardFrenzy CM.Cache.Conjure = CM.Cache.Lucky * 2; CM.Cache.ConjureReward = CM.Cache.Conjure * 0.15; } -CM.Cache.MaxChainMoni = function(digit, maxPayout) { - var GCmult = CM.Sim.eff('goldenCookieGain') +CM.Cache.MaxChainMoni = function(digit, maxPayout, mult) { + // TODO wrathMult 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 * GCmult), maxPayout)); - var nextMoni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain + 1) * digit * GCmult), maxPayout)); + 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 * GCmult), maxPayout)); - nextMoni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain + 1) * digit * GCmult), maxPayout)); + 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; } @@ -256,9 +279,12 @@ CM.Cache.RemakeChain = function() { maxPayout = 0; } - CM.Cache.ChainReward = CM.Cache.MaxChainMoni(7, maxPayout); + var goldenMult = CM.Cache.GoldenCookiesMult; + var wrathMult = CM.Cache.WrathCookiesMult; - CM.Cache.ChainWrathReward = CM.Cache.MaxChainMoni(6, maxPayout); + 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; @@ -273,9 +299,9 @@ CM.Cache.RemakeChain = function() { CM.Cache.ChainWrath = CM.Cache.NextNumber(CM.Cache.ChainWrathReward) / 0.5; } - CM.Cache.ChainFrenzyReward = CM.Cache.MaxChainMoni(7, maxPayout * 7); + CM.Cache.ChainFrenzyReward = CM.Cache.MaxChainMoni(7, maxPayout * 7, goldenMult); - CM.Cache.ChainFrenzyWrathReward = CM.Cache.MaxChainMoni(6, maxPayout * 7); + CM.Cache.ChainFrenzyWrathReward = CM.Cache.MaxChainMoni(6, maxPayout * 7, wrathMult); if ((maxPayout * 7) < CM.Cache.ChainFrenzyReward) { CM.Cache.ChainFrenzy = 0; @@ -445,6 +471,8 @@ 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.NoGoldSwitchCookiesPS = 0; CM.Cache.Lucky = 0; CM.Cache.LuckyReward = 0; diff --git a/src/Disp.js b/src/Disp.js index b3ba47e..221943a 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -1579,23 +1579,8 @@ CM.Disp.AddMenuStats = function(title) { var luckyRewardMaxWrath = CM.Cache.LuckyReward; var luckyRewardFrenzyMax = CM.Cache.LuckyRewardFrenzy; var luckyRewardFrenzyMaxWrath = CM.Cache.LuckyRewardFrenzy; - var luckyCur = luckyCurBase; - var luckyCurWrath = luckyCurBase; - // Old way - if (Game.hasAura('Ancestral Metamorphosis')) { - luckyRewardMax *= 1.1; - luckyRewardFrenzyMax *= 1.1; - luckyCur *= 1.1; - } - /*luckyRewardMax *= 1 + Game.auraMult('Ancestral Metamorphosis') * 0.1; - luckyRewardFrenzyMax *= 1 + Game.auraMult('Ancestral Metamorphosis') * 0.1; - luckyCur *= 1 + Game.auraMult('Ancestral Metamorphosis') * 0.1;*/ - // Old way - if (Game.hasAura('Unholy Dominion')) { - luckyRewardMaxWrath *= 1.1; - luckyRewardFrenzyMaxWrath *= 1.1; - luckyCurWrath *= 1.1; - } + var luckyCur = CM.Cache.GoldenCookiesMult * luckyCurBase; + var luckyCurWrath = CM.Cache.WrathCookiesMult * luckyCurBase; var luckySplit = luckyRewardMax != luckyRewardMaxWrath; var luckyReqFrag = document.createDocumentFragment(); @@ -1643,18 +1628,8 @@ CM.Disp.AddMenuStats = function(title) { var chainFrenzyRewardMax = CM.Cache.ChainFrenzyReward; var chainFrenzyWrathRewardMax = CM.Cache.ChainFrenzyWrathReward; var chainCurMax = Math.min(CM.Cache.NoGoldSwitchCookiesPS * 60 * 60 * 6, (Game.cookies + CM.Disp.GetWrinkConfigBank()) * 0.5); - var chainCur = CM.Cache.MaxChainMoni(7, chainCurMax); - var chainCurWrath = CM.Cache.MaxChainMoni(6, chainCurMax); - if (Game.hasAura('Ancestral Metamorphosis')) { - chainRewardMax *= 1.1; - chainFrenzyRewardMax *= 1.1; - chainCur *= 1.1; - } - if (Game.hasAura('Unholy Dominion')) { - chainWrathRewardMax *= 1.1; - chainFrenzyWrathRewardMax *= 1.1; - chainCurWrath *= 1.1; - } + 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'); diff --git a/src/Main.js b/src/Main.js index cfcfb66..b95cd58 100644 --- a/src/Main.js +++ b/src/Main.js @@ -132,6 +132,7 @@ CM.Loop = function() { CM.Cache.RemakeIncome(); CM.Sim.NoGoldSwitchCookiesPS(); // Needed first + CM.Cache.RemakeGoldenAndWrathCookiesMults(); CM.Cache.RemakeLucky(); CM.Cache.RemakeChain(); From 8a3609092d8fd3d17d390c45dce6d95b9d9f43e7 Mon Sep 17 00:00:00 2001 From: Chorizorro Date: Tue, 1 Dec 2020 14:07:11 +0100 Subject: [PATCH 41/49] Handle lucky wrath cookies rewards (#379) --- CookieMonster.js | 13 +++++++------ src/Cache.js | 9 +++++---- src/Disp.js | 4 ++-- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 571c736..cfd9adc 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -259,7 +259,7 @@ CM.Cache.RemakeGoldenAndWrathCookiesMults = function() { CM.Cache.RemakeLucky = function() { var goldenMult = CM.Cache.GoldenCookiesMult; - // TODO wrathMult + var wrathMult = CM.Cache.WrathCookiesMult; CM.Cache.Lucky = (CM.Cache.NoGoldSwitchCookiesPS * 900) / 0.15; var cpsBuffMult = CM.Sim.getCPSBuffMult(); @@ -269,16 +269,15 @@ CM.Cache.RemakeLucky = function() { CM.Cache.Lucky = 0; } CM.Cache.LuckyReward = goldenMult * (CM.Cache.Lucky * 0.15) + 13; - // TODO LuckyWrathReward + 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; - // TODO LuckyWrathRewardFrenzy + 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) { - // TODO wrathMult 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)); @@ -496,8 +495,10 @@ CM.Cache.WrathCookiesMult = 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; @@ -2400,9 +2401,9 @@ CM.Disp.AddMenuStats = function(title) { 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 * 60 * 15) + 13; var luckyRewardMax = CM.Cache.LuckyReward; - var luckyRewardMaxWrath = CM.Cache.LuckyReward; + var luckyRewardMaxWrath = CM.Cache.LuckyWrathReward; var luckyRewardFrenzyMax = CM.Cache.LuckyRewardFrenzy; - var luckyRewardFrenzyMaxWrath = CM.Cache.LuckyRewardFrenzy; + var luckyRewardFrenzyMaxWrath = CM.Cache.LuckyWrathRewardFrenzy; var luckyCur = CM.Cache.GoldenCookiesMult * luckyCurBase; var luckyCurWrath = CM.Cache.WrathCookiesMult * luckyCurBase; var luckySplit = luckyRewardMax != luckyRewardMaxWrath; diff --git a/src/Cache.js b/src/Cache.js index 6bc7aad..8650868 100644 --- a/src/Cache.js +++ b/src/Cache.js @@ -239,7 +239,7 @@ CM.Cache.RemakeGoldenAndWrathCookiesMults = function() { CM.Cache.RemakeLucky = function() { var goldenMult = CM.Cache.GoldenCookiesMult; - // TODO wrathMult + var wrathMult = CM.Cache.WrathCookiesMult; CM.Cache.Lucky = (CM.Cache.NoGoldSwitchCookiesPS * 900) / 0.15; var cpsBuffMult = CM.Sim.getCPSBuffMult(); @@ -249,16 +249,15 @@ CM.Cache.RemakeLucky = function() { CM.Cache.Lucky = 0; } CM.Cache.LuckyReward = goldenMult * (CM.Cache.Lucky * 0.15) + 13; - // TODO LuckyWrathReward + 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; - // TODO LuckyWrathRewardFrenzy + 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) { - // TODO wrathMult 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)); @@ -476,8 +475,10 @@ CM.Cache.WrathCookiesMult = 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; diff --git a/src/Disp.js b/src/Disp.js index 221943a..35d250c 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -1576,9 +1576,9 @@ CM.Disp.AddMenuStats = function(title) { 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 * 60 * 15) + 13; var luckyRewardMax = CM.Cache.LuckyReward; - var luckyRewardMaxWrath = CM.Cache.LuckyReward; + var luckyRewardMaxWrath = CM.Cache.LuckyWrathReward; var luckyRewardFrenzyMax = CM.Cache.LuckyRewardFrenzy; - var luckyRewardFrenzyMaxWrath = CM.Cache.LuckyRewardFrenzy; + var luckyRewardFrenzyMaxWrath = CM.Cache.LuckyWrathRewardFrenzy; var luckyCur = CM.Cache.GoldenCookiesMult * luckyCurBase; var luckyCurWrath = CM.Cache.WrathCookiesMult * luckyCurBase; var luckySplit = luckyRewardMax != luckyRewardMaxWrath; From cb6b97a269586738e50686359cf261faec1975b1 Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Tue, 1 Dec 2020 16:10:12 +0100 Subject: [PATCH 42/49] Added cookies till achievement in building tooltip --- CookieMonster.js | 21 +++++++++++++++++++++ src/Disp.js | 20 ++++++++++++++++++++ src/Sim.js | 1 + 3 files changed, 42 insertions(+) diff --git a/CookieMonster.js b/CookieMonster.js index cfd9adc..fe93f19 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -3035,8 +3035,15 @@ CM.Disp.Tooltip = function(type, name) { tooltip.appendChild(pp); tooltip.appendChild(header('Time Left')); var time = document.createElement('div'); + time.style.marginBottom = '4px'; time.id = 'CMTooltipTime'; tooltip.appendChild(time); + if (type == 'b') { + tooltip.appendChild(header('Production left till next achievement')); + var production = document.createElement('div'); + production.id = 'CMTooltipProduction'; + tooltip.appendChild(production); + } area.appendChild(tooltip); } @@ -3080,6 +3087,19 @@ CM.Disp.UpdateTooltip = function() { l('CMTooltipPP').textContent = Beautify(CM.Cache[target][CM.Disp.tooltipName].pp, 2); l('CMTooltipPP').className = CM.Disp.colorTextPre + CM.Cache[target][CM.Disp.tooltipName].color; } + if (CM.Config.TooltipBuildUp) { + for (var i in Game.Objects[CM.Disp.tooltipName].productionAchievs) { + if (!CM.Sim.Has(Game.Objects[CM.Disp.tooltipName].productionAchievs[i].achiev.name)) { + var nextProductionAchiev = Game.Objects[CM.Disp.tooltipName].productionAchievs[i] + break + } + } + if (typeof nextProductionAchiev != "undefined") { + l('CMTooltipProduction').className = "ProdAchievement" + CM.Disp.tooltipName; + l('CMTooltipProduction').textContent = Beautify(nextProductionAchiev.pow - CM.Sim.Objects[CM.Disp.tooltipName].totalCookies, 15); + l('CMTooltipProduction').style.color = "white"; + } + } } else { // Upgrades bonus = CM.Cache.Upgrades[Game.UpgradesInStore[CM.Disp.tooltipName].name].bonus; @@ -4013,6 +4033,7 @@ CM.Sim.CopyData = function() { } you.amount = me.amount; you.level = me.level; + you.totalCookies = me.totalCookies; if (me.minigameLoaded) you.minigameLoaded = me.minigameLoaded; you.minigame = me.minigame; } diff --git a/src/Disp.js b/src/Disp.js index 35d250c..474a3ae 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -2210,8 +2210,15 @@ CM.Disp.Tooltip = function(type, name) { tooltip.appendChild(pp); tooltip.appendChild(header('Time Left')); var time = document.createElement('div'); + time.style.marginBottom = '4px'; time.id = 'CMTooltipTime'; tooltip.appendChild(time); + if (type == 'b') { + tooltip.appendChild(header('Production left till next achievement')); + var production = document.createElement('div'); + production.id = 'CMTooltipProduction'; + tooltip.appendChild(production); + } area.appendChild(tooltip); } @@ -2255,6 +2262,19 @@ CM.Disp.UpdateTooltip = function() { l('CMTooltipPP').textContent = Beautify(CM.Cache[target][CM.Disp.tooltipName].pp, 2); l('CMTooltipPP').className = CM.Disp.colorTextPre + CM.Cache[target][CM.Disp.tooltipName].color; } + if (CM.Config.TooltipBuildUp) { + for (var i in Game.Objects[CM.Disp.tooltipName].productionAchievs) { + if (!CM.Sim.Has(Game.Objects[CM.Disp.tooltipName].productionAchievs[i].achiev.name)) { + var nextProductionAchiev = Game.Objects[CM.Disp.tooltipName].productionAchievs[i] + break + } + } + if (typeof nextProductionAchiev != "undefined") { + l('CMTooltipProduction').className = "ProdAchievement" + CM.Disp.tooltipName; + l('CMTooltipProduction').textContent = Beautify(nextProductionAchiev.pow - CM.Sim.Objects[CM.Disp.tooltipName].totalCookies, 15); + l('CMTooltipProduction').style.color = "white"; + } + } } else { // Upgrades bonus = CM.Cache.Upgrades[Game.UpgradesInStore[CM.Disp.tooltipName].name].bonus; diff --git a/src/Sim.js b/src/Sim.js index a8fba6f..902cc7b 100644 --- a/src/Sim.js +++ b/src/Sim.js @@ -222,6 +222,7 @@ CM.Sim.CopyData = function() { } you.amount = me.amount; you.level = me.level; + you.totalCookies = me.totalCookies; if (me.minigameLoaded) you.minigameLoaded = me.minigameLoaded; you.minigame = me.minigame; } From af0f210c54fea0ef5cac4764a7122b7c19d3063e Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Tue, 1 Dec 2020 16:26:11 +0100 Subject: [PATCH 43/49] Changed CM.Sim.Has to HasAchiev --- CookieMonster.js | 3 ++- src/Disp.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index fe93f19..051e279 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -3057,6 +3057,7 @@ CM.Disp.Tooltip = function(type, name) { } CM.Disp.UpdateTooltip = function() { + CM.Sim.CopyData(); if (l('tooltipAnchor').style.display != 'none') { if (l('CMTooltipArea') != null) { @@ -3089,7 +3090,7 @@ CM.Disp.UpdateTooltip = function() { } if (CM.Config.TooltipBuildUp) { for (var i in Game.Objects[CM.Disp.tooltipName].productionAchievs) { - if (!CM.Sim.Has(Game.Objects[CM.Disp.tooltipName].productionAchievs[i].achiev.name)) { + if (!CM.Sim.HasAchiev(Game.Objects[CM.Disp.tooltipName].productionAchievs[i].achiev.name)) { var nextProductionAchiev = Game.Objects[CM.Disp.tooltipName].productionAchievs[i] break } diff --git a/src/Disp.js b/src/Disp.js index 474a3ae..fc385ad 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -2232,6 +2232,7 @@ CM.Disp.Tooltip = function(type, name) { } CM.Disp.UpdateTooltip = function() { + CM.Sim.CopyData(); if (l('tooltipAnchor').style.display != 'none') { if (l('CMTooltipArea') != null) { @@ -2264,7 +2265,7 @@ CM.Disp.UpdateTooltip = function() { } if (CM.Config.TooltipBuildUp) { for (var i in Game.Objects[CM.Disp.tooltipName].productionAchievs) { - if (!CM.Sim.Has(Game.Objects[CM.Disp.tooltipName].productionAchievs[i].achiev.name)) { + if (!CM.Sim.HasAchiev(Game.Objects[CM.Disp.tooltipName].productionAchievs[i].achiev.name)) { var nextProductionAchiev = Game.Objects[CM.Disp.tooltipName].productionAchievs[i] break } From 63e5ddf1ca57547120eeab6d7d87a043ddf96067 Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Tue, 1 Dec 2020 16:43:23 +0100 Subject: [PATCH 44/49] Added warning for lagginess of "Missing Achievs" --- CookieMonster.js | 2 +- src/Config.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index cfd9adc..4866b01 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -782,7 +782,7 @@ CM.ConfigData.TooltipGrim = {label: ['Grimoire Tooltip Information OFF', 'Grimoi 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.', 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();}}; diff --git a/src/Config.js b/src/Config.js index aa04353..5ff8665 100644 --- a/src/Config.js +++ b/src/Config.js @@ -247,7 +247,7 @@ CM.ConfigData.TooltipGrim = {label: ['Grimoire Tooltip Information OFF', 'Grimoi 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.', 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();}}; From 53117009e737284f72bf2beacd6c59b28c7eb62d Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Tue, 1 Dec 2020 17:46:20 +0100 Subject: [PATCH 45/49] Remove Cookes till achievement if all are got --- CookieMonster.js | 7 ++++++- src/Disp.js | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 86a9d2c..6d73375 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -3035,11 +3035,11 @@ CM.Disp.Tooltip = function(type, name) { tooltip.appendChild(pp); tooltip.appendChild(header('Time Left')); var time = document.createElement('div'); - time.style.marginBottom = '4px'; time.id = 'CMTooltipTime'; tooltip.appendChild(time); if (type == 'b') { tooltip.appendChild(header('Production left till next achievement')); + tooltip.lastChild.id = 'CMTooltipProductionHeader'; var production = document.createElement('div'); production.id = 'CMTooltipProduction'; tooltip.appendChild(production); @@ -3096,9 +3096,14 @@ CM.Disp.UpdateTooltip = function() { } } if (typeof nextProductionAchiev != "undefined") { + l('CMTooltipTime').style.marginBottom = '4px'; + l('CMTooltipProductionHeader').style.display = ""; l('CMTooltipProduction').className = "ProdAchievement" + CM.Disp.tooltipName; l('CMTooltipProduction').textContent = Beautify(nextProductionAchiev.pow - CM.Sim.Objects[CM.Disp.tooltipName].totalCookies, 15); l('CMTooltipProduction').style.color = "white"; + } else { + l('CMTooltipProductionHeader').style.display = "none"; + l('CMTooltipTime').style.marginBottom = '0px'; } } } diff --git a/src/Disp.js b/src/Disp.js index fc385ad..f2ceee8 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -2210,11 +2210,11 @@ CM.Disp.Tooltip = function(type, name) { tooltip.appendChild(pp); tooltip.appendChild(header('Time Left')); var time = document.createElement('div'); - time.style.marginBottom = '4px'; time.id = 'CMTooltipTime'; tooltip.appendChild(time); if (type == 'b') { tooltip.appendChild(header('Production left till next achievement')); + tooltip.lastChild.id = 'CMTooltipProductionHeader'; var production = document.createElement('div'); production.id = 'CMTooltipProduction'; tooltip.appendChild(production); @@ -2271,9 +2271,14 @@ CM.Disp.UpdateTooltip = function() { } } if (typeof nextProductionAchiev != "undefined") { + l('CMTooltipTime').style.marginBottom = '4px'; + l('CMTooltipProductionHeader').style.display = ""; l('CMTooltipProduction').className = "ProdAchievement" + CM.Disp.tooltipName; l('CMTooltipProduction').textContent = Beautify(nextProductionAchiev.pow - CM.Sim.Objects[CM.Disp.tooltipName].totalCookies, 15); l('CMTooltipProduction').style.color = "white"; + } else { + l('CMTooltipProductionHeader').style.display = "none"; + l('CMTooltipTime').style.marginBottom = '0px'; } } } From cb8114ecfb6e38e144b0d4300512d16fc051e3b4 Mon Sep 17 00:00:00 2001 From: Chorizorro Date: Tue, 1 Dec 2020 21:28:42 +0100 Subject: [PATCH 46/49] Adjust Lucky/Chain stats for Dragon's Fortune #289 Add a multiplier adjustment when Dragon's Fortune aura is set (either via Dragon's Fortune itself or via Reality Bending) and use it to adjust CPS with 1 golden cookie even if there are no golden cookies currently on screen --- CookieMonster.js | 42 ++++++++++++++++++++++++++++-------------- src/Cache.js | 12 ++++++++++++ src/Disp.js | 30 ++++++++++++++++-------------- 3 files changed, 56 insertions(+), 28 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 6d73375..a9a2b8b 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -255,6 +255,15 @@ CM.Cache.RemakeGoldenAndWrathCookiesMults = function() { // 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() { @@ -262,6 +271,7 @@ CM.Cache.RemakeLucky = function() { 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; @@ -291,6 +301,7 @@ CM.Cache.MaxChainMoni = function(digit, maxPayout, mult) { 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; @@ -492,6 +503,7 @@ 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; @@ -2392,6 +2404,7 @@ CM.Disp.AddMenuStats = function(title) { return frag; } + var goldCookTooltip = CM.Sim.auraMult('Dragon\'s Fortune') ? 'GoldCookDragonsFortuneTooltipPlaceholder' : 'GoldCookTooltipPlaceholder'; stats.appendChild(header('Lucky Cookies', 'Lucky')); if (CM.Config.StatsPref.Lucky) { @@ -2399,7 +2412,7 @@ CM.Disp.AddMenuStats = function(title) { 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 * 60 * 15) + 13; + 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; @@ -2419,7 +2432,7 @@ CM.Disp.AddMenuStats = function(title) { luckyReqSmall.textContent = ' (' + luckyTime + ')'; luckyReqFrag.appendChild(luckyReqSmall); } - stats.appendChild(listing(listingQuest('\"Lucky!\" Cookies Required', 'GoldCookTooltipPlaceholder'), luckyReqFrag)); + stats.appendChild(listing(listingQuest('\"Lucky!\" Cookies Required', goldCookTooltip), luckyReqFrag)); var luckyReqFrenFrag = document.createDocumentFragment(); var luckyReqFrenSpan = document.createElement('span'); luckyReqFrenSpan.style.fontWeight = 'bold'; @@ -2431,10 +2444,10 @@ CM.Disp.AddMenuStats = function(title) { luckyReqFrenSmall.textContent = ' (' + luckyTimeFrenzy + ')'; luckyReqFrenFrag.appendChild(luckyReqFrenSmall); } - stats.appendChild(listing(listingQuest('\"Lucky!\" Cookies Required (Frenzy)', 'GoldCookTooltipPlaceholder'), luckyReqFrenFrag)); - stats.appendChild(listing(listingQuest('\"Lucky!\" Reward (MAX)' + (luckySplit ? ' (Golden / Wrath)' : ''), 'GoldCookTooltipPlaceholder'), document.createTextNode(Beautify(luckyRewardMax) + (luckySplit ? (' / ' + Beautify(luckyRewardMaxWrath)) : '')))); - stats.appendChild(listing(listingQuest('\"Lucky!\" Reward (MAX) (Frenzy)' + (luckySplit ? ' (Golden / Wrath)' : ''), 'GoldCookTooltipPlaceholder'), document.createTextNode(Beautify(luckyRewardFrenzyMax) + (luckySplit ? (' / ' + Beautify(luckyRewardFrenzyMaxWrath)) : '')))); - stats.appendChild(listing(listingQuest('\"Lucky!\" Reward (CUR)' + (luckySplit ? ' (Golden / Wrath)' : ''), 'GoldCookTooltipPlaceholder'), document.createTextNode(Beautify(luckyCur) + (luckySplit ? (' / ' + Beautify(luckyCurWrath)) : '')))); + 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')); @@ -2452,7 +2465,7 @@ CM.Disp.AddMenuStats = function(title) { var chainWrathRewardMax = CM.Cache.ChainWrathReward; var chainFrenzyRewardMax = CM.Cache.ChainFrenzyReward; var chainFrenzyWrathRewardMax = CM.Cache.ChainFrenzyWrathReward; - var chainCurMax = Math.min(CM.Cache.NoGoldSwitchCookiesPS * 60 * 60 * 6, (Game.cookies + CM.Disp.GetWrinkConfigBank()) * 0.5); + 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); @@ -2467,7 +2480,7 @@ CM.Disp.AddMenuStats = function(title) { chainReqSmall.textContent = ' (' + chainTime + ')'; chainReqFrag.appendChild(chainReqSmall); } - stats.appendChild(listing(listingQuest('\"Chain\" Cookies Required', 'GoldCookTooltipPlaceholder'), chainReqFrag)); + stats.appendChild(listing(listingQuest('\"Chain\" Cookies Required', goldCookTooltip), chainReqFrag)); var chainWrathReqFrag = document.createDocumentFragment(); var chainWrathReqSpan = document.createElement('span'); chainWrathReqSpan.style.fontWeight = 'bold'; @@ -2479,7 +2492,7 @@ CM.Disp.AddMenuStats = function(title) { chainWrathReqSmall.textContent = ' (' + chainWrathTime + ')'; chainWrathReqFrag.appendChild(chainWrathReqSmall); } - stats.appendChild(listing(listingQuest('\"Chain\" Cookies Required (Wrath)', 'GoldCookTooltipPlaceholder'), chainWrathReqFrag)); + stats.appendChild(listing(listingQuest('\"Chain\" Cookies Required (Wrath)', goldCookTooltip), chainWrathReqFrag)); var chainReqFrenFrag = document.createDocumentFragment(); var chainReqFrenSpan = document.createElement('span'); chainReqFrenSpan.style.fontWeight = 'bold'; @@ -2491,7 +2504,7 @@ CM.Disp.AddMenuStats = function(title) { chainReqFrenSmall.textContent = ' (' + chainTimeFrenzy + ')'; chainReqFrenFrag.appendChild(chainReqFrenSmall); } - stats.appendChild(listing(listingQuest('\"Chain\" Cookies Required (Frenzy)', 'GoldCookTooltipPlaceholder'), chainReqFrenFrag)); + stats.appendChild(listing(listingQuest('\"Chain\" Cookies Required (Frenzy)', goldCookTooltip), chainReqFrenFrag)); var chainWrathReqFrenFrag = document.createDocumentFragment(); var chainWrathReqFrenFrag = document.createDocumentFragment(); var chainWrathReqFrenSpan = document.createElement('span'); @@ -2504,10 +2517,10 @@ CM.Disp.AddMenuStats = function(title) { chainWrathReqFrenSmall.textContent = ' (' + chainWrathTimeFrenzy + ')'; chainWrathReqFrenFrag.appendChild(chainWrathReqFrenSmall); } - stats.appendChild(listing(listingQuest('\"Chain\" Cookies Required (Frenzy) (Wrath)', 'GoldCookTooltipPlaceholder'), chainWrathReqFrenFrag)); - stats.appendChild(listing(listingQuest('\"Chain\" Reward (MAX) (Golden / Wrath)', 'GoldCookTooltipPlaceholder'), document.createTextNode(Beautify(chainRewardMax) + ' / ' + Beautify(chainWrathRewardMax)))); - stats.appendChild(listing(listingQuest('\"Chain\" Reward (MAX) (Frenzy) (Golden / Wrath)', 'GoldCookTooltipPlaceholder'), document.createTextNode(Beautify(chainFrenzyRewardMax) + ' / ' + Beautify(chainFrenzyWrathRewardMax)))); - stats.appendChild(listing(listingQuest('\"Chain\" Reward (CUR) (Golden / Wrath)', 'GoldCookTooltipPlaceholder'), document.createTextNode(Beautify(chainCur) + ' / ' + Beautify(chainCurWrath)))); + 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')); @@ -3472,6 +3485,7 @@ for (var i in Game.wrinklers) { CM.Disp.TooltipText = [ ['GoldCookTooltipPlaceholder', 'Calculated with Golden Switch off', '200px'], + ['GoldCookDragonsFortuneTooltipPlaceholder', 'Calculated with Golden Switch off and at least one golden cookie on-screen', '240px'], ['PrestMaxTooltipPlaceholder', 'The MAX prestige is calculated with the cookies gained from popping all wrinklers with Skruuia god in Diamond slot, selling all stock market goods, selling all buildings with Earth Shatterer and Reality Bending auras, and buying Chocolate egg', '320px'], ['NextPrestTooltipPlaceholder', 'Calculated with cookies gained from wrinklers and Chocolate egg', '200px'], ['HeavenChipMaxTooltipPlaceholder', 'The MAX heavenly chips is calculated with the cookies gained from popping all wrinklers with Skruuia god in Diamond slot, selling all stock market goods, selling all buildings with Earth Shatterer and Reality Bending auras, and buying Chocolate egg', '330px'], diff --git a/src/Cache.js b/src/Cache.js index 8650868..3498447 100644 --- a/src/Cache.js +++ b/src/Cache.js @@ -235,6 +235,15 @@ CM.Cache.RemakeGoldenAndWrathCookiesMults = function() { // 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() { @@ -242,6 +251,7 @@ CM.Cache.RemakeLucky = function() { 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; @@ -271,6 +281,7 @@ CM.Cache.MaxChainMoni = function(digit, maxPayout, mult) { 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; @@ -472,6 +483,7 @@ 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; diff --git a/src/Disp.js b/src/Disp.js index f2ceee8..154065c 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -1567,6 +1567,7 @@ CM.Disp.AddMenuStats = function(title) { return frag; } + var goldCookTooltip = CM.Sim.auraMult('Dragon\'s Fortune') ? 'GoldCookDragonsFortuneTooltipPlaceholder' : 'GoldCookTooltipPlaceholder'; stats.appendChild(header('Lucky Cookies', 'Lucky')); if (CM.Config.StatsPref.Lucky) { @@ -1574,7 +1575,7 @@ CM.Disp.AddMenuStats = function(title) { 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 * 60 * 15) + 13; + 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; @@ -1594,7 +1595,7 @@ CM.Disp.AddMenuStats = function(title) { luckyReqSmall.textContent = ' (' + luckyTime + ')'; luckyReqFrag.appendChild(luckyReqSmall); } - stats.appendChild(listing(listingQuest('\"Lucky!\" Cookies Required', 'GoldCookTooltipPlaceholder'), luckyReqFrag)); + stats.appendChild(listing(listingQuest('\"Lucky!\" Cookies Required', goldCookTooltip), luckyReqFrag)); var luckyReqFrenFrag = document.createDocumentFragment(); var luckyReqFrenSpan = document.createElement('span'); luckyReqFrenSpan.style.fontWeight = 'bold'; @@ -1606,10 +1607,10 @@ CM.Disp.AddMenuStats = function(title) { luckyReqFrenSmall.textContent = ' (' + luckyTimeFrenzy + ')'; luckyReqFrenFrag.appendChild(luckyReqFrenSmall); } - stats.appendChild(listing(listingQuest('\"Lucky!\" Cookies Required (Frenzy)', 'GoldCookTooltipPlaceholder'), luckyReqFrenFrag)); - stats.appendChild(listing(listingQuest('\"Lucky!\" Reward (MAX)' + (luckySplit ? ' (Golden / Wrath)' : ''), 'GoldCookTooltipPlaceholder'), document.createTextNode(Beautify(luckyRewardMax) + (luckySplit ? (' / ' + Beautify(luckyRewardMaxWrath)) : '')))); - stats.appendChild(listing(listingQuest('\"Lucky!\" Reward (MAX) (Frenzy)' + (luckySplit ? ' (Golden / Wrath)' : ''), 'GoldCookTooltipPlaceholder'), document.createTextNode(Beautify(luckyRewardFrenzyMax) + (luckySplit ? (' / ' + Beautify(luckyRewardFrenzyMaxWrath)) : '')))); - stats.appendChild(listing(listingQuest('\"Lucky!\" Reward (CUR)' + (luckySplit ? ' (Golden / Wrath)' : ''), 'GoldCookTooltipPlaceholder'), document.createTextNode(Beautify(luckyCur) + (luckySplit ? (' / ' + Beautify(luckyCurWrath)) : '')))); + 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')); @@ -1627,7 +1628,7 @@ CM.Disp.AddMenuStats = function(title) { var chainWrathRewardMax = CM.Cache.ChainWrathReward; var chainFrenzyRewardMax = CM.Cache.ChainFrenzyReward; var chainFrenzyWrathRewardMax = CM.Cache.ChainFrenzyWrathReward; - var chainCurMax = Math.min(CM.Cache.NoGoldSwitchCookiesPS * 60 * 60 * 6, (Game.cookies + CM.Disp.GetWrinkConfigBank()) * 0.5); + 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); @@ -1642,7 +1643,7 @@ CM.Disp.AddMenuStats = function(title) { chainReqSmall.textContent = ' (' + chainTime + ')'; chainReqFrag.appendChild(chainReqSmall); } - stats.appendChild(listing(listingQuest('\"Chain\" Cookies Required', 'GoldCookTooltipPlaceholder'), chainReqFrag)); + stats.appendChild(listing(listingQuest('\"Chain\" Cookies Required', goldCookTooltip), chainReqFrag)); var chainWrathReqFrag = document.createDocumentFragment(); var chainWrathReqSpan = document.createElement('span'); chainWrathReqSpan.style.fontWeight = 'bold'; @@ -1654,7 +1655,7 @@ CM.Disp.AddMenuStats = function(title) { chainWrathReqSmall.textContent = ' (' + chainWrathTime + ')'; chainWrathReqFrag.appendChild(chainWrathReqSmall); } - stats.appendChild(listing(listingQuest('\"Chain\" Cookies Required (Wrath)', 'GoldCookTooltipPlaceholder'), chainWrathReqFrag)); + stats.appendChild(listing(listingQuest('\"Chain\" Cookies Required (Wrath)', goldCookTooltip), chainWrathReqFrag)); var chainReqFrenFrag = document.createDocumentFragment(); var chainReqFrenSpan = document.createElement('span'); chainReqFrenSpan.style.fontWeight = 'bold'; @@ -1666,7 +1667,7 @@ CM.Disp.AddMenuStats = function(title) { chainReqFrenSmall.textContent = ' (' + chainTimeFrenzy + ')'; chainReqFrenFrag.appendChild(chainReqFrenSmall); } - stats.appendChild(listing(listingQuest('\"Chain\" Cookies Required (Frenzy)', 'GoldCookTooltipPlaceholder'), chainReqFrenFrag)); + stats.appendChild(listing(listingQuest('\"Chain\" Cookies Required (Frenzy)', goldCookTooltip), chainReqFrenFrag)); var chainWrathReqFrenFrag = document.createDocumentFragment(); var chainWrathReqFrenFrag = document.createDocumentFragment(); var chainWrathReqFrenSpan = document.createElement('span'); @@ -1679,10 +1680,10 @@ CM.Disp.AddMenuStats = function(title) { chainWrathReqFrenSmall.textContent = ' (' + chainWrathTimeFrenzy + ')'; chainWrathReqFrenFrag.appendChild(chainWrathReqFrenSmall); } - stats.appendChild(listing(listingQuest('\"Chain\" Cookies Required (Frenzy) (Wrath)', 'GoldCookTooltipPlaceholder'), chainWrathReqFrenFrag)); - stats.appendChild(listing(listingQuest('\"Chain\" Reward (MAX) (Golden / Wrath)', 'GoldCookTooltipPlaceholder'), document.createTextNode(Beautify(chainRewardMax) + ' / ' + Beautify(chainWrathRewardMax)))); - stats.appendChild(listing(listingQuest('\"Chain\" Reward (MAX) (Frenzy) (Golden / Wrath)', 'GoldCookTooltipPlaceholder'), document.createTextNode(Beautify(chainFrenzyRewardMax) + ' / ' + Beautify(chainFrenzyWrathRewardMax)))); - stats.appendChild(listing(listingQuest('\"Chain\" Reward (CUR) (Golden / Wrath)', 'GoldCookTooltipPlaceholder'), document.createTextNode(Beautify(chainCur) + ' / ' + Beautify(chainCurWrath)))); + 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')); @@ -2647,6 +2648,7 @@ for (var i in Game.wrinklers) { CM.Disp.TooltipText = [ ['GoldCookTooltipPlaceholder', 'Calculated with Golden Switch off', '200px'], + ['GoldCookDragonsFortuneTooltipPlaceholder', 'Calculated with Golden Switch off and at least one golden cookie on-screen', '240px'], ['PrestMaxTooltipPlaceholder', 'The MAX prestige is calculated with the cookies gained from popping all wrinklers with Skruuia god in Diamond slot, selling all stock market goods, selling all buildings with Earth Shatterer and Reality Bending auras, and buying Chocolate egg', '320px'], ['NextPrestTooltipPlaceholder', 'Calculated with cookies gained from wrinklers and Chocolate egg', '200px'], ['HeavenChipMaxTooltipPlaceholder', 'The MAX heavenly chips is calculated with the cookies gained from popping all wrinklers with Skruuia god in Diamond slot, selling all stock market goods, selling all buildings with Earth Shatterer and Reality Bending auras, and buying Chocolate egg', '330px'], From 94745fb0133fe29e8da318183bb5ea56ee94ebd8 Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Wed, 2 Dec 2020 13:24:56 +0100 Subject: [PATCH 47/49] Avoid crash on double-loading --- CookieMonster.js | 27 ++++++++++++++++++--------- src/Footer.js | 6 +++++- src/Header.js | 21 +++++++++++++-------- 3 files changed, 36 insertions(+), 18 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index a9a2b8b..9803540 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -1,22 +1,27 @@ /********** * Header * **********/ +RunCookieMonsterHeader = function() { + CM = {}; -CM = {}; + CM.Backup = {}; -CM.Backup = {}; + CM.Cache = {}; -CM.Cache = {}; + CM.Config = {}; -CM.Config = {}; + CM.ConfigData = {}; -CM.ConfigData = {}; + CM.Data = {}; -CM.Data = {}; + CM.Disp = {}; -CM.Disp = {}; + CM.Sim = {}; +} -CM.Sim = {}; +if (typeof CM == "undefined") { + RunCookieMonsterHeader(); +} /********* * Cache * @@ -4598,4 +4603,8 @@ CM.Sim.SellBuildingsForChoEgg = function() { * Footer * **********/ -CM.Init(); +if (!CM.isRunning) { + CM.Init(); + CM.isRunning = 1 +} + diff --git a/src/Footer.js b/src/Footer.js index 3a2fc97..c40dd31 100644 --- a/src/Footer.js +++ b/src/Footer.js @@ -2,4 +2,8 @@ * Footer * **********/ -CM.Init(); +if (!CM.isRunning) { + CM.Init(); + CM.isRunning = 1 +} + diff --git a/src/Header.js b/src/Header.js index 7e91767..26893fb 100644 --- a/src/Header.js +++ b/src/Header.js @@ -1,20 +1,25 @@ /********** * Header * **********/ +RunCookieMonsterHeader = function() { + CM = {}; -CM = {}; + CM.Backup = {}; -CM.Backup = {}; + CM.Cache = {}; -CM.Cache = {}; + CM.Config = {}; -CM.Config = {}; + CM.ConfigData = {}; -CM.ConfigData = {}; + CM.Data = {}; -CM.Data = {}; + CM.Disp = {}; -CM.Disp = {}; + CM.Sim = {}; +} -CM.Sim = {}; +if (typeof CM == "undefined") { + RunCookieMonsterHeader(); +} From e644fcb49f79d8e4798257da06474ee1e994e074 Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Wed, 2 Dec 2020 13:29:27 +0100 Subject: [PATCH 48/49] Pushed version to 2.031.2 --- CookieMonster.js | 3 ++- src/Main.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 9803540..d1f554e 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -3751,6 +3751,7 @@ CM.DelayInit = function() { if (Game.prefs.popups) Game.Popup('Cookie Monster version ' + CM.VersionMajor + '.' + CM.VersionMinor + ' loaded!'); else Game.Notify('Cookie Monster version ' + CM.VersionMajor + '.' + CM.VersionMinor + ' loaded!', '', '', 1, 1); + Game.Win('Third-party'); } @@ -3832,7 +3833,7 @@ CM.ConfigDefault = { CM.ConfigPrefix = 'CMConfig'; CM.VersionMajor = '2.031'; -CM.VersionMinor = '1'; +CM.VersionMinor = '2'; /******* * Sim * diff --git a/src/Main.js b/src/Main.js index b95cd58..657bdd8 100644 --- a/src/Main.js +++ b/src/Main.js @@ -252,6 +252,7 @@ CM.DelayInit = function() { if (Game.prefs.popups) Game.Popup('Cookie Monster version ' + CM.VersionMajor + '.' + CM.VersionMinor + ' loaded!'); else Game.Notify('Cookie Monster version ' + CM.VersionMajor + '.' + CM.VersionMinor + ' loaded!', '', '', 1, 1); + Game.Win('Third-party'); } @@ -333,5 +334,5 @@ CM.ConfigDefault = { CM.ConfigPrefix = 'CMConfig'; CM.VersionMajor = '2.031'; -CM.VersionMinor = '1'; +CM.VersionMinor = '2'; From 17efc105687b4850aa9fe06261148f38eebd4621 Mon Sep 17 00:00:00 2001 From: Chorizorro Date: Thu, 3 Dec 2020 13:32:01 +0100 Subject: [PATCH 49/49] Fix numbers Engineering notation #400 --- CookieMonster.js | 2 +- src/Disp.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index d1f554e..9c9b1cf 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -1001,7 +1001,7 @@ CM.Disp.Beautify = function(num, frac) { } } else if (CM.Config.Scale == 4) { - if (um >= 999999) { + if (num >= 999999) { var count = 0; while (num >= 1000) { count++; diff --git a/src/Disp.js b/src/Disp.js index 154065c..b5667dd 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -159,7 +159,7 @@ CM.Disp.Beautify = function(num, frac) { } } else if (CM.Config.Scale == 4) { - if (um >= 999999) { + if (num >= 999999) { var count = 0; while (num >= 1000) { count++;