From a920e9e5fb7ceb5b4b03f7c45bad402823d9b424 Mon Sep 17 00:00:00 2001 From: Aktanusa Date: Thu, 10 Oct 2019 22:22:44 -0400 Subject: [PATCH] Added stat to show missing Fortune upgrades left to buy (Issue #263 and #271) --- CookieMonster.js | 119 ++++++++++++++++++++++++++++++----------------- src/Data.js | 24 ++++++++++ src/Disp.js | 95 ++++++++++++++++++++----------------- 3 files changed, 154 insertions(+), 84 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 773f0554..fc68285a 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -593,6 +593,30 @@ CM.ConfigData.Scale = {label: ['Game\'s Setting Scale', 'Metric', 'Short Scale', * Data * ********/ +CM.Data.Fortunes = [ + 'Fortune #001', + 'Fortune #002', + 'Fortune #003', + 'Fortune #004', + 'Fortune #005', + 'Fortune #006', + 'Fortune #007', + 'Fortune #008', + 'Fortune #009', + 'Fortune #010', + 'Fortune #011', + 'Fortune #012', + 'Fortune #013', + 'Fortune #014', + 'Fortune #015', + 'Fortune #016', + 'Fortune #017', + 'Fortune #100', + 'Fortune #101', + 'Fortune #102', + 'Fortune #103', + 'Fortune #104' +]; CM.Data.HalloCookies = ['Skull cookies', 'Ghost cookies', 'Bat cookies', 'Slime cookies', 'Pumpkin cookies', 'Eyeball cookies', 'Spider cookies']; CM.Data.ChristCookies = ['Christmas tree biscuits', 'Snowflake biscuits', 'Snowman biscuits', 'Holly biscuits', 'Candy cane biscuits', 'Bell biscuits', 'Present biscuits']; CM.Data.ValCookies = ['Pure heart biscuits', 'Ardent heart biscuits', 'Sour heart biscuits', 'Weeping heart biscuits', 'Golden heart biscuits', 'Eternal heart biscuits']; @@ -1840,6 +1864,45 @@ CM.Disp.AddMenuStats = function(title) { frag.appendChild(span); return frag; } + + var createMissDisp = function(theMissDisp) { + var frag = document.createDocumentFragment(); + frag.appendChild(document.createTextNode(theMissDisp.length + ' ')); + var span = document.createElement('span'); + span.onmouseout = function() { Game.tooltip.hide(); }; + var placeholder = document.createElement('div'); + var missing = document.createElement('div'); + missing.style.minWidth = '140px'; + missing.style.marginBottom = '4px'; + var title = document.createElement('div'); + title.className = 'name'; + title.style.marginBottom = '4px'; + title.style.textAlign = 'center'; + title.textContent = 'Missing'; + missing.appendChild(title); + for (var i in theMissDisp) { + var div = document.createElement('div'); + div.style.textAlign = 'center'; + div.appendChild(document.createTextNode(theMissDisp[i])); + missing.appendChild(div); + } + placeholder.appendChild(missing); + span.onmouseover = function() {Game.tooltip.draw(this, escape(placeholder.innerHTML));}; + span.style.cursor = 'default'; + span.style.display = 'inline-block'; + span.style.height = '10px'; + span.style.width = '10px'; + span.style.borderRadius = '5px'; + span.style.textAlign = 'center'; + span.style.backgroundColor = '#C0C0C0'; + span.style.color = 'black'; + span.style.fontSize = '9px'; + span.style.verticalAlign = 'bottom'; + span.textContent = '?'; + frag.appendChild(span); + return frag; + } + stats.appendChild(header('Lucky Cookies', 'Lucky')); if (CM.Config.StatsPref.Lucky) { @@ -2067,48 +2130,11 @@ CM.Disp.AddMenuStats = function(title) { stats.appendChild(header('Season Specials', 'Sea')); if (CM.Config.StatsPref.Sea) { if (specDisp) { - var createSpecDisp = function(theSpecDisp) { - var frag = document.createDocumentFragment(); - frag.appendChild(document.createTextNode(theSpecDisp.length + ' ')); - var span = document.createElement('span'); - span.onmouseout = function() { Game.tooltip.hide(); }; - var placeholder = document.createElement('div'); - var missing = document.createElement('div'); - missing.style.minWidth = '140px'; - missing.style.marginBottom = '4px'; - var title = document.createElement('div'); - title.className = 'name'; - title.style.marginBottom = '4px'; - title.style.textAlign = 'center'; - title.textContent = 'Missing'; - missing.appendChild(title); - for (var i in theSpecDisp) { - var div = document.createElement('div'); - div.style.textAlign = 'center'; - div.appendChild(document.createTextNode(theSpecDisp[i])); - missing.appendChild(div); - } - placeholder.appendChild(missing); - span.onmouseover = function() {Game.tooltip.draw(this, escape(placeholder.innerHTML));}; - span.style.cursor = 'default'; - span.style.display = 'inline-block'; - span.style.height = '10px'; - span.style.width = '10px'; - span.style.borderRadius = '5px'; - span.style.textAlign = 'center'; - span.style.backgroundColor = '#C0C0C0'; - span.style.color = 'black'; - span.style.fontSize = '9px'; - span.style.verticalAlign = 'bottom'; - span.textContent = '?'; - frag.appendChild(span); - return frag; - } - if (halloCook.length != 0) stats.appendChild(listing('Halloween Cookies Left to Buy', createSpecDisp(halloCook))); - if (christCook.length != 0) stats.appendChild(listing('Christmas Cookies Left to Buy', createSpecDisp(christCook))); - if (valCook.length != 0) stats.appendChild(listing('Valentine Cookies Left to Buy', createSpecDisp(valCook))); - if (normEggs.length != 0) stats.appendChild(listing('Normal Easter Eggs Left to Unlock', createSpecDisp(normEggs))); - if (rareEggs.length != 0) stats.appendChild(listing('Rare Easter Eggs Left to Unlock', createSpecDisp(rareEggs))); + if (halloCook.length != 0) stats.appendChild(listing('Halloween Cookies Left to Buy', createMissDisp(halloCook))); + if (christCook.length != 0) stats.appendChild(listing('Christmas Cookies Left to Buy', createMissDisp(christCook))); + if (valCook.length != 0) stats.appendChild(listing('Valentine Cookies Left to Buy', createMissDisp(valCook))); + if (normEggs.length != 0) stats.appendChild(listing('Normal Easter Eggs Left to Unlock', createMissDisp(normEggs))); + if (rareEggs.length != 0) stats.appendChild(listing('Rare Easter Eggs Left to Unlock', createMissDisp(rareEggs))); } if (Game.season == 'christmas') stats.appendChild(listing('Reindeer Reward', document.createTextNode(Beautify(CM.Cache.SeaSpec)))); @@ -2128,6 +2154,15 @@ CM.Disp.AddMenuStats = function(title) { document.createTextNode(Beautify(CM.Cache.AvgCPS, 3)) )); stats.appendChild(listing('Average Cookie Clicks Per Second (Past ' + CM.Disp.clickTimes[CM.Config.AvgClicksHist] + (CM.Config.AvgClicksHist == 0 ? ' second' : ' seconds') + ')', document.createTextNode(Beautify(CM.Cache.AvgClicks, 1)))); + if (Game.Has('Fortune cookies')) { + var fortunes = []; + for (var i in CM.Data.Fortunes) { + if (!Game.Has(CM.Data.Fortunes[i])) { + fortunes.push(CM.Data.Fortunes[i]); + } + } + if (fortunes.length != 0) stats.appendChild(listing('Fortune Upgrades Left to Buy', createMissDisp(fortunes))); + } stats.appendChild(listing('Missed Golden Cookies', document.createTextNode(Beautify(Game.missedGoldenClicks)))); } diff --git a/src/Data.js b/src/Data.js index 84571d85..4202c893 100644 --- a/src/Data.js +++ b/src/Data.js @@ -2,6 +2,30 @@ * Data * ********/ +CM.Data.Fortunes = [ + 'Fortune #001', + 'Fortune #002', + 'Fortune #003', + 'Fortune #004', + 'Fortune #005', + 'Fortune #006', + 'Fortune #007', + 'Fortune #008', + 'Fortune #009', + 'Fortune #010', + 'Fortune #011', + 'Fortune #012', + 'Fortune #013', + 'Fortune #014', + 'Fortune #015', + 'Fortune #016', + 'Fortune #017', + 'Fortune #100', + 'Fortune #101', + 'Fortune #102', + 'Fortune #103', + 'Fortune #104' +]; CM.Data.HalloCookies = ['Skull cookies', 'Ghost cookies', 'Bat cookies', 'Slime cookies', 'Pumpkin cookies', 'Eyeball cookies', 'Spider cookies']; CM.Data.ChristCookies = ['Christmas tree biscuits', 'Snowflake biscuits', 'Snowman biscuits', 'Holly biscuits', 'Candy cane biscuits', 'Bell biscuits', 'Present biscuits']; CM.Data.ValCookies = ['Pure heart biscuits', 'Ardent heart biscuits', 'Sour heart biscuits', 'Weeping heart biscuits', 'Golden heart biscuits', 'Eternal heart biscuits']; diff --git a/src/Disp.js b/src/Disp.js index 53fbcb07..fcb1d2de 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -1241,6 +1241,45 @@ CM.Disp.AddMenuStats = function(title) { frag.appendChild(span); return frag; } + + var createMissDisp = function(theMissDisp) { + var frag = document.createDocumentFragment(); + frag.appendChild(document.createTextNode(theMissDisp.length + ' ')); + var span = document.createElement('span'); + span.onmouseout = function() { Game.tooltip.hide(); }; + var placeholder = document.createElement('div'); + var missing = document.createElement('div'); + missing.style.minWidth = '140px'; + missing.style.marginBottom = '4px'; + var title = document.createElement('div'); + title.className = 'name'; + title.style.marginBottom = '4px'; + title.style.textAlign = 'center'; + title.textContent = 'Missing'; + missing.appendChild(title); + for (var i in theMissDisp) { + var div = document.createElement('div'); + div.style.textAlign = 'center'; + div.appendChild(document.createTextNode(theMissDisp[i])); + missing.appendChild(div); + } + placeholder.appendChild(missing); + span.onmouseover = function() {Game.tooltip.draw(this, escape(placeholder.innerHTML));}; + span.style.cursor = 'default'; + span.style.display = 'inline-block'; + span.style.height = '10px'; + span.style.width = '10px'; + span.style.borderRadius = '5px'; + span.style.textAlign = 'center'; + span.style.backgroundColor = '#C0C0C0'; + span.style.color = 'black'; + span.style.fontSize = '9px'; + span.style.verticalAlign = 'bottom'; + span.textContent = '?'; + frag.appendChild(span); + return frag; + } + stats.appendChild(header('Lucky Cookies', 'Lucky')); if (CM.Config.StatsPref.Lucky) { @@ -1468,48 +1507,11 @@ CM.Disp.AddMenuStats = function(title) { stats.appendChild(header('Season Specials', 'Sea')); if (CM.Config.StatsPref.Sea) { if (specDisp) { - var createSpecDisp = function(theSpecDisp) { - var frag = document.createDocumentFragment(); - frag.appendChild(document.createTextNode(theSpecDisp.length + ' ')); - var span = document.createElement('span'); - span.onmouseout = function() { Game.tooltip.hide(); }; - var placeholder = document.createElement('div'); - var missing = document.createElement('div'); - missing.style.minWidth = '140px'; - missing.style.marginBottom = '4px'; - var title = document.createElement('div'); - title.className = 'name'; - title.style.marginBottom = '4px'; - title.style.textAlign = 'center'; - title.textContent = 'Missing'; - missing.appendChild(title); - for (var i in theSpecDisp) { - var div = document.createElement('div'); - div.style.textAlign = 'center'; - div.appendChild(document.createTextNode(theSpecDisp[i])); - missing.appendChild(div); - } - placeholder.appendChild(missing); - span.onmouseover = function() {Game.tooltip.draw(this, escape(placeholder.innerHTML));}; - span.style.cursor = 'default'; - span.style.display = 'inline-block'; - span.style.height = '10px'; - span.style.width = '10px'; - span.style.borderRadius = '5px'; - span.style.textAlign = 'center'; - span.style.backgroundColor = '#C0C0C0'; - span.style.color = 'black'; - span.style.fontSize = '9px'; - span.style.verticalAlign = 'bottom'; - span.textContent = '?'; - frag.appendChild(span); - return frag; - } - if (halloCook.length != 0) stats.appendChild(listing('Halloween Cookies Left to Buy', createSpecDisp(halloCook))); - if (christCook.length != 0) stats.appendChild(listing('Christmas Cookies Left to Buy', createSpecDisp(christCook))); - if (valCook.length != 0) stats.appendChild(listing('Valentine Cookies Left to Buy', createSpecDisp(valCook))); - if (normEggs.length != 0) stats.appendChild(listing('Normal Easter Eggs Left to Unlock', createSpecDisp(normEggs))); - if (rareEggs.length != 0) stats.appendChild(listing('Rare Easter Eggs Left to Unlock', createSpecDisp(rareEggs))); + if (halloCook.length != 0) stats.appendChild(listing('Halloween Cookies Left to Buy', createMissDisp(halloCook))); + if (christCook.length != 0) stats.appendChild(listing('Christmas Cookies Left to Buy', createMissDisp(christCook))); + if (valCook.length != 0) stats.appendChild(listing('Valentine Cookies Left to Buy', createMissDisp(valCook))); + if (normEggs.length != 0) stats.appendChild(listing('Normal Easter Eggs Left to Unlock', createMissDisp(normEggs))); + if (rareEggs.length != 0) stats.appendChild(listing('Rare Easter Eggs Left to Unlock', createMissDisp(rareEggs))); } if (Game.season == 'christmas') stats.appendChild(listing('Reindeer Reward', document.createTextNode(Beautify(CM.Cache.SeaSpec)))); @@ -1529,6 +1531,15 @@ CM.Disp.AddMenuStats = function(title) { document.createTextNode(Beautify(CM.Cache.AvgCPS, 3)) )); stats.appendChild(listing('Average Cookie Clicks Per Second (Past ' + CM.Disp.clickTimes[CM.Config.AvgClicksHist] + (CM.Config.AvgClicksHist == 0 ? ' second' : ' seconds') + ')', document.createTextNode(Beautify(CM.Cache.AvgClicks, 1)))); + if (Game.Has('Fortune cookies')) { + var fortunes = []; + for (var i in CM.Data.Fortunes) { + if (!Game.Has(CM.Data.Fortunes[i])) { + fortunes.push(CM.Data.Fortunes[i]); + } + } + if (fortunes.length != 0) stats.appendChild(listing('Fortune Upgrades Left to Buy', createMissDisp(fortunes))); + } stats.appendChild(listing('Missed Golden Cookies', document.createTextNode(Beautify(Game.missedGoldenClicks)))); }