Changes according to Eslint

This commit is contained in:
Daniël van Noord
2021-03-16 09:32:50 +01:00
parent 26d8e75935
commit a65af049b6
63 changed files with 314 additions and 295 deletions

View File

@@ -31,15 +31,15 @@ export default function CalculateGains() {
let mult = 1;
// Include minigame effects
const effs = {};
for (const i of Object.keys(Game.Objects)) {
Object.keys(Game.Objects).forEach((i) => {
if (Game.Objects[i].minigameLoaded && Game.Objects[i].minigame.effs) {
const myEffs = Game.Objects[i].minigame.effs;
for (const ii in myEffs) {
Object.keys(myEffs).forEach((ii) => {
if (effs[ii]) effs[ii] *= myEffs[ii];
else effs[ii] = myEffs[ii];
}
});
}
}
});
SimEffs = effs;
if (Game.ascensionMode !== 1)
@@ -54,7 +54,7 @@ export default function CalculateGains() {
if (SimHas('Heralds') && Game.ascensionMode !== 1)
mult *= 1 + 0.01 * Game.heralds;
for (const i of Object.keys(Game.cookieUpgrades)) {
Object.keys(Game.cookieUpgrades).forEach((i) => {
const me = Game.cookieUpgrades[i];
if (SimHas(me.name)) {
// Some upgrades have a functio as .power (notably the valentine cookies)
@@ -64,7 +64,7 @@ export default function CalculateGains() {
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;
@@ -160,7 +160,7 @@ export default function CalculateGains() {
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)) {
Object.keys(SimObjects).forEach((i) => {
const me = SimObjects[i];
let storedCps = me.cps(me);
if (Game.ascensionMode !== 1)
@@ -171,7 +171,7 @@ export default function CalculateGains() {
)
storedCps *= 1 + 0.05 * milkProgress * milkMult;
SimCookiesPs += me.amount * storedCps;
}
});
if (SimHas('"egg"')) SimCookiesPs += 9; // "egg"
@@ -210,14 +210,14 @@ export default function CalculateGains() {
mult *= 1 + SimAuraMult('Radiant Appetite');
const rawCookiesPs = SimCookiesPs * mult;
for (const i of Object.keys(Game.CpsAchievements)) {
Object.keys(Game.CpsAchievements).forEach((i) => {
if (rawCookiesPs >= Game.CpsAchievements[i].threshold)
SimWin(Game.CpsAchievements[i].name);
}
});
SimCookiesPsRaw = rawCookiesPs;
const n = Game.shimmerTypes.golden.n;
const { n } = Game.shimmerTypes.golden;
const auraMult = SimAuraMult("Dragon's Fortune");
for (let i = 0; i < n; i++) {
mult *= 1 + auraMult * 1.23;
@@ -233,9 +233,9 @@ export default function CalculateGains() {
let goldenSwitchMult = 1.5;
if (SimHas('Residual luck')) {
const upgrades = Game.goldenCookieUpgrades;
for (const i of Object.keys(upgrades)) {
Object.keys(upgrades).forEach((i) => {
if (SimHas(upgrades[i])) goldenSwitchMult += 0.1;
}
});
}
mult *= goldenSwitchMult;
}

View File

@@ -11,9 +11,9 @@ import { SimObjects, SimUpgradesOwned } from '../VariablesAndData';
*/
export default function CheckOtherAchiev() {
let grandmas = 0;
for (const i of Object.keys(Game.GrandmaSynergies)) {
if (SimHas(Game.GrandmaSynergies[i])) grandmas++;
}
Object.keys(Game.GrandmaSynergies).forEach((i) => {
if (SimHas(Game.GrandmaSynergies[i])) grandmas += 1;
});
if (!SimHasAchiev('Elder') && grandmas >= 7) SimWin('Elder');
if (!SimHasAchiev('Veteran') && grandmas >= 14) SimWin('Veteran');
@@ -21,7 +21,7 @@ export default function CheckOtherAchiev() {
let mathematician = 1;
let base10 = 1;
let minAmount = 100000;
for (const i of Object.keys(SimObjects)) {
Object.keys(SimObjects).forEach((i) => {
buildingsOwned += SimObjects[i].amount;
minAmount = Math.min(SimObjects[i].amount, minAmount);
if (!SimHasAchiev('Mathematician')) {
@@ -38,7 +38,7 @@ export default function CheckOtherAchiev() {
)
base10 = 0;
}
}
});
if (minAmount >= 1) SimWin('One with everything');
if (mathematician === 1) SimWin('Mathematician');
if (base10 === 1) SimWin('Base 10');
@@ -76,23 +76,23 @@ export default function CheckOtherAchiev() {
SimWin('The elder scrolls');
let hasAllHalloCook = true;
for (const i of Object.keys(HalloCookies)) {
Object.keys(HalloCookies).forEach((i) => {
if (!SimHas(HalloCookies[i])) hasAllHalloCook = false;
}
});
if (hasAllHalloCook) SimWin('Spooky cookies');
let hasAllChristCook = true;
for (const i of Object.keys(ChristCookies)) {
Object.keys(ChristCookies).forEach((i) => {
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++;
}
Object.keys(list).forEach((i) => {
if (SimHas(list[i].name)) fortunes += 1;
});
if (fortunes >= list.length) SimWin('O Fortuna');
}
}

View File

@@ -12,20 +12,20 @@ import InitUpgrade from './InitUpgrade';
export default function InitData() {
// Buildings
SimObjects = [];
for (const i of Object.keys(Game.Objects)) {
Object.keys(Game.Objects).forEach((i) => {
SimObjects[i] = InitialBuildingData(i);
}
});
// Upgrades
SimUpgrades = [];
for (const i of Object.keys(Game.Upgrades)) {
Object.keys(Game.Upgrades).forEach((i) => {
SimUpgrades[i] = InitUpgrade(i);
}
});
// Achievements
SimAchievements = [];
for (const i of Object.keys(Game.Achievements)) {
Object.keys(Game.Achievements).forEach((i) => {
SimAchievements[i] = InitAchievement(i);
}
});
CopyData();
}

View File

@@ -16,9 +16,9 @@ export default function InitUpgrade(upgradeName) {
if (me.name === 'Sugar crystal cookies') {
you.power = function () {
let n = 5;
for (const i in SimObjects) {
Object.keys(SimObjects).forEach((i) => {
if (SimObjects[i].level >= 10) n += 1;
}
});
return n;
};
} else {

View File

@@ -29,9 +29,9 @@ export default function InitialBuildingData(buildingName) {
if (SimHas('Nonillion fingers')) add *= 20;
let mult = 1;
let num = 0;
for (const i in SimObjects) {
Object.keys(SimObjects).forEach((i) => {
if (SimObjects[i].name !== 'Cursor') num += SimObjects[i].amount;
}
});
add *= num;
mult *= SimGetTieredCpsMult(it);
mult *= Game.magicCpS('Cursor');
@@ -49,9 +49,9 @@ export default function InitialBuildingData(buildingName) {
} else if (me.name === 'Grandma') {
you.cps = function (it) {
let mult = 1;
for (const i in Game.GrandmaSynergies) {
Object.keys(Game.GrandmaSynergies).forEach((i) => {
if (SimHas(Game.GrandmaSynergies[i])) mult *= 2;
}
});
if (SimHas('Bingo center/Research facility')) mult *= 4;
if (SimHas('Ritual rolling pins')) mult *= 2;
if (SimHas('Naughty list')) mult *= 2;
@@ -75,9 +75,9 @@ export default function InitialBuildingData(buildingName) {
if (SimHas('Elder Pact')) add += SimObjects.Portal.amount * 0.05;
let num = 0;
for (const i in SimObjects) {
Object.keys(SimObjects).forEach((i) => {
if (SimObjects[i].name !== 'Grandma') num += SimObjects[i].amount;
}
});
// if (Game.hasAura('Elder Battalion')) mult*=1+0.01*num;
mult *= 1 + SimAuraMult('Elder Battalion') * 0.01 * num;

View File

@@ -6,14 +6,14 @@ import SimHas from './SimHas';
*/
export default function SimGetTieredCpsMult(me) {
let mult = 1;
for (const i in me.tieredUpgrades) {
Object.keys(me.tieredUpgrades).forEach((i) => {
if (
!Game.Tiers[me.tieredUpgrades[i].tier].special &&
SimHas(me.tieredUpgrades[i].name)
)
mult *= 2;
}
for (const i in me.synergies) {
});
Object.keys(me.synergies).forEach((i) => {
if (SimHas(me.synergies[i].name)) {
const syn = me.synergies[i];
if (syn.buildingTie1.name === me.name)
@@ -21,7 +21,7 @@ export default function SimGetTieredCpsMult(me) {
else if (syn.buildingTie2.name === me.name)
mult *= 1 + 0.001 * syn.buildingTie1.amount;
}
}
});
if (me.fortune && SimHas(me.fortune.name)) mult *= 1.07;
if (me.grandma && SimHas(me.grandma.name))
mult *= 1 + SimObjects.Grandma.amount * 0.01 * (1 / (me.id - 1));

View File

@@ -8,26 +8,27 @@ import SimHasGod from './SimHasGod';
* This function calculates the sell price of a building based on current "sim data"
* @param {string} building Name of the building
* @param {number} price Current price of building
* @returns {number} price The modified building price
* @returns {number} ModifiedPrice The modified building price
*/
export default function SimModifyBuildingPrice(building, price) {
if (SimHas('Season savings')) price *= 0.99;
if (SimHas("Santa's dominion")) price *= 0.99;
if (SimHas('Faberge egg')) price *= 0.99;
if (SimHas('Divine discount')) price *= 0.99;
if (SimHas('Fortune #100')) price *= 0.99;
// if (SimHasAura('Fierce Hoarder')) price *= 0.98;
price *= 1 - SimAuraMult('Fierce Hoarder') * 0.02;
if (Game.hasBuff('Everything must go')) price *= 0.95;
if (Game.hasBuff('Crafty pixies')) price *= 0.98;
if (Game.hasBuff('Nasty goblins')) price *= 1.02;
if (building.fortune && SimHas(building.fortune.name)) price *= 0.93;
price *= SimEff('buildingCost');
let ModifiedPrice = price;
if (SimHas('Season savings')) ModifiedPrice *= 0.99;
if (SimHas("Santa's dominion")) ModifiedPrice *= 0.99;
if (SimHas('Faberge egg')) ModifiedPrice *= 0.99;
if (SimHas('Divine discount')) ModifiedPrice *= 0.99;
if (SimHas('Fortune #100')) ModifiedPrice *= 0.99;
// if (SimHasAura('Fierce Hoarder')) ModifiedPrice *= 0.98;
ModifiedPrice *= 1 - SimAuraMult('Fierce Hoarder') * 0.02;
if (Game.hasBuff('Everything must go')) ModifiedPrice *= 0.95;
if (Game.hasBuff('Crafty pixies')) ModifiedPrice *= 0.98;
if (Game.hasBuff('Nasty goblins')) ModifiedPrice *= 1.02;
if (building.fortune && SimHas(building.fortune.name)) ModifiedPrice *= 0.93;
ModifiedPrice *= SimEff('buildingCost');
if (SimObjects.Temple.minigameLoaded) {
const godLvl = SimHasGod('creation');
if (godLvl === 1) price *= 0.93;
else if (godLvl === 2) price *= 0.95;
else if (godLvl === 3) price *= 0.98;
if (godLvl === 1) ModifiedPrice *= 0.93;
else if (godLvl === 2) ModifiedPrice *= 0.95;
else if (godLvl === 3) ModifiedPrice *= 0.98;
}
return price;
return ModifiedPrice;
}

View File

@@ -37,7 +37,7 @@ export default function CopyData() {
SimPrestige = Game.prestige;
// Buildings
for (const i of Object.keys(Game.Objects)) {
Object.keys(Game.Objects).forEach((i) => {
const me = Game.Objects[i];
let you = SimObjects[i];
if (you === undefined) {
@@ -61,10 +61,10 @@ export default function CopyData() {
you.minigame = me.minigame;
}
SimObjects[i] = you;
}
});
// Upgrades
for (const i of Object.keys(Game.Upgrades)) {
Object.keys(Game.Upgrades).forEach((i) => {
const me = Game.Upgrades[i];
let you = SimUpgrades[i];
if (you === undefined) {
@@ -73,10 +73,10 @@ export default function CopyData() {
}
you.bought = me.bought;
SimUpgrades[i] = you;
}
});
// Achievements
for (const i of Object.keys(Game.Achievements)) {
Object.keys(Game.Achievements).forEach((i) => {
const me = Game.Achievements[i];
let you = SimAchievements[i];
if (you === undefined) {
@@ -85,7 +85,7 @@ export default function CopyData() {
}
you.won = me.won;
SimAchievements[i] = you;
}
});
// Auras
CacheDragonAuras();

View File

@@ -11,7 +11,7 @@ export default function SimWin(what) {
if (SimAchievements[what]) {
if (SimAchievements[what].won === 0) {
SimAchievements[what].won = 1;
if (Game.Achievements[what].pool !== 'shadow') SimAchievementsOwned++;
if (Game.Achievements[what].pool !== 'shadow') SimAchievementsOwned += 1;
}
}
}

View File

@@ -16,13 +16,15 @@ export default function BuildingGetPrice(
free,
increase,
) {
let startingAmount = start;
let moni = 0;
for (let i = 0; i < increase; i++) {
let price = basePrice * Game.priceIncrease ** Math.max(0, start - free);
for (let i = 0; i < increase; i += 1) {
let price =
basePrice * Game.priceIncrease ** Math.max(0, startingAmount - free);
price = Game.modifyBuildingPrice(build, price);
price = Math.ceil(price);
moni += price;
start++;
startingAmount += 1;
}
return moni;
}

View File

@@ -33,14 +33,14 @@ export default function BuyBuildingsBonusIncome(building, amount) {
if (me.amount >= 700) SimWin('Gotta hand it to you');
if (me.amount >= 800) SimWin("The devil's workshop");
} else {
for (const j in Game.Objects[me.name].tieredAchievs) {
Object.keys(Game.Objects[me.name].tieredAchievs).forEach((j) => {
if (
me.amount >=
Game.Tiers[Game.Objects[me.name].tieredAchievs[j].tier].achievUnlock
) {
SimWin(Game.Objects[me.name].tieredAchievs[j].name);
}
}
});
}
const lastAchievementsOwned = SimAchievementsOwned;

View File

@@ -34,9 +34,9 @@ function MouseCps() {
if (SimHas('Octillion fingers')) add *= 20;
if (SimHas('Nonillion fingers')) add *= 20;
let num = 0;
for (const i of Object.keys(SimObjects)) {
Object.keys(SimObjects).forEach((i) => {
num += SimObjects[i].amount;
}
});
num -= SimObjects.Cursor.amount;
add *= num;
@@ -83,10 +83,10 @@ function MouseCps() {
}
}
for (const i of Object.keys(Game.buffs)) {
Object.keys(Game.buffs).forEach((i) => {
if (typeof Game.buffs[i].multClick !== 'undefined')
mult *= Game.buffs[i].multClick;
}
});
// if (CM.Sim.auraMult('Dragon Cursor')) mult*=1.05;
mult *= 1 + SimAuraMult('Dragon Cursor') * 0.05;
@@ -132,10 +132,10 @@ export default function BuyUpgradesBonusIncome(upgrade) {
}
const me = SimUpgrades[upgrade];
if (Game.CountsAsUpgradeOwned(Game.Upgrades[upgrade].pool))
SimUpgradesOwned++;
SimUpgradesOwned += 1;
if (upgrade === 'Elder Pledge') {
SimPledges++;
SimPledges += 1;
if (SimPledges > 0) SimWin('Elder nap');
if (SimPledges >= 5) SimWin('Elder slumber');
} else if (upgrade === 'Elder Covenant') {

View File

@@ -22,21 +22,26 @@ export default function BuildingSell(
) {
// Calculate money gains from selling buildings
// If noSim is set, use Game methods to compute price instead of Sim ones.
noSim = typeof noSim === 'undefined' ? 0 : noSim;
const noSimRes = typeof noSim === 'undefined' ? 0 : noSim;
let toChange = amount;
let startingAmount = start;
let moni = 0;
if (amount === -1) amount = start;
if (!amount) amount = Game.buyBulk;
for (let i = 0; i < amount; i++) {
let price = basePrice * Game.priceIncrease ** Math.max(0, start - free);
price = noSim
if (amount === -1) toChange = startingAmount;
if (!amount) toChange = Game.buyBulk;
for (let i = 0; i < toChange; i++) {
let price =
basePrice * Game.priceIncrease ** Math.max(0, startingAmount - free);
price = noSimRes
? Game.modifyBuildingPrice(build, price)
: SimModifyBuildingPrice(build, price);
price = Math.ceil(price);
const giveBack = noSim ? build.getSellMultiplier() : SimGetSellMultiplier();
const giveBack = noSimRes
? build.getSellMultiplier()
: SimGetSellMultiplier();
price = Math.floor(price * giveBack);
if (start > 0) {
if (startingAmount > 0) {
moni += price;
start--;
startingAmount -= 1;
}
}
return moni;

View File

@@ -21,10 +21,10 @@ export default function SellBuildingsForChoEgg() {
// Change auras to Earth Shatterer + Reality bending to optimize money made by selling
let buildingsToSacrifice = 2;
if (SimDragonAura === 5 || SimDragonAura === 18) {
--buildingsToSacrifice;
buildingsToSacrifice -= 1;
}
if (SimDragonAura2 === 5 || SimDragonAura2 === 18) {
--buildingsToSacrifice;
buildingsToSacrifice -= 1;
}
SimDragonAura = 5;
SimDragonAura2 = 18;
@@ -32,17 +32,17 @@ export default function SellBuildingsForChoEgg() {
// Sacrifice highest buildings for the aura switch
for (let i = 0; i < buildingsToSacrifice; ++i) {
let highestBuilding = 'Cursor';
for (const j in SimObjects) {
Object.keys(SimObjects).forEach((j) => {
if (SimObjects[j].amount > 0) {
highestBuilding = j;
}
}
SimObjects[highestBuilding].amount--;
SimBuildingsOwned--;
});
SimObjects[highestBuilding].amount -= 1;
SimBuildingsOwned -= 1;
}
// Get money made by selling all remaining buildings
for (const i of Object.keys(SimObjects)) {
Object.keys(SimObjects).forEach((i) => {
const me = SimObjects[i];
sellTotal += BuildingSell(
Game.Objects[me.name],
@@ -51,7 +51,7 @@ export default function SellBuildingsForChoEgg() {
Game.Objects[i].free,
me.amount,
);
}
});
return sellTotal;
}