remove the no-bitwise rule and all the eslint-disable-rule stuff

This commit is contained in:
IvarK 2022-08-04 19:02:39 +03:00
parent 871626e992
commit a590c353a9
28 changed files with 2 additions and 93 deletions

View File

@ -200,7 +200,6 @@
],
"new-parens": "error",
"no-array-constructor": "warn",
"no-bitwise": "warn",
"no-inline-comments": "error",
"no-lonely-if": "error",
"no-mixed-spaces-and-tabs": "error",

View File

@ -1,4 +1,4 @@
/* eslint-disable no-bitwise, no-console */
/* eslint-disable no-console */
const fs = require("fs");
const path = require("path");

View File

@ -5,9 +5,7 @@ class AchievementState extends GameMechanicState {
super(config);
this._row = Math.floor(this.id / 10);
this._column = this.id % 10;
// eslint-disable-next-line no-bitwise
this._bitmask = 1 << (this.column - 1);
// eslint-disable-next-line no-bitwise
this._inverseBitmask = ~this._bitmask;
this.registerEvents(config.checkEvent, args => this.tryUnlock(args));
}
@ -33,7 +31,6 @@ class AchievementState extends GameMechanicState {
}
get isUnlocked() {
// eslint-disable-next-line no-bitwise
return (player.achievementBits[this.row - 1] & this._bitmask) !== 0;
}
@ -52,13 +49,11 @@ class AchievementState extends GameMechanicState {
}
lock() {
// eslint-disable-next-line no-bitwise
player.achievementBits[this.row - 1] &= this._inverseBitmask;
}
unlock(auto) {
if (this.isUnlocked) return;
// eslint-disable-next-line no-bitwise
player.achievementBits[this.row - 1] |= this._bitmask;
if (this.id === 85 || this.id === 93) {
Autobuyer.bigCrunch.bumpAmount(4);

View File

@ -5,9 +5,7 @@ class SecretAchievementState extends GameMechanicState {
super(config);
this._row = Math.floor(this.id / 10);
this._column = this.id % 10;
// eslint-disable-next-line no-bitwise
this._bitmask = 1 << (this.column - 1);
// eslint-disable-next-line no-bitwise
this._inverseBitmask = ~this._bitmask;
this.registerEvents(config.checkEvent, args => this.tryUnlock(args));
}
@ -25,7 +23,6 @@ class SecretAchievementState extends GameMechanicState {
}
get isUnlocked() {
// eslint-disable-next-line no-bitwise
return (player.secretAchievementBits[this.row - 1] & this._bitmask) !== 0;
}
@ -37,14 +34,12 @@ class SecretAchievementState extends GameMechanicState {
unlock() {
if (this.isUnlocked) return;
// eslint-disable-next-line no-bitwise
player.secretAchievementBits[this.row - 1] |= this._bitmask;
GameUI.notify.success(`Secret Achievement: ${this.name}`);
EventHub.dispatch(GAME_EVENT.ACHIEVEMENT_UNLOCKED);
}
lock() {
// eslint-disable-next-line no-bitwise
player.secretAchievementBits[this.row - 1] &= this._inverseBitmask;
}
}

View File

@ -176,7 +176,6 @@ export const V = {
return VUnlocks.vAchievementUnlock.canBeUnlocked;
},
unlockCelestial() {
// eslint-disable-next-line no-bitwise
player.celestials.v.unlockBits |= (1 << VUnlocks.vAchievementUnlock.id);
GameUI.notify.success("You have unlocked V, The Celestial Of Achievements!", 10000);
V.quotes.unlock.show();

View File

@ -53,11 +53,9 @@ export const Effarig = {
get glyphEffectAmount() {
const genEffectBitmask = Glyphs.activeList
.filter(g => generatedTypes.includes(g.type))
// eslint-disable-next-line no-bitwise
.reduce((prev, curr) => prev | curr.effects, 0);
const nongenEffectBitmask = Glyphs.activeList
.filter(g => !generatedTypes.includes(g.type))
// eslint-disable-next-line no-bitwise
.reduce((prev, curr) => prev | curr.effects, 0);
return countValuesFromBitmask(genEffectBitmask) + countValuesFromBitmask(nongenEffectBitmask);
},

View File

@ -204,12 +204,10 @@ class EnslavedProgressState extends BitUpgradeState {
set bits(value) { player.celestials.enslaved.hintBits = value; }
get hasProgress() {
// eslint-disable-next-line no-bitwise
return Boolean(player.celestials.enslaved.progressBits & (1 << this.id));
}
get hasHint() {
// eslint-disable-next-line no-bitwise
return this.hasProgress || this.isUnlocked;
}
@ -227,7 +225,6 @@ class EnslavedProgressState extends BitUpgradeState {
player.celestials.enslaved.zeroHintTime -= Math.log(2) / Math.log(3) * TimeSpan.fromDays(1).totalMilliseconds;
GameUI.notify.success("You found a crack in The Enslaved Ones' Reality!", 10000);
}
// eslint-disable-next-line no-bitwise
player.celestials.enslaved.progressBits |= (1 << this.id);
}
}

View File

@ -417,19 +417,16 @@ dev.testReplicantiCode = function(singleId, useDebugger = false) {
],
[
function() {
// eslint-disable-next-line no-bitwise
player.achievementBits[8] |= 16;
}
],
[
function() {
// eslint-disable-next-line no-bitwise
player.achievementBits[12] |= 8;
}
],
[
function() {
// eslint-disable-next-line no-bitwise
player.achievementBits[12] |= 128;
}
],
@ -459,7 +456,6 @@ dev.testReplicantiCode = function(singleId, useDebugger = false) {
],
[
function() {
// eslint-disable-next-line no-bitwise
player.reality.upgReqs = (1 << 6);
player.reality.upgradeBits = 64;
}

View File

@ -35,7 +35,6 @@ function giveEternityRewards(auto) {
AutomatorData.lastECCompletionCount = completionCount;
if (Enslaved.isRunning && completionCount > 5) EnslavedProgress.ec1.giveProgress();
}
// eslint-disable-next-line no-bitwise
player.challenge.eternity.requirementBits &= ~(1 << challenge.id);
respecTimeStudies(auto);
}

View File

@ -20,16 +20,13 @@ export class BitPurchasableMechanicState extends PurchasableMechanicState {
get bitIndex() { throw new NotImplementedError(); }
get isBought() {
// eslint-disable-next-line no-bitwise
return (this.bits & (1 << this.bitIndex)) !== 0;
}
set isBought(value) {
if (value) {
// eslint-disable-next-line no-bitwise
this.bits |= (1 << this.bitIndex);
} else {
// eslint-disable-next-line no-bitwise
this.bits &= ~(1 << this.bitIndex);
}
}

View File

@ -16,7 +16,6 @@ export class BitUpgradeState extends GameMechanicState {
set bits(value) { throw new NotImplementedError(); }
get isUnlocked() {
// eslint-disable-next-line no-bitwise
return Boolean(this.bits & (1 << this.id));
}
@ -33,7 +32,6 @@ export class BitUpgradeState extends GameMechanicState {
unlock() {
if (!this.canBeUnlocked) return;
// eslint-disable-next-line no-bitwise
this.bits |= (1 << this.id);
this.onUnlock();
}

View File

@ -201,14 +201,12 @@ export function findGlyphTypeEffects(glyphType) {
}
export function makeGlyphEffectBitmask(effectList) {
// eslint-disable-next-line no-bitwise
return effectList.reduce((mask, eff) => mask + (1 << GlyphEffects[eff].bitmaskIndex), 0);
}
export function getGlyphEffectsFromBitmask(bitmask) {
return orderedEffectList
.map(effectName => GlyphEffects[effectName])
// eslint-disable-next-line no-bitwise
.filter(effect => (bitmask & (1 << effect.bitmaskIndex)) !== 0);
}

View File

@ -424,7 +424,6 @@ export const Glyphs = {
},
sortByEffect() {
function reverseBitstring(eff) {
// eslint-disable-next-line no-bitwise
return parseInt(((1 << 30) + (eff >>> 0)).toString(2).split("").reverse().join(""), 2);
}
// The bitwise reversal is so that the effects with the LOWER id are valued higher in the sorting.
@ -449,7 +448,6 @@ export const Glyphs = {
g.type === glyph.type &&
g.id !== glyph.id &&
(g.level >= glyph.level || g.strength >= glyph.strength) &&
// eslint-disable-next-line no-bitwise
((g.effects & glyph.effects) === glyph.effects));
let compareThreshold = glyph.type === "effarig" || glyph.type === "reality" ? 1 : 5;
compareThreshold = Math.clampMax(compareThreshold, threshold);
@ -614,10 +612,8 @@ export const Glyphs = {
applyGamespeed(glyph) {
if (!Ra.unlocks.allGamespeedGlyphs.canBeApplied) return;
if (BASIC_GLYPH_TYPES.includes(glyph.type)) {
// eslint-disable-next-line no-bitwise
glyph.effects |= (1 << GlyphEffects.timespeed.bitmaskIndex);
if (glyph.type === "time") {
// eslint-disable-next-line no-bitwise
glyph.effects |= (1 << GlyphEffects.timeshardpow.bitmaskIndex);
}
}

View File

@ -66,7 +66,6 @@ export function getGlyphEffectValues(effectKey) {
throw new Error(`Unknown Glyph effect requested "${effectKey}"'`);
}
return player.reality.glyphs.active
// eslint-disable-next-line no-bitwise
.filter(glyph => ((1 << GlyphEffects[effectKey].bitmaskIndex) & glyph.effects) !== 0)
.filter(glyph => generatedTypes.includes(glyph.type) === GlyphEffects[effectKey].isGenerated)
.map(glyph => getSingleGlyphEffectFromBitmask(effectKey, glyph));
@ -110,7 +109,6 @@ export function getGlyphEffectValuesFromBitmask(bitmask, level, baseStrength, ty
// Pulls out a single effect value from a glyph's bitmask, returning just the value (nothing for missing effects)
export function getSingleGlyphEffectFromBitmask(effectName, glyph) {
const glyphEffect = GlyphEffects[effectName];
// eslint-disable-next-line no-bitwise
if ((glyph.effects & (1 << glyphEffect.bitmaskIndex)) === 0) {
return undefined;
}
@ -122,9 +120,7 @@ export function countValuesFromBitmask(bitmask) {
let numEffects = 0;
let bits = bitmask;
while (bits !== 0) {
// eslint-disable-next-line no-bitwise
numEffects += bits & 1;
// eslint-disable-next-line no-bitwise
bits >>= 1;
}
return numEffects;

View File

@ -154,7 +154,6 @@ export const GlyphGenerator = {
const effectList = GlyphEffects.all.filter(e => e.id.startsWith(type));
effectList.push(GlyphEffects.timespeed);
let bitmask = 0;
// eslint-disable-next-line no-bitwise
for (const effect of effectList) bitmask |= 1 << effect.bitmaskIndex;
const glyphLevel = Math.max(player.records.bestReality.glyphLevel, 5000);
return {

View File

@ -24,7 +24,6 @@ class ImaginaryUpgradeState extends BitPurchasableMechanicState {
}
get isAvailableForPurchase() {
// eslint-disable-next-line no-bitwise
return (player.reality.imaginaryUpgReqs & (1 << this.id)) !== 0;
}
@ -42,7 +41,6 @@ class ImaginaryUpgradeState extends BitPurchasableMechanicState {
tryUnlock() {
if (!MachineHandler.isIMUnlocked || this.isAvailableForPurchase || !this.config.checkRequirement()) return;
// eslint-disable-next-line no-bitwise
player.reality.imaginaryUpgReqs |= (1 << this.id);
GameUI.notify.reality(`You've unlocked an Imaginary Upgrade: ${this.config.name}`);
}
@ -114,7 +112,6 @@ export const ImaginaryUpgrades = {
return this.all.countWhere(u => u.isBought);
},
get allBought() {
// eslint-disable-next-line no-bitwise
return (player.reality.imaginaryUpgradeBits >> 6) + 1 === 1 << (GameDatabase.reality.imaginaryUpgrades.length - 5);
}
};

View File

@ -64,12 +64,10 @@ class InfinityChallengeState extends GameMechanicState {
}
get isCompleted() {
// eslint-disable-next-line no-bitwise
return (player.challenge.infinity.completedBits & (1 << this.id)) !== 0;
}
complete() {
// eslint-disable-next-line no-bitwise
player.challenge.infinity.completedBits |= 1 << this.id;
EventHub.dispatch(GAME_EVENT.INFINITY_CHALLENGE_COMPLETED);
}

View File

@ -516,13 +516,11 @@ window.logFactorial = (function() {
/** 32 bit XORSHIFT generator */
window.xorshift32Update = function xorshift32Update(state) {
/* eslint-disable no-bitwise */
/* eslint-disable no-param-reassign */
state ^= state << 13;
state ^= state >>> 17;
state ^= state << 5;
/* eslint-enable no-param-reassign */
/* eslint-enable no-bitwise */
return state;
};

View File

@ -22,7 +22,6 @@ export const NewsHandler = {
// If the bit array isn't large enough (ie. the numerical ID is the largest we've seen so far by a long shot), then
// we pad the array with zeroes until we can fit the new ID in before actually adding it.
while (this.BITS_PER_MASK * player.news.seen[type].length <= number) player.news.seen[type].push(0);
// eslint-disable-next-line no-bitwise
player.news.seen[type][Math.floor(number / this.BITS_PER_MASK)] |= 1 << (number % this.BITS_PER_MASK);
},
@ -33,7 +32,6 @@ export const NewsHandler = {
const bitArray = player.news.seen[type];
if (!bitArray || this.BITS_PER_MASK * bitArray.length < number) return false;
// eslint-disable-next-line no-bitwise
return (bitArray[Math.floor(number / this.BITS_PER_MASK)] |= 1 << (number % this.BITS_PER_MASK)) !== 0;
},

View File

@ -94,12 +94,10 @@ class NormalChallengeState extends GameMechanicState {
}
get isCompleted() {
// eslint-disable-next-line no-bitwise
return (player.challenge.normal.completedBits & (1 << this.id)) !== 0;
}
complete() {
// eslint-disable-next-line no-bitwise
player.challenge.normal.completedBits |= 1 << this.id;
// Since breaking infinity maxes even autobuyers that aren't unlocked,
// it's possible to get r52 or r53 from completing a challenge

View File

@ -35,7 +35,6 @@ class RealityUpgradeState extends BitPurchasableMechanicState {
}
get isAvailableForPurchase() {
// eslint-disable-next-line no-bitwise
return (player.reality.upgReqs & (1 << this.id)) !== 0;
}
@ -46,7 +45,6 @@ class RealityUpgradeState extends BitPurchasableMechanicState {
tryUnlock() {
const realityReached = PlayerProgress.realityUnlocked() || TimeStudy.reality.isBought;
if (!realityReached || this.isAvailableForPurchase || !this.config.checkRequirement()) return;
// eslint-disable-next-line no-bitwise
player.reality.upgReqs |= (1 << this.id);
GameUI.notify.reality(`You've unlocked a Reality Upgrade: ${this.config.name}`);
}
@ -102,7 +100,6 @@ export const RealityUpgrades = {
*/
all: RealityUpgradeState.index.compact(),
get allBought() {
// eslint-disable-next-line no-bitwise
return (player.reality.upgradeBits >> 6) + 1 === 1 << (GameDatabase.reality.upgrades.length - 5);
}
};

View File

@ -1,4 +1,4 @@
/* eslint-disable no-bitwise,no-param-reassign */
/* eslint-disable no-param-reassign */
// Copyright (c) 2011, Daniel Guerrero
// All rights reserved.

View File

@ -2,7 +2,6 @@ import { GameStorage } from "./storage";
function arrayToBits(array) {
let bits = 0;
// eslint-disable-next-line no-bitwise
for (const id of array) bits |= (1 << id);
return bits;
}
@ -288,7 +287,6 @@ GameStorage.devMigrations = {
player.reality.upgradeBits = arrayToBits(player.reality.upg);
delete player.reality.upg;
}
// eslint-disable-next-line no-bitwise
if ((player.reality.upgradeBits & (1 << 25)) === 0) {
player.realityBuyer.isOn = false;
}
@ -358,7 +356,6 @@ GameStorage.devMigrations = {
for (const effect of orderedEffectList) {
const typeEffect = separateEffectKey(effect);
if (glyph.type === typeEffect[0] && glyph.effects[typeEffect[1]] !== undefined) {
// eslint-disable-next-line no-bitwise
effectBitmask += 1 << GlyphEffects[effect].bitmaskIndex;
}
}
@ -751,7 +748,6 @@ GameStorage.devMigrations = {
}
},
player => {
// eslint-disable-next-line no-bitwise
player.celestials.ra.unlockBits &= ~(1 << 29);
},
player => {
@ -975,7 +971,6 @@ GameStorage.devMigrations = {
let reqBitmask = 0;
for (let i = 0; i <= player.reality.upgReqs.length; i++) {
// eslint-disable-next-line no-bitwise
if (player.reality.upgReqs[i]) reqBitmask |= (1 << i);
}
player.reality.upgReqs = reqBitmask;
@ -1218,42 +1213,29 @@ GameStorage.devMigrations = {
player.celestials.pelle.galaxyGenerator.unlocked = player.celestials.pelle.galaxyGenerator.generatedGalaxies > 0;
},
player => {
// eslint-disable-next-line no-bitwise
if (player.celestials.pelle.doomed) player.achievementBits[17] |= 1;
// eslint-disable-next-line no-bitwise
if (player.celestials.pelle.upgrades.has(4)) player.achievementBits[17] |= 2;
if (player.celestials.pelle.doomed && player.challenge.infinity.completedBits === 510) {
// eslint-disable-next-line no-bitwise
player.achievementBits[17] |= (1 << 2);
}
// eslint-disable-next-line no-bitwise
if (player.timestudy.studies.compact().includes(181)) player.achievementBits[17] |= (1 << 5);
},
player => {
// eslint-disable-next-line no-bitwise
player.achievementBits[16] |= (player.achievementBits[16] & (1 << 4)) << 3;
// eslint-disable-next-line no-bitwise
player.achievementBits[16] &= ~(1 << 4);
// eslint-disable-next-line no-bitwise
player.achievementBits[16] |= (player.achievementBits[16] & (1 << 2)) << 2;
// eslint-disable-next-line no-bitwise
player.achievementBits[16] &= ~(1 << 2);
},
player => {
// eslint-disable-next-line no-bitwise
player.achievementBits[17] &= ~(1 << 5);
if (player.timestudy.studies.compact().includes(181) && player.celestials.pelle.doomed) {
// eslint-disable-next-line no-bitwise
player.achievementBits[17] |= (1 << 5);
}
},
player => {
// eslint-disable-next-line no-bitwise
if (player.celestials.pelle.doomed && (player.challenge.infinity.completedBits & (1 << 5)) !== 0) {
// eslint-disable-next-line no-bitwise
player.achievementBits[17] |= (1 << 2);
} else {
// eslint-disable-next-line no-bitwise
player.achievementBits[17] &= ~(1 << 2);
}
},
@ -1351,7 +1333,6 @@ GameStorage.devMigrations = {
},
player => {
const cel = player.celestials;
// eslint-disable-next-line no-bitwise
const convToBit = x => x.toBitmask() >> 1;
if (cel.teresa.quotes) player.celestials.teresa.quoteBits = convToBit(cel.teresa.quotes);
if (cel.effarig.quotes) player.celestials.effarig.quoteBits = convToBit(cel.effarig.quotes);

View File

@ -325,7 +325,6 @@ GameStorage.migrations = {
if (player.challenges) {
for (const fullID of player.challenges) {
const parsed = parseChallengeName(fullID);
// eslint-disable-next-line no-bitwise
player.challenge[parsed.type].completedBits |= 1 << parsed.id;
}
delete player.challenges;
@ -665,7 +664,6 @@ GameStorage.migrations = {
const number = parseInt(groups[2], 10);
if (!player.news.seen[type]) player.news.seen[type] = [];
while (maskLength * player.news.seen[type].length < number) player.news.seen[type].push(0);
// eslint-disable-next-line no-bitwise
player.news.seen[type][Math.floor(number / maskLength)] |= 1 << (number % maskLength);
}
@ -708,21 +706,17 @@ GameStorage.migrations = {
if (!isSecret && [row, column].join(",") in swaps) {
[row, column] = swaps[[row, column].join(",")].split(",");
}
// eslint-disable-next-line no-bitwise
newAchievements[row - 1] |= (1 << (column - 1));
}
// Handle the changed achievement "No DLC Required" correctly (otherwise saves could miss it).
if (!isSecret && (player.infinityUpgrades.size >= 16 || player.eternities.gt(0) || player.realities > 0)) {
// eslint-disable-next-line no-bitwise
newAchievements[3] |= 1;
} else {
// eslint-disable-next-line no-bitwise
newAchievements[3] &= ~1;
}
// "Professional Bodybuilder" (s38) was changed and shouldn't be migrated
if (isSecret) {
// eslint-disable-next-line no-bitwise
newAchievements[2] &= ~128;
}
};
@ -911,7 +905,6 @@ GameStorage.migrations = {
},
etercreqConversion(player) {
// eslint-disable-next-line no-bitwise
if (player.etercreq) player.challenge.eternity.requirementBits |= 1 << player.etercreq;
delete player.etercreq;
},

View File

@ -33,7 +33,6 @@ export class ECTimeStudyState extends TimeStudyState {
if (!auto) {
Tab.challenges.eternity.show();
}
// eslint-disable-next-line no-bitwise
player.challenge.eternity.requirementBits |= 1 << this.id;
Currency.timeTheorems.subtract(this.cost);
TimeStudyTree.commitToGameState([TimeStudy.eternityChallenge(this.id)]);
@ -118,7 +117,6 @@ export class ECTimeStudyState extends TimeStudyState {
get wasRequirementPreviouslyMet() {
if (this.id === 11 || this.id === 12) return false;
// eslint-disable-next-line no-bitwise
return (player.challenge.eternity.requirementBits & (1 << this.id)) !== 0;
}

View File

@ -9,7 +9,6 @@ class TabNotificationState {
}
get triggered() {
// eslint-disable-next-line no-bitwise
return player.triggeredTabNotificationBits & (1 << this.config.id);
}
@ -17,7 +16,6 @@ class TabNotificationState {
if (!this.config.condition() || this.triggered) return;
this.config.tabsToHighLight.map(t => t.parent + t.tab)
.forEach(tab => player.tabNotifications.add(tab));
// eslint-disable-next-line no-bitwise
player.triggeredTabNotificationBits |= 1 << this.config.id;
// Force all tabs and subtabs of this notification to be unhidden

View File

@ -22,7 +22,6 @@ class SubtabState {
get isHidden() {
if (Enslaved.isRunning || Pelle.hasGalaxyGenerator) return false;
// eslint-disable-next-line no-bitwise
return ((player.options.hiddenSubtabBits[this._parent.id] & (1 << this.id)) !== 0) &&
this.hidable;
}
@ -53,13 +52,11 @@ class SubtabState {
unhideTab() {
this._parent.unhideTab();
// eslint-disable-next-line no-bitwise
player.options.hiddenSubtabBits[this._parent.id] &= ~(1 << this.id);
}
toggleVisibility() {
if (this._parent.id === Tabs.current.id && this.id === Tabs.current._currentSubtab.id) return;
// eslint-disable-next-line no-bitwise
player.options.hiddenSubtabBits[this._parent.id] ^= (1 << this.id);
checkTabVisibilityForSecretAchievement();
@ -111,7 +108,6 @@ class TabState {
get isHidden() {
if (Enslaved.isRunning || Pelle.hasGalaxyGenerator) return false;
const hasVisibleSubtab = this.subtabs.some(t => t.isAvailable);
// eslint-disable-next-line no-bitwise
return (((player.options.hiddenTabBits & (1 << this.id)) !== 0) || !hasVisibleSubtab) && this.hidable;
}
@ -155,13 +151,11 @@ class TabState {
}
unhideTab() {
// eslint-disable-next-line no-bitwise
player.options.hiddenTabBits &= ~(1 << this.id);
}
toggleVisibility() {
if (this.id === Tabs.current.id) return;
// eslint-disable-next-line no-bitwise
player.options.hiddenTabBits ^= (1 << this.id);
checkTabVisibilityForSecretAchievement();

View File

@ -230,12 +230,9 @@ export default {
throw new Error(`Unrecognized glyph type "${this.glyph.type}" in glyph effect icons`);
}
const effectIDs = [];
// eslint-disable-next-line no-bitwise
let remainingEffects = this.glyph.effects >> minEffectID;
for (let id = 0; remainingEffects > 0; id++) {
// eslint-disable-next-line no-bitwise
if ((remainingEffects & 1) === 1) effectIDs.push(id);
// eslint-disable-next-line no-bitwise
remainingEffects >>= 1;
}
return effectIDs;