From d7883e72382b069cadf06f8a5559d11d27f165bd Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Sat, 28 Nov 2020 13:46:39 +0100 Subject: [PATCH] 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;