diff --git a/CookieMonster.js b/CookieMonster.js index b9692d4..7798d8c 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -641,6 +641,46 @@ CM.Disp.GetTimeColor = function(price, bank, cps, time) { return {text: text, color: color}; } +/** + * This function returns Name and Color as object for sugar lump type that is given as input param. + * @param type Sugar Lump Type. + * @returns {{text: string, color: string}} + * @constructor + */ +CM.Disp.GetLumpColor = function(type) { + var name = ""; + var color = ""; + + switch (type) { + case 0: + name = "Normal"; + color = CM.Disp.colorGray; + break; + case 1: + name = "Bifurcated"; + color = CM.Disp.colorGreen; + break; + case 2: + name = "Golden"; + color = CM.Disp.colorYellow; + break; + case 3: + name = "Meaty"; + color = CM.Disp.colorOrange; + break; + case 4: + name = "Caramelized"; + color = CM.Disp.colorPurple; + break; + default: + name = "Unknown Sugar Lump"; + color = CM.Disp.colorRed; + break; + } + + return {text: name, color: color}; +}; + CM.Disp.Beautify = function(num, frac) { if (CM.Config.Scale != 0 && isFinite(num)) { var answer = ''; @@ -2163,6 +2203,17 @@ CM.Disp.AddTooltipGrimoire = function() { } } +/** + * This function improves Sugar Lump tooltip by adding extra infromation. + * @constructor + */ +CM.Disp.AddTooltipLump = function() { + if (Game.canLumps()) { + CM.Disp.TooltipLumpBack = l('lumps').onmouseover; + eval('l(\'lumps\').onmouseover = function() {Game.tooltip.dynamic = 1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip(\'s\', \'Lump\');}, \'this\'); Game.tooltip.wobble();}'); + } +}; + CM.Disp.Tooltip = function(type, name) { if (type == 'b') { l('tooltip').innerHTML = Game.Objects[name].tooltip(); @@ -2201,6 +2252,10 @@ CM.Disp.Tooltip = function(type, name) { if (!Game.UpgradesInStore[name]) return ''; l('tooltip').innerHTML = Game.crate(Game.UpgradesInStore[name], 'store', undefined, undefined, 1)(); } + else if (type === 's') { + // Sugar Lump + l('tooltip').innerHTML = Game.lumpTooltip(); + } else { // Grimoire l('tooltip').innerHTML = Game.Objects['Wizard tower'].minigame.spellTooltip(name)(); } @@ -2350,6 +2405,38 @@ CM.Disp.UpdateTooltip = function() { CM.Disp.TooltipWarnCaut.style.display = 'none'; } } + else if (CM.Disp.tooltipType === 's') { + // Adding information about Sugar Lumps. + + CM.Disp.TooltipWarnCaut.style.display = 'none'; + l('CMDispTooltipWarn').style.display = 'none'; + l('CMDispTooltipCaut').style.display = 'none'; + + l('CMTooltipArea').innerHTML = ''; + + l('tooltip').firstChild.style.paddingBottom = '4px'; + var lumpTooltip = document.createElement('div'); + lumpTooltip.style.border = '1px solid'; + lumpTooltip.style.padding = '4px'; + lumpTooltip.style.margin = '0px -4px'; + lumpTooltip.id = 'CMTooltipBorder'; + lumpTooltip.className = CM.Disp.colorTextPre + CM.Disp.colorGray; + + var lumpHeader = document.createElement('div'); + lumpHeader.style.fontWeight = 'bold'; + lumpHeader.className = CM.Disp.colorTextPre + CM.Disp.colorBlue; + lumpHeader.textContent = 'Current Sugar Lump'; + + lumpTooltip.appendChild(lumpHeader); + var lumpType = document.createElement('div'); + lumpType.id = 'CMTooltipTime'; + lumpTooltip.appendChild(lumpType); + var lumpColor = CM.Disp.GetLumpColor(Game.lumpCurrentType); + lumpType.textContent = lumpColor.text; + lumpType.className = CM.Disp.colorTextPre + lumpColor.color; + + l('CMTooltipArea').appendChild(lumpTooltip); + } else { // Grimoire CM.Disp.TooltipWarnCaut.style.display = 'none'; l('CMDispTooltipWarn').style.display = 'none'; @@ -2788,6 +2875,7 @@ CM.DelayInit = function() { CM.Disp.CreateTooltipWarnCaut(); CM.Disp.AddTooltipBuild(); CM.Disp.AddTooltipGrimoire(); + CM.Disp.AddTooltipLump(); CM.Disp.AddWrinklerAreaDetect(); CM.Cache.InitCookiesDiff(); CM.ReplaceNative(); diff --git a/src/Disp.js b/src/Disp.js index c1c2edf..76e008d 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -88,6 +88,46 @@ CM.Disp.GetTimeColor = function(price, bank, cps, time) { return {text: text, color: color}; } +/** + * This function returns Name and Color as object for sugar lump type that is given as input param. + * @param type Sugar Lump Type. + * @returns {{text: string, color: string}} + * @constructor + */ +CM.Disp.GetLumpColor = function(type) { + var name = ""; + var color = ""; + + switch (type) { + case 0: + name = "Normal"; + color = CM.Disp.colorGray; + break; + case 1: + name = "Bifurcated"; + color = CM.Disp.colorGreen; + break; + case 2: + name = "Golden"; + color = CM.Disp.colorYellow; + break; + case 3: + name = "Meaty"; + color = CM.Disp.colorOrange; + break; + case 4: + name = "Caramelized"; + color = CM.Disp.colorPurple; + break; + default: + name = "Unknown Sugar Lump"; + color = CM.Disp.colorRed; + break; + } + + return {text: name, color: color}; +}; + CM.Disp.Beautify = function(num, frac) { if (CM.Config.Scale != 0 && isFinite(num)) { var answer = ''; @@ -1610,6 +1650,17 @@ CM.Disp.AddTooltipGrimoire = function() { } } +/** + * This function improves Sugar Lump tooltip by adding extra infromation. + * @constructor + */ +CM.Disp.AddTooltipLump = function() { + if (Game.canLumps()) { + CM.Disp.TooltipLumpBack = l('lumps').onmouseover; + eval('l(\'lumps\').onmouseover = function() {Game.tooltip.dynamic = 1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip(\'s\', \'Lump\');}, \'this\'); Game.tooltip.wobble();}'); + } +}; + CM.Disp.Tooltip = function(type, name) { if (type == 'b') { l('tooltip').innerHTML = Game.Objects[name].tooltip(); @@ -1648,6 +1699,10 @@ CM.Disp.Tooltip = function(type, name) { if (!Game.UpgradesInStore[name]) return ''; l('tooltip').innerHTML = Game.crate(Game.UpgradesInStore[name], 'store', undefined, undefined, 1)(); } + else if (type === 's') { + // Sugar Lump + l('tooltip').innerHTML = Game.lumpTooltip(); + } else { // Grimoire l('tooltip').innerHTML = Game.Objects['Wizard tower'].minigame.spellTooltip(name)(); } @@ -1797,6 +1852,38 @@ CM.Disp.UpdateTooltip = function() { CM.Disp.TooltipWarnCaut.style.display = 'none'; } } + else if (CM.Disp.tooltipType === 's') { + // Adding information about Sugar Lumps. + + CM.Disp.TooltipWarnCaut.style.display = 'none'; + l('CMDispTooltipWarn').style.display = 'none'; + l('CMDispTooltipCaut').style.display = 'none'; + + l('CMTooltipArea').innerHTML = ''; + + l('tooltip').firstChild.style.paddingBottom = '4px'; + var lumpTooltip = document.createElement('div'); + lumpTooltip.style.border = '1px solid'; + lumpTooltip.style.padding = '4px'; + lumpTooltip.style.margin = '0px -4px'; + lumpTooltip.id = 'CMTooltipBorder'; + lumpTooltip.className = CM.Disp.colorTextPre + CM.Disp.colorGray; + + var lumpHeader = document.createElement('div'); + lumpHeader.style.fontWeight = 'bold'; + lumpHeader.className = CM.Disp.colorTextPre + CM.Disp.colorBlue; + lumpHeader.textContent = 'Current Sugar Lump'; + + lumpTooltip.appendChild(lumpHeader); + var lumpType = document.createElement('div'); + lumpType.id = 'CMTooltipTime'; + lumpTooltip.appendChild(lumpType); + var lumpColor = CM.Disp.GetLumpColor(Game.lumpCurrentType); + lumpType.textContent = lumpColor.text; + lumpType.className = CM.Disp.colorTextPre + lumpColor.color; + + l('CMTooltipArea').appendChild(lumpTooltip); + } else { // Grimoire CM.Disp.TooltipWarnCaut.style.display = 'none'; l('CMDispTooltipWarn').style.display = 'none'; diff --git a/src/Main.js b/src/Main.js index 1ea76d4..727ae1e 100644 --- a/src/Main.js +++ b/src/Main.js @@ -228,6 +228,7 @@ CM.DelayInit = function() { CM.Disp.CreateTooltipWarnCaut(); CM.Disp.AddTooltipBuild(); CM.Disp.AddTooltipGrimoire(); + CM.Disp.AddTooltipLump(); CM.Disp.AddWrinklerAreaDetect(); CM.Cache.InitCookiesDiff(); CM.ReplaceNative();