Fixed linting issues

This commit is contained in:
Daniël van Noord
2021-05-01 22:43:02 +02:00
parent 1d12977984
commit 1c8bd79640
94 changed files with 8692 additions and 1316 deletions

View File

@@ -37,11 +37,7 @@ export class CMAvgQueue {
if (time > this.maxLength) time = this.maxLength;
if (time > this.queue.length) time = this.queue.length;
let ret = 0;
for (
let i = this.queue.length - 1;
i >= 0 && i > this.queue.length - 1 - time;
i--
) {
for (let i = this.queue.length - 1; i >= 0 && i > this.queue.length - 1 - time; i--) {
ret += this.queue[i];
}
if (ret === 0) {

View File

@@ -45,11 +45,9 @@ export default function CacheAvgCPS() {
// Add recent gains to AvgQueue's
const timeDiff = currDate - CacheLastCPSCheck;
const bankDiffAvg = Math.max(0, Game.cookies - CacheLastCookies) / timeDiff;
const wrinkDiffAvg =
Math.max(0, CacheWrinklersTotal - CacheLastWrinkCookies) / timeDiff;
const wrinkDiffAvg = Math.max(0, CacheWrinklersTotal - CacheLastWrinkCookies) / timeDiff;
const wrinkFattestDiffAvg =
Math.max(0, CacheWrinklersFattest[0] - CacheLastWrinkFattestCookies) /
timeDiff;
Math.max(0, CacheWrinklersFattest[0] - CacheLastWrinkFattestCookies) / timeDiff;
const choEggDiffAvg = Math.max(0, choEggTotal - CacheLastChoEgg) / timeDiff;
const clicksDiffAvg = (Game.cookieClicks - CacheLastClicks) / timeDiff;
for (let i = 0; i < timeDiff; i++) {
@@ -76,22 +74,16 @@ export default function CacheAvgCPS() {
CacheAverageGainChoEgg = ChoEggDiff.calcAverage(cpsLength);
CacheAverageCPS = CacheAverageGainBank;
if (CMOptions.CalcWrink === 1) CacheAverageCPS += CacheAverageGainWrink;
if (CMOptions.CalcWrink === 2)
CacheAverageCPS += CacheAverageGainWrinkFattest;
if (CMOptions.CalcWrink === 2) CacheAverageCPS += CacheAverageGainWrinkFattest;
const choEgg =
Game.HasUnlocked('Chocolate egg') && !Game.Has('Chocolate egg');
const choEgg = Game.HasUnlocked('Chocolate egg') && !Game.Has('Chocolate egg');
if (choEgg || CMOptions.CalcWrink === 0) {
CacheAvgCPSWithChoEgg =
CacheAverageGainBank +
CacheAverageGainWrink +
(choEgg ? CacheAverageGainChoEgg : 0);
CacheAverageGainBank + CacheAverageGainWrink + (choEgg ? CacheAverageGainChoEgg : 0);
} else CacheAvgCPSWithChoEgg = CacheAverageCPS; // eslint-disable-line no-unused-vars
// eslint-disable-next-line no-unused-vars
CacheAverageClicks = ClicksDiff.calcAverage(
ClickTimes[CMOptions.AvgClicksHist],
);
CacheAverageClicks = ClicksDiff.calcAverage(ClickTimes[CMOptions.AvgClicksHist]);
}
}

View File

@@ -1,8 +1,5 @@
import { SimObjects } from '../../Sim/VariablesAndData';
import {
CacheCurrWrinklerCount,
CacheCurrWrinklerCPSMult,
} from '../VariablesAndData';
import { CacheCurrWrinklerCount, CacheCurrWrinklerCPSMult } from '../VariablesAndData';
/**
* This functions caches the current Wrinkler CPS multiplier

View File

@@ -5,8 +5,7 @@
export default function GetCPSBuffMult() {
let mult = 1;
Object.keys(Game.buffs).forEach((i) => {
if (typeof Game.buffs[i].multCpS !== 'undefined')
mult *= Game.buffs[i].multCpS;
if (typeof Game.buffs[i].multCpS !== 'undefined') mult *= Game.buffs[i].multCpS;
});
return mult;
}

View File

@@ -3,23 +3,14 @@ import { CMAvgQueue, InitCookiesDiff } from './CPS/AverageQueue';
import CacheAvgCPS from './CPS/CPS';
import CacheDragonAuras from './Dragon/CacheDragonAuras';
import CachePP from './PP/PP';
import {
CacheBuildingsPrices,
CacheIncome,
} from './PriceAndIncome/PriceAndIncome';
import { CacheBuildingsPrices, CacheIncome } from './PriceAndIncome/PriceAndIncome';
import { CacheChain } from './Stats/ChainCookies';
import CacheHeavenlyChipsPS from './Stats/HeavenlyChips';
import CacheAllMissingUpgrades from './Stats/MissingUpgrades';
import CacheSeasonSpec from './Stats/Reindeer';
import {
CacheGoldenAndWrathCookiesMults,
CacheStatsCookies,
} from './Stats/Stats';
import { CacheGoldenAndWrathCookiesMults, CacheStatsCookies } from './Stats/Stats';
import AllAmountTillNextAchievement from './TillNextAchievement/AllAmountTillNextAchievement';
import {
CacheAverageCookiesFromClicks,
HeavenlyChipsDiff,
} from './VariablesAndData';
import { CacheAverageCookiesFromClicks, HeavenlyChipsDiff } from './VariablesAndData';
import CacheWrinklers from './Wrinklers/Wrinklers';
/**
@@ -36,9 +27,7 @@ export default function InitCache() {
InitCookiesDiff();
/** Used by CM.Cache.CacheHeavenlyChipsPS() */
HeavenlyChipsDiff = new CMAvgQueue(5); // eslint-disable-line no-unused-vars
CacheAverageCookiesFromClicks = new CMAvgQueue( // eslint-disable-line no-unused-vars
ClickTimes[ClickTimes.length - 1] * 20,
);
CacheAverageCookiesFromClicks = new CMAvgQueue(ClickTimes[ClickTimes.length - 1] * 20); // eslint-disable-line no-unused-vars
CacheHeavenlyChipsPS();
AllAmountTillNextAchievement();
CacheAvgCPS();

View File

@@ -22,8 +22,7 @@ export default function LoopCache() {
const cookiesToNext =
Game.HowManyCookiesReset(
Math.floor(Game.HowMuchPrestige(Game.cookiesReset + Game.cookiesEarned)) +
1,
Math.floor(Game.HowMuchPrestige(Game.cookiesReset + Game.cookiesEarned)) + 1,
) -
(Game.cookiesEarned + Game.cookiesReset);
CacheTimeTillNextPrestige = FormatTime(cookiesToNext / GetCPS()); // eslint-disable-line no-unused-vars

View File

@@ -3,10 +3,7 @@
import Beautify from '../../Disp/BeautifyAndFormatting/Beautify';
import CopyData from '../../Sim/SimulationData/CopyData';
import { SimDoSims, SimObjects } from '../../Sim/VariablesAndData';
import {
CacheCostDragonUpgrade,
CacheLastDragonLevel,
} from '../VariablesAndData';
import { CacheCostDragonUpgrade, CacheLastDragonLevel } from '../VariablesAndData';
/**
* This functions caches the current cost of upgrading the dragon level so it can be displayed in the tooltip
@@ -17,9 +14,7 @@ export default function CacheDragonCost() {
Game.dragonLevel < 25 &&
Game.dragonLevels[Game.dragonLevel].buy.toString().includes('sacrifice')
) {
let target = Game.dragonLevels[Game.dragonLevel].buy
.toString()
.match(/Objects\[(.*)\]/)[1];
let target = Game.dragonLevels[Game.dragonLevel].buy.toString().match(/Objects\[(.*)\]/)[1];
const amount = Game.dragonLevels[Game.dragonLevel].buy
.toString()
.match(/sacrifice\((.*?)\)/)[1];
@@ -34,10 +29,7 @@ export default function CacheDragonCost() {
let price =
SimObjects[target].basePrice *
Game.priceIncrease **
Math.max(
0,
SimObjects[target].amount - 1 - SimObjects[target].free,
);
Math.max(0, SimObjects[target].amount - 1 - SimObjects[target].free);
price = Game.modifyBuildingPrice(SimObjects[target], price);
price = Math.ceil(price);
cost += price;
@@ -58,10 +50,7 @@ export default function CacheDragonCost() {
let price =
SimObjects[target].basePrice *
Game.priceIncrease **
Math.max(
0,
SimObjects[target].amount - 1 - SimObjects[target].free,
);
Math.max(0, SimObjects[target].amount - 1 - SimObjects[target].free);
price = Game.modifyBuildingPrice(SimObjects[target], price);
price = Math.ceil(price);
cost += price;

View File

@@ -22,10 +22,7 @@ function CacheColour(target, amount) {
return;
}
// eslint-disable-next-line no-param-reassign
target[i].color = ColourOfPP(
target[i],
Game.Objects[i].getSumPrice(amount),
);
target[i].color = ColourOfPP(target[i], Game.Objects[i].getSumPrice(amount));
// Colour based on excluding certain top-buildings
for (let j = 0; j < CMOptions.PPExcludeTop; j++) {
if (target[i].pp === CachePPArray[j][0]) target[i].color = ColourGray; // eslint-disable-line no-param-reassign
@@ -38,12 +35,10 @@ function CachePP(target, amount) {
const price = Game.Objects[i].getSumPrice(amount);
if (Game.cookiesPs) {
target[i].pp = // eslint-disable-line no-param-reassign
Math.max(price - (Game.cookies + GetWrinkConfigBank()), 0) /
Game.cookiesPs +
Math.max(price - (Game.cookies + GetWrinkConfigBank()), 0) / Game.cookiesPs +
price / target[i].bonus;
} else target[i].pp = price / target[i].bonus; // eslint-disable-line no-param-reassign
if (!(CMOptions.PPRigidelMode && amount === 1))
CachePPArray.push([target[i].pp, amount]);
if (!(CMOptions.PPRigidelMode && amount === 1)) CachePPArray.push([target[i].pp, amount]);
});
}

View File

@@ -31,8 +31,7 @@ export default function ColourOfPP(me, price) {
// Colour based on price in terms of CPS
if (Number(CMOptions.PPSecondsLowerLimit) !== 0) {
if (price / GetCPS() < Number(CMOptions.PPSecondsLowerLimit))
color = ColourBlue;
if (price / GetCPS() < Number(CMOptions.PPSecondsLowerLimit)) color = ColourBlue;
}
// Colour based on being able to purchase
if (CMOptions.PPOnlyConsiderBuyable) {

View File

@@ -10,20 +10,12 @@ export default function CacheUpgradePP() {
Object.keys(CacheUpgrades).forEach((i) => {
if (Game.cookiesPs) {
CacheUpgrades[i].pp =
Math.max(
Game.Upgrades[i].getPrice() - (Game.cookies + GetWrinkConfigBank()),
0,
) /
Math.max(Game.Upgrades[i].getPrice() - (Game.cookies + GetWrinkConfigBank()), 0) /
Game.cookiesPs +
Game.Upgrades[i].getPrice() / CacheUpgrades[i].bonus;
} else
CacheUpgrades[i].pp =
Game.Upgrades[i].getPrice() / CacheUpgrades[i].bonus;
} else CacheUpgrades[i].pp = Game.Upgrades[i].getPrice() / CacheUpgrades[i].bonus;
if (Number.isNaN(CacheUpgrades[i].pp)) CacheUpgrades[i].pp = Infinity;
CacheUpgrades[i].color = ColourOfPP(
CacheUpgrades[i],
Game.Upgrades[i].getPrice(),
);
CacheUpgrades[i].color = ColourOfPP(CacheUpgrades[i], Game.Upgrades[i].getPrice());
});
}

View File

@@ -44,10 +44,8 @@ function CacheUpgradeIncome() {
const bonusIncome = BuyUpgradesBonusIncome(i);
if (i === 'Elder Pledge') {
CacheUpgrades[i] = { bonus: Game.cookiesPs - CacheAverageGainBank };
if (CMOptions.CalcWrink === 1)
CacheUpgrades[i].bonus -= CacheAverageGainWrink;
else if (CMOptions.CalcWrink === 2)
CacheUpgrades[i].bonus -= CacheAverageGainWrinkFattest;
if (CMOptions.CalcWrink === 1) CacheUpgrades[i].bonus -= CacheAverageGainWrink;
else if (CMOptions.CalcWrink === 2) CacheUpgrades[i].bonus -= CacheAverageGainWrinkFattest;
if (!Number.isFinite(CacheUpgrades[i].bonus)) CacheUpgrades[i].bonus = 0;
} else {
CacheUpgrades[i] = {};

View File

@@ -31,22 +31,15 @@ export function MaxChainCookieReward(digit, maxPayout, mult) {
let moni = 0;
let nextMoni = 0;
let nextRequired = 0;
let chain =
1 + Math.max(0, Math.ceil(Math.log(Game.cookies) / Math.LN10) - 10);
let chain = 1 + Math.max(0, Math.ceil(Math.log(Game.cookies) / Math.LN10) - 10);
while (nextMoni < maxPayout * mult) {
moni = Math.max(
digit,
Math.min(
Math.floor((1 / 9) * 10 ** chain * digit * mult),
maxPayout * mult,
),
Math.min(Math.floor((1 / 9) * 10 ** chain * digit * mult), maxPayout * mult),
);
nextMoni = Math.max(
digit,
Math.min(
Math.floor((1 / 9) * 10 ** (chain + 1) * digit * mult),
maxPayout * mult,
),
Math.min(Math.floor((1 / 9) * 10 ** (chain + 1) * digit * mult), maxPayout * mult),
);
nextRequired = Math.floor((1 / 9) * 10 ** (chain + 1) * digit * mult);
totalFromChain += moni;
@@ -72,65 +65,28 @@ export function MaxChainCookieReward(digit, maxPayout, mult) {
* @global {number} CM.Cache.ChainFrenzyWrathRequiredNext Total cookies needed for next level for wrath frenzy chain
*/
export function CacheChain() {
let maxPayout =
CacheNoGoldSwitchCookiesPS *
60 *
60 *
6 *
CacheDragonsFortuneMultAdjustment;
let maxPayout = CacheNoGoldSwitchCookiesPS * 60 * 60 * 6 * CacheDragonsFortuneMultAdjustment;
// Removes effect of Frenzy etc.
const cpsBuffMult = GetCPSBuffMult();
if (cpsBuffMult > 0) maxPayout /= cpsBuffMult;
else maxPayout = 0;
CacheChainMaxReward = MaxChainCookieReward(
7,
maxPayout,
CacheGoldenCookiesMult,
);
CacheChainMaxReward = MaxChainCookieReward(7, maxPayout, CacheGoldenCookiesMult);
CacheChainRequired = (CacheChainMaxReward[1] * 2) / CacheGoldenCookiesMult; // eslint-disable-line no-unused-vars
CacheChainRequiredNext = // eslint-disable-line no-unused-vars
CacheChainMaxReward[2] / 60 / 60 / 6 / CacheDragonsFortuneMultAdjustment;
CacheChainRequiredNext = CacheChainMaxReward[2] / 60 / 60 / 6 / CacheDragonsFortuneMultAdjustment; // eslint-disable-line no-unused-vars
CacheChainWrathMaxReward = MaxChainCookieReward(
6,
maxPayout,
CacheWrathCookiesMult,
);
CacheChainWrathRequired = // eslint-disable-line no-unused-vars
(CacheChainWrathMaxReward[1] * 2) / CacheWrathCookiesMult;
CacheChainWrathMaxReward = MaxChainCookieReward(6, maxPayout, CacheWrathCookiesMult);
CacheChainWrathRequired = (CacheChainWrathMaxReward[1] * 2) / CacheWrathCookiesMult; // eslint-disable-line no-unused-vars
CacheChainWrathRequiredNext = // eslint-disable-line no-unused-vars
CacheChainWrathMaxReward[2] /
60 /
60 /
6 /
CacheDragonsFortuneMultAdjustment;
CacheChainWrathMaxReward[2] / 60 / 60 / 6 / CacheDragonsFortuneMultAdjustment;
CacheChainFrenzyMaxReward = MaxChainCookieReward(
7,
maxPayout * 7,
CacheGoldenCookiesMult,
);
CacheChainFrenzyRequired = // eslint-disable-line no-unused-vars
(CacheChainFrenzyMaxReward[1] * 2) / CacheGoldenCookiesMult;
CacheChainFrenzyMaxReward = MaxChainCookieReward(7, maxPayout * 7, CacheGoldenCookiesMult);
CacheChainFrenzyRequired = (CacheChainFrenzyMaxReward[1] * 2) / CacheGoldenCookiesMult; // eslint-disable-line no-unused-vars
CacheChainFrenzyRequiredNext = // eslint-disable-line no-unused-vars
CacheChainFrenzyMaxReward[2] /
60 /
60 /
6 /
CacheDragonsFortuneMultAdjustment;
CacheChainFrenzyMaxReward[2] / 60 / 60 / 6 / CacheDragonsFortuneMultAdjustment;
CacheChainFrenzyWrathMaxReward = MaxChainCookieReward(
6,
maxPayout * 7,
CacheWrathCookiesMult,
);
CacheChainFrenzyWrathRequired = // eslint-disable-line no-unused-vars
(CacheChainFrenzyWrathMaxReward[1] * 2) / CacheWrathCookiesMult;
CacheChainFrenzyWrathMaxReward = MaxChainCookieReward(6, maxPayout * 7, CacheWrathCookiesMult);
CacheChainFrenzyWrathRequired = (CacheChainFrenzyWrathMaxReward[1] * 2) / CacheWrathCookiesMult; // eslint-disable-line no-unused-vars
CacheChainFrenzyWrathRequiredNext = // eslint-disable-line no-unused-vars
CacheChainFrenzyWrathMaxReward[2] /
60 /
60 /
6 /
CacheDragonsFortuneMultAdjustment;
CacheChainFrenzyWrathMaxReward[2] / 60 / 60 / 6 / CacheDragonsFortuneMultAdjustment;
}

View File

@@ -15,15 +15,12 @@ export default function CacheHeavenlyChipsPS() {
// Only calculate every new second
if ((Game.T / Game.fps) % 1 === 0) {
const chipsOwned = Game.HowMuchPrestige(Game.cookiesReset);
const ascendNowToOwn = Math.floor(
Game.HowMuchPrestige(Game.cookiesReset + Game.cookiesEarned),
);
const ascendNowToOwn = Math.floor(Game.HowMuchPrestige(Game.cookiesReset + Game.cookiesEarned));
const ascendNowToGet = ascendNowToOwn - Math.floor(chipsOwned);
// Add recent gains to AvgQueue's
const timeDiff = currDate - CacheLastHeavenlyCheck;
const heavenlyChipsDiffAvg =
Math.max(0, ascendNowToGet - CacheLastHeavenlyChips) / timeDiff;
const heavenlyChipsDiffAvg = Math.max(0, ascendNowToGet - CacheLastHeavenlyChips) / timeDiff;
for (let i = 0; i < timeDiff; i++) {
HeavenlyChipsDiff.addLatest(heavenlyChipsDiffAvg);
}

View File

@@ -38,11 +38,7 @@ export default function CacheAllMissingUpgrades() {
/* eslint-disable no-unused-vars */
if (me.pool === 'prestige') CacheMissingUpgradesPrestige += str;
else if (me.pool === 'cookie') CacheMissingUpgradesCookies += str;
else if (
me.pool !== 'toggle' &&
me.pool !== 'unused' &&
me.pool !== 'debug'
)
else if (me.pool !== 'toggle' && me.pool !== 'unused' && me.pool !== 'debug')
CacheMissingUpgrades += str;
/* eslint-enable no-unused-vars */
}

View File

@@ -31,10 +31,8 @@ export function CacheStatsCookies() {
CacheLuckyReward = CacheGoldenCookiesMult * (CacheLucky * 0.15) + 13; // eslint-disable-line no-unused-vars
CacheLuckyWrathReward = CacheWrathCookiesMult * (CacheLucky * 0.15) + 13; // eslint-disable-line no-unused-vars
CacheLuckyFrenzy = CacheLucky * 7;
CacheLuckyRewardFrenzy = // eslint-disable-line no-unused-vars
CacheGoldenCookiesMult * (CacheLuckyFrenzy * 0.15) + 13;
CacheLuckyWrathRewardFrenzy = // eslint-disable-line no-unused-vars
CacheWrathCookiesMult * (CacheLuckyFrenzy * 0.15) + 13;
CacheLuckyRewardFrenzy = CacheGoldenCookiesMult * (CacheLuckyFrenzy * 0.15) + 13; // eslint-disable-line no-unused-vars
CacheLuckyWrathRewardFrenzy = CacheWrathCookiesMult * (CacheLuckyFrenzy * 0.15) + 13; // eslint-disable-line no-unused-vars
CacheConjure = CacheLucky * 2;
CacheConjureReward = CacheConjure * 0.15; // eslint-disable-line no-unused-vars
@@ -84,7 +82,6 @@ export function CacheGoldenAndWrathCookiesMults() {
// Otherwise, the aura effect will be factored in the base CPS making the multiplier not requiring adjustment.
CacheDragonsFortuneMultAdjustment = 1;
if (Game.shimmerTypes.golden.n === 0) {
CacheDragonsFortuneMultAdjustment *=
1 + Game.auraMult("Dragon's Fortune") * 1.23;
CacheDragonsFortuneMultAdjustment *= 1 + Game.auraMult("Dragon's Fortune") * 1.23;
}
}

View File

@@ -10,8 +10,7 @@ export default function AllAmountTillNextAchievement() {
CacheObjectsNextAchievement[i].TotalNeeded > Game.Objects[i].amount
) {
result[i] = {
AmountNeeded:
CacheObjectsNextAchievement[i].TotalNeeded - Game.Objects[i].amount,
AmountNeeded: CacheObjectsNextAchievement[i].TotalNeeded - Game.Objects[i].amount,
TotalNeeded: CacheObjectsNextAchievement[i].TotalNeeded,
};
} else {

View File

@@ -34,8 +34,7 @@ export default function CacheWrinklers() {
CacheWrinklersTotal += sucked; // eslint-disable-line no-unused-vars
if (Game.wrinklers[i].type === 0) {
CacheWrinklersNormal += sucked; // eslint-disable-line no-unused-vars
if (sucked > CacheWrinklersFattest[0])
CacheWrinklersFattest = [sucked, i];
if (sucked > CacheWrinklersFattest[0]) CacheWrinklersFattest = [sucked, i];
}
}
}