diff --git a/CookieMonster.js b/CookieMonster.js index 09edb61..de50e13 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -44,70 +44,72 @@ CM.Cache.RemakeIncome = function() { CM.Sim.BuyBuildings(100, 'Objects100'); } -CM.Cache.RemakeBuildingsBCI = function() { - CM.Disp.min = -1; - CM.Disp.max = -1; - CM.Disp.mid = -1; +CM.Cache.RemakeBuildingsROI = function() { + CM.Cache.min = -1; + CM.Cache.max = -1; + CM.Cache.mid = -1; for (var i in CM.Cache.Objects) { - CM.Cache.Objects[i].bci = Game.Objects[i].getPrice() / CM.Cache.Objects[i].bonus; - if (CM.Disp.min == -1 || CM.Cache.Objects[i].bci < CM.Disp.min) CM.Disp.min = CM.Cache.Objects[i].bci; - if (CM.Disp.max == -1 || CM.Cache.Objects[i].bci > CM.Disp.max) CM.Disp.max = CM.Cache.Objects[i].bci; + //CM.Cache.Objects[i].roi = Game.Objects[i].getPrice() / CM.Cache.Objects[i].bonus; + CM.Cache.Objects[i].roi = (Math.max(Game.Objects[i].getPrice() - Game.cookies, 0) / Game.cookiesPs) + (Game.Objects[i].getPrice() / CM.Cache.Objects[i].bonus); + if (CM.Cache.min == -1 || CM.Cache.Objects[i].roi < CM.Cache.min) CM.Cache.min = CM.Cache.Objects[i].roi; + if (CM.Cache.max == -1 || CM.Cache.Objects[i].roi > CM.Cache.max) CM.Cache.max = CM.Cache.Objects[i].roi; } - CM.Disp.mid = ((CM.Disp.max - CM.Disp.min) / 2) + CM.Disp.min; + 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].bci == CM.Disp.min) color = CM.Disp.colorGreen; - else if (CM.Cache.Objects[i].bci == CM.Disp.max) color = CM.Disp.colorRed; - else if (CM.Cache.Objects[i].bci > CM.Disp.mid) color = CM.Disp.colorOrange; + if (CM.Cache.Objects[i].roi == CM.Cache.min) color = CM.Disp.colorGreen; + else if (CM.Cache.Objects[i].roi == CM.Cache.max) color = CM.Disp.colorRed; + else if (CM.Cache.Objects[i].roi > CM.Cache.mid) color = CM.Disp.colorOrange; else color = CM.Disp.colorYellow; CM.Cache.Objects[i].color = color; } } -CM.Cache.RemakeUpgradeBCI = function() { +CM.Cache.RemakeUpgradeROI = function() { for (var i in CM.Cache.Upgrades) { - CM.Cache.Upgrades[i].bci = Game.Upgrades[i].getPrice() / CM.Cache.Upgrades[i].bonus; - if (isNaN(CM.Cache.Upgrades[i].bci)) CM.Cache.Upgrades[i].bci = 'Infinity'; + //CM.Cache.Upgrades[i].roi = Game.Upgrades[i].getPrice() / CM.Cache.Upgrades[i].bonus; + CM.Cache.Upgrades[i].roi = (Math.max(Game.Upgrades[i].getPrice() - Game.cookies, 0) / Game.cookiesPs) + (Game.Upgrades[i].getPrice() / CM.Cache.Upgrades[i].bonus); + if (isNaN(CM.Cache.Upgrades[i].roi)) CM.Cache.Upgrades[i].roi = 'Infinity'; var color = ''; - if (CM.Cache.Upgrades[i].bci <= 0 || CM.Cache.Upgrades[i].bci == 'Infinity') color = CM.Disp.colorGray; - else if (CM.Cache.Upgrades[i].bci < CM.Disp.min) color = CM.Disp.colorBlue; - else if (CM.Cache.Upgrades[i].bci == CM.Disp.min) color = CM.Disp.colorGreen; - else if (CM.Cache.Upgrades[i].bci == CM.Disp.max) color = CM.Disp.colorRed; - else if (CM.Cache.Upgrades[i].bci > CM.Disp.max) color = CM.Disp.colorPurple; - else if (CM.Cache.Upgrades[i].bci > CM.Disp.mid) color = CM.Disp.colorOrange; + if (CM.Cache.Upgrades[i].roi <= 0 || CM.Cache.Upgrades[i].roi == 'Infinity') color = CM.Disp.colorGray; + else if (CM.Cache.Upgrades[i].roi < CM.Cache.min) color = CM.Disp.colorBlue; + else if (CM.Cache.Upgrades[i].roi == CM.Cache.min) color = CM.Disp.colorGreen; + else if (CM.Cache.Upgrades[i].roi == CM.Cache.max) color = CM.Disp.colorRed; + else if (CM.Cache.Upgrades[i].roi > CM.Cache.max) color = CM.Disp.colorPurple; + else if (CM.Cache.Upgrades[i].roi > CM.Cache.mid) color = CM.Disp.colorOrange; else color = CM.Disp.colorYellow; CM.Cache.Upgrades[i].color = color; } } -CM.Cache.RemakeBuildingsOtherBCI = function(amount, target) { +CM.Cache.RemakeBuildingsOtherROI = function(amount, target) { for (var i in CM.Cache[target]) { - CM.Cache[target][i].price = CM.Sim.BuildingGetPrice(Game.Objects[i].basePrice, Game.Objects[i].amount, Game.Objects[i].free, amount); - CM.Cache[target][i].bci = CM.Cache[target][i].price / CM.Cache[target][i].bonus; + //CM.Cache[target][i].roi = CM.Cache[target][i].price / CM.Cache[target][i].bonus; + CM.Cache[target][i].roi = (Math.max(CM.Cache[target][i].price - Game.cookies, 0) / Game.cookiesPs) + (CM.Cache[target][i].price / CM.Cache[target][i].bonus); var color = ''; - if (CM.Cache[target][i].bci <= 0 || CM.Cache[target][i].bci == 'Infinity') color = CM.Disp.colorGray; - else if (CM.Cache[target][i].bci < CM.Disp.min) color = CM.Disp.colorBlue; - else if (CM.Cache[target][i].bci == CM.Disp.min) color = CM.Disp.colorGreen; - else if (CM.Cache[target][i].bci == CM.Disp.max) color = CM.Disp.colorRed; - else if (CM.Cache[target][i].bci > CM.Disp.max) color = CM.Disp.colorPurple; - else if (CM.Cache[target][i].bci > CM.Disp.mid) color = CM.Disp.colorOrange; + if (CM.Cache[target][i].roi <= 0 || CM.Cache[target][i].roi == 'Infinity') color = CM.Disp.colorGray; + else if (CM.Cache[target][i].roi < CM.Cache.min) color = CM.Disp.colorBlue; + else if (CM.Cache[target][i].roi == CM.Cache.min) color = CM.Disp.colorGreen; + else if (CM.Cache[target][i].roi == CM.Cache.max) color = CM.Disp.colorRed; + else if (CM.Cache[target][i].roi > CM.Cache.max) color = CM.Disp.colorPurple; + else if (CM.Cache[target][i].roi > CM.Cache.mid) color = CM.Disp.colorOrange; else color = CM.Disp.colorYellow; CM.Cache[target][i].color = color; } } -CM.Cache.RemakeBCI = function() { +CM.Cache.RemakeROI = function() { // Buildings for 1 amount - CM.Cache.RemakeBuildingsBCI(); + CM.Cache.RemakeBuildingsROI(); // Upgrades - CM.Cache.RemakeUpgradeBCI(); + CM.Cache.RemakeUpgradeROI(); // Buildings for 10 amount - CM.Cache.RemakeBuildingsOtherBCI(10, 'Objects10'); + CM.Cache.RemakeBuildingsOtherROI(10, 'Objects10'); // Buildings for 100 amount - CM.Cache.RemakeBuildingsOtherBCI(100, 'Objects100'); + CM.Cache.RemakeBuildingsOtherROI(100, 'Objects100'); } CM.Cache.RemakeLucky = function() { @@ -209,6 +211,9 @@ CM.Cache.RemakeSellForChoEgg = function() { CM.Cache.SellForChoEgg = sellTotal; } +CM.Cache.min = -1; +CM.Cache.max = -1; +CM.Cache.mid = -1; CM.Cache.Lucky = 0; CM.Cache.LuckyReward = 0; CM.Cache.LuckyFrenzy = 0; @@ -345,7 +350,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.UpBarColor = {label: ['Upgrade Bar/Colors OFF', 'Upgrade Bar/Colors ON'], desc: 'Color code upgrades and add a counter', toggle: true, func: function() {CM.Disp.ToggleUpBarColor();}}; -CM.ConfigData.Colors = {desc: {Blue: 'Color Blue. Used to show better than best BCI building, for Click Frenzy bar, and for various labels', Green: 'Color Green. Used to show best BCI building, for Blood Frenzy bar, and for various labels', Yellow: 'Color Yellow. Used to show between best and worst BCI buildings closer to best, for Frenzy bar, and for various labels', Orange: 'Color Orange. Used to show between best and worst BCI buildings closer to worst, for Next Reindeer bar, and for various labels', Red: 'Color Red. Used to show worst BCI building, for Clot bar, and for various labels', Purple: 'Color Purple. Used to show worse than worst BCI building, for Next Cookie bar, and for various labels', Gray: 'Color Gray. Used to show negative or infinity BCI, and for Next Cookie/Next Reindeer bar', Pink: 'Color Pink. Used for Dragonflight bar', Brown: 'Color Brown. Used for Dragon Harvest bar'}, func: function() {CM.Disp.UpdateColors();}}; +CM.ConfigData.Colors = {desc: {Blue: 'Color Blue. Used to show better than best ROI building, for Click Frenzy bar, and for various labels', Green: 'Color Green. Used to show best ROI building, for Blood Frenzy bar, and for various labels', Yellow: 'Color Yellow. Used to show between best and worst ROI buildings closer to best, for Frenzy bar, and for various labels', Orange: 'Color Orange. Used to show between best and worst ROI buildings closer to worst, for Next Reindeer bar, and for various labels', Red: 'Color Red. Used to show worst ROI building, for Clot bar, and for various labels', Purple: 'Color Purple. Used to show worse than worst ROI building, for Next Cookie bar, and for various labels', Gray: 'Color Gray. Used to show negative or infinity ROI, and for Next Cookie/Next Reindeer bar', Pink: 'Color Pink. Used for Dragonflight bar', Brown: 'Color Brown. Used for Dragon Harvest bar'}, func: function() {CM.Disp.UpdateColors();}}; CM.ConfigData.Flash = {label: ['Flash OFF', 'Flash ON'], desc: 'Flash screen on Golden Cookie/Season Popup', toggle: true}; CM.ConfigData.Sound = {label: ['Sounds OFF', 'Sounds ON'], desc: 'Play a sound on Golden Cookie/Season Popup', toggle: true}; CM.ConfigData.Volume = {label: [], desc: 'Volume of the sound'}; @@ -526,9 +531,9 @@ CM.Disp.CreateBotBar = function() { var bonus = document.createElement('tr'); bonus.appendChild(firstCol('Bonus Income', CM.Disp.colorBlue)); tbody.appendChild(bonus); - var bci = document.createElement('tr'); - bci.appendChild(firstCol('Base Cost Per Income', CM.Disp.colorBlue)); - tbody.appendChild(bci); + var roi = document.createElement('tr'); + roi.appendChild(firstCol('Return On Investment', CM.Disp.colorBlue)); + tbody.appendChild(roi); var time = document.createElement('tr'); time.appendChild(firstCol('Time Left', CM.Disp.colorBlue)); tbody.appendChild(time); @@ -542,7 +547,7 @@ CM.Disp.CreateBotBar = function() { header.appendChild(document.createTextNode(')')); type.appendChild(header); bonus.appendChild(document.createElement('td')); - bci.appendChild(document.createElement('td')); + roi.appendChild(document.createElement('td')); time.appendChild(document.createElement('td')); } @@ -572,7 +577,7 @@ CM.Disp.UpdateBotBarOther = function() { 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].bci, 2); + CM.Disp.BotBar.firstChild.firstChild.childNodes[2].childNodes[count].textContent = Beautify(CM.Cache.Objects[i].roi, 2); } } } @@ -824,13 +829,13 @@ CM.Disp.UpdateBuildings = function() { if (CM.Config.BuildColor == 1 && Game.buyMode == 1) { var target = ''; if (Game.buyBulk == 10) { - target = 'Objects10' + target = 'Objects10'; } else if (Game.buyBulk == 100) { - target = 'Objects100' + target = 'Objects100'; } else { - target = 'Objects' + target = 'Objects'; } for (var i in CM.Cache[target]) { l('productPrice' + Game.Objects[i].id).style.color = CM.Config.Colors[CM.Cache[target][i].color]; @@ -877,13 +882,13 @@ CM.Disp.CreateUpgradeBar = function() { return div; } - legend.appendChild(legendLine(CM.Disp.colorBlue, 'Better than best BCI building')); - legend.appendChild(legendLine(CM.Disp.colorGreen, 'Same as best BCI building')); - legend.appendChild(legendLine(CM.Disp.colorYellow, 'Between best and worst BCI buildings closer to best')); - legend.appendChild(legendLine(CM.Disp.colorOrange, 'Between best and worst BCI buildings closer to worst')); - legend.appendChild(legendLine(CM.Disp.colorRed, 'Same as worst BCI building')); - legend.appendChild(legendLine(CM.Disp.colorPurple, 'Worse than worst BCI building')); - legend.appendChild(legendLine(CM.Disp.colorGray, 'Negative or infinity BCI')); + legend.appendChild(legendLine(CM.Disp.colorBlue, 'Better than best ROI building')); + legend.appendChild(legendLine(CM.Disp.colorGreen, 'Same as best ROI building')); + legend.appendChild(legendLine(CM.Disp.colorYellow, 'Between best and worst ROI buildings closer to best')); + legend.appendChild(legendLine(CM.Disp.colorOrange, 'Between best and worst ROI buildings closer to worst')); + legend.appendChild(legendLine(CM.Disp.colorRed, 'Same as worst ROI building')); + legend.appendChild(legendLine(CM.Disp.colorPurple, 'Worse than worst ROI building')); + legend.appendChild(legendLine(CM.Disp.colorGray, 'Negative or infinity ROI')); placeholder.appendChild(legend); CM.Disp.UpgradeBar.onmouseover = function() {Game.tooltip.draw(this, escape(placeholder.innerHTML), 'store');}; @@ -1864,11 +1869,11 @@ CM.Disp.Tooltip = function(type, name) { income.style.color = 'white'; income.id = 'CMTooltipIncome'; tooltip.appendChild(income); - tooltip.appendChild(header('Base Cost Per Income')); - var bci = document.createElement('div'); - bci.style.marginBottom = '4px'; - bci.id = 'CMTooltipBCI'; - tooltip.appendChild(bci); + tooltip.appendChild(header('Return On Investment')); + var roi = document.createElement('div'); + roi.style.marginBottom = '4px'; + roi.id = 'CMTooltipROI'; + tooltip.appendChild(roi); tooltip.appendChild(header('Time Left')); var time = document.createElement('div'); time.id = 'CMTooltipTime'; @@ -1906,8 +1911,8 @@ CM.Disp.UpdateTooltip = function() { bonus = CM.Cache[target][CM.Disp.tooltipName].bonus; if (CM.Config.Tooltip == 1 && Game.buyMode == 1) { l('CMTooltipBorder').className = CM.Disp.colorTextPre + CM.Cache[target][CM.Disp.tooltipName].color; - l('CMTooltipBCI').textContent = Beautify(CM.Cache[target][CM.Disp.tooltipName].bci, 2); - l('CMTooltipBCI').className = CM.Disp.colorTextPre + CM.Cache[target][CM.Disp.tooltipName].color; + l('CMTooltipROI').textContent = Beautify(CM.Cache[target][CM.Disp.tooltipName].roi, 2); + l('CMTooltipROI').className = CM.Disp.colorTextPre + CM.Cache[target][CM.Disp.tooltipName].color; } } else { // Upgrades @@ -1915,8 +1920,8 @@ CM.Disp.UpdateTooltip = function() { price = Game.Upgrades[Game.UpgradesInStore[CM.Disp.tooltipName].name].getPrice(); if (CM.Config.Tooltip == 1) { l('CMTooltipBorder').className = CM.Disp.colorTextPre + CM.Cache.Upgrades[Game.UpgradesInStore[CM.Disp.tooltipName].name].color; - l('CMTooltipBCI').textContent = Beautify(CM.Cache.Upgrades[Game.UpgradesInStore[CM.Disp.tooltipName].name].bci, 2); - l('CMTooltipBCI').className = CM.Disp.colorTextPre + CM.Cache.Upgrades[Game.UpgradesInStore[CM.Disp.tooltipName].name].color; + l('CMTooltipROI').textContent = Beautify(CM.Cache.Upgrades[Game.UpgradesInStore[CM.Disp.tooltipName].name].roi, 2); + l('CMTooltipROI').className = CM.Disp.colorTextPre + CM.Cache.Upgrades[Game.UpgradesInStore[CM.Disp.tooltipName].name].color; } } if (CM.Config.Tooltip == 1 && (CM.Disp.tooltipType != 'b' || Game.buyMode == 1)) { @@ -2090,9 +2095,6 @@ CM.Disp.RefreshScale = function() { CM.Disp.UpdateUpgrades(); } -CM.Disp.min = -1; -CM.Disp.max = -1; -CM.Disp.mid = -1; CM.Disp.colorTextPre = 'CMText'; CM.Disp.colorBackPre = 'CMBack'; CM.Disp.colorBorderPre = 'CMBorder'; @@ -2108,8 +2110,6 @@ 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.lastGoldenCookieState = 'none'; CM.Disp.lastAscendState = -1; -CM.Disp.lastBuyMode = -1; -CM.Disp.lastBuyBulk = -1; 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']; @@ -2211,33 +2211,22 @@ CM.Loop = function() { if (!Game.OnAscend && Game.AscendTimer == 0) { if (CM.Sim.DoSims) { CM.Cache.RemakeIncome(); - CM.Cache.RemakeBCI(); CM.Cache.RemakeLucky(); CM.Cache.RemakeChain(); CM.Cache.RemakeSeaSpec(); CM.Cache.RemakeSellForChoEgg(); - - CM.Disp.UpdateBotBarOther(); - CM.Disp.UpdateBuildings(); - CM.Disp.UpdateUpgrades(); CM.Sim.DoSims = 0; } - // Update Buildings Color for different buy/sell modes - var updateBuildings = false; - if (CM.Disp.lastBuyMode != Game.buyMode) { - CM.Disp.lastBuyMode = Game.buyMode; - updateBuildings = true; - } - if (CM.Disp.lastBuyBulk != Game.buyBulk) { - CM.Disp.lastBuyBulk = Game.buyBulk; - updateBuildings = true; - } - if (updateBuildings) { - CM.Disp.UpdateBuildings(); - } + // Calculate ROI + CM.Cache.RemakeROI(); + // Update colors + CM.Disp.UpdateBotBarOther(); + CM.Disp.UpdateBuildings(); + CM.Disp.UpdateUpgrades(); + // Redraw timers CM.Disp.UpdateBotBarTime(); CM.Disp.UpdateTimerBar(); @@ -2669,6 +2658,9 @@ CM.Sim.BuyBuildings = function(amount, target) { CM.Cache[target][i] = {}; CM.Cache[target][i].bonus = CM.Sim.cookiesPs - Game.cookiesPs; + if (amount != 1) { + CM.Cache[target][i].price = CM.Sim.BuildingGetPrice(Game.Objects[i].basePrice, Game.Objects[i].amount, Game.Objects[i].free, amount); + } } } diff --git a/README.md b/README.md index 192e2a7..a6c3ca2 100644 --- a/README.md +++ b/README.md @@ -131,7 +131,6 @@ All suggestions are welcome, even the smallest ones. * **[Raving_Kumquat](http://cookieclicker.wikia.com/wiki/User:Raving_Kumquat)**: Original author * **[Maxime Fabre](https://github.com/Anahkiasen)**: Previous maintainer -* **Alderi Tokori**: ROI calculations (unused now) * **[Alhifar](https://github.com/Alhifar)**: Missed Golden Cookie Stat * **[BlackenedGem](https://github.com/BlackenedGem)**: Golden/Wrath Cookie Favicons * **[Aktanusa](https://github.com/Aktanusa)**: Current maintainer \ No newline at end of file diff --git a/src/Cache.js b/src/Cache.js index eb7eecc..2e6dc50 100644 --- a/src/Cache.js +++ b/src/Cache.js @@ -24,70 +24,72 @@ CM.Cache.RemakeIncome = function() { CM.Sim.BuyBuildings(100, 'Objects100'); } -CM.Cache.RemakeBuildingsBCI = function() { - CM.Disp.min = -1; - CM.Disp.max = -1; - CM.Disp.mid = -1; +CM.Cache.RemakeBuildingsROI = function() { + CM.Cache.min = -1; + CM.Cache.max = -1; + CM.Cache.mid = -1; for (var i in CM.Cache.Objects) { - CM.Cache.Objects[i].bci = Game.Objects[i].getPrice() / CM.Cache.Objects[i].bonus; - if (CM.Disp.min == -1 || CM.Cache.Objects[i].bci < CM.Disp.min) CM.Disp.min = CM.Cache.Objects[i].bci; - if (CM.Disp.max == -1 || CM.Cache.Objects[i].bci > CM.Disp.max) CM.Disp.max = CM.Cache.Objects[i].bci; + //CM.Cache.Objects[i].roi = Game.Objects[i].getPrice() / CM.Cache.Objects[i].bonus; + CM.Cache.Objects[i].roi = (Math.max(Game.Objects[i].getPrice() - Game.cookies, 0) / Game.cookiesPs) + (Game.Objects[i].getPrice() / CM.Cache.Objects[i].bonus); + if (CM.Cache.min == -1 || CM.Cache.Objects[i].roi < CM.Cache.min) CM.Cache.min = CM.Cache.Objects[i].roi; + if (CM.Cache.max == -1 || CM.Cache.Objects[i].roi > CM.Cache.max) CM.Cache.max = CM.Cache.Objects[i].roi; } - CM.Disp.mid = ((CM.Disp.max - CM.Disp.min) / 2) + CM.Disp.min; + 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].bci == CM.Disp.min) color = CM.Disp.colorGreen; - else if (CM.Cache.Objects[i].bci == CM.Disp.max) color = CM.Disp.colorRed; - else if (CM.Cache.Objects[i].bci > CM.Disp.mid) color = CM.Disp.colorOrange; + if (CM.Cache.Objects[i].roi == CM.Cache.min) color = CM.Disp.colorGreen; + else if (CM.Cache.Objects[i].roi == CM.Cache.max) color = CM.Disp.colorRed; + else if (CM.Cache.Objects[i].roi > CM.Cache.mid) color = CM.Disp.colorOrange; else color = CM.Disp.colorYellow; CM.Cache.Objects[i].color = color; } } -CM.Cache.RemakeUpgradeBCI = function() { +CM.Cache.RemakeUpgradeROI = function() { for (var i in CM.Cache.Upgrades) { - CM.Cache.Upgrades[i].bci = Game.Upgrades[i].getPrice() / CM.Cache.Upgrades[i].bonus; - if (isNaN(CM.Cache.Upgrades[i].bci)) CM.Cache.Upgrades[i].bci = 'Infinity'; + //CM.Cache.Upgrades[i].roi = Game.Upgrades[i].getPrice() / CM.Cache.Upgrades[i].bonus; + CM.Cache.Upgrades[i].roi = (Math.max(Game.Upgrades[i].getPrice() - Game.cookies, 0) / Game.cookiesPs) + (Game.Upgrades[i].getPrice() / CM.Cache.Upgrades[i].bonus); + if (isNaN(CM.Cache.Upgrades[i].roi)) CM.Cache.Upgrades[i].roi = 'Infinity'; var color = ''; - if (CM.Cache.Upgrades[i].bci <= 0 || CM.Cache.Upgrades[i].bci == 'Infinity') color = CM.Disp.colorGray; - else if (CM.Cache.Upgrades[i].bci < CM.Disp.min) color = CM.Disp.colorBlue; - else if (CM.Cache.Upgrades[i].bci == CM.Disp.min) color = CM.Disp.colorGreen; - else if (CM.Cache.Upgrades[i].bci == CM.Disp.max) color = CM.Disp.colorRed; - else if (CM.Cache.Upgrades[i].bci > CM.Disp.max) color = CM.Disp.colorPurple; - else if (CM.Cache.Upgrades[i].bci > CM.Disp.mid) color = CM.Disp.colorOrange; + if (CM.Cache.Upgrades[i].roi <= 0 || CM.Cache.Upgrades[i].roi == 'Infinity') color = CM.Disp.colorGray; + else if (CM.Cache.Upgrades[i].roi < CM.Cache.min) color = CM.Disp.colorBlue; + else if (CM.Cache.Upgrades[i].roi == CM.Cache.min) color = CM.Disp.colorGreen; + else if (CM.Cache.Upgrades[i].roi == CM.Cache.max) color = CM.Disp.colorRed; + else if (CM.Cache.Upgrades[i].roi > CM.Cache.max) color = CM.Disp.colorPurple; + else if (CM.Cache.Upgrades[i].roi > CM.Cache.mid) color = CM.Disp.colorOrange; else color = CM.Disp.colorYellow; CM.Cache.Upgrades[i].color = color; } } -CM.Cache.RemakeBuildingsOtherBCI = function(amount, target) { +CM.Cache.RemakeBuildingsOtherROI = function(amount, target) { for (var i in CM.Cache[target]) { - CM.Cache[target][i].price = CM.Sim.BuildingGetPrice(Game.Objects[i].basePrice, Game.Objects[i].amount, Game.Objects[i].free, amount); - CM.Cache[target][i].bci = CM.Cache[target][i].price / CM.Cache[target][i].bonus; + //CM.Cache[target][i].roi = CM.Cache[target][i].price / CM.Cache[target][i].bonus; + CM.Cache[target][i].roi = (Math.max(CM.Cache[target][i].price - Game.cookies, 0) / Game.cookiesPs) + (CM.Cache[target][i].price / CM.Cache[target][i].bonus); var color = ''; - if (CM.Cache[target][i].bci <= 0 || CM.Cache[target][i].bci == 'Infinity') color = CM.Disp.colorGray; - else if (CM.Cache[target][i].bci < CM.Disp.min) color = CM.Disp.colorBlue; - else if (CM.Cache[target][i].bci == CM.Disp.min) color = CM.Disp.colorGreen; - else if (CM.Cache[target][i].bci == CM.Disp.max) color = CM.Disp.colorRed; - else if (CM.Cache[target][i].bci > CM.Disp.max) color = CM.Disp.colorPurple; - else if (CM.Cache[target][i].bci > CM.Disp.mid) color = CM.Disp.colorOrange; + if (CM.Cache[target][i].roi <= 0 || CM.Cache[target][i].roi == 'Infinity') color = CM.Disp.colorGray; + else if (CM.Cache[target][i].roi < CM.Cache.min) color = CM.Disp.colorBlue; + else if (CM.Cache[target][i].roi == CM.Cache.min) color = CM.Disp.colorGreen; + else if (CM.Cache[target][i].roi == CM.Cache.max) color = CM.Disp.colorRed; + else if (CM.Cache[target][i].roi > CM.Cache.max) color = CM.Disp.colorPurple; + else if (CM.Cache[target][i].roi > CM.Cache.mid) color = CM.Disp.colorOrange; else color = CM.Disp.colorYellow; CM.Cache[target][i].color = color; } } -CM.Cache.RemakeBCI = function() { +CM.Cache.RemakeROI = function() { // Buildings for 1 amount - CM.Cache.RemakeBuildingsBCI(); + CM.Cache.RemakeBuildingsROI(); // Upgrades - CM.Cache.RemakeUpgradeBCI(); + CM.Cache.RemakeUpgradeROI(); // Buildings for 10 amount - CM.Cache.RemakeBuildingsOtherBCI(10, 'Objects10'); + CM.Cache.RemakeBuildingsOtherROI(10, 'Objects10'); // Buildings for 100 amount - CM.Cache.RemakeBuildingsOtherBCI(100, 'Objects100'); + CM.Cache.RemakeBuildingsOtherROI(100, 'Objects100'); } CM.Cache.RemakeLucky = function() { @@ -189,6 +191,9 @@ CM.Cache.RemakeSellForChoEgg = function() { CM.Cache.SellForChoEgg = sellTotal; } +CM.Cache.min = -1; +CM.Cache.max = -1; +CM.Cache.mid = -1; CM.Cache.Lucky = 0; CM.Cache.LuckyReward = 0; CM.Cache.LuckyFrenzy = 0; diff --git a/src/Config.js b/src/Config.js index e0d2678..a6ea9ff 100644 --- a/src/Config.js +++ b/src/Config.js @@ -119,7 +119,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.UpBarColor = {label: ['Upgrade Bar/Colors OFF', 'Upgrade Bar/Colors ON'], desc: 'Color code upgrades and add a counter', toggle: true, func: function() {CM.Disp.ToggleUpBarColor();}}; -CM.ConfigData.Colors = {desc: {Blue: 'Color Blue. Used to show better than best BCI building, for Click Frenzy bar, and for various labels', Green: 'Color Green. Used to show best BCI building, for Blood Frenzy bar, and for various labels', Yellow: 'Color Yellow. Used to show between best and worst BCI buildings closer to best, for Frenzy bar, and for various labels', Orange: 'Color Orange. Used to show between best and worst BCI buildings closer to worst, for Next Reindeer bar, and for various labels', Red: 'Color Red. Used to show worst BCI building, for Clot bar, and for various labels', Purple: 'Color Purple. Used to show worse than worst BCI building, for Next Cookie bar, and for various labels', Gray: 'Color Gray. Used to show negative or infinity BCI, and for Next Cookie/Next Reindeer bar', Pink: 'Color Pink. Used for Dragonflight bar', Brown: 'Color Brown. Used for Dragon Harvest bar'}, func: function() {CM.Disp.UpdateColors();}}; +CM.ConfigData.Colors = {desc: {Blue: 'Color Blue. Used to show better than best ROI building, for Click Frenzy bar, and for various labels', Green: 'Color Green. Used to show best ROI building, for Blood Frenzy bar, and for various labels', Yellow: 'Color Yellow. Used to show between best and worst ROI buildings closer to best, for Frenzy bar, and for various labels', Orange: 'Color Orange. Used to show between best and worst ROI buildings closer to worst, for Next Reindeer bar, and for various labels', Red: 'Color Red. Used to show worst ROI building, for Clot bar, and for various labels', Purple: 'Color Purple. Used to show worse than worst ROI building, for Next Cookie bar, and for various labels', Gray: 'Color Gray. Used to show negative or infinity ROI, and for Next Cookie/Next Reindeer bar', Pink: 'Color Pink. Used for Dragonflight bar', Brown: 'Color Brown. Used for Dragon Harvest bar'}, func: function() {CM.Disp.UpdateColors();}}; CM.ConfigData.Flash = {label: ['Flash OFF', 'Flash ON'], desc: 'Flash screen on Golden Cookie/Season Popup', toggle: true}; CM.ConfigData.Sound = {label: ['Sounds OFF', 'Sounds ON'], desc: 'Play a sound on Golden Cookie/Season Popup', toggle: true}; CM.ConfigData.Volume = {label: [], desc: 'Volume of the sound'}; diff --git a/src/Disp.js b/src/Disp.js index 4874ab3..cddb867 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -148,9 +148,9 @@ CM.Disp.CreateBotBar = function() { var bonus = document.createElement('tr'); bonus.appendChild(firstCol('Bonus Income', CM.Disp.colorBlue)); tbody.appendChild(bonus); - var bci = document.createElement('tr'); - bci.appendChild(firstCol('Base Cost Per Income', CM.Disp.colorBlue)); - tbody.appendChild(bci); + var roi = document.createElement('tr'); + roi.appendChild(firstCol('Return On Investment', CM.Disp.colorBlue)); + tbody.appendChild(roi); var time = document.createElement('tr'); time.appendChild(firstCol('Time Left', CM.Disp.colorBlue)); tbody.appendChild(time); @@ -164,7 +164,7 @@ CM.Disp.CreateBotBar = function() { header.appendChild(document.createTextNode(')')); type.appendChild(header); bonus.appendChild(document.createElement('td')); - bci.appendChild(document.createElement('td')); + roi.appendChild(document.createElement('td')); time.appendChild(document.createElement('td')); } @@ -194,7 +194,7 @@ CM.Disp.UpdateBotBarOther = function() { 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].bci, 2); + CM.Disp.BotBar.firstChild.firstChild.childNodes[2].childNodes[count].textContent = Beautify(CM.Cache.Objects[i].roi, 2); } } } @@ -446,13 +446,13 @@ CM.Disp.UpdateBuildings = function() { if (CM.Config.BuildColor == 1 && Game.buyMode == 1) { var target = ''; if (Game.buyBulk == 10) { - target = 'Objects10' + target = 'Objects10'; } else if (Game.buyBulk == 100) { - target = 'Objects100' + target = 'Objects100'; } else { - target = 'Objects' + target = 'Objects'; } for (var i in CM.Cache[target]) { l('productPrice' + Game.Objects[i].id).style.color = CM.Config.Colors[CM.Cache[target][i].color]; @@ -499,13 +499,13 @@ CM.Disp.CreateUpgradeBar = function() { return div; } - legend.appendChild(legendLine(CM.Disp.colorBlue, 'Better than best BCI building')); - legend.appendChild(legendLine(CM.Disp.colorGreen, 'Same as best BCI building')); - legend.appendChild(legendLine(CM.Disp.colorYellow, 'Between best and worst BCI buildings closer to best')); - legend.appendChild(legendLine(CM.Disp.colorOrange, 'Between best and worst BCI buildings closer to worst')); - legend.appendChild(legendLine(CM.Disp.colorRed, 'Same as worst BCI building')); - legend.appendChild(legendLine(CM.Disp.colorPurple, 'Worse than worst BCI building')); - legend.appendChild(legendLine(CM.Disp.colorGray, 'Negative or infinity BCI')); + legend.appendChild(legendLine(CM.Disp.colorBlue, 'Better than best ROI building')); + legend.appendChild(legendLine(CM.Disp.colorGreen, 'Same as best ROI building')); + legend.appendChild(legendLine(CM.Disp.colorYellow, 'Between best and worst ROI buildings closer to best')); + legend.appendChild(legendLine(CM.Disp.colorOrange, 'Between best and worst ROI buildings closer to worst')); + legend.appendChild(legendLine(CM.Disp.colorRed, 'Same as worst ROI building')); + legend.appendChild(legendLine(CM.Disp.colorPurple, 'Worse than worst ROI building')); + legend.appendChild(legendLine(CM.Disp.colorGray, 'Negative or infinity ROI')); placeholder.appendChild(legend); CM.Disp.UpgradeBar.onmouseover = function() {Game.tooltip.draw(this, escape(placeholder.innerHTML), 'store');}; @@ -1486,11 +1486,11 @@ CM.Disp.Tooltip = function(type, name) { income.style.color = 'white'; income.id = 'CMTooltipIncome'; tooltip.appendChild(income); - tooltip.appendChild(header('Base Cost Per Income')); - var bci = document.createElement('div'); - bci.style.marginBottom = '4px'; - bci.id = 'CMTooltipBCI'; - tooltip.appendChild(bci); + tooltip.appendChild(header('Return On Investment')); + var roi = document.createElement('div'); + roi.style.marginBottom = '4px'; + roi.id = 'CMTooltipROI'; + tooltip.appendChild(roi); tooltip.appendChild(header('Time Left')); var time = document.createElement('div'); time.id = 'CMTooltipTime'; @@ -1528,8 +1528,8 @@ CM.Disp.UpdateTooltip = function() { bonus = CM.Cache[target][CM.Disp.tooltipName].bonus; if (CM.Config.Tooltip == 1 && Game.buyMode == 1) { l('CMTooltipBorder').className = CM.Disp.colorTextPre + CM.Cache[target][CM.Disp.tooltipName].color; - l('CMTooltipBCI').textContent = Beautify(CM.Cache[target][CM.Disp.tooltipName].bci, 2); - l('CMTooltipBCI').className = CM.Disp.colorTextPre + CM.Cache[target][CM.Disp.tooltipName].color; + l('CMTooltipROI').textContent = Beautify(CM.Cache[target][CM.Disp.tooltipName].roi, 2); + l('CMTooltipROI').className = CM.Disp.colorTextPre + CM.Cache[target][CM.Disp.tooltipName].color; } } else { // Upgrades @@ -1537,8 +1537,8 @@ CM.Disp.UpdateTooltip = function() { price = Game.Upgrades[Game.UpgradesInStore[CM.Disp.tooltipName].name].getPrice(); if (CM.Config.Tooltip == 1) { l('CMTooltipBorder').className = CM.Disp.colorTextPre + CM.Cache.Upgrades[Game.UpgradesInStore[CM.Disp.tooltipName].name].color; - l('CMTooltipBCI').textContent = Beautify(CM.Cache.Upgrades[Game.UpgradesInStore[CM.Disp.tooltipName].name].bci, 2); - l('CMTooltipBCI').className = CM.Disp.colorTextPre + CM.Cache.Upgrades[Game.UpgradesInStore[CM.Disp.tooltipName].name].color; + l('CMTooltipROI').textContent = Beautify(CM.Cache.Upgrades[Game.UpgradesInStore[CM.Disp.tooltipName].name].roi, 2); + l('CMTooltipROI').className = CM.Disp.colorTextPre + CM.Cache.Upgrades[Game.UpgradesInStore[CM.Disp.tooltipName].name].color; } } if (CM.Config.Tooltip == 1 && (CM.Disp.tooltipType != 'b' || Game.buyMode == 1)) { @@ -1712,9 +1712,6 @@ CM.Disp.RefreshScale = function() { CM.Disp.UpdateUpgrades(); } -CM.Disp.min = -1; -CM.Disp.max = -1; -CM.Disp.mid = -1; CM.Disp.colorTextPre = 'CMText'; CM.Disp.colorBackPre = 'CMBack'; CM.Disp.colorBorderPre = 'CMBorder'; @@ -1730,8 +1727,6 @@ 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.lastGoldenCookieState = 'none'; CM.Disp.lastAscendState = -1; -CM.Disp.lastBuyMode = -1; -CM.Disp.lastBuyBulk = -1; 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']; diff --git a/src/Main.js b/src/Main.js index 04151dc..0076180 100644 --- a/src/Main.js +++ b/src/Main.js @@ -86,33 +86,22 @@ CM.Loop = function() { if (!Game.OnAscend && Game.AscendTimer == 0) { if (CM.Sim.DoSims) { CM.Cache.RemakeIncome(); - CM.Cache.RemakeBCI(); CM.Cache.RemakeLucky(); CM.Cache.RemakeChain(); CM.Cache.RemakeSeaSpec(); CM.Cache.RemakeSellForChoEgg(); - - CM.Disp.UpdateBotBarOther(); - CM.Disp.UpdateBuildings(); - CM.Disp.UpdateUpgrades(); CM.Sim.DoSims = 0; } - // Update Buildings Color for different buy/sell modes - var updateBuildings = false; - if (CM.Disp.lastBuyMode != Game.buyMode) { - CM.Disp.lastBuyMode = Game.buyMode; - updateBuildings = true; - } - if (CM.Disp.lastBuyBulk != Game.buyBulk) { - CM.Disp.lastBuyBulk = Game.buyBulk; - updateBuildings = true; - } - if (updateBuildings) { - CM.Disp.UpdateBuildings(); - } + // Calculate ROI + CM.Cache.RemakeROI(); + // Update colors + CM.Disp.UpdateBotBarOther(); + CM.Disp.UpdateBuildings(); + CM.Disp.UpdateUpgrades(); + // Redraw timers CM.Disp.UpdateBotBarTime(); CM.Disp.UpdateTimerBar(); diff --git a/src/Sim.js b/src/Sim.js index 1c98632..fb7d962 100644 --- a/src/Sim.js +++ b/src/Sim.js @@ -357,6 +357,9 @@ CM.Sim.BuyBuildings = function(amount, target) { CM.Cache[target][i] = {}; CM.Cache[target][i].bonus = CM.Sim.cookiesPs - Game.cookiesPs; + if (amount != 1) { + CM.Cache[target][i].price = CM.Sim.BuildingGetPrice(Game.Objects[i].basePrice, Game.Objects[i].amount, Game.Objects[i].free, amount); + } } }