diff --git a/CookieMonster.js b/CookieMonster.js index 57856cf..9b4148f 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -30,6 +30,13 @@ CM.Cache.NextNumber = function(base) { return (base + count); } +CM.Cache.RemakeBuildingsPrices = function() { + for (var i in Game.Objects) { + CM.Cache.Objects10[i].price = CM.Sim.BuildingGetPrice(Game.Objects[i].basePrice, Game.Objects[i].amount, Game.Objects[i].free, 10); + CM.Cache.Objects100[i].price = CM.Sim.BuildingGetPrice(Game.Objects[i].basePrice, Game.Objects[i].amount, Game.Objects[i].free, 100); + } +} + CM.Cache.RemakeIncome = function() { // Simulate Building Buys for 1 amount CM.Sim.BuyBuildings(1, 'Objects'); @@ -230,6 +237,8 @@ CM.Cache.ChainFrenzyReward = 0; CM.Cache.ChainFrenzyWrathReward = 0; CM.Cache.CentEgg = 0; CM.Cache.SellForChoEgg = 0; +CM.Cache.Title = ''; +CM.Cache.HadFierHoard = false; /********** * Config * @@ -363,7 +372,7 @@ for (var i = 0; i < 101; i++) { CM.ConfigData.GCSoundURL = {label: 'Golden Cookie Sound URL:', desc: 'URL of the sound to be played when a Golden Cookie spawns'}; CM.ConfigData.SeaSoundURL = {label: 'Season Special Sound URL:', desc: 'URL of the sound to be played when a Season Special spawns'}; CM.ConfigData.GCTimer = {label: ['Golden Cookie Timer OFF', 'Golden Cookie Timer ON'], desc: 'A timer on the Golden Cookie when it has been spawned', toggle: true, func: function() {CM.Disp.ToggleGCTimer();}}; -CM.ConfigData.Title = {label: ['Title OFF', 'Title ON'], desc: 'Update title with Golden Cookie/Season Popup timers', toggle: true}; +CM.ConfigData.Title = {label: ['Title OFF', 'Title ON', 'Title Pinned Tab Highlight'], desc: 'Update title with Golden Cookie/Season Popup timers; pinned tab highlight only changes the title when a Golden Cookie/Season Popup spawns', toggle: true}; CM.ConfigData.Favicon = {label: ['Favicon OFF', 'Favicon ON'], desc: 'Update favicon with Golden/Wrath Cookie', toggle: true, func: function() {CM.Disp.UpdateFavicon();}}; CM.ConfigData.Tooltip = {label: ['Tooltip Information OFF', 'Tooltip Information ON'], desc: 'Extra information in tooltip for buildings/upgrades', toggle: true}; CM.ConfigData.TooltipAmor = {label: ['Tooltip Amortization Information OFF', 'Tooltip Amortization Information ON'], desc: 'Add amortization information to buildings tooltip', toggle: true}; @@ -1112,7 +1121,10 @@ CM.Disp.EmphSeasonPopup = function() { } CM.Disp.UpdateTitle = function() { - if (CM.Config.Title == 1) { + if (Game.OnAscend || CM.Config.Title == 0) { + document.title = CM.Cache.Title; + } + else if (CM.Config.Title == 1) { var addSP = false; var titleGC; @@ -1141,13 +1153,35 @@ CM.Disp.UpdateTitle = function() { } } - var str = document.title; + var str = CM.Cache.Title; if (str.charAt(0) == '[') { str = str.substring(str.lastIndexOf(']') + 1); } document.title = titleGC + (addSP ? titleSP : '') + ' ' + str; } + else if (CM.Config.Title == 2) { + var str = ''; + var spawn = false; + if (l('goldenCookie').style.display != 'none') { + spawn = true; + if (Game.goldenCookie.wrath) { + str += '[W ' + Math.ceil(Game.goldenCookie.life / Game.fps) + ']'; + } + else { + str += '[G ' + Math.ceil(Game.goldenCookie.life / Game.fps) + ']'; + } + } + if (Game.season=='christmas' && l('seasonPopup').style.display != 'none') { + str += '[R ' + Math.ceil(Game.seasonPopup.life / Game.fps) + ']'; + spawn = true; + } + if (spawn) str += ' - '; + var title = 'Cookie Clicker'; + if (Game.season == 'fools') title = 'Cookie Baker'; + str += title; + document.title = str; + } } CM.Disp.CollectWrinklers = function() { @@ -1673,7 +1707,7 @@ CM.Disp.AddMenuStats = function(title) { stats.appendChild(listing(listingQuest('Chocolate Egg Cookies', 'ChoEggTooltipPlaceholder'), document.createTextNode(Beautify(choEggTotal)))); } if (centEgg) { - stats.appendChild(listing('Century Egg Multiplier', document.createTextNode(Beautify(CM.Cache.CentEgg, 1) + '%'))); + stats.appendChild(listing('Century Egg Multiplier', document.createTextNode((Math.round(CM.Cache.CentEgg * 100) / 100) + '%'))); } } } @@ -1703,7 +1737,7 @@ CM.Disp.AddMenu = function() { } CM.Disp.RefreshMenu = function() { - if (CM.Config.UpStats && Game.onMenu == 'stats' && Game.drawT % (Game.fps * 5) != 0 && Game.drawT % Game.fps == 0) Game.UpdateMenu(); + if (CM.Config.UpStats && Game.onMenu == 'stats' && (Game.drawT - 1) % (Game.fps * 5) != 0 && (Game.drawT - 1) % Game.fps == 0) Game.UpdateMenu(); } CM.Disp.UpdateTooltipLocation = function() { @@ -1891,6 +1925,11 @@ CM.Disp.Tooltip = function(type, name) { CM.Disp.UpdateTooltip = function() { if (l('tooltipAnchor').style.display != 'none' && l('CMTooltipArea') != null) { + + // Error checking + if (CM.Disp.tooltipType == 'u' && (typeof Game.UpgradesInStore[CM.Disp.tooltipName] === 'undefined' || typeof CM.Cache.Upgrades[Game.UpgradesInStore[CM.Disp.tooltipName].name] === 'undefined')) { + return; + } var price; var bonus; if (CM.Disp.tooltipType == 'b') { @@ -2200,6 +2239,15 @@ CM.ReplaceNative = function() { CM.Backup.Loop(); CM.Loop(); } + + CM.Backup.Logic = Game.Logic; + eval('CM.Backup.LogicMod = ' + Game.Logic.toString().split('document.title').join('CM.Cache.Title')); + Game.Logic = function() { + CM.Backup.LogicMod(); + + // Update Title + CM.Disp.UpdateTitle(); + } } CM.Loop = function() { @@ -2221,6 +2269,21 @@ CM.Loop = function() { CM.Sim.DoSims = 0; } + var hasFierHoard = Game.hasAura('Fierce Hoarder'); + if (!CM.Cache.HadFierHoard && hasFierHoard) { + CM.Cache.HadFierHoard = true; + CM.Cache.DoRemakeBuildPrices = 1; + } + else if (CM.Cache.HadFierHoard && !hasFierHoard) { + CM.Cache.HadFierHoard = false; + CM.Cache.DoRemakeBuildPrices = 1; + } + + if (CM.Cache.DoRemakeBuildPrices) { + CM.Cache.RemakeBuildingsPrices(); + CM.Cache.DoRemakeBuildPrices = 0; + } + // Calculate ROI CM.Cache.RemakeROI(); @@ -2240,9 +2303,6 @@ CM.Loop = function() { CM.Disp.CheckWrinklerTooltip(); CM.Disp.UpdateWrinklerTooltip(); - // Update Title - CM.Disp.UpdateTitle(); - // Change menu refresh interval CM.Disp.RefreshMenu(); } @@ -2282,7 +2342,7 @@ CM.DelayInit = function() { CM.Disp.CreateTooltip('NextPrestTooltipPlaceholder', 'Not calculated with cookies gained from wrinklers or Chocolate egg', '200px'); CM.Disp.CreateTooltip('HeavenChipMaxTooltipPlaceholder', 'The MAX heavenly chips is calculated with the cookies gained from popping all wrinklers, selling all buildings with Earth Shatterer aura, and buying Chocolate egg', '310px'); CM.Disp.CreateTooltip('ResetTooltipPlaceholder', 'The bonus income you would get from new prestige levels at 100% of its potential and from reset achievements if you have the same buildings/upgrades after reset', '340px'); - CM.Disp.CreateTooltip('ChoEggTooltipPlaceholder', 'The amount of cookies you would get from popping all wrinklers, selling all buildings with Earth Shatterer aura, and then buying Chocolate egg', '290px'); + CM.Disp.CreateTooltip('ChoEggTooltipPlaceholder', 'The amount of cookies you would get from popping all wrinklers, selling all buildings with Earth Shatterer aura, and then buying Chocolate egg', '300px'); CM.Disp.CreateTooltipWarnCaut(); CM.Disp.AddTooltipBuild(); CM.Disp.AddWrinklerAreaDetect(); @@ -2666,7 +2726,7 @@ 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); + CM.Cache.DoRemakeBuildPrices = 1; } } } diff --git a/src/Cache.js b/src/Cache.js index 51d781b..96ea3da 100644 --- a/src/Cache.js +++ b/src/Cache.js @@ -10,6 +10,13 @@ CM.Cache.NextNumber = function(base) { return (base + count); } +CM.Cache.RemakeBuildingsPrices = function() { + for (var i in Game.Objects) { + CM.Cache.Objects10[i].price = CM.Sim.BuildingGetPrice(Game.Objects[i].basePrice, Game.Objects[i].amount, Game.Objects[i].free, 10); + CM.Cache.Objects100[i].price = CM.Sim.BuildingGetPrice(Game.Objects[i].basePrice, Game.Objects[i].amount, Game.Objects[i].free, 100); + } +} + CM.Cache.RemakeIncome = function() { // Simulate Building Buys for 1 amount CM.Sim.BuyBuildings(1, 'Objects'); @@ -210,4 +217,6 @@ CM.Cache.ChainFrenzyReward = 0; CM.Cache.ChainFrenzyWrathReward = 0; CM.Cache.CentEgg = 0; CM.Cache.SellForChoEgg = 0; +CM.Cache.Title = ''; +CM.Cache.HadFierHoard = false; diff --git a/src/Config.js b/src/Config.js index 6e511bf..6f09801 100644 --- a/src/Config.js +++ b/src/Config.js @@ -130,7 +130,7 @@ for (var i = 0; i < 101; i++) { CM.ConfigData.GCSoundURL = {label: 'Golden Cookie Sound URL:', desc: 'URL of the sound to be played when a Golden Cookie spawns'}; CM.ConfigData.SeaSoundURL = {label: 'Season Special Sound URL:', desc: 'URL of the sound to be played when a Season Special spawns'}; CM.ConfigData.GCTimer = {label: ['Golden Cookie Timer OFF', 'Golden Cookie Timer ON'], desc: 'A timer on the Golden Cookie when it has been spawned', toggle: true, func: function() {CM.Disp.ToggleGCTimer();}}; -CM.ConfigData.Title = {label: ['Title OFF', 'Title ON'], desc: 'Update title with Golden Cookie/Season Popup timers', toggle: true}; +CM.ConfigData.Title = {label: ['Title OFF', 'Title ON', 'Title Pinned Tab Highlight'], desc: 'Update title with Golden Cookie/Season Popup timers; pinned tab highlight only changes the title when a Golden Cookie/Season Popup spawns', toggle: true}; CM.ConfigData.Favicon = {label: ['Favicon OFF', 'Favicon ON'], desc: 'Update favicon with Golden/Wrath Cookie', toggle: true, func: function() {CM.Disp.UpdateFavicon();}}; CM.ConfigData.Tooltip = {label: ['Tooltip Information OFF', 'Tooltip Information ON'], desc: 'Extra information in tooltip for buildings/upgrades', toggle: true}; CM.ConfigData.TooltipAmor = {label: ['Tooltip Amortization Information OFF', 'Tooltip Amortization Information ON'], desc: 'Add amortization information to buildings tooltip', toggle: true}; diff --git a/src/Disp.js b/src/Disp.js index ba3d973..09621c1 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -726,7 +726,10 @@ CM.Disp.EmphSeasonPopup = function() { } CM.Disp.UpdateTitle = function() { - if (CM.Config.Title == 1) { + if (Game.OnAscend || CM.Config.Title == 0) { + document.title = CM.Cache.Title; + } + else if (CM.Config.Title == 1) { var addSP = false; var titleGC; @@ -755,13 +758,35 @@ CM.Disp.UpdateTitle = function() { } } - var str = document.title; + var str = CM.Cache.Title; if (str.charAt(0) == '[') { str = str.substring(str.lastIndexOf(']') + 1); } document.title = titleGC + (addSP ? titleSP : '') + ' ' + str; } + else if (CM.Config.Title == 2) { + var str = ''; + var spawn = false; + if (l('goldenCookie').style.display != 'none') { + spawn = true; + if (Game.goldenCookie.wrath) { + str += '[W ' + Math.ceil(Game.goldenCookie.life / Game.fps) + ']'; + } + else { + str += '[G ' + Math.ceil(Game.goldenCookie.life / Game.fps) + ']'; + } + } + if (Game.season=='christmas' && l('seasonPopup').style.display != 'none') { + str += '[R ' + Math.ceil(Game.seasonPopup.life / Game.fps) + ']'; + spawn = true; + } + if (spawn) str += ' - '; + var title = 'Cookie Clicker'; + if (Game.season == 'fools') title = 'Cookie Baker'; + str += title; + document.title = str; + } } CM.Disp.CollectWrinklers = function() { @@ -1287,7 +1312,7 @@ CM.Disp.AddMenuStats = function(title) { stats.appendChild(listing(listingQuest('Chocolate Egg Cookies', 'ChoEggTooltipPlaceholder'), document.createTextNode(Beautify(choEggTotal)))); } if (centEgg) { - stats.appendChild(listing('Century Egg Multiplier', document.createTextNode(Beautify(CM.Cache.CentEgg, 1) + '%'))); + stats.appendChild(listing('Century Egg Multiplier', document.createTextNode((Math.round(CM.Cache.CentEgg * 100) / 100) + '%'))); } } } @@ -1317,7 +1342,7 @@ CM.Disp.AddMenu = function() { } CM.Disp.RefreshMenu = function() { - if (CM.Config.UpStats && Game.onMenu == 'stats' && Game.drawT % (Game.fps * 5) != 0 && Game.drawT % Game.fps == 0) Game.UpdateMenu(); + if (CM.Config.UpStats && Game.onMenu == 'stats' && (Game.drawT - 1) % (Game.fps * 5) != 0 && (Game.drawT - 1) % Game.fps == 0) Game.UpdateMenu(); } CM.Disp.UpdateTooltipLocation = function() { @@ -1505,6 +1530,11 @@ CM.Disp.Tooltip = function(type, name) { CM.Disp.UpdateTooltip = function() { if (l('tooltipAnchor').style.display != 'none' && l('CMTooltipArea') != null) { + + // Error checking + if (CM.Disp.tooltipType == 'u' && (typeof Game.UpgradesInStore[CM.Disp.tooltipName] === 'undefined' || typeof CM.Cache.Upgrades[Game.UpgradesInStore[CM.Disp.tooltipName].name] === 'undefined')) { + return; + } var price; var bonus; if (CM.Disp.tooltipType == 'b') { diff --git a/src/Main.js b/src/Main.js index 141417a..be46d4b 100644 --- a/src/Main.js +++ b/src/Main.js @@ -76,6 +76,15 @@ CM.ReplaceNative = function() { CM.Backup.Loop(); CM.Loop(); } + + CM.Backup.Logic = Game.Logic; + eval('CM.Backup.LogicMod = ' + Game.Logic.toString().split('document.title').join('CM.Cache.Title')); + Game.Logic = function() { + CM.Backup.LogicMod(); + + // Update Title + CM.Disp.UpdateTitle(); + } } CM.Loop = function() { @@ -97,6 +106,21 @@ CM.Loop = function() { CM.Sim.DoSims = 0; } + var hasFierHoard = Game.hasAura('Fierce Hoarder'); + if (!CM.Cache.HadFierHoard && hasFierHoard) { + CM.Cache.HadFierHoard = true; + CM.Cache.DoRemakeBuildPrices = 1; + } + else if (CM.Cache.HadFierHoard && !hasFierHoard) { + CM.Cache.HadFierHoard = false; + CM.Cache.DoRemakeBuildPrices = 1; + } + + if (CM.Cache.DoRemakeBuildPrices) { + CM.Cache.RemakeBuildingsPrices(); + CM.Cache.DoRemakeBuildPrices = 0; + } + // Calculate ROI CM.Cache.RemakeROI(); @@ -116,9 +140,6 @@ CM.Loop = function() { CM.Disp.CheckWrinklerTooltip(); CM.Disp.UpdateWrinklerTooltip(); - // Update Title - CM.Disp.UpdateTitle(); - // Change menu refresh interval CM.Disp.RefreshMenu(); } @@ -158,7 +179,7 @@ CM.DelayInit = function() { CM.Disp.CreateTooltip('NextPrestTooltipPlaceholder', 'Not calculated with cookies gained from wrinklers or Chocolate egg', '200px'); CM.Disp.CreateTooltip('HeavenChipMaxTooltipPlaceholder', 'The MAX heavenly chips is calculated with the cookies gained from popping all wrinklers, selling all buildings with Earth Shatterer aura, and buying Chocolate egg', '310px'); CM.Disp.CreateTooltip('ResetTooltipPlaceholder', 'The bonus income you would get from new prestige levels at 100% of its potential and from reset achievements if you have the same buildings/upgrades after reset', '340px'); - CM.Disp.CreateTooltip('ChoEggTooltipPlaceholder', 'The amount of cookies you would get from popping all wrinklers, selling all buildings with Earth Shatterer aura, and then buying Chocolate egg', '290px'); + CM.Disp.CreateTooltip('ChoEggTooltipPlaceholder', 'The amount of cookies you would get from popping all wrinklers, selling all buildings with Earth Shatterer aura, and then buying Chocolate egg', '300px'); CM.Disp.CreateTooltipWarnCaut(); CM.Disp.AddTooltipBuild(); CM.Disp.AddWrinklerAreaDetect(); diff --git a/src/Sim.js b/src/Sim.js index c2952ee..84ee7fb 100644 --- a/src/Sim.js +++ b/src/Sim.js @@ -359,7 +359,7 @@ 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); + CM.Cache.DoRemakeBuildPrices = 1; } } }