From f9c4f68bb87cefdc5bdf58804e447bb162b90a72 Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Thu, 10 Dec 2020 22:13:26 +0100 Subject: [PATCH 1/6] Add config and replace-function for AuraInfo --- CookieMonster.js | 25 +++++++++++++++++++++++++ src/Data.js | 1 + src/Disp.js | 11 +++++++++++ src/Main.js | 13 +++++++++++++ 4 files changed, 50 insertions(+) diff --git a/CookieMonster.js b/CookieMonster.js index 88f9c03..143155e 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -874,6 +874,7 @@ CM.ConfigData.ToolWarnPos = {type: 'bool', group: 'Tooltip', label: ['Tooltip Wa CM.ConfigData.TooltipGrim = {type: 'bool', group: 'Tooltip', label: ['Grimoire Tooltip Information OFF', 'Grimoire Tooltip Information ON'], desc: 'Extra information in tooltip for grimoire', toggle: true}; CM.ConfigData.ToolWrink = {type: 'bool', group: 'Tooltip', 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 = {type: 'bool', group: 'Tooltip', label: ['Sugar Lump Tooltip OFF', 'Sugar Lump Tooltip ON'], desc: 'Shows the current Sugar Lump type in Sugar lump tooltip.', toggle: true}; +CM.ConfigData.DragonAuraInfo = {type: 'bool', group: 'Tooltip', label: ['Extra Dragon Aura OFF', 'Extra Dragon Aura ON'], desc: 'Shows information about changes in CPS and costs in the dragon aura interface.', toggle: true}; // Statistics CM.ConfigData.Stats = {type: 'bool', group: 'Statistics', label: ['Statistics OFF', 'Statistics ON'], desc: 'Extra Cookie Monster statistics!', toggle: true}; @@ -2654,6 +2655,17 @@ CM.Disp.UpdateWrinklerTooltip = function() { } } +/******** + * Section: Functions related to the dragon aura interface */ + +CM.Disp.AddAuraInfo = function() { + if (CM.Config.DragonAuraInfo == 1) { + console.log("Yes!") + } else { + console.log("No!") + } +} + /******** * Section: General functions related to the Options/Stats pages @@ -3608,6 +3620,18 @@ CM.ReplaceNative = function() { Game.CalculateGains(); } + + CM.Backup.DescribeDragonAura = Game.DescribeDragonAura; + /** + * This functions adds the function CM.Disp.AddAuraInfo() to Game.DescribeDragonAura() + * This adds information about CPS differences and costs to the aura choosing interface + * @param {number} aura The number of the aura current selected by the mouse/user + */ + Game.DescribeDragonAura = function(aura) { + CM.Backup.DescribeDragonAura(aura); + CM.Disp.AddAuraInfo(); + } + CM.Backup.UpdateMenu = Game.UpdateMenu; Game.UpdateMenu = function() { if (typeof jscolor.picker === 'undefined' || typeof jscolor.picker.owner === 'undefined') { @@ -4081,6 +4105,7 @@ CM.ConfigDefault = { TooltipGrim:1, ToolWrink: 1, TooltipLump: 1, + DragonAuraInfo: 1, Stats: 1, MissingUpgrades: 0, UpStats: 1, diff --git a/src/Data.js b/src/Data.js index b005688..ec95b30 100644 --- a/src/Data.js +++ b/src/Data.js @@ -162,6 +162,7 @@ CM.ConfigData.ToolWarnPos = {type: 'bool', group: 'Tooltip', label: ['Tooltip Wa CM.ConfigData.TooltipGrim = {type: 'bool', group: 'Tooltip', label: ['Grimoire Tooltip Information OFF', 'Grimoire Tooltip Information ON'], desc: 'Extra information in tooltip for grimoire', toggle: true}; CM.ConfigData.ToolWrink = {type: 'bool', group: 'Tooltip', 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 = {type: 'bool', group: 'Tooltip', label: ['Sugar Lump Tooltip OFF', 'Sugar Lump Tooltip ON'], desc: 'Shows the current Sugar Lump type in Sugar lump tooltip.', toggle: true}; +CM.ConfigData.DragonAuraInfo = {type: 'bool', group: 'Tooltip', label: ['Extra Dragon Aura OFF', 'Extra Dragon Aura ON'], desc: 'Shows information about changes in CPS and costs in the dragon aura interface.', toggle: true}; // Statistics CM.ConfigData.Stats = {type: 'bool', group: 'Statistics', label: ['Statistics OFF', 'Statistics ON'], desc: 'Extra Cookie Monster statistics!', toggle: true}; diff --git a/src/Disp.js b/src/Disp.js index df69041..065517c 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -1766,6 +1766,17 @@ CM.Disp.UpdateWrinklerTooltip = function() { } } +/******** + * Section: Functions related to the dragon aura interface */ + +CM.Disp.AddAuraInfo = function() { + if (CM.Config.DragonAuraInfo == 1) { + console.log("Yes!") + } else { + console.log("No!") + } +} + /******** * Section: General functions related to the Options/Stats pages diff --git a/src/Main.js b/src/Main.js index 23519fa..2067cd7 100644 --- a/src/Main.js +++ b/src/Main.js @@ -58,6 +58,18 @@ CM.ReplaceNative = function() { Game.CalculateGains(); } + + CM.Backup.DescribeDragonAura = Game.DescribeDragonAura; + /** + * This functions adds the function CM.Disp.AddAuraInfo() to Game.DescribeDragonAura() + * This adds information about CPS differences and costs to the aura choosing interface + * @param {number} aura The number of the aura current selected by the mouse/user + */ + Game.DescribeDragonAura = function(aura) { + CM.Backup.DescribeDragonAura(aura); + CM.Disp.AddAuraInfo(); + } + CM.Backup.UpdateMenu = Game.UpdateMenu; Game.UpdateMenu = function() { if (typeof jscolor.picker === 'undefined' || typeof jscolor.picker.owner === 'undefined') { @@ -531,6 +543,7 @@ CM.ConfigDefault = { TooltipGrim:1, ToolWrink: 1, TooltipLump: 1, + DragonAuraInfo: 1, Stats: 1, MissingUpgrades: 0, UpStats: 1, From 8ffc0a2664ea5ad399a1e77275af343a55ad0839 Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Thu, 10 Dec 2020 22:30:07 +0100 Subject: [PATCH 2/6] Added CM.Disp.AddAuraInfo() --- CookieMonster.js | 24 ++++++++++++++++++------ src/Disp.js | 20 ++++++++++++++++---- src/Main.js | 4 ++-- 3 files changed, 36 insertions(+), 12 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 143155e..1dfc4bf 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -2657,12 +2657,24 @@ CM.Disp.UpdateWrinklerTooltip = function() { /******** * Section: Functions related to the dragon aura interface */ - +/** + * This functions adds the two extra lines about CPS and time to recover to the aura picker infoscreen + * This adds information about CPS differences and costs to the aura choosing interface + * @param {number} aura The number of the aura currently selected by the mouse/user + */ CM.Disp.AddAuraInfo = function() { if (CM.Config.DragonAuraInfo == 1) { - console.log("Yes!") - } else { - console.log("No!") + console.log("called") + var bonusCPS = "TESTCPS"; + var bonusCPSPercentage = "TESTCPS%"; + var timeToRecover = "TESTTIME"; + l('dragonAuraInfo').style.minHeight = "90px" + l('dragonAuraInfo').appendChild(document.createElement("div")).className = "line" + var div = document.createElement("div"); + div.style.minWidth = "200px"; + div.style.textAlign = "center"; + div.textContent = "Picking this aura will change CPS by " + bonusCPS + " (" + bonusCPSPercentage + "% of current cps). It will take " + timeToRecover + " to recover the cost."; + l('dragonAuraInfo').appendChild(div); } } @@ -3625,11 +3637,11 @@ CM.ReplaceNative = function() { /** * This functions adds the function CM.Disp.AddAuraInfo() to Game.DescribeDragonAura() * This adds information about CPS differences and costs to the aura choosing interface - * @param {number} aura The number of the aura current selected by the mouse/user + * @param {number} aura The number of the aura currently selected by the mouse/user */ Game.DescribeDragonAura = function(aura) { CM.Backup.DescribeDragonAura(aura); - CM.Disp.AddAuraInfo(); + CM.Disp.AddAuraInfo(aura); } CM.Backup.UpdateMenu = Game.UpdateMenu; diff --git a/src/Disp.js b/src/Disp.js index 065517c..946dd25 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -1768,12 +1768,24 @@ CM.Disp.UpdateWrinklerTooltip = function() { /******** * Section: Functions related to the dragon aura interface */ - +/** + * This functions adds the two extra lines about CPS and time to recover to the aura picker infoscreen + * This adds information about CPS differences and costs to the aura choosing interface + * @param {number} aura The number of the aura currently selected by the mouse/user + */ CM.Disp.AddAuraInfo = function() { if (CM.Config.DragonAuraInfo == 1) { - console.log("Yes!") - } else { - console.log("No!") + console.log("called") + var bonusCPS = "TESTCPS"; + var bonusCPSPercentage = "TESTCPS%"; + var timeToRecover = "TESTTIME"; + l('dragonAuraInfo').style.minHeight = "90px" + l('dragonAuraInfo').appendChild(document.createElement("div")).className = "line" + var div = document.createElement("div"); + div.style.minWidth = "200px"; + div.style.textAlign = "center"; + div.textContent = "Picking this aura will change CPS by " + bonusCPS + " (" + bonusCPSPercentage + "% of current cps). It will take " + timeToRecover + " to recover the cost."; + l('dragonAuraInfo').appendChild(div); } } diff --git a/src/Main.js b/src/Main.js index 2067cd7..efc9e5c 100644 --- a/src/Main.js +++ b/src/Main.js @@ -63,11 +63,11 @@ CM.ReplaceNative = function() { /** * This functions adds the function CM.Disp.AddAuraInfo() to Game.DescribeDragonAura() * This adds information about CPS differences and costs to the aura choosing interface - * @param {number} aura The number of the aura current selected by the mouse/user + * @param {number} aura The number of the aura currently selected by the mouse/user */ Game.DescribeDragonAura = function(aura) { CM.Backup.DescribeDragonAura(aura); - CM.Disp.AddAuraInfo(); + CM.Disp.AddAuraInfo(aura); } CM.Backup.UpdateMenu = Game.UpdateMenu; From f72e95301c10a428ce94d62f748462542ebee5d3 Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Thu, 10 Dec 2020 22:31:26 +0100 Subject: [PATCH 3/6] Fixed some annotations in Sim.js --- CookieMonster.js | 9 ++++++--- src/Sim.js | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 1dfc4bf..7c69fee 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -4280,7 +4280,8 @@ CM.Sim.getCPSBuffMult = function() { return mult; } -/* Constructs an object with the static properties of a building, +/** + * Constructs an object with the static properties of a building, * but with a 'cps' method changed to use 'CM.Sim.Has' instead of 'Game.Has' * (and similar to 'hasAura', 'Objects', 'GetTieredCpsMult' and 'auraMult'). * @@ -4304,7 +4305,8 @@ CM.Sim.InitialBuildingData = function(buildingName) { return you; } -/* Similar to the previous function, but for upgrades. +/** + * Similar to the previous function, but for upgrades. * Note: currently no static data is used by Cookie Monster, * so this function just returns an empty object. */ @@ -4316,7 +4318,8 @@ CM.Sim.InitUpgrade = function(upgradeName) { return you; } -/* Similar to the previous function, but for achievements. +/** + * Similar to the previous function, but for achievements. * Note: currently no static data is used by Cookie Monster, * so this function just returns an empty object. */ diff --git a/src/Sim.js b/src/Sim.js index 8eb7f83..95fe7d5 100644 --- a/src/Sim.js +++ b/src/Sim.js @@ -142,7 +142,8 @@ CM.Sim.getCPSBuffMult = function() { return mult; } -/* Constructs an object with the static properties of a building, +/** + * Constructs an object with the static properties of a building, * but with a 'cps' method changed to use 'CM.Sim.Has' instead of 'Game.Has' * (and similar to 'hasAura', 'Objects', 'GetTieredCpsMult' and 'auraMult'). * @@ -166,7 +167,8 @@ CM.Sim.InitialBuildingData = function(buildingName) { return you; } -/* Similar to the previous function, but for upgrades. +/** + * Similar to the previous function, but for upgrades. * Note: currently no static data is used by Cookie Monster, * so this function just returns an empty object. */ @@ -178,7 +180,8 @@ CM.Sim.InitUpgrade = function(upgradeName) { return you; } -/* Similar to the previous function, but for achievements. +/** + * Similar to the previous function, but for achievements. * Note: currently no static data is used by Cookie Monster, * so this function just returns an empty object. */ From f13c9fb02d2e9565fd766e4388017501feffad6d Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Sun, 13 Dec 2020 21:50:04 +0100 Subject: [PATCH 4/6] Added Aura caching and changing --- CookieMonster.js | 87 ++++++++++++++++++++++++++++++++++++++++++------ src/Cache.js | 16 +++++++++ src/Disp.js | 24 ++++++++----- src/Sim.js | 46 +++++++++++++++++++++++-- 4 files changed, 152 insertions(+), 21 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 7c69fee..7785723 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -29,6 +29,16 @@ if (typeof CM == "undefined") { * Cache * *********/ +/** + * This functions caches the currently selected Dragon Auras + * It is called by CM.Sim.CopyData() and CM.Sim.InitData() + * Uncapitalized dragon follows Game-naming + */ +CM.Cache.CacheDragonAuras = function() { + CM.Cache.dragonAura = Game.dragonAura; + CM.Cache.dragonAura2 = Game.dragonAura2; +} + /******** * Section: UNSORTED */ @@ -557,7 +567,12 @@ CM.Cache.MissingCookiesString = null; CM.Cache.seasonPopShimmer; CM.Cache.goldenShimmersByID = {}; CM.Cache.spawnedGoldenShimmer = 0; -/********** + +/** + * This variables are used by CM.Cache.CacheDragonAuras(), naming follows naming in Game + */ +CM.Cache.dragonAura = 0; +CM.Cache.dragonAura2 = 0;/********** * Config * **********/ @@ -2657,24 +2672,32 @@ CM.Disp.UpdateWrinklerTooltip = function() { /******** * Section: Functions related to the dragon aura interface */ + /** * This functions adds the two extra lines about CPS and time to recover to the aura picker infoscreen - * This adds information about CPS differences and costs to the aura choosing interface + * It is called by Game.DescribeDragonAura() after CM.ReplaceNative() * @param {number} aura The number of the aura currently selected by the mouse/user */ -CM.Disp.AddAuraInfo = function() { +CM.Disp.AddAuraInfo = function(aura) { if (CM.Config.DragonAuraInfo == 1) { - console.log("called") - var bonusCPS = "TESTCPS"; - var bonusCPSPercentage = "TESTCPS%"; - var timeToRecover = "TESTTIME"; - l('dragonAuraInfo').style.minHeight = "90px" + var [bonusCPS, priceOfChange] = CM.Sim.CalculateChangeAura(aura); + var timeToRecover = CM.Disp.FormatTime(priceOfChange / (bonusCPS + Game.cookiesPs)); + var bonusCPSPercentage = CM.Disp.Beautify(bonusCPS / Game.cookiesPs); + bonusCPS = CM.Disp.Beautify(bonusCPS); + + l('dragonAuraInfo').style.minHeight = "60px" + l('dragonAuraInfo').style.margin = "8px" l('dragonAuraInfo').appendChild(document.createElement("div")).className = "line" var div = document.createElement("div"); div.style.minWidth = "200px"; div.style.textAlign = "center"; - div.textContent = "Picking this aura will change CPS by " + bonusCPS + " (" + bonusCPSPercentage + "% of current cps). It will take " + timeToRecover + " to recover the cost."; + div.textContent = "Picking this aura will change CPS by " + bonusCPS + " (" + bonusCPSPercentage + "% of current CPS)."; l('dragonAuraInfo').appendChild(div); + var div2 = document.createElement("div"); + div2.style.minWidth = "200px"; + div2.style.textAlign = "center"; + div2.textContent = "It will take " + timeToRecover + " to recover the cost."; + l('dragonAuraInfo').appendChild(div2); } } @@ -4345,6 +4368,9 @@ CM.Sim.InitData = function() { for (var i in Game.Achievements) { CM.Sim.Achievements[i] = CM.Sim.InitAchievement(i); } + + // Auras + CM.Cache.CacheDragonAuras(); } CM.Sim.CopyData = function() { @@ -4354,8 +4380,6 @@ CM.Sim.CopyData = function() { CM.Sim.AchievementsOwned = Game.AchievementsOwned; CM.Sim.heavenlyPower = Game.heavenlyPower; // Unneeded? > Might be modded CM.Sim.prestige = Game.prestige; - CM.Sim.dragonAura = Game.dragonAura; - CM.Sim.dragonAura2 = Game.dragonAura2; // Buildings for (var i in Game.Objects) { @@ -4368,6 +4392,8 @@ CM.Sim.CopyData = function() { you.amount = me.amount; you.level = me.level; you.totalCookies = me.totalCookies; + you.basePrice = me.basePrice; + you.free = me.free; if (me.minigameLoaded) you.minigameLoaded = me.minigameLoaded; you.minigame = me.minigame; } @@ -4390,6 +4416,11 @@ CM.Sim.CopyData = function() { } you.won = me.won; } + + // Auras + CM.Cache.CacheDragonAuras(); + CM.Sim.dragonAura = CM.Cache.dragonAura; + CM.Sim.dragonAura2 = CM.Cache.dragonAura2; }; CM.Sim.CalculateGains = function() { @@ -4758,6 +4789,40 @@ CM.Sim.BuyUpgrades = function() { } } +CM.Sim.CalculateChangeAura = function(aura) { + CM.Sim.CopyData(); + + // Check if aura being changed is first or second aura + var auraToBeChanged = l('promptContent').children[0].innerHTML.includes("secondary") + if (auraToBeChanged) CM.Sim.dragonAura2 = aura; + else CM.Sim.dragonAura = aura; + + // Sell highest building but only if aura is different + if (CM.Sim.dragonAura != CM.Cache.dragonAura || CM.Sim.dragonAura2 != CM.Cache.dragonAura2) { + for (var i = Game.ObjectsById.length; i > -1, --i;) { + if (Game.ObjectsById[i].amount > 0) { + var highestBuilding = CM.Sim.Objects[Game.ObjectsById[i].name].name; + CM.Sim.Objects[highestBuilding].amount -=1; + CM.Sim.buildingsOwned -= 1; + break + } + } + // This calculates price of highest building + var price = CM.Sim.Objects[highestBuilding].basePrice * Math.pow(Game.priceIncrease, Math.max(0, CM.Sim.Objects[highestBuilding].amount - 1 -CM.Sim.Objects[highestBuilding].free)); + price = Game.modifyBuildingPrice(CM.Sim.Objects[highestBuilding], price); + price = Math.ceil(price); + } else var price = 0; + + var lastAchievementsOwned = CM.Sim.AchievementsOwned; + CM.Sim.CalculateGains(); + + CM.Sim.CheckOtherAchiev(); + if (lastAchievementsOwned != CM.Sim.AchievementsOwned) { + CM.Sim.CalculateGains(); + } + return [CM.Sim.cookiesPs - Game.cookiesPs, price] +} + CM.Sim.NoGoldSwitchCookiesPS = function() { if (Game.Has('Golden switch [off]')) { CM.Sim.CopyData(); diff --git a/src/Cache.js b/src/Cache.js index b3a08ed..84eb53a 100644 --- a/src/Cache.js +++ b/src/Cache.js @@ -2,6 +2,16 @@ * Cache * *********/ +/** + * This functions caches the currently selected Dragon Auras + * It is called by CM.Sim.CopyData() and CM.Sim.InitData() + * Uncapitalized dragon follows Game-naming + */ +CM.Cache.CacheDragonAuras = function() { + CM.Cache.dragonAura = Game.dragonAura; + CM.Cache.dragonAura2 = Game.dragonAura2; +} + /******** * Section: UNSORTED */ @@ -530,3 +540,9 @@ CM.Cache.MissingCookiesString = null; CM.Cache.seasonPopShimmer; CM.Cache.goldenShimmersByID = {}; CM.Cache.spawnedGoldenShimmer = 0; + +/** + * This variables are used by CM.Cache.CacheDragonAuras(), naming follows naming in Game + */ +CM.Cache.dragonAura = 0; +CM.Cache.dragonAura2 = 0; \ No newline at end of file diff --git a/src/Disp.js b/src/Disp.js index 946dd25..06f2399 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -1768,24 +1768,32 @@ CM.Disp.UpdateWrinklerTooltip = function() { /******** * Section: Functions related to the dragon aura interface */ + /** * This functions adds the two extra lines about CPS and time to recover to the aura picker infoscreen - * This adds information about CPS differences and costs to the aura choosing interface + * It is called by Game.DescribeDragonAura() after CM.ReplaceNative() * @param {number} aura The number of the aura currently selected by the mouse/user */ -CM.Disp.AddAuraInfo = function() { +CM.Disp.AddAuraInfo = function(aura) { if (CM.Config.DragonAuraInfo == 1) { - console.log("called") - var bonusCPS = "TESTCPS"; - var bonusCPSPercentage = "TESTCPS%"; - var timeToRecover = "TESTTIME"; - l('dragonAuraInfo').style.minHeight = "90px" + var [bonusCPS, priceOfChange] = CM.Sim.CalculateChangeAura(aura); + var timeToRecover = CM.Disp.FormatTime(priceOfChange / (bonusCPS + Game.cookiesPs)); + var bonusCPSPercentage = CM.Disp.Beautify(bonusCPS / Game.cookiesPs); + bonusCPS = CM.Disp.Beautify(bonusCPS); + + l('dragonAuraInfo').style.minHeight = "60px" + l('dragonAuraInfo').style.margin = "8px" l('dragonAuraInfo').appendChild(document.createElement("div")).className = "line" var div = document.createElement("div"); div.style.minWidth = "200px"; div.style.textAlign = "center"; - div.textContent = "Picking this aura will change CPS by " + bonusCPS + " (" + bonusCPSPercentage + "% of current cps). It will take " + timeToRecover + " to recover the cost."; + div.textContent = "Picking this aura will change CPS by " + bonusCPS + " (" + bonusCPSPercentage + "% of current CPS)."; l('dragonAuraInfo').appendChild(div); + var div2 = document.createElement("div"); + div2.style.minWidth = "200px"; + div2.style.textAlign = "center"; + div2.textContent = "It will take " + timeToRecover + " to recover the cost."; + l('dragonAuraInfo').appendChild(div2); } } diff --git a/src/Sim.js b/src/Sim.js index 95fe7d5..f32dbcc 100644 --- a/src/Sim.js +++ b/src/Sim.js @@ -207,6 +207,9 @@ CM.Sim.InitData = function() { for (var i in Game.Achievements) { CM.Sim.Achievements[i] = CM.Sim.InitAchievement(i); } + + // Auras + CM.Cache.CacheDragonAuras(); } CM.Sim.CopyData = function() { @@ -216,8 +219,6 @@ CM.Sim.CopyData = function() { CM.Sim.AchievementsOwned = Game.AchievementsOwned; CM.Sim.heavenlyPower = Game.heavenlyPower; // Unneeded? > Might be modded CM.Sim.prestige = Game.prestige; - CM.Sim.dragonAura = Game.dragonAura; - CM.Sim.dragonAura2 = Game.dragonAura2; // Buildings for (var i in Game.Objects) { @@ -230,6 +231,8 @@ CM.Sim.CopyData = function() { you.amount = me.amount; you.level = me.level; you.totalCookies = me.totalCookies; + you.basePrice = me.basePrice; + you.free = me.free; if (me.minigameLoaded) you.minigameLoaded = me.minigameLoaded; you.minigame = me.minigame; } @@ -252,6 +255,11 @@ CM.Sim.CopyData = function() { } you.won = me.won; } + + // Auras + CM.Cache.CacheDragonAuras(); + CM.Sim.dragonAura = CM.Cache.dragonAura; + CM.Sim.dragonAura2 = CM.Cache.dragonAura2; }; CM.Sim.CalculateGains = function() { @@ -620,6 +628,40 @@ CM.Sim.BuyUpgrades = function() { } } +CM.Sim.CalculateChangeAura = function(aura) { + CM.Sim.CopyData(); + + // Check if aura being changed is first or second aura + var auraToBeChanged = l('promptContent').children[0].innerHTML.includes("secondary") + if (auraToBeChanged) CM.Sim.dragonAura2 = aura; + else CM.Sim.dragonAura = aura; + + // Sell highest building but only if aura is different + if (CM.Sim.dragonAura != CM.Cache.dragonAura || CM.Sim.dragonAura2 != CM.Cache.dragonAura2) { + for (var i = Game.ObjectsById.length; i > -1, --i;) { + if (Game.ObjectsById[i].amount > 0) { + var highestBuilding = CM.Sim.Objects[Game.ObjectsById[i].name].name; + CM.Sim.Objects[highestBuilding].amount -=1; + CM.Sim.buildingsOwned -= 1; + break + } + } + // This calculates price of highest building + var price = CM.Sim.Objects[highestBuilding].basePrice * Math.pow(Game.priceIncrease, Math.max(0, CM.Sim.Objects[highestBuilding].amount - 1 -CM.Sim.Objects[highestBuilding].free)); + price = Game.modifyBuildingPrice(CM.Sim.Objects[highestBuilding], price); + price = Math.ceil(price); + } else var price = 0; + + var lastAchievementsOwned = CM.Sim.AchievementsOwned; + CM.Sim.CalculateGains(); + + CM.Sim.CheckOtherAchiev(); + if (lastAchievementsOwned != CM.Sim.AchievementsOwned) { + CM.Sim.CalculateGains(); + } + return [CM.Sim.cookiesPs - Game.cookiesPs, price] +} + CM.Sim.NoGoldSwitchCookiesPS = function() { if (Game.Has('Golden switch [off]')) { CM.Sim.CopyData(); From 15b859e8b9e1a0b737a2e0051233d124efe003f7 Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Sun, 13 Dec 2020 21:50:39 +0100 Subject: [PATCH 5/6] Changed display of DragonAuraInfo in options --- CookieMonster.js | 2 +- src/Data.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 7785723..280ac51 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -889,7 +889,7 @@ CM.ConfigData.ToolWarnPos = {type: 'bool', group: 'Tooltip', label: ['Tooltip Wa CM.ConfigData.TooltipGrim = {type: 'bool', group: 'Tooltip', label: ['Grimoire Tooltip Information OFF', 'Grimoire Tooltip Information ON'], desc: 'Extra information in tooltip for grimoire', toggle: true}; CM.ConfigData.ToolWrink = {type: 'bool', group: 'Tooltip', 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 = {type: 'bool', group: 'Tooltip', label: ['Sugar Lump Tooltip OFF', 'Sugar Lump Tooltip ON'], desc: 'Shows the current Sugar Lump type in Sugar lump tooltip.', toggle: true}; -CM.ConfigData.DragonAuraInfo = {type: 'bool', group: 'Tooltip', label: ['Extra Dragon Aura OFF', 'Extra Dragon Aura ON'], desc: 'Shows information about changes in CPS and costs in the dragon aura interface.', toggle: true}; +CM.ConfigData.DragonAuraInfo = {type: 'bool', group: 'Tooltip', label: ['Extra Dragon Aura Info OFF', 'Extra Dragon Aura Info ON'], desc: 'Shows information about changes in CPS and costs in the dragon aura interface.', toggle: true}; // Statistics CM.ConfigData.Stats = {type: 'bool', group: 'Statistics', label: ['Statistics OFF', 'Statistics ON'], desc: 'Extra Cookie Monster statistics!', toggle: true}; diff --git a/src/Data.js b/src/Data.js index ec95b30..21cba91 100644 --- a/src/Data.js +++ b/src/Data.js @@ -162,7 +162,7 @@ CM.ConfigData.ToolWarnPos = {type: 'bool', group: 'Tooltip', label: ['Tooltip Wa CM.ConfigData.TooltipGrim = {type: 'bool', group: 'Tooltip', label: ['Grimoire Tooltip Information OFF', 'Grimoire Tooltip Information ON'], desc: 'Extra information in tooltip for grimoire', toggle: true}; CM.ConfigData.ToolWrink = {type: 'bool', group: 'Tooltip', 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 = {type: 'bool', group: 'Tooltip', label: ['Sugar Lump Tooltip OFF', 'Sugar Lump Tooltip ON'], desc: 'Shows the current Sugar Lump type in Sugar lump tooltip.', toggle: true}; -CM.ConfigData.DragonAuraInfo = {type: 'bool', group: 'Tooltip', label: ['Extra Dragon Aura OFF', 'Extra Dragon Aura ON'], desc: 'Shows information about changes in CPS and costs in the dragon aura interface.', toggle: true}; +CM.ConfigData.DragonAuraInfo = {type: 'bool', group: 'Tooltip', label: ['Extra Dragon Aura Info OFF', 'Extra Dragon Aura Info ON'], desc: 'Shows information about changes in CPS and costs in the dragon aura interface.', toggle: true}; // Statistics CM.ConfigData.Stats = {type: 'bool', group: 'Statistics', label: ['Statistics OFF', 'Statistics ON'], desc: 'Extra Cookie Monster statistics!', toggle: true}; From 6a6a27680f1fd220ca6599b71f083a930d64578f Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Sun, 13 Dec 2020 21:54:29 +0100 Subject: [PATCH 6/6] Annotated CM.Sim.CalculateChangeAura --- CookieMonster.js | 6 ++++++ src/Sim.js | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/CookieMonster.js b/CookieMonster.js index 280ac51..119ad03 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -4789,6 +4789,12 @@ CM.Sim.BuyUpgrades = function() { } } +/** + * This functions calculates the cps and cost of changing a Dragon Aura + * It is called by CM.Disp.AddAuraInfo() + * @param {number} aura The number of the aura currently selected by the mouse/user + * @returns {[number, number]} [CM.Sim.cookiesPs - Game.cookiesPs, price] The bonus cps and the price of the change + */ CM.Sim.CalculateChangeAura = function(aura) { CM.Sim.CopyData(); diff --git a/src/Sim.js b/src/Sim.js index f32dbcc..fe9bc60 100644 --- a/src/Sim.js +++ b/src/Sim.js @@ -628,6 +628,12 @@ CM.Sim.BuyUpgrades = function() { } } +/** + * This functions calculates the cps and cost of changing a Dragon Aura + * It is called by CM.Disp.AddAuraInfo() + * @param {number} aura The number of the aura currently selected by the mouse/user + * @returns {[number, number]} [CM.Sim.cookiesPs - Game.cookiesPs, price] The bonus cps and the price of the change + */ CM.Sim.CalculateChangeAura = function(aura) { CM.Sim.CopyData();