From 450db504beb3a7681bf251bcf2be485cbd30856c Mon Sep 17 00:00:00 2001 From: Aktanusa Date: Sat, 6 Sep 2014 13:50:08 -0400 Subject: [PATCH 1/9] Version change --- CookieMonster.js | 2 +- src/Main.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 4cc33e8..9b42aea 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -1982,7 +1982,7 @@ CM.ConfigDefault = {BotBar: 1, TimerBar: 1, TimerBarPos: 0, BuildColor: 1, UpBar CM.ConfigPrefix = 'CMConfig'; CM.VersionMajor = '1.0465'; -CM.VersionMinor = '12'; +CM.VersionMinor = '13'; /******* * Sim * diff --git a/src/Main.js b/src/Main.js index f21d565..a62acf1 100644 --- a/src/Main.js +++ b/src/Main.js @@ -133,5 +133,5 @@ CM.ConfigDefault = {BotBar: 1, TimerBar: 1, TimerBarPos: 0, BuildColor: 1, UpBar CM.ConfigPrefix = 'CMConfig'; CM.VersionMajor = '1.0465'; -CM.VersionMinor = '12'; +CM.VersionMinor = '13'; From c54ecefe4b4f7cd514272bef342b8e0d717df951 Mon Sep 17 00:00:00 2001 From: Aktanusa Date: Sat, 6 Sep 2014 16:18:06 -0400 Subject: [PATCH 2/9] Hopefully fix jscolor not loading before CM.Init is called (Thanks The_omniscent_pie) --- CookieMonster.js | 48 +++++++++++++++++++++++++++++------------------- src/Main.js | 48 +++++++++++++++++++++++++++++------------------- 2 files changed, 58 insertions(+), 38 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 9b42aea..47825ba 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -1894,7 +1894,7 @@ CM.ReplaceNative = function() { CM.Backup.UpdateMenu = Game.UpdateMenu; Game.UpdateMenu = function() { - if (jscolor == undefined || jscolor.picker == undefined || jscolor.picker.owner == undefined) { + if (jscolor.picker == undefined || jscolor.picker.owner == undefined) { CM.Backup.UpdateMenu(); CM.Disp.AddMenu(); } @@ -1956,28 +1956,38 @@ CM.Init = function() { } if (proceed) { CM.Disp.AddJscolor(); - CM.Disp.CreateCssArea(); - CM.Disp.CreateBotBar(); - CM.Disp.CreateTimerBar(); - CM.Disp.CreateUpgradeBar(); - CM.Disp.CreateWhiteScreen(); - CM.Disp.CreateGCTimer(); - CM.Disp.CreateResetTooltip(); - CM.Disp.CreateTooltipWarnCaut(); - CM.Disp.AddTooltipBuild(); - CM.Disp.AddTooltipBuild10(); - CM.Disp.AddWrinklerAreaDetect(); - CM.ReplaceNative(); - Game.CalculateGains(); - CM.LoadConfig(); // Must be after all things are created! - - 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); - Game.Win('Third-party'); + var delay = setInterval(function() { + if (jscolor != undefined) { + CM.DelayInit(); + clearInterval(delay); + } + }, 500); } } +CM.DelayInit = function() { + CM.Disp.CreateCssArea(); + CM.Disp.CreateBotBar(); + CM.Disp.CreateTimerBar(); + CM.Disp.CreateUpgradeBar(); + CM.Disp.CreateWhiteScreen(); + CM.Disp.CreateGCTimer(); + CM.Disp.CreateResetTooltip(); + CM.Disp.CreateTooltipWarnCaut(); + CM.Disp.AddTooltipBuild(); + CM.Disp.AddTooltipBuild10(); + CM.Disp.AddWrinklerAreaDetect(); + CM.ReplaceNative(); + Game.CalculateGains(); + CM.LoadConfig(); // Must be after all things are created! + + 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); + + Game.Win('Third-party'); +} + CM.ConfigDefault = {BotBar: 1, TimerBar: 1, TimerBarPos: 0, BuildColor: 1, UpBarColor: 1, Flash: 1, Sound: 1, Volume: 100, GCSoundURL: 'http://freesound.org/data/previews/66/66717_931655-lq.mp3', SeaSoundURL: 'http://www.freesound.org/data/previews/121/121099_2193266-lq.mp3', GCTimer: 1, Title: 1, Tooltip: 1, ToolWarnCaut: 1, ToolWarnCautPos: 1, ToolWrink: 1, Stats: 1, UpStats: 1, SayTime: 1, Scale: 2, StatsPref: {Lucky: 1, Chain: 1, HC: 1, Wrink: 1, Sea: 1}, Colors : {Blue: '#4bb8f0', Green: '#00ff00', Yellow: '#ffff00', Orange: '#ff7f00', Red: '#ff0000', Purple: '#ff00ff', Gray: '#b3b3b3'}}; CM.ConfigPrefix = 'CMConfig'; diff --git a/src/Main.js b/src/Main.js index a62acf1..e9fe9a2 100644 --- a/src/Main.js +++ b/src/Main.js @@ -45,7 +45,7 @@ CM.ReplaceNative = function() { CM.Backup.UpdateMenu = Game.UpdateMenu; Game.UpdateMenu = function() { - if (jscolor == undefined || jscolor.picker == undefined || jscolor.picker.owner == undefined) { + if (jscolor.picker == undefined || jscolor.picker.owner == undefined) { CM.Backup.UpdateMenu(); CM.Disp.AddMenu(); } @@ -107,28 +107,38 @@ CM.Init = function() { } if (proceed) { CM.Disp.AddJscolor(); - CM.Disp.CreateCssArea(); - CM.Disp.CreateBotBar(); - CM.Disp.CreateTimerBar(); - CM.Disp.CreateUpgradeBar(); - CM.Disp.CreateWhiteScreen(); - CM.Disp.CreateGCTimer(); - CM.Disp.CreateResetTooltip(); - CM.Disp.CreateTooltipWarnCaut(); - CM.Disp.AddTooltipBuild(); - CM.Disp.AddTooltipBuild10(); - CM.Disp.AddWrinklerAreaDetect(); - CM.ReplaceNative(); - Game.CalculateGains(); - CM.LoadConfig(); // Must be after all things are created! - - 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); - Game.Win('Third-party'); + var delay = setInterval(function() { + if (jscolor != undefined) { + CM.DelayInit(); + clearInterval(delay); + } + }, 500); } } +CM.DelayInit = function() { + CM.Disp.CreateCssArea(); + CM.Disp.CreateBotBar(); + CM.Disp.CreateTimerBar(); + CM.Disp.CreateUpgradeBar(); + CM.Disp.CreateWhiteScreen(); + CM.Disp.CreateGCTimer(); + CM.Disp.CreateResetTooltip(); + CM.Disp.CreateTooltipWarnCaut(); + CM.Disp.AddTooltipBuild(); + CM.Disp.AddTooltipBuild10(); + CM.Disp.AddWrinklerAreaDetect(); + CM.ReplaceNative(); + Game.CalculateGains(); + CM.LoadConfig(); // Must be after all things are created! + + 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); + + Game.Win('Third-party'); +} + CM.ConfigDefault = {BotBar: 1, TimerBar: 1, TimerBarPos: 0, BuildColor: 1, UpBarColor: 1, Flash: 1, Sound: 1, Volume: 100, GCSoundURL: 'http://freesound.org/data/previews/66/66717_931655-lq.mp3', SeaSoundURL: 'http://www.freesound.org/data/previews/121/121099_2193266-lq.mp3', GCTimer: 1, Title: 1, Tooltip: 1, ToolWarnCaut: 1, ToolWarnCautPos: 1, ToolWrink: 1, Stats: 1, UpStats: 1, SayTime: 1, Scale: 2, StatsPref: {Lucky: 1, Chain: 1, HC: 1, Wrink: 1, Sea: 1}, Colors : {Blue: '#4bb8f0', Green: '#00ff00', Yellow: '#ffff00', Orange: '#ff7f00', Red: '#ff0000', Purple: '#ff00ff', Gray: '#b3b3b3'}}; CM.ConfigPrefix = 'CMConfig'; From 69575139607ab272d14bcfcca7eb40999d97b8f4 Mon Sep 17 00:00:00 2001 From: Aktanusa Date: Sat, 6 Sep 2014 18:09:38 -0400 Subject: [PATCH 3/9] Added Chocolate egg stat (Issue #22) --- CookieMonster.js | 62 +++++++++++++++++++++++++++++++++++++++++++++--- src/Cache.js | 10 ++++++++ src/Disp.js | 36 +++++++++++++++++++++++++++- src/Main.js | 6 +++-- src/Sim.js | 10 ++++++++ 5 files changed, 118 insertions(+), 6 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 47825ba..837b06d 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -175,6 +175,15 @@ CM.Cache.RemakeSeaSpec = function() { } } +CM.Cache.RemakeChoEgg = function() { + var sellTotal = 0; + for (var i in Game.Objects) { + var me = Game.Objects[i]; + sellTotal += CM.Sim.BuildingSell(me.basePrice, me.amount, me.amount); + } + CM.Cache.ChoEgg = (Game.cookies + sellTotal) * 0.05; +} + CM.Cache.Lucky = 0; CM.Cache.LuckyReward = 0; CM.Cache.LuckyFrenzy = 0; @@ -186,6 +195,7 @@ CM.Cache.ChainWrathReward = 0; CM.Cache.ChainFrenzy = 0; CM.Cache.ChainFrenzyReward = 0; CM.Cache.ChainFrenzyWrathReward = 0; +CM.Cache.ChoEgg = 0; /********** * Config * @@ -1045,6 +1055,18 @@ CM.Disp.CreateResetTooltip = function() { CM.Disp.ResetTooltipPlaceholder.appendChild(resetTitleDesc); } +CM.Disp.CreateChoEggTooltip = function() { + CM.Disp.ChoEggTooltipPlaceholder = document.createElement('div'); + var choEggTitleDesc = document.createElement('div'); + choEggTitleDesc.style.minWidth = '290px'; + choEggTitleDesc.style.marginBottom = '4px'; + var div = document.createElement('div'); + div.style.textAlign = 'left'; + div.textContent = 'The amount of cookies you would get from selling all buildings and then buying Chocolate egg'; + choEggTitleDesc.appendChild(div); + CM.Disp.ChoEggTooltipPlaceholder.appendChild(choEggTitleDesc); +} + CM.Disp.AddMenuPref = function(title) { var header = function(text) { var div = document.createElement('div'); @@ -1401,7 +1423,9 @@ CM.Disp.AddMenuStats = function(title) { specDisp = true; } } - if (Game.season == 'christmas' || specDisp) { + var choEgg = (Game.HasUnlocked('Chocolate egg') && !Game.Has('Chocolate egg')); + + if (Game.season == 'christmas' || specDisp || choEgg) { stats.appendChild(header('Season Specials', 'Sea')); if (CM.Config.StatsPref.Sea) { if (specDisp) { @@ -1450,6 +1474,26 @@ CM.Disp.AddMenuStats = function(title) { } if (Game.season == 'christmas') stats.appendChild(listing('Reindeer Reward', document.createTextNode(Beautify(CM.Cache.SeaSpec)))); + if (choEgg) { + var choEggTitleFrag = document.createDocumentFragment(); + choEggTitleFrag.appendChild(document.createTextNode('Chocolate Egg Cookies ')) + var choEggTitleSpan = document.createElement('span'); + choEggTitleSpan.onmouseout = function() { Game.tooltip.hide(); }; + choEggTitleSpan.onmouseover = function() {Game.tooltip.draw(this, escape(CM.Disp.ChoEggTooltipPlaceholder.innerHTML));}; + choEggTitleSpan.style.cursor = 'default'; + choEggTitleSpan.style.display = 'inline-block'; + choEggTitleSpan.style.height = '10px'; + choEggTitleSpan.style.width = '10px'; + choEggTitleSpan.style.borderRadius = '5px'; + choEggTitleSpan.style.textAlign = 'center'; + choEggTitleSpan.style.backgroundColor = '#C0C0C0'; + choEggTitleSpan.style.color = 'black'; + choEggTitleSpan.style.fontSize = '9px'; + choEggTitleSpan.style.verticalAlign = 'bottom'; + choEggTitleSpan.textContent = '?'; + choEggTitleFrag.appendChild(choEggTitleSpan); + stats.appendChild(listing(choEggTitleFrag, document.createTextNode(Beautify(CM.Cache.ChoEgg)))); + } } } @@ -1920,6 +1964,7 @@ CM.Loop = function() { CM.Cache.RemakeLucky(); CM.Cache.RemakeChain(); CM.Cache.RemakeSeaSpec(); + CM.Cache.RemakeChoEgg(); CM.Disp.UpdateBotBarOther(); CM.Disp.UpdateBuildings(); @@ -1959,8 +2004,8 @@ CM.Init = function() { var delay = setInterval(function() { if (jscolor != undefined) { - CM.DelayInit(); - clearInterval(delay); + CM.DelayInit(); + clearInterval(delay); } }, 500); } @@ -1974,6 +2019,7 @@ CM.DelayInit = function() { CM.Disp.CreateWhiteScreen(); CM.Disp.CreateGCTimer(); CM.Disp.CreateResetTooltip(); + CM.Disp.CreateChoEggTooltip(); CM.Disp.CreateTooltipWarnCaut(); CM.Disp.AddTooltipBuild(); CM.Disp.AddTooltipBuild10(); @@ -2012,6 +2058,16 @@ CM.Sim.BuildingGetPrice = function (basePrice, start, increase) { return totalPrice; } +CM.Sim.BuildingSell = function(basePrice, start, amount) { + var totalMoni = 0; + while (amount > 0) { + totalMoni += Math.floor(CM.Sim.BuildingGetPrice(basePrice, start, 1) * 0.5); + start--; + amount--; + } + return totalMoni; +} + eval('CM.Sim.Has = ' + Game.Has.toString().split('Game').join('CM.Sim')); CM.Sim.Win = function(what) { diff --git a/src/Cache.js b/src/Cache.js index 5690976..8b821c5 100644 --- a/src/Cache.js +++ b/src/Cache.js @@ -155,6 +155,15 @@ CM.Cache.RemakeSeaSpec = function() { } } +CM.Cache.RemakeChoEgg = function() { + var sellTotal = 0; + for (var i in Game.Objects) { + var me = Game.Objects[i]; + sellTotal += CM.Sim.BuildingSell(me.basePrice, me.amount, me.amount); + } + CM.Cache.ChoEgg = (Game.cookies + sellTotal) * 0.05; +} + CM.Cache.Lucky = 0; CM.Cache.LuckyReward = 0; CM.Cache.LuckyFrenzy = 0; @@ -166,4 +175,5 @@ CM.Cache.ChainWrathReward = 0; CM.Cache.ChainFrenzy = 0; CM.Cache.ChainFrenzyReward = 0; CM.Cache.ChainFrenzyWrathReward = 0; +CM.Cache.ChoEgg = 0; diff --git a/src/Disp.js b/src/Disp.js index 5c72472..1096f9e 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -719,6 +719,18 @@ CM.Disp.CreateResetTooltip = function() { CM.Disp.ResetTooltipPlaceholder.appendChild(resetTitleDesc); } +CM.Disp.CreateChoEggTooltip = function() { + CM.Disp.ChoEggTooltipPlaceholder = document.createElement('div'); + var choEggTitleDesc = document.createElement('div'); + choEggTitleDesc.style.minWidth = '290px'; + choEggTitleDesc.style.marginBottom = '4px'; + var div = document.createElement('div'); + div.style.textAlign = 'left'; + div.textContent = 'The amount of cookies you would get from selling all buildings and then buying Chocolate egg'; + choEggTitleDesc.appendChild(div); + CM.Disp.ChoEggTooltipPlaceholder.appendChild(choEggTitleDesc); +} + CM.Disp.AddMenuPref = function(title) { var header = function(text) { var div = document.createElement('div'); @@ -1075,7 +1087,9 @@ CM.Disp.AddMenuStats = function(title) { specDisp = true; } } - if (Game.season == 'christmas' || specDisp) { + var choEgg = (Game.HasUnlocked('Chocolate egg') && !Game.Has('Chocolate egg')); + + if (Game.season == 'christmas' || specDisp || choEgg) { stats.appendChild(header('Season Specials', 'Sea')); if (CM.Config.StatsPref.Sea) { if (specDisp) { @@ -1124,6 +1138,26 @@ CM.Disp.AddMenuStats = function(title) { } if (Game.season == 'christmas') stats.appendChild(listing('Reindeer Reward', document.createTextNode(Beautify(CM.Cache.SeaSpec)))); + if (choEgg) { + var choEggTitleFrag = document.createDocumentFragment(); + choEggTitleFrag.appendChild(document.createTextNode('Chocolate Egg Cookies ')) + var choEggTitleSpan = document.createElement('span'); + choEggTitleSpan.onmouseout = function() { Game.tooltip.hide(); }; + choEggTitleSpan.onmouseover = function() {Game.tooltip.draw(this, escape(CM.Disp.ChoEggTooltipPlaceholder.innerHTML));}; + choEggTitleSpan.style.cursor = 'default'; + choEggTitleSpan.style.display = 'inline-block'; + choEggTitleSpan.style.height = '10px'; + choEggTitleSpan.style.width = '10px'; + choEggTitleSpan.style.borderRadius = '5px'; + choEggTitleSpan.style.textAlign = 'center'; + choEggTitleSpan.style.backgroundColor = '#C0C0C0'; + choEggTitleSpan.style.color = 'black'; + choEggTitleSpan.style.fontSize = '9px'; + choEggTitleSpan.style.verticalAlign = 'bottom'; + choEggTitleSpan.textContent = '?'; + choEggTitleFrag.appendChild(choEggTitleSpan); + stats.appendChild(listing(choEggTitleFrag, document.createTextNode(Beautify(CM.Cache.ChoEgg)))); + } } } diff --git a/src/Main.js b/src/Main.js index e9fe9a2..8e7c34b 100644 --- a/src/Main.js +++ b/src/Main.js @@ -71,6 +71,7 @@ CM.Loop = function() { CM.Cache.RemakeLucky(); CM.Cache.RemakeChain(); CM.Cache.RemakeSeaSpec(); + CM.Cache.RemakeChoEgg(); CM.Disp.UpdateBotBarOther(); CM.Disp.UpdateBuildings(); @@ -110,8 +111,8 @@ CM.Init = function() { var delay = setInterval(function() { if (jscolor != undefined) { - CM.DelayInit(); - clearInterval(delay); + CM.DelayInit(); + clearInterval(delay); } }, 500); } @@ -125,6 +126,7 @@ CM.DelayInit = function() { CM.Disp.CreateWhiteScreen(); CM.Disp.CreateGCTimer(); CM.Disp.CreateResetTooltip(); + CM.Disp.CreateChoEggTooltip(); CM.Disp.CreateTooltipWarnCaut(); CM.Disp.AddTooltipBuild(); CM.Disp.AddTooltipBuild10(); diff --git a/src/Sim.js b/src/Sim.js index dbc5bcd..0aea15e 100644 --- a/src/Sim.js +++ b/src/Sim.js @@ -16,6 +16,16 @@ CM.Sim.BuildingGetPrice = function (basePrice, start, increase) { return totalPrice; } +CM.Sim.BuildingSell = function(basePrice, start, amount) { + var totalMoni = 0; + while (amount > 0) { + totalMoni += Math.floor(CM.Sim.BuildingGetPrice(basePrice, start, 1) * 0.5); + start--; + amount--; + } + return totalMoni; +} + eval('CM.Sim.Has = ' + Game.Has.toString().split('Game').join('CM.Sim')); CM.Sim.Win = function(what) { From fb83f6679adeae678d9aba6255d132e50c6c84e5 Mon Sep 17 00:00:00 2001 From: Aktanusa Date: Mon, 8 Sep 2014 08:56:12 -0400 Subject: [PATCH 4/9] Added amortization stat to building tooltip (Issue #19) --- CookieMonster.js | 15 ++++++++++----- src/Disp.js | 15 ++++++++++----- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 837b06d..a90c76c 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -361,15 +361,15 @@ CM.Disp.FormatTime = function(time, format) { return str; } -CM.Disp.GetTimeColor = function(price) { +CM.Disp.GetTimeColor = function(price, bank, cps) { var color; var text; - if (Game.cookies >= price) { + if (bank >= price) { color = CM.Disp.colorGreen; text = 'Done!'; } else { - var time = (price - Game.cookies) / (Game.cookiesPs * (1 - Game.cpsSucked)); + var time = (price - bank) / cps; text = CM.Disp.FormatTime(time); if (time > 300) { color = CM.Disp.colorRed; @@ -541,7 +541,7 @@ CM.Disp.UpdateBotBarTime = function() { for (var i in CM.Cache.Objects) { count++; - var timeColor = CM.Disp.GetTimeColor(Game.Objects[i].getPrice()); + var timeColor = CM.Disp.GetTimeColor(Game.Objects[i].getPrice(), Game.cookies, (Game.cookiesPs * (1 - Game.cpsSucked))); CM.Disp.BotBar.firstChild.firstChild.childNodes[3].childNodes[count].className = CM.Disp.colorTextPre + timeColor.color; CM.Disp.BotBar.firstChild.firstChild.childNodes[3].childNodes[count].textContent = timeColor.text; } @@ -1623,6 +1623,11 @@ CM.Disp.AddTooltipBuild10 = function() { CM.Disp.Tooltip = function(type, name) { if (type == 'b') { l('tooltip').innerHTML = Game.Objects[name].tooltip(); + var buildPrice = CM.Sim.BuildingGetPrice(Game.Objects[name].basePrice, 0, Game.Objects[name].amount); + var amortizeAmount = buildPrice - Game.Objects[name].totalCookies; + if (amortizeAmount > 0) { + l('tooltip').innerHTML = l('tooltip').innerHTML.split('so far').join('so far
' + Beautify(amortizeAmount) + ' ' + (Math.floor(amortizeAmount) == 1 ? 'cookie' : 'cookies') + ' left to amortize (' + CM.Disp.GetTimeColor(buildPrice, Game.Objects[name].totalCookies, (Game.Objects[name].storedTotalCps * Game.globalCpsMult)).text+')'); + } if (CM.Disp.TooltipBuy10) { l('tooltip').innerHTML = l('tooltip').innerHTML.split(Beautify(Game.Objects[name].getPrice())).join(Beautify(CM.Cache.Objects10[name].price)); } @@ -1720,7 +1725,7 @@ CM.Disp.UpdateTooltip = function() { l('CMTooltipIncome').textContent += ' (' + (increase / 100) + '% of income)'; } - var timeColor = CM.Disp.GetTimeColor(price); + var timeColor = CM.Disp.GetTimeColor(price, Game.cookies, (Game.cookiesPs * (1 - Game.cpsSucked))); l('CMTooltipTime').textContent = timeColor.text; l('CMTooltipTime').className = CM.Disp.colorTextPre + timeColor.color; } diff --git a/src/Disp.js b/src/Disp.js index 1096f9e..83eb7ec 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -25,15 +25,15 @@ CM.Disp.FormatTime = function(time, format) { return str; } -CM.Disp.GetTimeColor = function(price) { +CM.Disp.GetTimeColor = function(price, bank, cps) { var color; var text; - if (Game.cookies >= price) { + if (bank >= price) { color = CM.Disp.colorGreen; text = 'Done!'; } else { - var time = (price - Game.cookies) / (Game.cookiesPs * (1 - Game.cpsSucked)); + var time = (price - bank) / cps; text = CM.Disp.FormatTime(time); if (time > 300) { color = CM.Disp.colorRed; @@ -205,7 +205,7 @@ CM.Disp.UpdateBotBarTime = function() { for (var i in CM.Cache.Objects) { count++; - var timeColor = CM.Disp.GetTimeColor(Game.Objects[i].getPrice()); + var timeColor = CM.Disp.GetTimeColor(Game.Objects[i].getPrice(), Game.cookies, (Game.cookiesPs * (1 - Game.cpsSucked))); CM.Disp.BotBar.firstChild.firstChild.childNodes[3].childNodes[count].className = CM.Disp.colorTextPre + timeColor.color; CM.Disp.BotBar.firstChild.firstChild.childNodes[3].childNodes[count].textContent = timeColor.text; } @@ -1287,6 +1287,11 @@ CM.Disp.AddTooltipBuild10 = function() { CM.Disp.Tooltip = function(type, name) { if (type == 'b') { l('tooltip').innerHTML = Game.Objects[name].tooltip(); + var buildPrice = CM.Sim.BuildingGetPrice(Game.Objects[name].basePrice, 0, Game.Objects[name].amount); + var amortizeAmount = buildPrice - Game.Objects[name].totalCookies; + if (amortizeAmount > 0) { + l('tooltip').innerHTML = l('tooltip').innerHTML.split('so far').join('so far
' + Beautify(amortizeAmount) + ' ' + (Math.floor(amortizeAmount) == 1 ? 'cookie' : 'cookies') + ' left to amortize (' + CM.Disp.GetTimeColor(buildPrice, Game.Objects[name].totalCookies, (Game.Objects[name].storedTotalCps * Game.globalCpsMult)).text+')'); + } if (CM.Disp.TooltipBuy10) { l('tooltip').innerHTML = l('tooltip').innerHTML.split(Beautify(Game.Objects[name].getPrice())).join(Beautify(CM.Cache.Objects10[name].price)); } @@ -1384,7 +1389,7 @@ CM.Disp.UpdateTooltip = function() { l('CMTooltipIncome').textContent += ' (' + (increase / 100) + '% of income)'; } - var timeColor = CM.Disp.GetTimeColor(price); + var timeColor = CM.Disp.GetTimeColor(price, Game.cookies, (Game.cookiesPs * (1 - Game.cpsSucked))); l('CMTooltipTime').textContent = timeColor.text; l('CMTooltipTime').className = CM.Disp.colorTextPre + timeColor.color; } From e5ce8e5ebd57130f97a20e9eeb11b7ddda071ead Mon Sep 17 00:00:00 2001 From: Aktanusa Date: Tue, 9 Sep 2014 20:13:56 -0400 Subject: [PATCH 5/9] Fixed minor bug with Chocolate Egg stat and fixed how undefined was checked (Thanks The_omniscent_pie) --- CookieMonster.js | 29 +++++++++++++++-------------- README.md | 2 +- src/Cache.js | 6 +++--- src/Config.js | 12 ++++++------ src/Disp.js | 5 +++-- src/Main.js | 6 +++--- 6 files changed, 31 insertions(+), 29 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index a90c76c..f70064b 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -175,13 +175,13 @@ CM.Cache.RemakeSeaSpec = function() { } } -CM.Cache.RemakeChoEgg = function() { +CM.Cache.RemakeSellAllTotal = function() { var sellTotal = 0; for (var i in Game.Objects) { var me = Game.Objects[i]; sellTotal += CM.Sim.BuildingSell(me.basePrice, me.amount, me.amount); } - CM.Cache.ChoEgg = (Game.cookies + sellTotal) * 0.05; + CM.Cache.SellAllTotal = sellTotal; } CM.Cache.Lucky = 0; @@ -195,7 +195,7 @@ CM.Cache.ChainWrathReward = 0; CM.Cache.ChainFrenzy = 0; CM.Cache.ChainFrenzyReward = 0; CM.Cache.ChainFrenzyWrathReward = 0; -CM.Cache.ChoEgg = 0; +CM.Cache.SellAllTotal = 0; /********** * Config * @@ -212,7 +212,7 @@ CM.LoadConfig = function() { // Check values var mod = false; for (var i in CM.ConfigDefault) { - if (CM.Config[i] == undefined) { + if (typeof CM.Config[i] === 'undefined') { mod = true; CM.Config[i] = CM.ConfigDefault[i]; } @@ -232,7 +232,7 @@ CM.LoadConfig = function() { } else if (i == 'StatsPref') { for (var j in CM.ConfigDefault.StatsPref) { - if (CM.Config[i][j] == undefined || !(CM.Config[i][j] > -1 && CM.Config[i][j] < 2)) { + if (typeof CM.Config[i][j] === 'undefined' || !(CM.Config[i][j] > -1 && CM.Config[i][j] < 2)) { mod = true; CM.Config[i][j] = CM.ConfigDefault[i][j]; } @@ -240,7 +240,7 @@ CM.LoadConfig = function() { } else { // Colors for (var j in CM.ConfigDefault.StatsPref) { - if (CM.Config[i][j] == undefined || typeof CM.Config[i][j] != 'string') { + if (typeof CM.Config[i][j] === 'undefined' || typeof CM.Config[i][j] != 'string') { mod = true; CM.Config[i][j] = CM.ConfigDefault[i][j]; } @@ -250,7 +250,7 @@ CM.LoadConfig = function() { if (mod) CM.SaveConfig(CM.Config); CM.Loop(); // Do loop once for (var i in CM.ConfigDefault) { - if (i != 'StatsPref' && CM.ConfigData[i].func != undefined) { + if (i != 'StatsPref' && typeof CM.ConfigData[i].func !== 'undefined') { CM.ConfigData[i].func(); } } @@ -272,7 +272,7 @@ CM.ToggleConfigUp = function(config) { if (CM.Config[config] == CM.ConfigData[config].label.length) { CM.Config[config] = 0; } - if (CM.ConfigData[config].func != undefined) { + if (typeof CM.ConfigData[config].func !== 'undefined') { CM.ConfigData[config].func(); } l(CM.ConfigPrefix + config).innerHTML = CM.Disp.GetConfigDisplay(config); @@ -284,7 +284,7 @@ CM.ToggleConfigDown = function(config) { if (CM.Config[config] < 0) { CM.Config[config] = CM.ConfigData[config].label.length - 1; } - if (CM.ConfigData[config].func != undefined) { + if (typeof CM.ConfigData[config].func !== 'undefined') { CM.ConfigData[config].func(); } l(CM.ConfigPrefix + config).innerHTML = CM.Disp.GetConfigDisplay(config); @@ -587,7 +587,7 @@ CM.Disp.CreateTimerBar = function() { colorBar.style.borderTopRightRadius = '10px'; colorBar.style.borderBottomRightRadius = '10px'; } - if (bars[i].color != undefined) { + if (typeof bars[i].color !== 'undefined') { colorBar.className = CM.Disp.colorBackPre + bars[i].color; } div.appendChild(colorBar); @@ -1492,7 +1492,8 @@ CM.Disp.AddMenuStats = function(title) { choEggTitleSpan.style.verticalAlign = 'bottom'; choEggTitleSpan.textContent = '?'; choEggTitleFrag.appendChild(choEggTitleSpan); - stats.appendChild(listing(choEggTitleFrag, document.createTextNode(Beautify(CM.Cache.ChoEgg)))); + var choEggTotal = (Game.cookies + CM.Cache.SellAllTotal) * 0.05; + stats.appendChild(listing(choEggTitleFrag, document.createTextNode(Beautify(choEggTotal)))); } } } @@ -1943,7 +1944,7 @@ CM.ReplaceNative = function() { CM.Backup.UpdateMenu = Game.UpdateMenu; Game.UpdateMenu = function() { - if (jscolor.picker == undefined || jscolor.picker.owner == undefined) { + if (typeof jscolor.picker === 'undefined' || typeof jscolor.picker.owner === 'undefined') { CM.Backup.UpdateMenu(); CM.Disp.AddMenu(); } @@ -1969,7 +1970,7 @@ CM.Loop = function() { CM.Cache.RemakeLucky(); CM.Cache.RemakeChain(); CM.Cache.RemakeSeaSpec(); - CM.Cache.RemakeChoEgg(); + CM.Cache.RemakeSellAllTotal(); CM.Disp.UpdateBotBarOther(); CM.Disp.UpdateBuildings(); @@ -2008,7 +2009,7 @@ CM.Init = function() { CM.Disp.AddJscolor(); var delay = setInterval(function() { - if (jscolor != undefined) { + if (typeof jscolor !== 'undefined') { CM.DelayInit(); clearInterval(delay); } diff --git a/README.md b/README.md index 57bcd3c..4f5a30d 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ If you'd rather use the addon as a script via per example *Greasemonkey* or *Tam javascript:(function() { var checkReady = setInterval(function() { - if (Game.ready != undefined && Game.ready) { + if (typeof Game.ready !== 'undefined' && Game.ready) { Game.LoadMod('http://aktanusa.github.io/CookieMonster/CookieMonster.js'); clearInterval(checkReady); } diff --git a/src/Cache.js b/src/Cache.js index 8b821c5..42099f1 100644 --- a/src/Cache.js +++ b/src/Cache.js @@ -155,13 +155,13 @@ CM.Cache.RemakeSeaSpec = function() { } } -CM.Cache.RemakeChoEgg = function() { +CM.Cache.RemakeSellAllTotal = function() { var sellTotal = 0; for (var i in Game.Objects) { var me = Game.Objects[i]; sellTotal += CM.Sim.BuildingSell(me.basePrice, me.amount, me.amount); } - CM.Cache.ChoEgg = (Game.cookies + sellTotal) * 0.05; + CM.Cache.SellAllTotal = sellTotal; } CM.Cache.Lucky = 0; @@ -175,5 +175,5 @@ CM.Cache.ChainWrathReward = 0; CM.Cache.ChainFrenzy = 0; CM.Cache.ChainFrenzyReward = 0; CM.Cache.ChainFrenzyWrathReward = 0; -CM.Cache.ChoEgg = 0; +CM.Cache.SellAllTotal = 0; diff --git a/src/Config.js b/src/Config.js index 16c30f8..1dc1a7b 100644 --- a/src/Config.js +++ b/src/Config.js @@ -13,7 +13,7 @@ CM.LoadConfig = function() { // Check values var mod = false; for (var i in CM.ConfigDefault) { - if (CM.Config[i] == undefined) { + if (typeof CM.Config[i] === 'undefined') { mod = true; CM.Config[i] = CM.ConfigDefault[i]; } @@ -33,7 +33,7 @@ CM.LoadConfig = function() { } else if (i == 'StatsPref') { for (var j in CM.ConfigDefault.StatsPref) { - if (CM.Config[i][j] == undefined || !(CM.Config[i][j] > -1 && CM.Config[i][j] < 2)) { + if (typeof CM.Config[i][j] === 'undefined' || !(CM.Config[i][j] > -1 && CM.Config[i][j] < 2)) { mod = true; CM.Config[i][j] = CM.ConfigDefault[i][j]; } @@ -41,7 +41,7 @@ CM.LoadConfig = function() { } else { // Colors for (var j in CM.ConfigDefault.StatsPref) { - if (CM.Config[i][j] == undefined || typeof CM.Config[i][j] != 'string') { + if (typeof CM.Config[i][j] === 'undefined' || typeof CM.Config[i][j] != 'string') { mod = true; CM.Config[i][j] = CM.ConfigDefault[i][j]; } @@ -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' && CM.ConfigData[i].func != undefined) { + if (i != 'StatsPref' && typeof CM.ConfigData[i].func !== 'undefined') { CM.ConfigData[i].func(); } } @@ -73,7 +73,7 @@ CM.ToggleConfigUp = function(config) { if (CM.Config[config] == CM.ConfigData[config].label.length) { CM.Config[config] = 0; } - if (CM.ConfigData[config].func != undefined) { + if (typeof CM.ConfigData[config].func !== 'undefined') { CM.ConfigData[config].func(); } l(CM.ConfigPrefix + config).innerHTML = CM.Disp.GetConfigDisplay(config); @@ -85,7 +85,7 @@ CM.ToggleConfigDown = function(config) { if (CM.Config[config] < 0) { CM.Config[config] = CM.ConfigData[config].label.length - 1; } - if (CM.ConfigData[config].func != undefined) { + if (typeof CM.ConfigData[config].func !== 'undefined') { CM.ConfigData[config].func(); } l(CM.ConfigPrefix + config).innerHTML = CM.Disp.GetConfigDisplay(config); diff --git a/src/Disp.js b/src/Disp.js index 83eb7ec..52875ab 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -251,7 +251,7 @@ CM.Disp.CreateTimerBar = function() { colorBar.style.borderTopRightRadius = '10px'; colorBar.style.borderBottomRightRadius = '10px'; } - if (bars[i].color != undefined) { + if (typeof bars[i].color !== 'undefined') { colorBar.className = CM.Disp.colorBackPre + bars[i].color; } div.appendChild(colorBar); @@ -1156,7 +1156,8 @@ CM.Disp.AddMenuStats = function(title) { choEggTitleSpan.style.verticalAlign = 'bottom'; choEggTitleSpan.textContent = '?'; choEggTitleFrag.appendChild(choEggTitleSpan); - stats.appendChild(listing(choEggTitleFrag, document.createTextNode(Beautify(CM.Cache.ChoEgg)))); + var choEggTotal = (Game.cookies + CM.Cache.SellAllTotal) * 0.05; + stats.appendChild(listing(choEggTitleFrag, document.createTextNode(Beautify(choEggTotal)))); } } } diff --git a/src/Main.js b/src/Main.js index 8e7c34b..e584b22 100644 --- a/src/Main.js +++ b/src/Main.js @@ -45,7 +45,7 @@ CM.ReplaceNative = function() { CM.Backup.UpdateMenu = Game.UpdateMenu; Game.UpdateMenu = function() { - if (jscolor.picker == undefined || jscolor.picker.owner == undefined) { + if (typeof jscolor.picker === 'undefined' || typeof jscolor.picker.owner === 'undefined') { CM.Backup.UpdateMenu(); CM.Disp.AddMenu(); } @@ -71,7 +71,7 @@ CM.Loop = function() { CM.Cache.RemakeLucky(); CM.Cache.RemakeChain(); CM.Cache.RemakeSeaSpec(); - CM.Cache.RemakeChoEgg(); + CM.Cache.RemakeSellAllTotal(); CM.Disp.UpdateBotBarOther(); CM.Disp.UpdateBuildings(); @@ -110,7 +110,7 @@ CM.Init = function() { CM.Disp.AddJscolor(); var delay = setInterval(function() { - if (jscolor != undefined) { + if (typeof jscolor !== 'undefined') { CM.DelayInit(); clearInterval(delay); } From 47b6d4d83fc119eb161c230fc6ae5624a7ac3ef0 Mon Sep 17 00:00:00 2001 From: Aktanusa Date: Sat, 27 Sep 2014 16:05:45 -0400 Subject: [PATCH 6/9] Add amortization to tooltip config (Issue #19) --- CookieMonster.js | 14 +++++++++----- src/Config.js | 1 + src/Disp.js | 11 +++++++---- src/Main.js | 2 +- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index f70064b..e4e1672 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -318,6 +318,7 @@ CM.ConfigData.SeaSoundURL = {label: 'Season Special Sound URL:', desc: 'URL of t CM.ConfigData.GCTimer = {label: ['Golden Cookie Timer OFF', 'Golden Cookie Timer ON'], desc: 'A timer on the Golden Cookie when it has been spawned', func: function() {CM.Disp.ToggleGCTimer();}}; CM.ConfigData.Title = {label: ['Title OFF', 'Title ON'], desc: 'Update title with Golden Cookie/Season Popup timers'}; CM.ConfigData.Tooltip = {label: ['Tooltip Information OFF', 'Tooltip Information ON'], desc: 'Extra information in tooltip for buildings/upgrades'}; +CM.ConfigData.TooltipAmor = {label: ['Tooltip Amortization Information OFF', 'Tooltip Amortization Information ON'], desc: 'Add amortization information to buildings tooltip'}; 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', 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', func: function() {CM.Disp.ToggleToolWarnCautPos();}}; CM.ConfigData.ToolWrink = {label: ['Wrinkler Tooltip OFF', 'Wrinkler Tooltip ON'], desc: 'Shows the amount of cookies a wrinkler will give when popping it'}; @@ -1178,6 +1179,7 @@ CM.Disp.AddMenuPref = function(title) { frag.appendChild(header('Tooltip')); frag.appendChild(listing('Tooltip')); + frag.appendChild(listing('TooltipAmor')); frag.appendChild(listing('ToolWarnCaut')); frag.appendChild(listing('ToolWarnCautPos')); frag.appendChild(listing('ToolWrink')); @@ -1624,10 +1626,12 @@ CM.Disp.AddTooltipBuild10 = function() { CM.Disp.Tooltip = function(type, name) { if (type == 'b') { l('tooltip').innerHTML = Game.Objects[name].tooltip(); - var buildPrice = CM.Sim.BuildingGetPrice(Game.Objects[name].basePrice, 0, Game.Objects[name].amount); - var amortizeAmount = buildPrice - Game.Objects[name].totalCookies; - if (amortizeAmount > 0) { - l('tooltip').innerHTML = l('tooltip').innerHTML.split('so far').join('so far
' + Beautify(amortizeAmount) + ' ' + (Math.floor(amortizeAmount) == 1 ? 'cookie' : 'cookies') + ' left to amortize (' + CM.Disp.GetTimeColor(buildPrice, Game.Objects[name].totalCookies, (Game.Objects[name].storedTotalCps * Game.globalCpsMult)).text+')'); + if (CM.Config.TooltipAmor == 1) { + var buildPrice = CM.Sim.BuildingGetPrice(Game.Objects[name].basePrice, 0, Game.Objects[name].amount); + var amortizeAmount = buildPrice - Game.Objects[name].totalCookies; + if (amortizeAmount > 0) { + l('tooltip').innerHTML = l('tooltip').innerHTML.split('so far').join('so far
' + Beautify(amortizeAmount) + ' ' + (Math.floor(amortizeAmount) == 1 ? 'cookie' : 'cookies') + ' left to amortize (' + CM.Disp.GetTimeColor(buildPrice, Game.Objects[name].totalCookies, (Game.Objects[name].storedTotalCps * Game.globalCpsMult)).text + ')'); + } } if (CM.Disp.TooltipBuy10) { l('tooltip').innerHTML = l('tooltip').innerHTML.split(Beautify(Game.Objects[name].getPrice())).join(Beautify(CM.Cache.Objects10[name].price)); @@ -2040,7 +2044,7 @@ CM.DelayInit = function() { Game.Win('Third-party'); } -CM.ConfigDefault = {BotBar: 1, TimerBar: 1, TimerBarPos: 0, BuildColor: 1, UpBarColor: 1, Flash: 1, Sound: 1, Volume: 100, GCSoundURL: 'http://freesound.org/data/previews/66/66717_931655-lq.mp3', SeaSoundURL: 'http://www.freesound.org/data/previews/121/121099_2193266-lq.mp3', GCTimer: 1, Title: 1, Tooltip: 1, ToolWarnCaut: 1, ToolWarnCautPos: 1, ToolWrink: 1, Stats: 1, UpStats: 1, SayTime: 1, Scale: 2, StatsPref: {Lucky: 1, Chain: 1, HC: 1, Wrink: 1, Sea: 1}, Colors : {Blue: '#4bb8f0', Green: '#00ff00', Yellow: '#ffff00', Orange: '#ff7f00', Red: '#ff0000', Purple: '#ff00ff', Gray: '#b3b3b3'}}; +CM.ConfigDefault = {BotBar: 1, TimerBar: 1, TimerBarPos: 0, BuildColor: 1, UpBarColor: 1, Flash: 1, Sound: 1, Volume: 100, GCSoundURL: 'http://freesound.org/data/previews/66/66717_931655-lq.mp3', SeaSoundURL: 'http://www.freesound.org/data/previews/121/121099_2193266-lq.mp3', GCTimer: 1, Title: 1, Tooltip: 1, TooltipAmor: 0, ToolWarnCaut: 1, ToolWarnCautPos: 1, ToolWrink: 1, Stats: 1, UpStats: 1, SayTime: 1, Scale: 2, StatsPref: {Lucky: 1, Chain: 1, HC: 1, Wrink: 1, Sea: 1}, Colors : {Blue: '#4bb8f0', Green: '#00ff00', Yellow: '#ffff00', Orange: '#ff7f00', Red: '#ff0000', Purple: '#ff00ff', Gray: '#b3b3b3'}}; CM.ConfigPrefix = 'CMConfig'; CM.VersionMajor = '1.0465'; diff --git a/src/Config.js b/src/Config.js index 1dc1a7b..10be1f7 100644 --- a/src/Config.js +++ b/src/Config.js @@ -119,6 +119,7 @@ CM.ConfigData.SeaSoundURL = {label: 'Season Special Sound URL:', desc: 'URL of t CM.ConfigData.GCTimer = {label: ['Golden Cookie Timer OFF', 'Golden Cookie Timer ON'], desc: 'A timer on the Golden Cookie when it has been spawned', func: function() {CM.Disp.ToggleGCTimer();}}; CM.ConfigData.Title = {label: ['Title OFF', 'Title ON'], desc: 'Update title with Golden Cookie/Season Popup timers'}; CM.ConfigData.Tooltip = {label: ['Tooltip Information OFF', 'Tooltip Information ON'], desc: 'Extra information in tooltip for buildings/upgrades'}; +CM.ConfigData.TooltipAmor = {label: ['Tooltip Amortization Information OFF', 'Tooltip Amortization Information ON'], desc: 'Add amortization information to buildings tooltip'}; 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', 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', func: function() {CM.Disp.ToggleToolWarnCautPos();}}; CM.ConfigData.ToolWrink = {label: ['Wrinkler Tooltip OFF', 'Wrinkler Tooltip ON'], desc: 'Shows the amount of cookies a wrinkler will give when popping it'}; diff --git a/src/Disp.js b/src/Disp.js index 52875ab..9129116 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -842,6 +842,7 @@ CM.Disp.AddMenuPref = function(title) { frag.appendChild(header('Tooltip')); frag.appendChild(listing('Tooltip')); + frag.appendChild(listing('TooltipAmor')); frag.appendChild(listing('ToolWarnCaut')); frag.appendChild(listing('ToolWarnCautPos')); frag.appendChild(listing('ToolWrink')); @@ -1288,10 +1289,12 @@ CM.Disp.AddTooltipBuild10 = function() { CM.Disp.Tooltip = function(type, name) { if (type == 'b') { l('tooltip').innerHTML = Game.Objects[name].tooltip(); - var buildPrice = CM.Sim.BuildingGetPrice(Game.Objects[name].basePrice, 0, Game.Objects[name].amount); - var amortizeAmount = buildPrice - Game.Objects[name].totalCookies; - if (amortizeAmount > 0) { - l('tooltip').innerHTML = l('tooltip').innerHTML.split('so far').join('so far
' + Beautify(amortizeAmount) + ' ' + (Math.floor(amortizeAmount) == 1 ? 'cookie' : 'cookies') + ' left to amortize (' + CM.Disp.GetTimeColor(buildPrice, Game.Objects[name].totalCookies, (Game.Objects[name].storedTotalCps * Game.globalCpsMult)).text+')'); + if (CM.Config.TooltipAmor == 1) { + var buildPrice = CM.Sim.BuildingGetPrice(Game.Objects[name].basePrice, 0, Game.Objects[name].amount); + var amortizeAmount = buildPrice - Game.Objects[name].totalCookies; + if (amortizeAmount > 0) { + l('tooltip').innerHTML = l('tooltip').innerHTML.split('so far').join('so far
' + Beautify(amortizeAmount) + ' ' + (Math.floor(amortizeAmount) == 1 ? 'cookie' : 'cookies') + ' left to amortize (' + CM.Disp.GetTimeColor(buildPrice, Game.Objects[name].totalCookies, (Game.Objects[name].storedTotalCps * Game.globalCpsMult)).text + ')'); + } } if (CM.Disp.TooltipBuy10) { l('tooltip').innerHTML = l('tooltip').innerHTML.split(Beautify(Game.Objects[name].getPrice())).join(Beautify(CM.Cache.Objects10[name].price)); diff --git a/src/Main.js b/src/Main.js index e584b22..377203c 100644 --- a/src/Main.js +++ b/src/Main.js @@ -141,7 +141,7 @@ CM.DelayInit = function() { Game.Win('Third-party'); } -CM.ConfigDefault = {BotBar: 1, TimerBar: 1, TimerBarPos: 0, BuildColor: 1, UpBarColor: 1, Flash: 1, Sound: 1, Volume: 100, GCSoundURL: 'http://freesound.org/data/previews/66/66717_931655-lq.mp3', SeaSoundURL: 'http://www.freesound.org/data/previews/121/121099_2193266-lq.mp3', GCTimer: 1, Title: 1, Tooltip: 1, ToolWarnCaut: 1, ToolWarnCautPos: 1, ToolWrink: 1, Stats: 1, UpStats: 1, SayTime: 1, Scale: 2, StatsPref: {Lucky: 1, Chain: 1, HC: 1, Wrink: 1, Sea: 1}, Colors : {Blue: '#4bb8f0', Green: '#00ff00', Yellow: '#ffff00', Orange: '#ff7f00', Red: '#ff0000', Purple: '#ff00ff', Gray: '#b3b3b3'}}; +CM.ConfigDefault = {BotBar: 1, TimerBar: 1, TimerBarPos: 0, BuildColor: 1, UpBarColor: 1, Flash: 1, Sound: 1, Volume: 100, GCSoundURL: 'http://freesound.org/data/previews/66/66717_931655-lq.mp3', SeaSoundURL: 'http://www.freesound.org/data/previews/121/121099_2193266-lq.mp3', GCTimer: 1, Title: 1, Tooltip: 1, TooltipAmor: 0, ToolWarnCaut: 1, ToolWarnCautPos: 1, ToolWrink: 1, Stats: 1, UpStats: 1, SayTime: 1, Scale: 2, StatsPref: {Lucky: 1, Chain: 1, HC: 1, Wrink: 1, Sea: 1}, Colors : {Blue: '#4bb8f0', Green: '#00ff00', Yellow: '#ffff00', Orange: '#ff7f00', Red: '#ff0000', Purple: '#ff00ff', Gray: '#b3b3b3'}}; CM.ConfigPrefix = 'CMConfig'; CM.VersionMajor = '1.0465'; From 89e8ec86db3a669acb923f6e964d73f8d97146b8 Mon Sep 17 00:00:00 2001 From: Aktanusa Date: Sat, 27 Sep 2014 17:15:25 -0400 Subject: [PATCH 7/9] Added a pop all button for wrinklers (Issue #24) --- CookieMonster.js | 10 +++++++++- src/Disp.js | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index e4e1672..55ef1f3 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -1385,7 +1385,15 @@ CM.Disp.AddMenuStats = function(title) { } sucked *= 1.1; if (Game.Has('Wrinklerspawn')) sucked *= 1.05; - stats.appendChild(listing('Rewards of Popping', document.createTextNode(Beautify(sucked)))); + var popAllFrag = document.createDocumentFragment(); + popAllFrag.appendChild(document.createTextNode(Beautify(sucked) + ' ')); + + var popAllA = document.createElement('a'); + popAllA.textContent = 'Pop All'; + popAllA.className = 'option'; + popAllA.onclick = function() {Game.CollectWrinklers();}; + popAllFrag.appendChild(popAllA); + stats.appendChild(listing('Rewards of Popping', popAllFrag)); } } diff --git a/src/Disp.js b/src/Disp.js index 9129116..55385b3 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -1048,7 +1048,15 @@ CM.Disp.AddMenuStats = function(title) { } sucked *= 1.1; if (Game.Has('Wrinklerspawn')) sucked *= 1.05; - stats.appendChild(listing('Rewards of Popping', document.createTextNode(Beautify(sucked)))); + var popAllFrag = document.createDocumentFragment(); + popAllFrag.appendChild(document.createTextNode(Beautify(sucked) + ' ')); + + var popAllA = document.createElement('a'); + popAllA.textContent = 'Pop All'; + popAllA.className = 'option'; + popAllA.onclick = function() {Game.CollectWrinklers();}; + popAllFrag.appendChild(popAllA); + stats.appendChild(listing('Rewards of Popping', popAllFrag)); } } From cd7376eaf615eeb792914a3d5da17ee9d96aeded Mon Sep 17 00:00:00 2001 From: Aktanusa Date: Mon, 29 Sep 2014 21:29:23 -0400 Subject: [PATCH 8/9] Added sell and sell all amounts to the building tooltips --- CookieMonster.js | 16 ++++++++++++++-- src/Disp.js | 14 +++++++++++++- src/Main.js | 2 +- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 55ef1f3..760b717 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -1623,11 +1623,15 @@ CM.Disp.AddTooltipUpgrade = function() { } } -CM.Disp.AddTooltipBuild10 = function() { +CM.Disp.AddTooltipBuildExtra = function() { for (var i in Game.Objects) { var me = Game.Objects[i]; l('buttonBuy10-' + me.id).onmouseover = function() {CM.Disp.TooltipBuy10 = true;}; l('buttonBuy10-' + me.id).onmouseout = function() {CM.Disp.TooltipBuy10 = false;}; + l('buttonSell-' + me.id).onmouseover = function() {CM.Disp.TooltipSell = true;}; + l('buttonSell-' + me.id).onmouseout = function() {CM.Disp.TooltipSell = false;}; + l('buttonSellAll-' + me.id).onmouseover = function() {CM.Disp.TooltipSellAll = true;}; + l('buttonSellAll-' + me.id).onmouseout = function() {CM.Disp.TooltipSellAll = false;}; } } @@ -1644,6 +1648,12 @@ CM.Disp.Tooltip = function(type, name) { if (CM.Disp.TooltipBuy10) { l('tooltip').innerHTML = l('tooltip').innerHTML.split(Beautify(Game.Objects[name].getPrice())).join(Beautify(CM.Cache.Objects10[name].price)); } + if (CM.Disp.TooltipSell) { + l('tooltip').innerHTML = l('tooltip').innerHTML.split(Beautify(Game.Objects[name].getPrice())).join('-' + Beautify(CM.Sim.BuildingSell(Game.Objects[name].basePrice, Game.Objects[name].amount, 1))); + } + if (CM.Disp.TooltipSellAll) { + l('tooltip').innerHTML = l('tooltip').innerHTML.split(Beautify(Game.Objects[name].getPrice())).join('-' + Beautify(CM.Sim.BuildingSell(Game.Objects[name].basePrice, Game.Objects[name].amount, Game.Objects[name].amount))); + } } else { // Upgrades CM.Disp.TooltipUpgradeBack[name](); @@ -1901,6 +1911,8 @@ CM.Disp.metric = ['M', 'G', 'T', 'P', 'E', 'Z', 'Y']; CM.Disp.shortScale = ['M', 'B', 'Tr', 'Quadr', 'Quint', 'Sext', 'Sept', 'Oct', 'Non', 'Dec', 'Undec', 'Duodec', 'Tredec']; CM.Disp.TooltipBuy10 = false; +CM.Disp.TooltipSell = false; +CM.Disp.TooltipSellAll = false; CM.Disp.TooltipWrinklerArea = 0; CM.Disp.TooltipWrinkler = -1; @@ -2040,7 +2052,7 @@ CM.DelayInit = function() { CM.Disp.CreateChoEggTooltip(); CM.Disp.CreateTooltipWarnCaut(); CM.Disp.AddTooltipBuild(); - CM.Disp.AddTooltipBuild10(); + CM.Disp.AddTooltipBuildExtra(); CM.Disp.AddWrinklerAreaDetect(); CM.ReplaceNative(); Game.CalculateGains(); diff --git a/src/Disp.js b/src/Disp.js index 55385b3..6a90815 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -1286,11 +1286,15 @@ CM.Disp.AddTooltipUpgrade = function() { } } -CM.Disp.AddTooltipBuild10 = function() { +CM.Disp.AddTooltipBuildExtra = function() { for (var i in Game.Objects) { var me = Game.Objects[i]; l('buttonBuy10-' + me.id).onmouseover = function() {CM.Disp.TooltipBuy10 = true;}; l('buttonBuy10-' + me.id).onmouseout = function() {CM.Disp.TooltipBuy10 = false;}; + l('buttonSell-' + me.id).onmouseover = function() {CM.Disp.TooltipSell = true;}; + l('buttonSell-' + me.id).onmouseout = function() {CM.Disp.TooltipSell = false;}; + l('buttonSellAll-' + me.id).onmouseover = function() {CM.Disp.TooltipSellAll = true;}; + l('buttonSellAll-' + me.id).onmouseout = function() {CM.Disp.TooltipSellAll = false;}; } } @@ -1307,6 +1311,12 @@ CM.Disp.Tooltip = function(type, name) { if (CM.Disp.TooltipBuy10) { l('tooltip').innerHTML = l('tooltip').innerHTML.split(Beautify(Game.Objects[name].getPrice())).join(Beautify(CM.Cache.Objects10[name].price)); } + if (CM.Disp.TooltipSell) { + l('tooltip').innerHTML = l('tooltip').innerHTML.split(Beautify(Game.Objects[name].getPrice())).join('-' + Beautify(CM.Sim.BuildingSell(Game.Objects[name].basePrice, Game.Objects[name].amount, 1))); + } + if (CM.Disp.TooltipSellAll) { + l('tooltip').innerHTML = l('tooltip').innerHTML.split(Beautify(Game.Objects[name].getPrice())).join('-' + Beautify(CM.Sim.BuildingSell(Game.Objects[name].basePrice, Game.Objects[name].amount, Game.Objects[name].amount))); + } } else { // Upgrades CM.Disp.TooltipUpgradeBack[name](); @@ -1564,6 +1574,8 @@ CM.Disp.metric = ['M', 'G', 'T', 'P', 'E', 'Z', 'Y']; CM.Disp.shortScale = ['M', 'B', 'Tr', 'Quadr', 'Quint', 'Sext', 'Sept', 'Oct', 'Non', 'Dec', 'Undec', 'Duodec', 'Tredec']; CM.Disp.TooltipBuy10 = false; +CM.Disp.TooltipSell = false; +CM.Disp.TooltipSellAll = false; CM.Disp.TooltipWrinklerArea = 0; CM.Disp.TooltipWrinkler = -1; diff --git a/src/Main.js b/src/Main.js index 377203c..00b37b7 100644 --- a/src/Main.js +++ b/src/Main.js @@ -129,7 +129,7 @@ CM.DelayInit = function() { CM.Disp.CreateChoEggTooltip(); CM.Disp.CreateTooltipWarnCaut(); CM.Disp.AddTooltipBuild(); - CM.Disp.AddTooltipBuild10(); + CM.Disp.AddTooltipBuildExtra(); CM.Disp.AddWrinklerAreaDetect(); CM.ReplaceNative(); Game.CalculateGains(); From 971f08b1255dc51260939912d9b381c9eb2c7fd7 Mon Sep 17 00:00:00 2001 From: Aktanusa Date: Mon, 29 Sep 2014 22:21:50 -0400 Subject: [PATCH 9/9] Chocolate egg stat now includes popping wrinklers (Issue #27) --- CookieMonster.js | 33 ++++++++++++++++++++------------- src/Disp.js | 33 ++++++++++++++++++++------------- 2 files changed, 40 insertions(+), 26 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 760b717..d8dac27 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -1059,11 +1059,11 @@ CM.Disp.CreateResetTooltip = function() { CM.Disp.CreateChoEggTooltip = function() { CM.Disp.ChoEggTooltipPlaceholder = document.createElement('div'); var choEggTitleDesc = document.createElement('div'); - choEggTitleDesc.style.minWidth = '290px'; + choEggTitleDesc.style.minWidth = '240px'; choEggTitleDesc.style.marginBottom = '4px'; var div = document.createElement('div'); div.style.textAlign = 'left'; - div.textContent = 'The amount of cookies you would get from selling all buildings and then buying Chocolate egg'; + div.textContent = 'The amount of cookies you would get from selling all buildings, popping all wrinklers, and then buying Chocolate egg'; choEggTitleDesc.appendChild(div); CM.Disp.ChoEggTooltipPlaceholder.appendChild(choEggTitleDesc); } @@ -1376,24 +1376,28 @@ CM.Disp.AddMenuStats = function(title) { stats.appendChild(listing(resetTitleFrag, resetFrag)); } + var choEgg = (Game.HasUnlocked('Chocolate egg') && !Game.Has('Chocolate egg')); // Needs to be done for the checking below + if (Game.cpsSucked > 0) { stats.appendChild(header('Wrinklers', 'Wrink')); - if (CM.Config.StatsPref.Wrink) { + if (CM.Config.StatsPref.Wrink || (CM.Config.StatsPref.Sea && choEgg)) { var sucked = 0; for (var i in Game.wrinklers) { sucked += Game.wrinklers[i].sucked; } sucked *= 1.1; if (Game.Has('Wrinklerspawn')) sucked *= 1.05; - var popAllFrag = document.createDocumentFragment(); - popAllFrag.appendChild(document.createTextNode(Beautify(sucked) + ' ')); - var popAllA = document.createElement('a'); - popAllA.textContent = 'Pop All'; - popAllA.className = 'option'; - popAllA.onclick = function() {Game.CollectWrinklers();}; - popAllFrag.appendChild(popAllA); - stats.appendChild(listing('Rewards of Popping', popAllFrag)); + if (CM.Config.StatsPref.Wrink) { + var popAllFrag = document.createDocumentFragment(); + popAllFrag.appendChild(document.createTextNode(Beautify(sucked) + ' ')); + var popAllA = document.createElement('a'); + popAllA.textContent = 'Pop All'; + popAllA.className = 'option'; + popAllA.onclick = function() {Game.CollectWrinklers();}; + popAllFrag.appendChild(popAllA); + stats.appendChild(listing('Rewards of Popping', popAllFrag)); + } } } @@ -1433,7 +1437,6 @@ CM.Disp.AddMenuStats = function(title) { specDisp = true; } } - var choEgg = (Game.HasUnlocked('Chocolate egg') && !Game.Has('Chocolate egg')); if (Game.season == 'christmas' || specDisp || choEgg) { stats.appendChild(header('Season Specials', 'Sea')); @@ -1502,7 +1505,11 @@ CM.Disp.AddMenuStats = function(title) { choEggTitleSpan.style.verticalAlign = 'bottom'; choEggTitleSpan.textContent = '?'; choEggTitleFrag.appendChild(choEggTitleSpan); - var choEggTotal = (Game.cookies + CM.Cache.SellAllTotal) * 0.05; + var choEggTotal = Game.cookies + CM.Cache.SellAllTotal; + if (Game.cpsSucked > 0) { + choEggTotal += sucked; + } + choEggTotal *= 0.05; stats.appendChild(listing(choEggTitleFrag, document.createTextNode(Beautify(choEggTotal)))); } } diff --git a/src/Disp.js b/src/Disp.js index 6a90815..c0d5517 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -722,11 +722,11 @@ CM.Disp.CreateResetTooltip = function() { CM.Disp.CreateChoEggTooltip = function() { CM.Disp.ChoEggTooltipPlaceholder = document.createElement('div'); var choEggTitleDesc = document.createElement('div'); - choEggTitleDesc.style.minWidth = '290px'; + choEggTitleDesc.style.minWidth = '240px'; choEggTitleDesc.style.marginBottom = '4px'; var div = document.createElement('div'); div.style.textAlign = 'left'; - div.textContent = 'The amount of cookies you would get from selling all buildings and then buying Chocolate egg'; + div.textContent = 'The amount of cookies you would get from selling all buildings, popping all wrinklers, and then buying Chocolate egg'; choEggTitleDesc.appendChild(div); CM.Disp.ChoEggTooltipPlaceholder.appendChild(choEggTitleDesc); } @@ -1039,24 +1039,28 @@ CM.Disp.AddMenuStats = function(title) { stats.appendChild(listing(resetTitleFrag, resetFrag)); } + var choEgg = (Game.HasUnlocked('Chocolate egg') && !Game.Has('Chocolate egg')); // Needs to be done for the checking below + if (Game.cpsSucked > 0) { stats.appendChild(header('Wrinklers', 'Wrink')); - if (CM.Config.StatsPref.Wrink) { + if (CM.Config.StatsPref.Wrink || (CM.Config.StatsPref.Sea && choEgg)) { var sucked = 0; for (var i in Game.wrinklers) { sucked += Game.wrinklers[i].sucked; } sucked *= 1.1; if (Game.Has('Wrinklerspawn')) sucked *= 1.05; - var popAllFrag = document.createDocumentFragment(); - popAllFrag.appendChild(document.createTextNode(Beautify(sucked) + ' ')); - var popAllA = document.createElement('a'); - popAllA.textContent = 'Pop All'; - popAllA.className = 'option'; - popAllA.onclick = function() {Game.CollectWrinklers();}; - popAllFrag.appendChild(popAllA); - stats.appendChild(listing('Rewards of Popping', popAllFrag)); + if (CM.Config.StatsPref.Wrink) { + var popAllFrag = document.createDocumentFragment(); + popAllFrag.appendChild(document.createTextNode(Beautify(sucked) + ' ')); + var popAllA = document.createElement('a'); + popAllA.textContent = 'Pop All'; + popAllA.className = 'option'; + popAllA.onclick = function() {Game.CollectWrinklers();}; + popAllFrag.appendChild(popAllA); + stats.appendChild(listing('Rewards of Popping', popAllFrag)); + } } } @@ -1096,7 +1100,6 @@ CM.Disp.AddMenuStats = function(title) { specDisp = true; } } - var choEgg = (Game.HasUnlocked('Chocolate egg') && !Game.Has('Chocolate egg')); if (Game.season == 'christmas' || specDisp || choEgg) { stats.appendChild(header('Season Specials', 'Sea')); @@ -1165,7 +1168,11 @@ CM.Disp.AddMenuStats = function(title) { choEggTitleSpan.style.verticalAlign = 'bottom'; choEggTitleSpan.textContent = '?'; choEggTitleFrag.appendChild(choEggTitleSpan); - var choEggTotal = (Game.cookies + CM.Cache.SellAllTotal) * 0.05; + var choEggTotal = Game.cookies + CM.Cache.SellAllTotal; + if (Game.cpsSucked > 0) { + choEggTotal += sucked; + } + choEggTotal *= 0.05; stats.appendChild(listing(choEggTitleFrag, document.createTextNode(Beautify(choEggTotal)))); } }