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,