Complete overhaul of code structure and relevant files (#639)
This commit is contained in:
218
src/Sim/Calculations/CalculateGains.js
Normal file
218
src/Sim/Calculations/CalculateGains.js
Normal file
@@ -0,0 +1,218 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import GetCPSBuffMult from '../../Cache/CPS/GetCPSBuffMult';
|
||||
import { CacheCentEgg } from '../../Cache/VariablesAndData';
|
||||
import SimAuraMult from '../ReplacedGameFunctions/SimAuraMult';
|
||||
import SimEff from '../ReplacedGameFunctions/SimEff';
|
||||
import SimGetHeavenlyMultiplier from '../ReplacedGameFunctions/SimGetHeavenlyMultiplier';
|
||||
import SimHas from '../ReplacedGameFunctions/SimHas';
|
||||
import SimHasGod from '../ReplacedGameFunctions/SimHasGod';
|
||||
import SimWin from '../SimulationData/SimWin';
|
||||
import {
|
||||
SimAchievementsOwned, SimCookiesPs, SimCookiesPsRaw, SimDateAges, SimDateCentury, SimEffs, SimHeavenlyPower, SimObjects, SimPrestige, SimUpgrades,
|
||||
} from '../VariablesAndData';
|
||||
|
||||
/**
|
||||
* This function calculates the CPS of the current "sim data"
|
||||
* It is similar to Game.CalculateGains()
|
||||
* It is called at the start of any function that simulates certain behaviour or actions
|
||||
* @global {number} CM.Sim.cookiesPs The CPS of the current sim data
|
||||
*/
|
||||
export default function CalculateGains() {
|
||||
SimCookiesPs = 0;
|
||||
let mult = 1;
|
||||
// Include minigame effects
|
||||
const effs = {};
|
||||
for (const i of Object.keys(Game.Objects)) {
|
||||
if (Game.Objects[i].minigameLoaded && Game.Objects[i].minigame.effs) {
|
||||
const myEffs = Game.Objects[i].minigame.effs;
|
||||
for (const ii in myEffs) {
|
||||
if (effs[ii]) effs[ii] *= myEffs[ii];
|
||||
else effs[ii] = myEffs[ii];
|
||||
}
|
||||
}
|
||||
}
|
||||
SimEffs = effs;
|
||||
|
||||
if (Game.ascensionMode !== 1) mult += parseFloat(SimPrestige) * 0.01 * SimHeavenlyPower * SimGetHeavenlyMultiplier();
|
||||
|
||||
mult *= SimEff('cps');
|
||||
|
||||
if (SimHas('Heralds') && Game.ascensionMode !== 1) mult *= 1 + 0.01 * Game.heralds;
|
||||
|
||||
for (const i of Object.keys(Game.cookieUpgrades)) {
|
||||
const me = Game.cookieUpgrades[i];
|
||||
if (SimHas(me.name)) {
|
||||
// Some upgrades have a functio as .power (notably the valentine cookies)
|
||||
// CM.Sim.InitialBuildingData has changed to use CM.Sim.Has instead of Game.Has etc.
|
||||
// Therefore this call is to the .power of the Sim.Object
|
||||
if (typeof (me.power) === 'function') {
|
||||
mult *= 1 + (SimUpgrades[me.name].power(SimUpgrades[me.name]) * 0.01);
|
||||
} else mult *= 1 + (me.power * 0.01);
|
||||
}
|
||||
}
|
||||
|
||||
if (SimHas('Specialized chocolate chips')) mult *= 1.01;
|
||||
if (SimHas('Designer cocoa beans')) mult *= 1.02;
|
||||
if (SimHas('Underworld ovens')) mult *= 1.03;
|
||||
if (SimHas('Exotic nuts')) mult *= 1.04;
|
||||
if (SimHas('Arcane sugar')) mult *= 1.05;
|
||||
|
||||
if (SimHas('Increased merriness')) mult *= 1.15;
|
||||
if (SimHas('Improved jolliness')) mult *= 1.15;
|
||||
if (SimHas('A lump of coal')) mult *= 1.01;
|
||||
if (SimHas('An itchy sweater')) mult *= 1.01;
|
||||
if (SimHas('Santa\'s dominion')) mult *= 1.2;
|
||||
|
||||
if (SimHas('Fortune #100')) mult *= 1.01;
|
||||
if (SimHas('Fortune #101')) mult *= 1.07;
|
||||
|
||||
if (SimHas('Dragon scale')) mult *= 1.03;
|
||||
|
||||
// Check effect of chosen Gods
|
||||
let buildMult = 1;
|
||||
if (SimHasGod) {
|
||||
let godLvl = SimHasGod('asceticism');
|
||||
if (godLvl === 1) mult *= 1.15;
|
||||
else if (godLvl === 2) mult *= 1.1;
|
||||
else if (godLvl === 3) mult *= 1.05;
|
||||
|
||||
godLvl = SimHasGod('ages');
|
||||
if (godLvl === 1) mult *= 1 + 0.15 * Math.sin((SimDateAges / 1000 / (60 * 60 * 3)) * Math.PI * 2);
|
||||
else if (godLvl === 2) mult *= 1 + 0.15 * Math.sin((SimDateAges / 1000 / (60 * 60 * 12)) * Math.PI * 2);
|
||||
else if (godLvl === 3) mult *= 1 + 0.15 * Math.sin((SimDateAges / 1000 / (60 * 60 * 24)) * Math.PI * 2);
|
||||
|
||||
godLvl = SimHasGod('decadence');
|
||||
if (godLvl === 1) buildMult *= 0.93;
|
||||
else if (godLvl === 2) buildMult *= 0.95;
|
||||
else if (godLvl === 3) buildMult *= 0.98;
|
||||
|
||||
godLvl = SimHasGod('industry');
|
||||
if (godLvl === 1) buildMult *= 1.1;
|
||||
else if (godLvl === 2) buildMult *= 1.06;
|
||||
else if (godLvl === 3) buildMult *= 1.03;
|
||||
|
||||
godLvl = SimHasGod('labor');
|
||||
if (godLvl === 1) buildMult *= 0.97;
|
||||
else if (godLvl === 2) buildMult *= 0.98;
|
||||
else if (godLvl === 3) buildMult *= 0.99;
|
||||
}
|
||||
|
||||
if (SimHas('Santa\'s legacy')) mult *= 1 + (Game.santaLevel + 1) * 0.03;
|
||||
|
||||
const milkProgress = SimAchievementsOwned / 25;
|
||||
let milkMult = 1;
|
||||
if (SimHas('Santa\'s milk and cookies')) milkMult *= 1.05;
|
||||
// if (CM.Sim.hasAura('Breath of Milk')) milkMult *= 1.05;
|
||||
milkMult *= 1 + SimAuraMult('Breath of Milk') * 0.05;
|
||||
if (SimHasGod) {
|
||||
const godLvl = SimHasGod('mother');
|
||||
if (godLvl === 1) milkMult *= 1.1;
|
||||
else if (godLvl === 2) milkMult *= 1.05;
|
||||
else if (godLvl === 3) milkMult *= 1.03;
|
||||
}
|
||||
milkMult *= SimEff('milk');
|
||||
|
||||
let catMult = 1;
|
||||
|
||||
if (SimHas('Kitten helpers')) catMult *= (1 + milkProgress * 0.1 * milkMult);
|
||||
if (SimHas('Kitten workers')) catMult *= (1 + milkProgress * 0.125 * milkMult);
|
||||
if (SimHas('Kitten engineers')) catMult *= (1 + milkProgress * 0.15 * milkMult);
|
||||
if (SimHas('Kitten overseers')) catMult *= (1 + milkProgress * 0.175 * milkMult);
|
||||
if (SimHas('Kitten managers')) catMult *= (1 + milkProgress * 0.2 * milkMult);
|
||||
if (SimHas('Kitten accountants')) catMult *= (1 + milkProgress * 0.2 * milkMult);
|
||||
if (SimHas('Kitten specialists')) catMult *= (1 + milkProgress * 0.2 * milkMult);
|
||||
if (SimHas('Kitten experts')) catMult *= (1 + milkProgress * 0.2 * milkMult);
|
||||
if (SimHas('Kitten consultants')) catMult *= (1 + milkProgress * 0.2 * milkMult);
|
||||
if (SimHas('Kitten assistants to the regional manager')) catMult *= (1 + milkProgress * 0.175 * milkMult);
|
||||
if (SimHas('Kitten marketeers')) catMult *= (1 + milkProgress * 0.15 * milkMult);
|
||||
if (SimHas('Kitten analysts')) catMult *= (1 + milkProgress * 0.125 * milkMult);
|
||||
if (SimHas('Kitten executives')) catMult *= (1 + milkProgress * 0.115 * milkMult);
|
||||
if (SimHas('Kitten angels')) catMult *= (1 + milkProgress * 0.1 * milkMult);
|
||||
if (SimHas('Fortune #103')) catMult *= (1 + milkProgress * 0.05 * milkMult);
|
||||
|
||||
for (const i of Object.keys(SimObjects)) {
|
||||
const me = SimObjects[i];
|
||||
let storedCps = me.cps(me);
|
||||
if (Game.ascensionMode !== 1) storedCps *= (1 + me.level * 0.01) * buildMult;
|
||||
if (me.name === 'Grandma' && SimHas('Milkhelp® lactose intolerance relief tablets')) storedCps *= 1 + 0.05 * milkProgress * milkMult;
|
||||
SimCookiesPs += me.amount * storedCps;
|
||||
}
|
||||
|
||||
if (SimHas('"egg"')) SimCookiesPs += 9;// "egg"
|
||||
|
||||
mult *= catMult;
|
||||
|
||||
let eggMult = 1;
|
||||
if (SimHas('Chicken egg')) eggMult *= 1.01;
|
||||
if (SimHas('Duck egg')) eggMult *= 1.01;
|
||||
if (SimHas('Turkey egg')) eggMult *= 1.01;
|
||||
if (SimHas('Quail egg')) eggMult *= 1.01;
|
||||
if (SimHas('Robin egg')) eggMult *= 1.01;
|
||||
if (SimHas('Ostrich egg')) eggMult *= 1.01;
|
||||
if (SimHas('Cassowary egg')) eggMult *= 1.01;
|
||||
if (SimHas('Salmon roe')) eggMult *= 1.01;
|
||||
if (SimHas('Frogspawn')) eggMult *= 1.01;
|
||||
if (SimHas('Shark egg')) eggMult *= 1.01;
|
||||
if (SimHas('Turtle egg')) eggMult *= 1.01;
|
||||
if (SimHas('Ant larva')) eggMult *= 1.01;
|
||||
if (SimHas('Century egg')) {
|
||||
// The boost increases a little every day, with diminishing returns up to +10% on the 100th day
|
||||
let day = Math.floor((SimDateCentury - Game.startDate) / 1000 / 10) * 10 / 60 / 60 / 24;
|
||||
day = Math.min(day, 100);
|
||||
// Sets a Cache value to be displayed in the Stats page, could be moved...
|
||||
CacheCentEgg = 1 + (1 - (1 - day / 100) ** 3) * 0.1;
|
||||
eggMult *= CacheCentEgg;
|
||||
}
|
||||
mult *= eggMult;
|
||||
|
||||
if (SimHas('Sugar baking')) mult *= (1 + Math.min(100, Game.lumps) * 0.01);
|
||||
|
||||
// if (CM.Sim.hasAura('Radiant Appetite')) mult *= 2;
|
||||
mult *= 1 + SimAuraMult('Radiant Appetite');
|
||||
|
||||
const rawCookiesPs = SimCookiesPs * mult;
|
||||
for (const i of Object.keys(Game.CpsAchievements)) {
|
||||
if (rawCookiesPs >= Game.CpsAchievements[i].threshold) SimWin(Game.CpsAchievements[i].name);
|
||||
}
|
||||
|
||||
SimCookiesPsRaw = rawCookiesPs;
|
||||
|
||||
const n = Game.shimmerTypes.golden.n;
|
||||
const auraMult = SimAuraMult('Dragon\'s Fortune');
|
||||
for (let i = 0; i < n; i++) {
|
||||
mult *= 1 + auraMult * 1.23;
|
||||
}
|
||||
|
||||
const name = Game.bakeryName.toLowerCase();
|
||||
if (name === 'orteil') mult *= 0.99;
|
||||
else if (name === 'ortiel') mult *= 0.98;
|
||||
|
||||
if (SimHas('Elder Covenant')) mult *= 0.95;
|
||||
|
||||
if (SimHas('Golden switch [off]')) {
|
||||
let goldenSwitchMult = 1.5;
|
||||
if (SimHas('Residual luck')) {
|
||||
const upgrades = Game.goldenCookieUpgrades;
|
||||
for (const i of Object.keys(upgrades)) {
|
||||
if (SimHas(upgrades[i])) goldenSwitchMult += 0.1;
|
||||
}
|
||||
}
|
||||
mult *= goldenSwitchMult;
|
||||
}
|
||||
if (SimHas('Shimmering veil [off]')) {
|
||||
let veilMult = 0.5;
|
||||
if (SimHas('Reinforced membrane')) veilMult += 0.1;
|
||||
mult *= 1 + veilMult;
|
||||
}
|
||||
|
||||
if (SimHas('Magic shenanigans')) mult *= 1000;
|
||||
if (SimHas('Occult obstruction')) mult *= 0;
|
||||
|
||||
SimCookiesPs = Game.runModHookOnValue('cps', SimCookiesPs);
|
||||
|
||||
mult *= GetCPSBuffMult();
|
||||
|
||||
SimCookiesPs *= mult;
|
||||
|
||||
// if (Game.hasBuff('Cursed finger')) Game.cookiesPs = 0;
|
||||
}
|
||||
88
src/Sim/Calculations/CheckOtherAchiev.js
Normal file
88
src/Sim/Calculations/CheckOtherAchiev.js
Normal file
@@ -0,0 +1,88 @@
|
||||
import { ChristCookies, HalloCookies } from '../../Data/Gamedata';
|
||||
import SimHas from '../ReplacedGameFunctions/SimHas';
|
||||
import SimHasAchiev from '../ReplacedGameFunctions/SimHasAchiev';
|
||||
import SimWin from '../SimulationData/SimWin';
|
||||
import { SimObjects, SimUpgradesOwned } from '../VariablesAndData';
|
||||
|
||||
/**
|
||||
* This function calculates if any special achievements have been obtained
|
||||
* If so it SimWin()'s them and the caller function will know to recall CM.Sim.CalculateGains()
|
||||
* It is called at the end of any functions that simulates certain behaviour
|
||||
*/
|
||||
export default function CheckOtherAchiev() {
|
||||
let grandmas = 0;
|
||||
for (const i of Object.keys(Game.GrandmaSynergies)) {
|
||||
if (SimHas(Game.GrandmaSynergies[i])) grandmas++;
|
||||
}
|
||||
if (!SimHasAchiev('Elder') && grandmas >= 7) SimWin('Elder');
|
||||
if (!SimHasAchiev('Veteran') && grandmas >= 14) SimWin('Veteran');
|
||||
|
||||
let buildingsOwned = 0;
|
||||
let mathematician = 1;
|
||||
let base10 = 1;
|
||||
let minAmount = 100000;
|
||||
for (const i of Object.keys(SimObjects)) {
|
||||
buildingsOwned += SimObjects[i].amount;
|
||||
minAmount = Math.min(SimObjects[i].amount, minAmount);
|
||||
if (!SimHasAchiev('Mathematician')) {
|
||||
if (SimObjects[i].amount < Math.min(128, 2 ** ((Game.ObjectsById.length - Game.Objects[i].id) - 1))) mathematician = 0;
|
||||
}
|
||||
if (!SimHasAchiev('Base 10')) {
|
||||
if (SimObjects[i].amount < (Game.ObjectsById.length - Game.Objects[i].id) * 10) base10 = 0;
|
||||
}
|
||||
}
|
||||
if (minAmount >= 1) SimWin('One with everything');
|
||||
if (mathematician === 1) SimWin('Mathematician');
|
||||
if (base10 === 1) SimWin('Base 10');
|
||||
if (minAmount >= 100) SimWin('Centennial');
|
||||
if (minAmount >= 150) SimWin('Centennial and a half');
|
||||
if (minAmount >= 200) SimWin('Bicentennial');
|
||||
if (minAmount >= 250) SimWin('Bicentennial and a half');
|
||||
if (minAmount >= 300) SimWin('Tricentennial');
|
||||
if (minAmount >= 350) SimWin('Tricentennial and a half');
|
||||
if (minAmount >= 400) SimWin('Quadricentennial');
|
||||
if (minAmount >= 450) SimWin('Quadricentennial and a half');
|
||||
if (minAmount >= 500) SimWin('Quincentennial');
|
||||
if (minAmount >= 550) SimWin('Quincentennial and a half');
|
||||
if (minAmount >= 600) SimWin('Sexcentennial');
|
||||
|
||||
if (buildingsOwned >= 100) SimWin('Builder');
|
||||
if (buildingsOwned >= 500) SimWin('Architect');
|
||||
if (buildingsOwned >= 1000) SimWin('Engineer');
|
||||
if (buildingsOwned >= 2000) SimWin('Lord of Constructs');
|
||||
if (buildingsOwned >= 4000) SimWin('Grand design');
|
||||
if (buildingsOwned >= 8000) SimWin('Ecumenopolis');
|
||||
|
||||
if (SimUpgradesOwned >= 20) SimWin('Enhancer');
|
||||
if (SimUpgradesOwned >= 50) SimWin('Augmenter');
|
||||
if (SimUpgradesOwned >= 100) SimWin('Upgrader');
|
||||
if (SimUpgradesOwned >= 200) SimWin('Lord of Progress');
|
||||
if (SimUpgradesOwned >= 300) SimWin('The full picture');
|
||||
if (SimUpgradesOwned >= 400) SimWin('When there\'s nothing left to add');
|
||||
|
||||
if (buildingsOwned >= 4000 && SimUpgradesOwned >= 300) SimWin('Polymath');
|
||||
if (buildingsOwned >= 8000 && SimUpgradesOwned >= 400) SimWin('Renaissance baker');
|
||||
|
||||
if (SimObjects.Cursor.amount + SimObjects.Grandma.amount >= 777) SimWin('The elder scrolls');
|
||||
|
||||
let hasAllHalloCook = true;
|
||||
for (const i of Object.keys(HalloCookies)) {
|
||||
if (!SimHas(HalloCookies[i])) hasAllHalloCook = false;
|
||||
}
|
||||
if (hasAllHalloCook) SimWin('Spooky cookies');
|
||||
|
||||
let hasAllChristCook = true;
|
||||
for (const i of Object.keys(ChristCookies)) {
|
||||
if (!SimHas(ChristCookies[i])) hasAllChristCook = false;
|
||||
}
|
||||
if (hasAllChristCook) SimWin('Let it snow');
|
||||
|
||||
if (SimHas('Fortune cookies')) {
|
||||
const list = Game.Tiers.fortune.upgrades;
|
||||
let fortunes = 0;
|
||||
for (const i of Object.keys(list)) {
|
||||
if (SimHas(list[i].name)) fortunes++;
|
||||
}
|
||||
if (fortunes >= list.length) SimWin('O Fortuna');
|
||||
}
|
||||
}
|
||||
14
src/Sim/Calculations/NoGoldenSwitchCalc.js
Normal file
14
src/Sim/Calculations/NoGoldenSwitchCalc.js
Normal file
@@ -0,0 +1,14 @@
|
||||
import CopyData from '../SimulationData/CopyData';
|
||||
import { SimCookiesPs, SimUpgrades } from '../VariablesAndData';
|
||||
import CalculateGains from './CalculateGains';
|
||||
|
||||
/**
|
||||
* This function calculates CPS without the Golden Switch
|
||||
* It is called by CM.Cache.NoGoldSwitchCPS()
|
||||
*/
|
||||
export default function CalcNoGoldSwitchCPS() {
|
||||
CopyData();
|
||||
SimUpgrades['Golden switch [off]'].bought = 0;
|
||||
CalculateGains();
|
||||
return SimCookiesPs;
|
||||
}
|
||||
Reference in New Issue
Block a user