From 564d136df3c292276229b7f183f2c005d10a1dc0 Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Sat, 28 Nov 2020 12:41:26 +0100 Subject: [PATCH 1/4] Cleaned up CM.Sim.CalculateGains and added TODOs --- CookieMonster.js | 56 +++++++++++++++++++++++++++++------------------- src/Sim.js | 53 ++++++++++++++++++++++++++++----------------- 2 files changed, 67 insertions(+), 42 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 0587e53..b1bbd09 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -3577,6 +3577,8 @@ CM.Sim.hasAura = function(what) { return false; } +// Check if multiplier auras are present +// Used as CM.Sim.auraMult('Aura') * mult, i.e. CM.Sim.auraMult('Dragon God) * 0.05 CM.Sim.auraMult = function(what) { var n = 0; if (Game.dragonAuras[CM.Sim.dragonAura].name == what || Game.dragonAuras[CM.Sim.dragonAura2].name == what) @@ -3643,7 +3645,7 @@ CM.Sim.CopyData = function() { CM.Sim.UpgradesOwned = Game.UpgradesOwned; CM.Sim.pledges = Game.pledges; CM.Sim.AchievementsOwned = Game.AchievementsOwned; - CM.Sim.heavenlyPower = Game.heavenlyPower; // Unneeded? + CM.Sim.heavenlyPower = Game.heavenlyPower; // Unneeded? > Might be modded CM.Sim.prestige = Game.prestige; CM.Sim.dragonAura = Game.dragonAura; CM.Sim.dragonAura2 = Game.dragonAura2; @@ -3688,15 +3690,22 @@ CM.Sim.CopyData = function() { CM.Sim.CalculateGains = function() { CM.Sim.cookiesPs = 0; var mult = 1; - + // Include minigame effects + for (var i in CM.Cache.Objects) { + // TODO Store minigames and effects in Cache + // Include possibility of new/modded building and new/modded minigames + if (Game.Objects[i].minigameLoaded && Game.Objects[i].minigame.effs) { + } + } + if (Game.ascensionMode != 1) mult += parseFloat(CM.Sim.prestige) * 0.01 * CM.Sim.heavenlyPower * CM.Sim.GetHeavenlyMultiplier(); - // TODO Store minigame buffs? mult *= Game.eff('cps'); - + if (CM.Sim.Has('Heralds') && Game.ascensionMode != 1) mult *= 1 + 0.01 * Game.heralds; - var cookieMult = 0; + // TODO: Make function call cached function where Game.Has is replaced with CM.Has + // Related to valentine cookies for (var i in Game.cookieUpgrades) { var me = Game.cookieUpgrades[i]; if (CM.Sim.Has(me.name)) { @@ -3704,7 +3713,6 @@ CM.Sim.CalculateGains = function() { } } - mult *= (1 + 0.01 * cookieMult); if (CM.Sim.Has('Specialized chocolate chips')) mult *= 1.01; if (CM.Sim.Has('Designer cocoa beans')) mult *= 1.02; if (CM.Sim.Has('Underworld ovens')) mult *= 1.03; @@ -3722,6 +3730,8 @@ CM.Sim.CalculateGains = function() { if (CM.Sim.Has('Dragon scale')) mult *= 1.03; + // Cached and sim temple gods + // TODO: Caches chosen gods var buildMult = 1; if (Game.hasGod) { var godLvl = Game.hasGod('asceticism'); @@ -3729,6 +3739,7 @@ CM.Sim.CalculateGains = function() { else if (godLvl == 2) mult *= 1.1; else if (godLvl == 3) mult *= 1.05; + // TODO: What does DateAges do? var godLvl = Game.hasGod('ages'); if (godLvl == 1) mult *= 1 + 0.15 * Math.sin((CM.Sim.DateAges / 1000 / (60 * 60 * 3)) * Math.PI * 2); else if (godLvl == 2) mult *= 1 + 0.15 * Math.sin((CM.Sim.DateAges / 1000 / (60 * 60 * 12)) * Math.PI*2); @@ -3824,26 +3835,25 @@ CM.Sim.CalculateGains = function() { //if (CM.Sim.hasAura('Radiant Appetite')) mult *= 2; mult *= 1 + CM.Sim.auraMult('Radiant Appetite'); - if (true) { // || CM.Sim.hasAura('Dragon\'s Fortune')) { - var n = Game.shimmerTypes['golden'].n; - var auraMult = CM.Sim.auraMult('Dragon\'s Fortune'); - for (var i = 0; i < n; i++) { - mult *= 1 + auraMult * 1.23; - } - } - var rawCookiesPs = CM.Sim.cookiesPs * mult; - for (var i in Game.CpsAchievements) { if (rawCookiesPs >= Game.CpsAchievements[i].threshold) CM.Sim.Win(Game.CpsAchievements[i].name); } - mult *= CM.Sim.getCPSBuffMult(); + CM.Sim.cookiesPsRaw=rawCookiesPs; + + if (CM.Sim.hasAura('Dragon\'s Fortune')) { + var n = Game.shimmerTypes['golden'].n; + for (var i = 0; i < n; i++) { + mult *= 1.23; + } + } - // Pointless? var name = Game.bakeryName.toLowerCase(); if (name == 'orteil') mult *= 0.99; - else if (name == 'ortiel') mult *= 0.98; //or so help me + else if (name == 'ortiel') mult *= 0.98; + + // TODO: Move CalcWink option and calculation here from CM.Disp if (CM.Sim.Has('Elder Covenant')) mult *= 0.95; @@ -3862,13 +3872,15 @@ CM.Sim.CalculateGains = function() { if (CM.Sim.Has('Reinforced membrane')) veilMult += 0.1; mult *= 1 + veilMult; } + // Removed debug upgrades - // Removed buffs + mult *= CM.Sim.getCPSBuffMult(); + + // TODO: Handle ModHooks, see Game code CM.Sim.cookiesPs *= mult; - // TODO remove? // if (Game.hasBuff('Cursed finger')) Game.cookiesPs = 0; }; @@ -4091,6 +4103,7 @@ CM.Sim.ResetBonus = function(possiblePresMax) { CM.Sim.Upgrades['Heavenly confectionery'].bought = 1; CM.Sim.Upgrades['Heavenly key'].bought = 1; + // TODO: Fix this reseting. CM.Sim.prestige = possiblePresMax; lastAchievementsOwned = CM.Sim.AchievementsOwned; @@ -4164,8 +4177,7 @@ CM.Sim.SellBuildingsForChoEgg = function() { // Get money made by selling all remaining buildings for (var i in CM.Sim.Objects) { var me = CM.Sim.Objects[i]; - debug = CM.Sim.BuildingSell(Game.Objects[me.name], Game.Objects[i].basePrice, me.amount, Game.Objects[i].free, me.amount); - sellTotal += debug; + sellTotal += CM.Sim.BuildingSell(Game.Objects[me.name], Game.Objects[i].basePrice, me.amount, Game.Objects[i].free, me.amount); } // CM.Sim.CalculateGains(); diff --git a/src/Sim.js b/src/Sim.js index 72e03ea..0047faf 100644 --- a/src/Sim.js +++ b/src/Sim.js @@ -86,6 +86,8 @@ CM.Sim.hasAura = function(what) { return false; } +// Check if multiplier auras are present +// Used as CM.Sim.auraMult('Aura') * mult, i.e. CM.Sim.auraMult('Dragon God) * 0.05 CM.Sim.auraMult = function(what) { var n = 0; if (Game.dragonAuras[CM.Sim.dragonAura].name == what || Game.dragonAuras[CM.Sim.dragonAura2].name == what) @@ -152,7 +154,7 @@ CM.Sim.CopyData = function() { CM.Sim.UpgradesOwned = Game.UpgradesOwned; CM.Sim.pledges = Game.pledges; CM.Sim.AchievementsOwned = Game.AchievementsOwned; - CM.Sim.heavenlyPower = Game.heavenlyPower; // Unneeded? + CM.Sim.heavenlyPower = Game.heavenlyPower; // Unneeded? > Might be modded CM.Sim.prestige = Game.prestige; CM.Sim.dragonAura = Game.dragonAura; CM.Sim.dragonAura2 = Game.dragonAura2; @@ -197,15 +199,22 @@ CM.Sim.CopyData = function() { CM.Sim.CalculateGains = function() { CM.Sim.cookiesPs = 0; var mult = 1; - + // Include minigame effects + for (var i in CM.Cache.Objects) { + // TODO Store minigames and effects in Cache + // Include possibility of new/modded building and new/modded minigames + if (Game.Objects[i].minigameLoaded && Game.Objects[i].minigame.effs) { + } + } + if (Game.ascensionMode != 1) mult += parseFloat(CM.Sim.prestige) * 0.01 * CM.Sim.heavenlyPower * CM.Sim.GetHeavenlyMultiplier(); - // TODO Store minigame buffs? mult *= Game.eff('cps'); - + if (CM.Sim.Has('Heralds') && Game.ascensionMode != 1) mult *= 1 + 0.01 * Game.heralds; - var cookieMult = 0; + // TODO: Make function call cached function where Game.Has is replaced with CM.Has + // Related to valentine cookies for (var i in Game.cookieUpgrades) { var me = Game.cookieUpgrades[i]; if (CM.Sim.Has(me.name)) { @@ -213,7 +222,6 @@ CM.Sim.CalculateGains = function() { } } - mult *= (1 + 0.01 * cookieMult); if (CM.Sim.Has('Specialized chocolate chips')) mult *= 1.01; if (CM.Sim.Has('Designer cocoa beans')) mult *= 1.02; if (CM.Sim.Has('Underworld ovens')) mult *= 1.03; @@ -231,6 +239,8 @@ CM.Sim.CalculateGains = function() { if (CM.Sim.Has('Dragon scale')) mult *= 1.03; + // Cached and sim temple gods + // TODO: Caches chosen gods var buildMult = 1; if (Game.hasGod) { var godLvl = Game.hasGod('asceticism'); @@ -238,6 +248,7 @@ CM.Sim.CalculateGains = function() { else if (godLvl == 2) mult *= 1.1; else if (godLvl == 3) mult *= 1.05; + // TODO: What does DateAges do? var godLvl = Game.hasGod('ages'); if (godLvl == 1) mult *= 1 + 0.15 * Math.sin((CM.Sim.DateAges / 1000 / (60 * 60 * 3)) * Math.PI * 2); else if (godLvl == 2) mult *= 1 + 0.15 * Math.sin((CM.Sim.DateAges / 1000 / (60 * 60 * 12)) * Math.PI*2); @@ -333,26 +344,25 @@ CM.Sim.CalculateGains = function() { //if (CM.Sim.hasAura('Radiant Appetite')) mult *= 2; mult *= 1 + CM.Sim.auraMult('Radiant Appetite'); - if (true) { // || CM.Sim.hasAura('Dragon\'s Fortune')) { - var n = Game.shimmerTypes['golden'].n; - var auraMult = CM.Sim.auraMult('Dragon\'s Fortune'); - for (var i = 0; i < n; i++) { - mult *= 1 + auraMult * 1.23; - } - } - var rawCookiesPs = CM.Sim.cookiesPs * mult; - for (var i in Game.CpsAchievements) { if (rawCookiesPs >= Game.CpsAchievements[i].threshold) CM.Sim.Win(Game.CpsAchievements[i].name); } - mult *= CM.Sim.getCPSBuffMult(); + CM.Sim.cookiesPsRaw=rawCookiesPs; + + if (CM.Sim.hasAura('Dragon\'s Fortune')) { + var n = Game.shimmerTypes['golden'].n; + for (var i = 0; i < n; i++) { + mult *= 1.23; + } + } - // Pointless? var name = Game.bakeryName.toLowerCase(); if (name == 'orteil') mult *= 0.99; - else if (name == 'ortiel') mult *= 0.98; //or so help me + else if (name == 'ortiel') mult *= 0.98; + + // TODO: Move CalcWink option and calculation here from CM.Disp if (CM.Sim.Has('Elder Covenant')) mult *= 0.95; @@ -371,13 +381,15 @@ CM.Sim.CalculateGains = function() { if (CM.Sim.Has('Reinforced membrane')) veilMult += 0.1; mult *= 1 + veilMult; } + // Removed debug upgrades - // Removed buffs + mult *= CM.Sim.getCPSBuffMult(); + + // TODO: Handle ModHooks, see Game code CM.Sim.cookiesPs *= mult; - // TODO remove? // if (Game.hasBuff('Cursed finger')) Game.cookiesPs = 0; }; @@ -600,6 +612,7 @@ CM.Sim.ResetBonus = function(possiblePresMax) { CM.Sim.Upgrades['Heavenly confectionery'].bought = 1; CM.Sim.Upgrades['Heavenly key'].bought = 1; + // TODO: Fix this reseting. CM.Sim.prestige = possiblePresMax; lastAchievementsOwned = CM.Sim.AchievementsOwned; From 9de75915315d9431e24ef1347a96acd880e5be53 Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Sat, 28 Nov 2020 12:44:32 +0100 Subject: [PATCH 2/4] Fixed CM.Sim.prestige not resetting --- CookieMonster.js | 8 ++++++-- src/Sim.js | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index b1bbd09..939ea07 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -4103,7 +4103,6 @@ CM.Sim.ResetBonus = function(possiblePresMax) { CM.Sim.Upgrades['Heavenly confectionery'].bought = 1; CM.Sim.Upgrades['Heavenly key'].bought = 1; - // TODO: Fix this reseting. CM.Sim.prestige = possiblePresMax; lastAchievementsOwned = CM.Sim.AchievementsOwned; @@ -4116,7 +4115,12 @@ CM.Sim.ResetBonus = function(possiblePresMax) { CM.Sim.CalculateGains(); } - return (CM.Sim.cookiesPs - curCPS); + var ResetCPS = CM.Sim.cookiesPs - curCPS + + // Reset Pretige level after calculation + CM.Sim.prestige = Game.prestige; + + return (ResetCPS); } CM.Sim.getSellMultiplier = function() { diff --git a/src/Sim.js b/src/Sim.js index 0047faf..2f30ff7 100644 --- a/src/Sim.js +++ b/src/Sim.js @@ -612,7 +612,6 @@ CM.Sim.ResetBonus = function(possiblePresMax) { CM.Sim.Upgrades['Heavenly confectionery'].bought = 1; CM.Sim.Upgrades['Heavenly key'].bought = 1; - // TODO: Fix this reseting. CM.Sim.prestige = possiblePresMax; lastAchievementsOwned = CM.Sim.AchievementsOwned; @@ -625,7 +624,12 @@ CM.Sim.ResetBonus = function(possiblePresMax) { CM.Sim.CalculateGains(); } - return (CM.Sim.cookiesPs - curCPS); + var ResetCPS = CM.Sim.cookiesPs - curCPS + + // Reset Pretige level after calculation + CM.Sim.prestige = Game.prestige; + + return (ResetCPS); } CM.Sim.getSellMultiplier = function() { From d7883e72382b069cadf06f8a5559d11d27f165bd Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Sat, 28 Nov 2020 13:46:39 +0100 Subject: [PATCH 3/4] Cache gods and implement CM.Sim.hasGodI() --- CookieMonster.js | 47 +++++++++++++++++++++++++++++------------------ src/Cache.js | 8 ++++---- src/Disp.js | 4 ++-- src/Sim.js | 35 +++++++++++++++++++++++------------ 4 files changed, 58 insertions(+), 36 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 939ea07..7467a81 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -68,8 +68,8 @@ CM.Cache.RemakeWrinkBank = function() { if (Game.wrinklers[i].type==1) toSuck *= 3; // Shiny wrinklers sucked *= toSuck; if (Game.Has('Wrinklerspawn')) sucked *= 1.05; - if (Game.hasGod) { - var godLvl = Game.hasGod('scorn'); + if (CM.Sim.Objects.Temple.minigameLoaded) { + var godLvl = CM.Sim.hasGod('scorn'); if (godLvl == 1) sucked *= 1.15; else if (godLvl == 2) sucked *= 1.1; else if (godLvl == 3) sucked *= 1.05; @@ -78,8 +78,8 @@ CM.Cache.RemakeWrinkBank = function() { } CM.Cache.WrinkBank = totalSucked; CM.Cache.WrinkGodBank = totalSucked; - if (Game.hasGod) { - var godLvl = Game.hasGod('scorn'); + if (CM.Sim.Objects.Temple.minigameLoaded) { + var godLvl = CM.Sim.hasGod('scorn'); if (godLvl == 2) CM.Cache.WrinkGodBank = CM.Cache.WrinkGodBank * 1.15 / 1.1; else if (godLvl == 3) CM.Cache.WrinkGodBank = CM.Cache.WrinkGodBank * 1.15 / 1.05; else if (godLvl != 1) CM.Cache.WrinkGodBank *= 1.15; @@ -3066,8 +3066,8 @@ CM.Disp.UpdateWrinklerTooltip = function() { if (Game.wrinklers[CM.Disp.TooltipWrinkler].type == 1) toSuck *= 3; // Shiny wrinklers sucked *= toSuck; if (Game.Has('Wrinklerspawn')) sucked *= 1.05; - if (Game.hasGod) { - var godLvl = Game.hasGod('scorn'); + if (CM.Sim.Objects.Temple.minigameLoaded) { + var godLvl = CM.Sim.hasGod('scorn'); if (godLvl == 1) sucked *= 1.15; else if (godLvl == 2) sucked *= 1.1; else if (godLvl == 3) sucked *= 1.05; @@ -3570,6 +3570,7 @@ eval('CM.Sim.HasAchiev = ' + Game.HasAchiev.toString().split('Game').join('CM.Si eval('CM.Sim.GetHeavenlyMultiplier = ' + Game.GetHeavenlyMultiplier.toString().split('Game.Has').join('CM.Sim.Has').split('Game.hasAura').join('CM.Sim.hasAura').split('Game.auraMult').join('CM.Sim.auraMult')); +// Check for Pantheon Auras CM.Sim.hasAura = function(what) { if (Game.dragonAuras[CM.Sim.dragonAura].name == what || Game.dragonAuras[CM.Sim.dragonAura2].name == what) return true; @@ -3588,6 +3589,16 @@ CM.Sim.auraMult = function(what) { return n; } +CM.Sim.hasGod=function(what) { + var possibleGods = CM.Sim.Objects.Temple.minigame.gods + var god=possibleGods[what]; + for (var i=0;i<3;i++) + { + if (CM.Sim.Objects.Temple.minigame.slot[i]==god.id) return (i+1); + } + return false; +} + eval('CM.Sim.GetTieredCpsMult = ' + Game.GetTieredCpsMult.toString() .split('Game.Has').join('CM.Sim.Has') .split('me.tieredUpgrades').join('Game.Objects[me.name].tieredUpgrades') @@ -3661,6 +3672,7 @@ CM.Sim.CopyData = function() { } you.amount = me.amount; you.level = me.level; + if (me.minigameLoaded) you.minigameLoaded = me.minigameLoaded; you.minigame = me.minigame; } // Upgrades @@ -3730,32 +3742,31 @@ CM.Sim.CalculateGains = function() { if (CM.Sim.Has('Dragon scale')) mult *= 1.03; - // Cached and sim temple gods - // TODO: Caches chosen gods + // Check effect of chosen Gods var buildMult = 1; - if (Game.hasGod) { - var godLvl = Game.hasGod('asceticism'); + if (CM.Sim.Objects.Temple.minigameLoaded) { + var godLvl = CM.Sim.hasGod('asceticism'); if (godLvl == 1) mult *= 1.15; else if (godLvl == 2) mult *= 1.1; else if (godLvl == 3) mult *= 1.05; // TODO: What does DateAges do? - var godLvl = Game.hasGod('ages'); + var godLvl = CM.Sim.hasGod('ages'); if (godLvl == 1) mult *= 1 + 0.15 * Math.sin((CM.Sim.DateAges / 1000 / (60 * 60 * 3)) * Math.PI * 2); else if (godLvl == 2) mult *= 1 + 0.15 * Math.sin((CM.Sim.DateAges / 1000 / (60 * 60 * 12)) * Math.PI*2); else if (godLvl == 3) mult *= 1 + 0.15 * Math.sin((CM.Sim.DateAges / 1000 / (60 * 60 * 24)) * Math.PI*2); - var godLvl = Game.hasGod('decadence'); + var godLvl = CM.Sim.hasGod('decadence'); if (godLvl == 1) buildMult *= 0.93; else if (godLvl == 2) buildMult *= 0.95; else if (godLvl == 3) buildMult *= 0.98; - var godLvl = Game.hasGod('industry'); + var godLvl = CM.Sim.hasGod('industry'); if (godLvl == 1) buildMult *= 1.1; else if (godLvl == 2) buildMult *= 1.06; else if (godLvl == 3) buildMult *= 1.03; - var godLvl = Game.hasGod('labor'); + var godLvl = CM.Sim.hasGod('labor'); if (godLvl == 1) buildMult *= 0.97; else if (godLvl == 2) buildMult *= 0.98; else if (godLvl == 3) buildMult *= 0.99; @@ -3768,8 +3779,8 @@ CM.Sim.CalculateGains = function() { if (CM.Sim.Has('Santa\'s milk and cookies')) milkMult *= 1.05; //if (CM.Sim.hasAura('Breath of Milk')) milkMult *= 1.05; milkMult *= 1 + CM.Sim.auraMult('Breath of Milk') * 0.05; - if (Game.hasGod) { - var godLvl = Game.hasGod('mother'); + if (CM.Sim.Objects.Temple.minigameLoaded) { + var godLvl = CM.Sim.hasGod('mother'); if (godLvl == 1) milkMult *= 1.1; else if (godLvl == 2) milkMult *= 1.05; else if (godLvl == 3) milkMult *= 1.03; @@ -4142,8 +4153,8 @@ CM.Sim.modifyBuildingPrice = function(building,price) { if (Game.hasBuff('Nasty goblins')) price *= 1.02; if (building.fortune && CM.Sim.Has(building.fortune.name)) price *= 0.93; price *= Game.eff('buildingCost'); - if (Game.hasGod) { - var godLvl = Game.hasGod('creation'); + if (CM.Sim.Objects.Temple.minigameLoaded) { + var godLvl = CM.Sim.hasGod('creation'); if (godLvl == 1) price *= 0.93; else if (godLvl == 2) price *= 0.95; else if (godLvl == 3) price *= 0.98; diff --git a/src/Cache.js b/src/Cache.js index f5ed125..0821025 100644 --- a/src/Cache.js +++ b/src/Cache.js @@ -48,8 +48,8 @@ CM.Cache.RemakeWrinkBank = function() { if (Game.wrinklers[i].type==1) toSuck *= 3; // Shiny wrinklers sucked *= toSuck; if (Game.Has('Wrinklerspawn')) sucked *= 1.05; - if (Game.hasGod) { - var godLvl = Game.hasGod('scorn'); + if (CM.Sim.Objects.Temple.minigameLoaded) { + var godLvl = CM.Sim.hasGod('scorn'); if (godLvl == 1) sucked *= 1.15; else if (godLvl == 2) sucked *= 1.1; else if (godLvl == 3) sucked *= 1.05; @@ -58,8 +58,8 @@ CM.Cache.RemakeWrinkBank = function() { } CM.Cache.WrinkBank = totalSucked; CM.Cache.WrinkGodBank = totalSucked; - if (Game.hasGod) { - var godLvl = Game.hasGod('scorn'); + if (CM.Sim.Objects.Temple.minigameLoaded) { + var godLvl = CM.Sim.hasGod('scorn'); if (godLvl == 2) CM.Cache.WrinkGodBank = CM.Cache.WrinkGodBank * 1.15 / 1.1; else if (godLvl == 3) CM.Cache.WrinkGodBank = CM.Cache.WrinkGodBank * 1.15 / 1.05; else if (godLvl != 1) CM.Cache.WrinkGodBank *= 1.15; diff --git a/src/Disp.js b/src/Disp.js index fdcc56e..990e638 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -2340,8 +2340,8 @@ CM.Disp.UpdateWrinklerTooltip = function() { if (Game.wrinklers[CM.Disp.TooltipWrinkler].type == 1) toSuck *= 3; // Shiny wrinklers sucked *= toSuck; if (Game.Has('Wrinklerspawn')) sucked *= 1.05; - if (Game.hasGod) { - var godLvl = Game.hasGod('scorn'); + if (CM.Sim.Objects.Temple.minigameLoaded) { + var godLvl = CM.Sim.hasGod('scorn'); if (godLvl == 1) sucked *= 1.15; else if (godLvl == 2) sucked *= 1.1; else if (godLvl == 3) sucked *= 1.05; diff --git a/src/Sim.js b/src/Sim.js index 2f30ff7..96dc827 100644 --- a/src/Sim.js +++ b/src/Sim.js @@ -79,6 +79,7 @@ eval('CM.Sim.HasAchiev = ' + Game.HasAchiev.toString().split('Game').join('CM.Si eval('CM.Sim.GetHeavenlyMultiplier = ' + Game.GetHeavenlyMultiplier.toString().split('Game.Has').join('CM.Sim.Has').split('Game.hasAura').join('CM.Sim.hasAura').split('Game.auraMult').join('CM.Sim.auraMult')); +// Check for Pantheon Auras CM.Sim.hasAura = function(what) { if (Game.dragonAuras[CM.Sim.dragonAura].name == what || Game.dragonAuras[CM.Sim.dragonAura2].name == what) return true; @@ -97,6 +98,16 @@ CM.Sim.auraMult = function(what) { return n; } +CM.Sim.hasGod=function(what) { + var possibleGods = CM.Sim.Objects.Temple.minigame.gods + var god=possibleGods[what]; + for (var i=0;i<3;i++) + { + if (CM.Sim.Objects.Temple.minigame.slot[i]==god.id) return (i+1); + } + return false; +} + eval('CM.Sim.GetTieredCpsMult = ' + Game.GetTieredCpsMult.toString() .split('Game.Has').join('CM.Sim.Has') .split('me.tieredUpgrades').join('Game.Objects[me.name].tieredUpgrades') @@ -170,6 +181,7 @@ CM.Sim.CopyData = function() { } you.amount = me.amount; you.level = me.level; + if (me.minigameLoaded) you.minigameLoaded = me.minigameLoaded; you.minigame = me.minigame; } // Upgrades @@ -239,32 +251,31 @@ CM.Sim.CalculateGains = function() { if (CM.Sim.Has('Dragon scale')) mult *= 1.03; - // Cached and sim temple gods - // TODO: Caches chosen gods + // Check effect of chosen Gods var buildMult = 1; - if (Game.hasGod) { - var godLvl = Game.hasGod('asceticism'); + if (CM.Sim.Objects.Temple.minigameLoaded) { + var godLvl = CM.Sim.hasGod('asceticism'); if (godLvl == 1) mult *= 1.15; else if (godLvl == 2) mult *= 1.1; else if (godLvl == 3) mult *= 1.05; // TODO: What does DateAges do? - var godLvl = Game.hasGod('ages'); + var godLvl = CM.Sim.hasGod('ages'); if (godLvl == 1) mult *= 1 + 0.15 * Math.sin((CM.Sim.DateAges / 1000 / (60 * 60 * 3)) * Math.PI * 2); else if (godLvl == 2) mult *= 1 + 0.15 * Math.sin((CM.Sim.DateAges / 1000 / (60 * 60 * 12)) * Math.PI*2); else if (godLvl == 3) mult *= 1 + 0.15 * Math.sin((CM.Sim.DateAges / 1000 / (60 * 60 * 24)) * Math.PI*2); - var godLvl = Game.hasGod('decadence'); + var godLvl = CM.Sim.hasGod('decadence'); if (godLvl == 1) buildMult *= 0.93; else if (godLvl == 2) buildMult *= 0.95; else if (godLvl == 3) buildMult *= 0.98; - var godLvl = Game.hasGod('industry'); + var godLvl = CM.Sim.hasGod('industry'); if (godLvl == 1) buildMult *= 1.1; else if (godLvl == 2) buildMult *= 1.06; else if (godLvl == 3) buildMult *= 1.03; - var godLvl = Game.hasGod('labor'); + var godLvl = CM.Sim.hasGod('labor'); if (godLvl == 1) buildMult *= 0.97; else if (godLvl == 2) buildMult *= 0.98; else if (godLvl == 3) buildMult *= 0.99; @@ -277,8 +288,8 @@ CM.Sim.CalculateGains = function() { if (CM.Sim.Has('Santa\'s milk and cookies')) milkMult *= 1.05; //if (CM.Sim.hasAura('Breath of Milk')) milkMult *= 1.05; milkMult *= 1 + CM.Sim.auraMult('Breath of Milk') * 0.05; - if (Game.hasGod) { - var godLvl = Game.hasGod('mother'); + if (CM.Sim.Objects.Temple.minigameLoaded) { + var godLvl = CM.Sim.hasGod('mother'); if (godLvl == 1) milkMult *= 1.1; else if (godLvl == 2) milkMult *= 1.05; else if (godLvl == 3) milkMult *= 1.03; @@ -651,8 +662,8 @@ CM.Sim.modifyBuildingPrice = function(building,price) { if (Game.hasBuff('Nasty goblins')) price *= 1.02; if (building.fortune && CM.Sim.Has(building.fortune.name)) price *= 0.93; price *= Game.eff('buildingCost'); - if (Game.hasGod) { - var godLvl = Game.hasGod('creation'); + if (CM.Sim.Objects.Temple.minigameLoaded) { + var godLvl = CM.Sim.hasGod('creation'); if (godLvl == 1) price *= 0.93; else if (godLvl == 2) price *= 0.95; else if (godLvl == 3) price *= 0.98; From 57cfdad21573a3634062e8ddc154b92164d5449e Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Sat, 28 Nov 2020 15:36:41 +0100 Subject: [PATCH 4/4] Store minigame effects as Sim data --- CookieMonster.js | 31 +++++++++++++++++++++++-------- src/Sim.js | 27 ++++++++++++++++++++++----- 2 files changed, 45 insertions(+), 13 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 7467a81..e2054f9 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -3599,6 +3599,16 @@ CM.Sim.hasGod=function(what) { return false; } +CM.Sim.eff = function(name) { + if (typeof CM.Sim.effs[name]==='undefined') { + CM.Sim.effs[name] = 1 + return CM.Sim.effs[name] + } + else { + return Game.effs[name]; + } +} + eval('CM.Sim.GetTieredCpsMult = ' + Game.GetTieredCpsMult.toString() .split('Game.Has').join('CM.Sim.Has') .split('me.tieredUpgrades').join('Game.Objects[me.name].tieredUpgrades') @@ -3703,16 +3713,21 @@ CM.Sim.CalculateGains = function() { CM.Sim.cookiesPs = 0; var mult = 1; // Include minigame effects + var effs={}; for (var i in CM.Cache.Objects) { - // TODO Store minigames and effects in Cache - // Include possibility of new/modded building and new/modded minigames - if (Game.Objects[i].minigameLoaded && Game.Objects[i].minigame.effs) { + if (CM.Sim.Objects[i].minigameLoaded && CM.Sim.Objects[i].minigame.effs) { + var myEffs = CM.Sim.Objects[i].minigame.effs; + for (var ii in myEffs) { + if (effs[ii]) effs[ii]*=myEffs[ii]; + else effs[ii]=myEffs[ii]; + } } } - + CM.Sim.effs = effs; + if (Game.ascensionMode != 1) mult += parseFloat(CM.Sim.prestige) * 0.01 * CM.Sim.heavenlyPower * CM.Sim.GetHeavenlyMultiplier(); - mult *= Game.eff('cps'); + mult *= CM.Sim.eff('cps'); if (CM.Sim.Has('Heralds') && Game.ascensionMode != 1) mult *= 1 + 0.01 * Game.heralds; @@ -3785,8 +3800,8 @@ CM.Sim.CalculateGains = function() { else if (godLvl == 2) milkMult *= 1.05; else if (godLvl == 3) milkMult *= 1.03; } - // TODO Store minigame buffs? - milkMult *= Game.eff('milk'); + + milkMult *= CM.Sim.eff('milk'); var catMult = 1; @@ -4152,7 +4167,7 @@ CM.Sim.modifyBuildingPrice = function(building,price) { if (Game.hasBuff('Crafty pixies')) price *= 0.98; if (Game.hasBuff('Nasty goblins')) price *= 1.02; if (building.fortune && CM.Sim.Has(building.fortune.name)) price *= 0.93; - price *= Game.eff('buildingCost'); + price *= CM.Sim.eff('buildingCost'); if (CM.Sim.Objects.Temple.minigameLoaded) { var godLvl = CM.Sim.hasGod('creation'); if (godLvl == 1) price *= 0.93; diff --git a/src/Sim.js b/src/Sim.js index 96dc827..26d6484 100644 --- a/src/Sim.js +++ b/src/Sim.js @@ -108,6 +108,16 @@ CM.Sim.hasGod=function(what) { return false; } +CM.Sim.eff = function(name) { + if (typeof CM.Sim.effs[name]==='undefined') { + CM.Sim.effs[name] = 1 + return CM.Sim.effs[name] + } + else { + return Game.effs[name]; + } +} + eval('CM.Sim.GetTieredCpsMult = ' + Game.GetTieredCpsMult.toString() .split('Game.Has').join('CM.Sim.Has') .split('me.tieredUpgrades').join('Game.Objects[me.name].tieredUpgrades') @@ -212,16 +222,23 @@ CM.Sim.CalculateGains = function() { CM.Sim.cookiesPs = 0; var mult = 1; // Include minigame effects + var effs={}; for (var i in CM.Cache.Objects) { // TODO Store minigames and effects in Cache // Include possibility of new/modded building and new/modded minigames - if (Game.Objects[i].minigameLoaded && Game.Objects[i].minigame.effs) { + if (CM.Sim.Objects[i].minigameLoaded && CM.Sim.Objects[i].minigame.effs) { + var myEffs = CM.Sim.Objects[i].minigame.effs; + for (var ii in myEffs) { + if (effs[ii]) effs[ii]*=myEffs[ii]; + else effs[ii]=myEffs[ii]; + } } } - + CM.Sim.effs = effs; + if (Game.ascensionMode != 1) mult += parseFloat(CM.Sim.prestige) * 0.01 * CM.Sim.heavenlyPower * CM.Sim.GetHeavenlyMultiplier(); - mult *= Game.eff('cps'); + mult *= CM.Sim.eff('cps'); if (CM.Sim.Has('Heralds') && Game.ascensionMode != 1) mult *= 1 + 0.01 * Game.heralds; @@ -295,7 +312,7 @@ CM.Sim.CalculateGains = function() { else if (godLvl == 3) milkMult *= 1.03; } // TODO Store minigame buffs? - milkMult *= Game.eff('milk'); + milkMult *= CM.Sim.eff('milk'); var catMult = 1; @@ -661,7 +678,7 @@ CM.Sim.modifyBuildingPrice = function(building,price) { if (Game.hasBuff('Crafty pixies')) price *= 0.98; if (Game.hasBuff('Nasty goblins')) price *= 1.02; if (building.fortune && CM.Sim.Has(building.fortune.name)) price *= 0.93; - price *= Game.eff('buildingCost'); + price *= CM.Sim.eff('buildingCost'); if (CM.Sim.Objects.Temple.minigameLoaded) { var godLvl = CM.Sim.hasGod('creation'); if (godLvl == 1) price *= 0.93;