CODEBASE: Expand lint rules, and Aliases are stored as maps (#501)

This commit is contained in:
Snarling 2023-05-05 03:55:59 -04:00 committed by GitHub
parent d25254caf1
commit ebae35b1fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
202 changed files with 905 additions and 1110 deletions

@ -7,8 +7,8 @@ module.exports = {
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:@typescript-eslint/strict",
//"plugin:@typescript-eslint/recommended-requiring-type-checking",
//"plugin:@typescript-eslint/strict",
],
parser: "@typescript-eslint/parser",
parserOptions: {
@ -20,7 +20,6 @@ module.exports = {
project: ["./tsconfig.json", "./test/tsconfig.json", "./tools/tsconfig.json"],
},
plugins: ["@typescript-eslint"],
extends: ["plugin:@typescript-eslint/recommended"],
rules: {
"@typescript-eslint/no-unused-vars": [
"error",

@ -61,9 +61,7 @@ function bitNodeFinishedState(): boolean {
const wd = GetServer(SpecialServers.WorldDaemon);
if (!(wd instanceof Server)) return false;
if (wd.backdoorInstalled) return true;
return (
Player.bladeburner !== null && Player.bladeburner.blackops.hasOwnProperty(BlackOperationNames.OperationDaedalus)
);
return Player.bladeburner !== null && BlackOperationNames.OperationDaedalus in Player.bladeburner.blackops;
}
function hasAccessToSF(player: PlayerObject, bn: number): boolean {
@ -100,7 +98,7 @@ export const achievements: Record<string, Achievement> = {
Condition: () => Player.factions.includes(FactionNames.NiteSec),
},
THE_BLACK_HAND: {
...achievementData["THE_BLACK_HAND"],
...achievementData.THE_BLACK_HAND,
Icon: "TBH",
Condition: () => Player.factions.includes(FactionNames.TheBlackHand),
},
@ -115,7 +113,7 @@ export const achievements: Record<string, Achievement> = {
Condition: () => Player.factions.includes(FactionNames.Daedalus),
},
THE_COVENANT: {
...achievementData["THE_COVENANT"],
...achievementData.THE_COVENANT,
Icon: FactionNames.TheCovenant.toLowerCase().replace(/ /g, ""),
Condition: () => Player.factions.includes(FactionNames.TheCovenant),
},
@ -228,38 +226,38 @@ export const achievements: Record<string, Achievement> = {
Condition: () => Player.sourceFileLvl(12) >= 1,
},
MONEY_1Q: {
...achievementData["MONEY_1Q"],
...achievementData.MONEY_1Q,
Icon: "$1Q",
Condition: () => Player.money >= 1e18,
},
MONEY_M1B: {
...achievementData["MONEY_M1B"],
...achievementData.MONEY_M1B,
Icon: "-1b",
Secret: true,
Condition: () => Player.money <= -1e9,
},
INSTALL_1: {
...achievementData["INSTALL_1"],
...achievementData.INSTALL_1,
Icon: "install",
Condition: () => Player.augmentations.length >= 1,
},
INSTALL_100: {
...achievementData["INSTALL_100"],
...achievementData.INSTALL_100,
Icon: "install_100",
Condition: () => Player.augmentations.length >= 100,
},
QUEUE_40: {
...achievementData["QUEUE_40"],
...achievementData.QUEUE_40,
Icon: "queue40",
Condition: () => Player.queuedAugmentations.length >= 40,
},
HACKING_100000: {
...achievementData["HACKING_100000"],
...achievementData.HACKING_100000,
Icon: "hack100000",
Condition: () => Player.skills.hacking >= 100000,
},
COMBAT_3000: {
...achievementData["COMBAT_3000"],
...achievementData.COMBAT_3000,
Icon: "combat3000",
Condition: () =>
Player.skills.strength >= 3000 &&
@ -268,27 +266,27 @@ export const achievements: Record<string, Achievement> = {
Player.skills.agility >= 3000,
},
NEUROFLUX_255: {
...achievementData["NEUROFLUX_255"],
...achievementData.NEUROFLUX_255,
Icon: "nf255",
Condition: () => Player.augmentations.some((a) => a.name === AugmentationNames.NeuroFluxGovernor && a.level >= 255),
},
NS2: {
...achievementData["NS2"],
...achievementData.NS2,
Icon: "ns2",
Condition: () => [...Player.getHomeComputer().scripts.values()].some((s) => s.filename.endsWith(".js")),
},
FROZE: {
...achievementData["FROZE"],
...achievementData.FROZE,
Icon: "forze",
Condition: () => location.href.includes("noScripts"),
},
RUNNING_SCRIPTS_1000: {
...achievementData["RUNNING_SCRIPTS_1000"],
...achievementData.RUNNING_SCRIPTS_1000,
Icon: "run1000",
Condition: (): boolean => workerScripts.size >= 1000,
},
DRAIN_SERVER: {
...achievementData["DRAIN_SERVER"],
...achievementData.DRAIN_SERVER,
Icon: "drain",
Condition: (): boolean => {
for (const s of GetAllServers()) {
@ -300,33 +298,33 @@ export const achievements: Record<string, Achievement> = {
},
},
MAX_RAM: {
...achievementData["MAX_RAM"],
...achievementData.MAX_RAM,
Icon: "maxram",
Condition: () => Player.getHomeComputer().maxRam === CONSTANTS.HomeComputerMaxRam,
},
MAX_CORES: {
...achievementData["MAX_CORES"],
...achievementData.MAX_CORES,
Icon: "maxcores",
Condition: () => Player.getHomeComputer().cpuCores === 8,
},
SCRIPTS_30: {
...achievementData["SCRIPTS_30"],
...achievementData.SCRIPTS_30,
Icon: "folders",
Condition: () => Player.getHomeComputer().scripts.size >= 30,
},
KARMA_1000000: {
...achievementData["KARMA_1000000"],
...achievementData.KARMA_1000000,
Icon: "karma",
Secret: true,
Condition: () => Player.karma <= -1e6,
},
STOCK_1q: {
...achievementData["STOCK_1q"],
...achievementData.STOCK_1q,
Icon: "$1Q",
Condition: () => Player.moneySourceB.stock >= 1e15,
},
DISCOUNT: {
...achievementData["DISCOUNT"],
...achievementData.DISCOUNT,
Icon: "discount",
Condition: (): boolean => {
const p = GetServer("powerhouse-fitness");
@ -335,12 +333,12 @@ export const achievements: Record<string, Achievement> = {
},
},
SCRIPT_32GB: {
...achievementData["SCRIPT_32GB"],
...achievementData.SCRIPT_32GB,
Icon: "bigcost",
Condition: () => [...Player.getHomeComputer().scripts.values()].some((s) => (s.ramUsage ?? 0) >= 32),
},
FIRST_HACKNET_NODE: {
...achievementData["FIRST_HACKNET_NODE"],
...achievementData.FIRST_HACKNET_NODE,
Icon: "node",
Condition: () => !hasHacknetServers() && Player.hacknetNodes.length > 0,
},
@ -350,7 +348,7 @@ export const achievements: Record<string, Achievement> = {
Condition: () => !hasHacknetServers() && Player.hacknetNodes.length >= 30,
},
MAX_HACKNET_NODE: {
...achievementData["MAX_HACKNET_NODE"],
...achievementData.MAX_HACKNET_NODE,
Icon: "hacknet-max",
Condition: (): boolean => {
if (hasHacknetServers()) return false;
@ -367,17 +365,17 @@ export const achievements: Record<string, Achievement> = {
},
},
HACKNET_NODE_10M: {
...achievementData["HACKNET_NODE_10M"],
...achievementData.HACKNET_NODE_10M,
Icon: "hacknet-10m",
Condition: () => !hasHacknetServers() && Player.moneySourceB.hacknet >= 10e6,
},
REPUTATION_10M: {
...achievementData["REPUTATION_10M"],
...achievementData.REPUTATION_10M,
Icon: "reputation",
Condition: () => Object.values(Factions).some((f) => f.playerReputation >= 10e6),
},
DONATION: {
...achievementData["DONATION"],
...achievementData.DONATION,
Icon: "donation",
Condition: () =>
Object.values(Factions).some(
@ -385,45 +383,45 @@ export const achievements: Record<string, Achievement> = {
),
},
TRAVEL: {
...achievementData["TRAVEL"],
...achievementData.TRAVEL,
Icon: "TRAVEL",
Condition: () => Player.city !== CityName.Sector12,
},
WORKOUT: {
...achievementData["WORKOUT"],
...achievementData.WORKOUT,
Icon: "WORKOUT",
Condition: () => isClassWork(Player.currentWork),
},
TOR: {
...achievementData["TOR"],
...achievementData.TOR,
Icon: "TOR",
Condition: () => Player.hasTorRouter(),
},
HOSPITALIZED: {
...achievementData["HOSPITALIZED"],
...achievementData.HOSPITALIZED,
Icon: "OUCH",
Condition: () => Player.moneySourceB.hospitalization !== 0,
},
GANG: {
...achievementData["GANG"],
...achievementData.GANG,
Icon: "GANG",
Visible: () => hasAccessToSF(Player, 2),
Condition: () => Player.gang !== null,
},
FULL_GANG: {
...achievementData["FULL_GANG"],
...achievementData.FULL_GANG,
Icon: "GANGMAX",
Visible: () => hasAccessToSF(Player, 2),
Condition: () => Player.gang !== null && Player.gang.members.length === GangConstants.MaximumGangMembers,
},
GANG_TERRITORY: {
...achievementData["GANG_TERRITORY"],
...achievementData.GANG_TERRITORY,
Icon: "GANG100%",
Visible: () => hasAccessToSF(Player, 2),
Condition: () => Player.gang !== null && AllGangs[Player.gang.facName].territory >= 0.999,
},
GANG_MEMBER_POWER: {
...achievementData["GANG_MEMBER_POWER"],
...achievementData.GANG_MEMBER_POWER,
Icon: "GANG10000",
Visible: () => hasAccessToSF(Player, 2),
Condition: () =>
@ -434,25 +432,25 @@ export const achievements: Record<string, Achievement> = {
),
},
CORPORATION: {
...achievementData["CORPORATION"],
...achievementData.CORPORATION,
Icon: "CORP",
Visible: () => hasAccessToSF(Player, 3),
Condition: () => Player.corporation !== null,
},
CORPORATION_BRIBE: {
...achievementData["CORPORATION_BRIBE"],
...achievementData.CORPORATION_BRIBE,
Icon: "CORPLOBBY",
Visible: () => hasAccessToSF(Player, 3),
Condition: () => Player.corporation !== null && Player.corporation.unlockUpgrades[6] === 1,
},
CORPORATION_PROD_1000: {
...achievementData["CORPORATION_PROD_1000"],
...achievementData.CORPORATION_PROD_1000,
Icon: "CORP1000",
Visible: () => hasAccessToSF(Player, 3),
Condition: () => Player.corporation !== null && Player.corporation.divisions.some((d) => d.prodMult >= 1000),
},
CORPORATION_EMPLOYEE_3000: {
...achievementData["CORPORATION_EMPLOYEE_3000"],
...achievementData.CORPORATION_EMPLOYEE_3000,
Icon: "CORPCITY",
Visible: () => hasAccessToSF(Player, 3),
Condition: (): boolean => {
@ -466,7 +464,7 @@ export const achievements: Record<string, Achievement> = {
},
},
CORPORATION_REAL_ESTATE: {
...achievementData["CORPORATION_REAL_ESTATE"],
...achievementData.CORPORATION_REAL_ESTATE,
Icon: "CORPRE",
Name: "Own the land",
Description: "Expand to the Real Estate division.",
@ -475,19 +473,19 @@ export const achievements: Record<string, Achievement> = {
Player.corporation !== null && Player.corporation.divisions.some((d) => d.type === IndustryType.RealEstate),
},
INTELLIGENCE_255: {
...achievementData["INTELLIGENCE_255"],
...achievementData.INTELLIGENCE_255,
Icon: "INT255",
Visible: () => hasAccessToSF(Player, 5),
Condition: () => Player.skills.intelligence >= 255,
},
BLADEBURNER_DIVISION: {
...achievementData["BLADEBURNER_DIVISION"],
...achievementData.BLADEBURNER_DIVISION,
Icon: "BLADE",
Visible: () => hasAccessToSF(Player, 6),
Condition: () => Player.bladeburner !== null,
},
BLADEBURNER_OVERCLOCK: {
...achievementData["BLADEBURNER_OVERCLOCK"],
...achievementData.BLADEBURNER_OVERCLOCK,
Icon: "BLADEOVERCLOCK",
Visible: () => hasAccessToSF(Player, 6),
Condition: () =>
@ -495,7 +493,7 @@ export const achievements: Record<string, Achievement> = {
Player.bladeburner.skills[SkillNames.Overclock] === Skills[SkillNames.Overclock].maxLvl,
},
BLADEBURNER_UNSPENT_100000: {
...achievementData["BLADEBURNER_UNSPENT_100000"],
...achievementData.BLADEBURNER_UNSPENT_100000,
Icon: "BLADE100K",
Visible: () => hasAccessToSF(Player, 6),
Condition: () => Player.bladeburner !== null && Player.bladeburner.skillPoints >= 100000,
@ -506,21 +504,21 @@ export const achievements: Record<string, Achievement> = {
Condition: () => Player.has4SData,
},
FIRST_HACKNET_SERVER: {
...achievementData["FIRST_HACKNET_SERVER"],
...achievementData.FIRST_HACKNET_SERVER,
Icon: "HASHNET",
Visible: () => hasAccessToSF(Player, 9),
Condition: () => hasHacknetServers() && Player.hacknetNodes.length > 0,
AdditionalUnlock: [achievementData.FIRST_HACKNET_NODE.ID],
},
ALL_HACKNET_SERVER: {
...achievementData["ALL_HACKNET_SERVER"],
...achievementData.ALL_HACKNET_SERVER,
Icon: "HASHNETALL",
Visible: () => hasAccessToSF(Player, 9),
Condition: () => hasHacknetServers() && Player.hacknetNodes.length === HacknetServerConstants.MaxServers,
AdditionalUnlock: [achievementData["30_HACKNET_NODE"].ID],
},
MAX_HACKNET_SERVER: {
...achievementData["MAX_HACKNET_SERVER"],
...achievementData.MAX_HACKNET_SERVER,
Icon: "HASHNETALL",
Visible: () => hasAccessToSF(Player, 9),
Condition: (): boolean => {
@ -542,14 +540,14 @@ export const achievements: Record<string, Achievement> = {
AdditionalUnlock: [achievementData.MAX_HACKNET_NODE.ID],
},
HACKNET_SERVER_1B: {
...achievementData["HACKNET_SERVER_1B"],
...achievementData.HACKNET_SERVER_1B,
Icon: "HASHNETMONEY",
Visible: () => hasAccessToSF(Player, 9),
Condition: () => hasHacknetServers() && Player.moneySourceB.hacknet >= 1e9,
AdditionalUnlock: [achievementData.HACKNET_NODE_10M.ID],
},
MAX_CACHE: {
...achievementData["MAX_CACHE"],
...achievementData.MAX_CACHE,
Icon: "HASHNETCAP",
Visible: () => hasAccessToSF(Player, 9),
Condition: () =>
@ -558,13 +556,13 @@ export const achievements: Record<string, Achievement> = {
Player.hashManager.capacity > 0,
},
SLEEVE_8: {
...achievementData["SLEEVE_8"],
...achievementData.SLEEVE_8,
Icon: "SLEEVE8",
Visible: () => hasAccessToSF(Player, 10),
Condition: () => Player.sleeves.length === 8 && Player.sourceFileLvl(10) === 3,
},
INDECISIVE: {
...achievementData["INDECISIVE"],
...achievementData.INDECISIVE,
Icon: "1H",
Visible: () => knowsAboutBitverse(Player),
Condition: (function () {
@ -580,13 +578,13 @@ export const achievements: Record<string, Achievement> = {
})(),
},
FAST_BN: {
...achievementData["FAST_BN"],
...achievementData.FAST_BN,
Icon: "2DAYS",
Visible: () => knowsAboutBitverse(Player),
Condition: () => bitNodeFinishedState() && Player.playtimeSinceLastBitnode < 1000 * 60 * 60 * 24 * 2,
},
CHALLENGE_BN1: {
...achievementData["CHALLENGE_BN1"],
...achievementData.CHALLENGE_BN1,
Icon: "BN1+",
Visible: () => knowsAboutBitverse(Player),
Condition: () =>
@ -596,37 +594,37 @@ export const achievements: Record<string, Achievement> = {
Player.getHomeComputer().cpuCores === 1,
},
CHALLENGE_BN2: {
...achievementData["CHALLENGE_BN2"],
...achievementData.CHALLENGE_BN2,
Icon: "BN2+",
Visible: () => hasAccessToSF(Player, 2),
Condition: () => Player.bitNodeN === 2 && bitNodeFinishedState() && Player.gang === null,
},
CHALLENGE_BN3: {
...achievementData["CHALLENGE_BN3"],
...achievementData.CHALLENGE_BN3,
Icon: "BN3+",
Visible: () => hasAccessToSF(Player, 3),
Condition: () => Player.bitNodeN === 3 && bitNodeFinishedState() && Player.corporation === null,
},
CHALLENGE_BN6: {
...achievementData["CHALLENGE_BN6"],
...achievementData.CHALLENGE_BN6,
Icon: "BN6+",
Visible: () => hasAccessToSF(Player, 6),
Condition: () => Player.bitNodeN === 6 && bitNodeFinishedState() && Player.bladeburner === null,
},
CHALLENGE_BN7: {
...achievementData["CHALLENGE_BN7"],
...achievementData.CHALLENGE_BN7,
Icon: "BN7+",
Visible: () => hasAccessToSF(Player, 7),
Condition: () => Player.bitNodeN === 7 && bitNodeFinishedState() && Player.bladeburner === null,
},
CHALLENGE_BN8: {
...achievementData["CHALLENGE_BN8"],
...achievementData.CHALLENGE_BN8,
Icon: "BN8+",
Visible: () => hasAccessToSF(Player, 8),
Condition: () => Player.bitNodeN === 8 && bitNodeFinishedState() && !Player.has4SData && !Player.has4SDataTixApi,
},
CHALLENGE_BN9: {
...achievementData["CHALLENGE_BN9"],
...achievementData.CHALLENGE_BN9,
Icon: "BN9+",
Visible: () => hasAccessToSF(Player, 9),
Condition: () =>
@ -636,7 +634,7 @@ export const achievements: Record<string, Achievement> = {
Player.moneySourceB.hacknet_expenses === 0,
},
CHALLENGE_BN10: {
...achievementData["CHALLENGE_BN10"],
...achievementData.CHALLENGE_BN10,
Icon: "BN10+",
Visible: () => hasAccessToSF(Player, 10),
Condition: () =>
@ -654,68 +652,68 @@ export const achievements: Record<string, Achievement> = {
),
},
CHALLENGE_BN12: {
...achievementData["CHALLENGE_BN12"],
...achievementData.CHALLENGE_BN12,
Icon: "BN12+",
Visible: () => hasAccessToSF(Player, 12),
Condition: () => Player.sourceFileLvl(12) >= 50,
},
BYPASS: {
...achievementData["BYPASS"],
...achievementData.BYPASS,
Icon: "SF-1",
Secret: true,
Condition: () => Player.exploits.includes(Exploit.Bypass),
},
PROTOTYPETAMPERING: {
...achievementData["PROTOTYPETAMPERING"],
...achievementData.PROTOTYPETAMPERING,
Icon: "SF-1",
Secret: true,
Condition: () => Player.exploits.includes(Exploit.PrototypeTampering),
},
UNCLICKABLE: {
...achievementData["UNCLICKABLE"],
...achievementData.UNCLICKABLE,
Icon: "SF-1",
Secret: true,
Condition: () => Player.exploits.includes(Exploit.Unclickable),
},
UNDOCUMENTEDFUNCTIONCALL: {
...achievementData["UNDOCUMENTEDFUNCTIONCALL"],
...achievementData.UNDOCUMENTEDFUNCTIONCALL,
Icon: "SF-1",
Secret: true,
Condition: () => Player.exploits.includes(Exploit.UndocumentedFunctionCall),
},
TIMECOMPRESSION: {
...achievementData["TIMECOMPRESSION"],
...achievementData.TIMECOMPRESSION,
Icon: "SF-1",
Secret: true,
Condition: () => Player.exploits.includes(Exploit.TimeCompression),
},
REALITYALTERATION: {
...achievementData["REALITYALTERATION"],
...achievementData.REALITYALTERATION,
Icon: "SF-1",
Secret: true,
Condition: () => Player.exploits.includes(Exploit.RealityAlteration),
},
N00DLES: {
...achievementData["N00DLES"],
...achievementData.N00DLES,
Icon: "SF-1",
Secret: true,
Condition: () => Player.exploits.includes(Exploit.N00dles),
},
EDITSAVEFILE: {
...achievementData["EDITSAVEFILE"],
...achievementData.EDITSAVEFILE,
Icon: "SF-1",
Secret: true,
Condition: () => Player.exploits.includes(Exploit.EditSaveFile),
},
UNACHIEVABLE: {
...achievementData["UNACHIEVABLE"],
...achievementData.UNACHIEVABLE,
Icon: "SF-1",
Secret: true,
// Hey Players! Yes, you're supposed to modify this to get the achievement!
Condition: () => false,
},
CHALLENGE_BN13: {
...achievementData["CHALLENGE_BN13"],
...achievementData.CHALLENGE_BN13,
Icon: "BN13+",
Visible: () => hasAccessToSF(Player, 13),
Condition: () =>
@ -724,19 +722,19 @@ export const achievements: Record<string, Achievement> = {
!Player.augmentations.some((a) => a.name === AugmentationNames.StaneksGift1),
},
DEVMENU: {
...achievementData["DEVMENU"],
...achievementData.DEVMENU,
Icon: "SF-1",
Secret: true,
Condition: () => Player.exploits.includes(Exploit.YoureNotMeantToAccessThis),
},
RAINBOW: {
...achievementData["RAINBOW"],
...achievementData.RAINBOW,
Icon: "SF-1",
Secret: true,
Condition: () => Player.exploits.includes(Exploit.INeedARainbow),
},
TRUE_RECURSION: {
...achievementData["TRUE_RECURSION"],
...achievementData.TRUE_RECURSION,
Icon: "SF-1",
Secret: true,
Condition: () => Player.exploits.includes(Exploit.TrueRecursion),

@ -1,36 +1,30 @@
import { Terminal } from "./Terminal";
export let Aliases: Record<string, string> = {};
export let GlobalAliases: Record<string, string> = {};
export const Aliases = new Map<string, string>();
export const GlobalAliases = new Map<string, string>();
export function loadAliases(saveString: string): void {
if (saveString === "") {
Aliases = {};
} else {
Aliases = JSON.parse(saveString);
Aliases.clear();
const parsedAliases: unknown = JSON.parse(saveString);
if (!parsedAliases || typeof parsedAliases !== "object") return;
for (const [name, alias] of Object.entries(parsedAliases)) {
if (typeof name === "string" && typeof alias === "string") Aliases.set(name, alias);
}
}
export function loadGlobalAliases(saveString: string): void {
if (saveString === "") {
GlobalAliases = {};
} else {
GlobalAliases = JSON.parse(saveString);
GlobalAliases.clear();
const parsedAliases: unknown = JSON.parse(saveString);
if (!parsedAliases || typeof parsedAliases !== "object") return;
for (const [name, alias] of Object.entries(parsedAliases)) {
if (typeof name === "string" && typeof alias === "string") GlobalAliases.set(name, alias);
}
}
// Prints all aliases to terminal
export function printAliases(): void {
for (const name of Object.keys(Aliases)) {
if (Aliases.hasOwnProperty(name)) {
Terminal.print("alias " + name + "=" + Aliases[name]);
}
}
for (const name of Object.keys(GlobalAliases)) {
if (GlobalAliases.hasOwnProperty(name)) {
Terminal.print("global alias " + name + "=" + GlobalAliases[name]);
}
}
for (const [name, alias] of Aliases) Terminal.print("alias " + name + "=" + alias);
for (const [name, alias] of GlobalAliases) Terminal.print("global alias " + name + "=" + alias);
}
// Returns true if successful, false otherwise
@ -50,46 +44,20 @@ export function parseAliasDeclaration(dec: string, global = false): boolean {
}
function addAlias(name: string, value: string): void {
if (name in GlobalAliases) {
delete GlobalAliases[name];
}
Aliases[name] = value.trim();
GlobalAliases.delete(name);
Aliases.set(name, value.trim());
}
function addGlobalAlias(name: string, value: string): void {
if (name in Aliases) {
delete Aliases[name];
}
GlobalAliases[name] = value.trim();
}
function getAlias(name: string): string | null {
if (Aliases.hasOwnProperty(name)) {
return Aliases[name];
}
return null;
}
function getGlobalAlias(name: string): string | null {
if (GlobalAliases.hasOwnProperty(name)) {
return GlobalAliases[name];
}
return null;
Aliases.delete(name);
GlobalAliases.set(name, value.trim());
}
export function removeAlias(name: string): boolean {
if (Aliases.hasOwnProperty(name)) {
delete Aliases[name];
return true;
}
if (GlobalAliases.hasOwnProperty(name)) {
delete GlobalAliases[name];
return true;
}
return false;
const hadAlias = Aliases.has(name) || GlobalAliases.has(name);
Aliases.delete(name);
GlobalAliases.delete(name);
return hadAlias;
}
/**
@ -110,15 +78,15 @@ export function substituteAliases(origCommand: string): string {
while (somethingSubstituted && depth < 10) {
depth++;
somethingSubstituted = false;
const alias = getAlias(commandArray[0])?.split(" ");
if (alias != null) {
const alias = Aliases.get(commandArray[0])?.split(" ");
if (alias !== undefined) {
somethingSubstituted = true;
commandArray.splice(0, 1, ...alias);
//commandArray[0] = alias;
}
for (let i = 0; i < commandArray.length; ++i) {
const alias = getGlobalAlias(commandArray[i])?.split(" ");
if (alias != null) {
const alias = GlobalAliases.get(commandArray[i])?.split(" ");
if (alias !== undefined) {
somethingSubstituted = true;
commandArray.splice(i, 1, ...alias);
i += alias.length - 1;

@ -584,16 +584,8 @@ export class Augmentation {
// Adds this Augmentation to all Factions
addToAllFactions(): void {
for (const fac of Object.keys(Factions)) {
if (Factions.hasOwnProperty(fac)) {
const facObj: Faction | null = Factions[fac];
if (facObj == null) {
console.warn(`Invalid Faction object in addToAllFactions(). Key value: ${fac}`);
continue;
}
if (facObj.getInfo().special) continue;
facObj.augmentations.push(this.name);
}
for (const faction of Object.values(Factions)) {
if (!faction.getInfo().special) faction.augmentations.push(this.name);
}
}

@ -9,7 +9,6 @@ import { Player } from "@player";
import { prestigeAugmentation } from "../Prestige";
import { dialogBoxCreate } from "../ui/React/DialogBox";
import { clearObject } from "../utils/helpers/clearObject";
import { FactionNames } from "../Faction/data/FactionNames";
import {
@ -41,16 +40,12 @@ function createAugmentations(): void {
}
function resetFactionAugmentations(): void {
for (const name of Object.keys(Factions)) {
if (Factions.hasOwnProperty(name)) {
Factions[name].augmentations = [];
}
}
for (const faction of Object.values(Factions)) faction.augmentations = [];
}
function initAugmentations(): void {
resetFactionAugmentations();
clearObject(StaticAugmentations);
for (const augName of Object.getOwnPropertyNames(StaticAugmentations)) delete StaticAugmentations[augName];
createAugmentations();
Player.reapplyAllAugmentations();
}
@ -144,7 +139,7 @@ function installAugmentations(force?: boolean): boolean {
}
function augmentationExists(name: string): boolean {
return StaticAugmentations.hasOwnProperty(name);
return Object.hasOwn(StaticAugmentations, name);
}
export function isRepeatableAug(aug: Augmentation | string): boolean {

@ -17,36 +17,33 @@ interface IProps {
aug?: Augmentation;
}
export function PurchaseAugmentationModal(props: IProps): React.ReactElement {
if (!props.aug || !props.faction) {
export function PurchaseAugmentationModal({ aug, faction, onClose, open }: IProps): React.ReactElement {
if (!aug || !faction || (!isRepeatableAug(aug) && Player.hasAugmentation(aug.name))) {
return <></>;
}
function buy(): void {
if (!props.aug || (!isRepeatableAug(props.aug) && Player.hasAugmentation(props.aug.name))) {
return;
}
purchaseAugmentation(props.aug as Augmentation, props.faction as Faction);
props.onClose();
}
return (
<Modal open={props.open} onClose={props.onClose}>
<Typography variant="h4">{props.aug.name}</Typography>
<Modal open={open} onClose={onClose}>
<Typography variant="h4">{aug.name}</Typography>
<Typography>
{props.aug.info}
{aug.info}
<br />
<br />
{props.aug.stats}
{aug.stats}
<br />
<br />
Would you like to purchase the {props.aug.name} Augmentation for&nbsp;
<Money money={props.aug.getCost().moneyCost} />?
Would you like to purchase the {aug.name} Augmentation for&nbsp;
<Money money={aug.getCost().moneyCost} />?
<br />
<br />
</Typography>
<Button autoFocus onClick={buy}>
<Button
autoFocus
onClick={() => {
purchaseAugmentation(aug, faction);
onClose();
}}
>
Purchase
</Button>
</Modal>

@ -30,7 +30,7 @@ class BitNode {
export const BitNodes: Record<string, BitNode> = {};
export function initBitNodes() {
BitNodes["BitNode1"] = new BitNode(
BitNodes.BitNode1 = new BitNode(
1,
0,
"Source Genesis",
@ -57,7 +57,7 @@ export function initBitNodes() {
</>
),
);
BitNodes["BitNode2"] = new BitNode(
BitNodes.BitNode2 = new BitNode(
2,
0,
"Rise of the Underworld",
@ -95,7 +95,7 @@ export function initBitNodes() {
</>
),
);
BitNodes["BitNode3"] = new BitNode(
BitNodes.BitNode3 = new BitNode(
3,
0,
"Corporatocracy",
@ -127,7 +127,7 @@ export function initBitNodes() {
</>
),
);
BitNodes["BitNode4"] = new BitNode(
BitNodes.BitNode4 = new BitNode(
4,
1,
"The Singularity",
@ -155,7 +155,7 @@ export function initBitNodes() {
</>
),
);
BitNodes["BitNode5"] = new BitNode(
BitNodes.BitNode5 = new BitNode(
5,
1,
"Artificial Intelligence",
@ -185,7 +185,7 @@ export function initBitNodes() {
</>
),
);
BitNodes["BitNode6"] = new BitNode(
BitNodes.BitNode6 = new BitNode(
6,
1,
FactionNames.Bladeburners,
@ -217,7 +217,7 @@ export function initBitNodes() {
</>
),
);
BitNodes["BitNode7"] = new BitNode(
BitNodes.BitNode7 = new BitNode(
7,
2,
`${FactionNames.Bladeburners} 2079`,
@ -249,7 +249,7 @@ export function initBitNodes() {
</>
),
);
BitNodes["BitNode8"] = new BitNode(
BitNodes.BitNode8 = new BitNode(
8,
2,
"Ghost of Wall Street",
@ -290,7 +290,7 @@ export function initBitNodes() {
</>
),
);
BitNodes["BitNode9"] = new BitNode(
BitNodes.BitNode9 = new BitNode(
9,
2,
"Hacktocracy",
@ -332,7 +332,7 @@ export function initBitNodes() {
</>
),
);
BitNodes["BitNode10"] = new BitNode(
BitNodes.BitNode10 = new BitNode(
10,
2,
"Digital Carbon",
@ -363,7 +363,7 @@ export function initBitNodes() {
</>
),
);
BitNodes["BitNode11"] = new BitNode(
BitNodes.BitNode11 = new BitNode(
11,
1,
"The Big Crash",
@ -406,7 +406,7 @@ export function initBitNodes() {
</>
),
);
BitNodes["BitNode12"] = new BitNode(
BitNodes.BitNode12 = new BitNode(
12,
0,
"The Recursion",
@ -423,7 +423,7 @@ export function initBitNodes() {
</>
),
);
BitNodes["BitNode13"] = new BitNode(
BitNodes.BitNode13 = new BitNode(
13,
2,
"They're lunatics",

@ -165,5 +165,4 @@ export interface IBitNodeMultipliers {
}
/** The multipliers that are influenced by current Bitnode progression. */
// tslint:disable-next-line:variable-name
export const BitNodeMultipliers = Object.assign({}, defaultMultipliers);

@ -60,13 +60,14 @@ export const BitNodeMultipliersDisplay = ({ n, level }: IProps): React.ReactElem
);
};
interface IBNMultRows {
[mult: string]: {
type IBNMultRows = Record<
string,
{
name: string;
content?: string;
color?: string;
};
}
}
>;
interface IBNMultTableProps {
sectionName: string;

@ -122,7 +122,7 @@ export class Action {
// Check to make sure weights are summed properly
let sum = 0;
for (const weight of Object.keys(this.weights)) {
if (this.weights.hasOwnProperty(weight)) {
if (Object.hasOwn(this.weights, weight)) {
sum += this.weights[weight];
}
}
@ -136,7 +136,7 @@ export class Action {
}
for (const decay of Object.keys(this.decays)) {
if (this.decays.hasOwnProperty(decay)) {
if (Object.hasOwn(this.decays, decay)) {
if (this.decays[decay] > 1) {
throw new Error(`Invalid decays when constructing Action ${this.name}. Decay value cannot be greater than 1`);
}
@ -243,7 +243,7 @@ export class Action {
let difficulty = this.getDifficulty();
let competence = 0;
for (const stat of Object.keys(this.weights)) {
if (this.weights.hasOwnProperty(stat)) {
if (Object.hasOwn(this.weights, stat)) {
const playerStatLvl = person.queryStatFromString(stat);
const key = "eff" + stat.charAt(0).toUpperCase() + stat.slice(1);
let effMultiplier = inst.skillMultipliers[key];

@ -67,7 +67,7 @@ export class Bladeburner {
actionTimeOverflow = 0;
action: ActionIdentifier = new ActionIdentifier({
type: ActionTypes["Idle"],
type: ActionTypes.Idle,
});
cities: Record<CityName, City>;
@ -90,11 +90,11 @@ export class Bladeburner {
};
automateEnabled = false;
automateActionHigh: ActionIdentifier = new ActionIdentifier({
type: ActionTypes["Idle"],
type: ActionTypes.Idle,
});
automateThreshHigh = 0;
automateActionLow: ActionIdentifier = new ActionIdentifier({
type: ActionTypes["Idle"],
type: ActionTypes.Idle,
});
automateThreshLow = 0;
consoleHistory: string[] = [];
@ -138,7 +138,7 @@ export class Bladeburner {
// Can't start a BlackOp if you haven't done the one before it
const blackops = [];
for (const nm of Object.keys(BlackOperations)) {
if (BlackOperations.hasOwnProperty(nm)) {
if (Object.hasOwn(BlackOperations, nm)) {
blackops.push(nm);
}
}
@ -165,10 +165,10 @@ export class Bladeburner {
this.action = actionId;
this.actionTimeCurrent = 0;
switch (actionId.type) {
case ActionTypes["Idle"]:
case ActionTypes.Idle:
this.actionTimeToComplete = 0;
break;
case ActionTypes["Contract"]:
case ActionTypes.Contract:
try {
const action = this.getActionObject(actionId);
if (action == null) {
@ -182,7 +182,7 @@ export class Bladeburner {
exceptionAlert(e);
}
break;
case ActionTypes["Operation"]: {
case ActionTypes.Operation: {
try {
const action = this.getActionObject(actionId);
if (action == null) {
@ -200,8 +200,8 @@ export class Bladeburner {
}
break;
}
case ActionTypes["BlackOp"]:
case ActionTypes["BlackOperation"]: {
case ActionTypes.BlackOp:
case ActionTypes.BlackOperation: {
try {
const testBlackOp = this.canAttemptBlackOp(actionId);
if (!testBlackOp.isAvailable) {
@ -218,15 +218,15 @@ export class Bladeburner {
}
break;
}
case ActionTypes["Recruitment"]:
case ActionTypes.Recruitment:
this.actionTimeToComplete = this.getRecruitmentTime(Player);
break;
case ActionTypes["Training"]:
case ActionTypes["FieldAnalysis"]:
case ActionTypes.Training:
case ActionTypes.FieldAnalysis:
case ActionTypes["Field Analysis"]:
this.actionTimeToComplete = 30;
break;
case ActionTypes["Diplomacy"]:
case ActionTypes.Diplomacy:
case ActionTypes["Hyperbolic Regeneration Chamber"]:
case ActionTypes["Incite Violence"]:
this.actionTimeToComplete = 60;
@ -318,8 +318,8 @@ export class Bladeburner {
case "contract":
case "contracts":
case "contr":
action.type = ActionTypes["Contract"];
if (this.contracts.hasOwnProperty(name)) {
action.type = ActionTypes.Contract;
if (Object.hasOwn(this.contracts, name)) {
action.name = name;
return action;
}
@ -328,8 +328,8 @@ export class Bladeburner {
case "operations":
case "op":
case "ops":
action.type = ActionTypes["Operation"];
if (this.operations.hasOwnProperty(name)) {
action.type = ActionTypes.Operation;
if (Object.hasOwn(this.operations, name)) {
action.name = name;
return action;
}
@ -341,8 +341,8 @@ export class Bladeburner {
case "black ops":
case "blackop":
case "blackops":
action.type = ActionTypes["BlackOp"];
if (BlackOperations.hasOwnProperty(name)) {
action.type = ActionTypes.BlackOp;
if (Object.hasOwn(BlackOperations, name)) {
action.name = name;
return action;
}
@ -358,12 +358,12 @@ export class Bladeburner {
if (convertedType.startsWith("gen")) {
switch (convertedName) {
case "training":
action.type = ActionTypes["Training"];
action.type = ActionTypes.Training;
action.name = "Training";
break;
case "recruitment":
case "recruit":
action.type = ActionTypes["Recruitment"];
action.type = ActionTypes.Recruitment;
action.name = "Recruitment";
break;
case "field analysis":
@ -372,7 +372,7 @@ export class Bladeburner {
action.name = "Field Analysis";
break;
case "diplomacy":
action.type = ActionTypes["Diplomacy"];
action.type = ActionTypes.Diplomacy;
action.name = "Diplomacy";
break;
case "hyperbolic regeneration chamber":
@ -1063,7 +1063,7 @@ export class Bladeburner {
updateSkillMultipliers(): void {
this.resetSkillMultipliers();
for (const skillName of Object.keys(this.skills)) {
if (this.skills.hasOwnProperty(skillName)) {
if (Object.hasOwn(this.skills, skillName)) {
const skill = Skills[skillName];
if (skill == null) {
throw new Error("Could not find Skill Object for: " + skillName);
@ -1191,21 +1191,21 @@ export class Bladeburner {
* GeneralAction, Contract, Operation, or BlackOperation object
*/
switch (actionId.type) {
case ActionTypes["Contract"]:
case ActionTypes.Contract:
return this.contracts[actionId.name];
case ActionTypes["Operation"]:
case ActionTypes.Operation:
return this.operations[actionId.name];
case ActionTypes["BlackOp"]:
case ActionTypes["BlackOperation"]:
case ActionTypes.BlackOp:
case ActionTypes.BlackOperation:
return BlackOperations[actionId.name];
case ActionTypes["Training"]:
return GeneralActions["Training"];
case ActionTypes.Training:
return GeneralActions.Training;
case ActionTypes["Field Analysis"]:
return GeneralActions["Field Analysis"];
case ActionTypes["Recruitment"]:
return GeneralActions["Recruitment"];
case ActionTypes["Diplomacy"]:
return GeneralActions["Diplomacy"];
case ActionTypes.Recruitment:
return GeneralActions.Recruitment;
case ActionTypes.Diplomacy:
return GeneralActions.Diplomacy;
case ActionTypes["Hyperbolic Regeneration Chamber"]:
return GeneralActions["Hyperbolic Regeneration Chamber"];
case ActionTypes["Incite Violence"]:
@ -1243,10 +1243,10 @@ export class Bladeburner {
completeAction(person: Person, actionIdent: ActionIdentifier, isPlayer = true): WorkStats {
let retValue = newWorkStats();
switch (actionIdent.type) {
case ActionTypes["Contract"]:
case ActionTypes["Operation"]: {
case ActionTypes.Contract:
case ActionTypes.Operation: {
try {
const isOperation = actionIdent.type === ActionTypes["Operation"];
const isOperation = actionIdent.type === ActionTypes.Operation;
const action = this.getActionObject(actionIdent);
if (action == null) {
throw new Error("Failed to get Contract/Operation Object for: " + actionIdent.name);
@ -1340,8 +1340,8 @@ export class Bladeburner {
}
break;
}
case ActionTypes["BlackOp"]:
case ActionTypes["BlackOperation"]: {
case ActionTypes.BlackOp:
case ActionTypes.BlackOperation: {
try {
const action = this.getActionObject(actionIdent);
if (action == null || !(action instanceof BlackOperation)) {
@ -1441,7 +1441,7 @@ export class Bladeburner {
}
break;
}
case ActionTypes["Training"]: {
case ActionTypes.Training: {
this.stamina -= 0.5 * BladeburnerConstants.BaseStaminaLoss;
const strExpGain = 30 * person.mults.strength_exp,
defExpGain = 30 * person.mults.defense_exp,
@ -1471,7 +1471,7 @@ export class Bladeburner {
}
break;
}
case ActionTypes["FieldAnalysis"]:
case ActionTypes.FieldAnalysis:
case ActionTypes["Field Analysis"]: {
// Does not use stamina. Effectiveness depends on hacking, int, and cha
let eff =
@ -1500,7 +1500,7 @@ export class Bladeburner {
}
break;
}
case ActionTypes["Recruitment"]: {
case ActionTypes.Recruitment: {
const successChance = this.getRecruitmentSuccessChance(person);
const recruitTime = this.getRecruitmentTime(person) * 1000;
if (Math.random() < successChance) {
@ -1529,7 +1529,7 @@ export class Bladeburner {
}
break;
}
case ActionTypes["Diplomacy"]: {
case ActionTypes.Diplomacy: {
const eff = this.getDiplomacyEffectiveness(person);
this.getCurrentCity().chaos *= eff;
if (this.getCurrentCity().chaos < 0) {
@ -1638,7 +1638,7 @@ export class Bladeburner {
}
processAction(seconds: number): void {
if (this.action.type === ActionTypes["Idle"]) return;
if (this.action.type === ActionTypes.Idle) return;
if (this.actionTimeToComplete <= 0) {
throw new Error(`Invalid actionTimeToComplete value: ${this.actionTimeToComplete}, type; ${this.action.type}`);
}
@ -1659,7 +1659,7 @@ export class Bladeburner {
// Operation Daedalus
if (action == null) {
throw new Error("Failed to get BlackOperation Object for: " + this.action.name);
} else if (this.action.type != ActionTypes["BlackOperation"] && this.action.type != ActionTypes["BlackOp"]) {
} else if (this.action.type != ActionTypes.BlackOperation && this.action.type != ActionTypes.BlackOp) {
this.startAction(this.action); // Repeat action
}
}
@ -1689,7 +1689,7 @@ export class Bladeburner {
}
create(): void {
this.contracts["Tracking"] = new Contract({
this.contracts.Tracking = new Contract({
name: "Tracking",
baseDifficulty: 125,
difficultyFac: 1.02,
@ -1745,7 +1745,7 @@ export class Bladeburner {
},
isKill: true,
});
this.contracts["Retirement"] = new Contract({
this.contracts.Retirement = new Contract({
name: "Retirement",
baseDifficulty: 200,
difficultyFac: 1.03,
@ -1774,7 +1774,7 @@ export class Bladeburner {
isKill: true,
});
this.operations["Investigation"] = new Operation({
this.operations.Investigation = new Operation({
name: "Investigation",
baseDifficulty: 400,
difficultyFac: 1.03,
@ -1863,7 +1863,7 @@ export class Bladeburner {
},
isStealth: true,
});
this.operations["Raid"] = new Operation({
this.operations.Raid = new Operation({
name: "Raid",
baseDifficulty: 800,
difficultyFac: 1.045,
@ -1924,7 +1924,7 @@ export class Bladeburner {
isStealth: true,
isKill: true,
});
this.operations["Assassination"] = new Operation({
this.operations.Assassination = new Operation({
name: "Assassination",
baseDifficulty: 1500,
difficultyFac: 1.06,
@ -1963,7 +1963,7 @@ export class Bladeburner {
// If the Player starts doing some other actions, set action to idle and alert
if (!Player.hasAugmentation(AugmentationNames.BladesSimulacrum, true) && Player.currentWork) {
if (this.action.type !== ActionTypes["Idle"]) {
if (this.action.type !== ActionTypes.Idle) {
let msg = "Your Bladeburner action was cancelled because you started doing something else.";
if (this.automateEnabled) {
msg += `\n\nYour automation was disabled as well. You will have to re-enable it through the Bladeburner console`;
@ -2111,7 +2111,7 @@ export class Bladeburner {
}
// Special logic for Black Ops
if (actionId.type === ActionTypes["BlackOp"]) {
if (actionId.type === ActionTypes.BlackOp) {
const canRunOp = this.canAttemptBlackOp(actionId);
if (!canRunOp.isAvailable) {
workerScript.log("bladeburner.startAction", () => canRunOp.error + "");
@ -2145,18 +2145,18 @@ export class Bladeburner {
return "bladeburner.getActionTime";
}
switch (actionId.type) {
case ActionTypes["Contract"]:
case ActionTypes["Operation"]:
case ActionTypes["BlackOp"]:
case ActionTypes["BlackOperation"]:
case ActionTypes.Contract:
case ActionTypes.Operation:
case ActionTypes.BlackOp:
case ActionTypes.BlackOperation:
return actionObj.getActionTime(this, person) * 1000;
case ActionTypes["Training"]:
case ActionTypes.Training:
case ActionTypes["Field Analysis"]:
case ActionTypes["FieldAnalysis"]:
case ActionTypes.FieldAnalysis:
return 30000;
case ActionTypes["Recruitment"]:
case ActionTypes.Recruitment:
return this.getRecruitmentTime(person) * 1000;
case ActionTypes["Diplomacy"]:
case ActionTypes.Diplomacy:
case ActionTypes["Hyperbolic Regeneration Chamber"]:
case ActionTypes["Incite Violence"]:
return 60000;
@ -2176,19 +2176,19 @@ export class Bladeburner {
return "bladeburner.getActionEstimatedSuccessChance";
}
switch (actionId.type) {
case ActionTypes["Contract"]:
case ActionTypes["Operation"]:
case ActionTypes["BlackOp"]:
case ActionTypes["BlackOperation"]:
case ActionTypes.Contract:
case ActionTypes.Operation:
case ActionTypes.BlackOp:
case ActionTypes.BlackOperation:
return actionObj.getEstSuccessChance(this, person);
case ActionTypes["Training"]:
case ActionTypes.Training:
case ActionTypes["Field Analysis"]:
case ActionTypes["FieldAnalysis"]:
case ActionTypes["Diplomacy"]:
case ActionTypes.FieldAnalysis:
case ActionTypes.Diplomacy:
case ActionTypes["Hyperbolic Regeneration Chamber"]:
case ActionTypes["Incite Violence"]:
return [1, 1];
case ActionTypes["Recruitment"]: {
case ActionTypes.Recruitment: {
const recChance = this.getRecruitmentSuccessChance(person);
return [recChance, recChance];
}
@ -2212,21 +2212,21 @@ export class Bladeburner {
}
switch (actionId.type) {
case ActionTypes["Contract"]:
case ActionTypes["Operation"]:
case ActionTypes.Contract:
case ActionTypes.Operation:
return Math.floor(actionObj.count);
case ActionTypes["BlackOp"]:
case ActionTypes["BlackOperation"]:
case ActionTypes.BlackOp:
case ActionTypes.BlackOperation:
if (this.blackops[name] != null) {
return 0;
} else {
return 1;
}
case ActionTypes["Training"]:
case ActionTypes["Recruitment"]:
case ActionTypes.Training:
case ActionTypes.Recruitment:
case ActionTypes["Field Analysis"]:
case ActionTypes["FieldAnalysis"]:
case ActionTypes["Diplomacy"]:
case ActionTypes.FieldAnalysis:
case ActionTypes.Diplomacy:
case ActionTypes["Hyperbolic Regeneration Chamber"]:
case ActionTypes["Incite Violence"]:
return Infinity;
@ -2237,7 +2237,7 @@ export class Bladeburner {
}
getSkillLevelNetscriptFn(skillName: string, workerScript: WorkerScript): number {
if (skillName === "" || !Skills.hasOwnProperty(skillName)) {
if (skillName === "" || !Object.hasOwn(Skills, skillName)) {
workerScript.log("bladeburner.getSkillLevel", () => `Invalid skill: '${skillName}'`);
return -1;
}
@ -2250,7 +2250,7 @@ export class Bladeburner {
}
getSkillUpgradeCostNetscriptFn(skillName: string, count: number, workerScript: WorkerScript): number {
if (skillName === "" || !Skills.hasOwnProperty(skillName)) {
if (skillName === "" || !Object.hasOwn(Skills, skillName)) {
workerScript.log("bladeburner.getSkillUpgradeCost", () => `Invalid skill: '${skillName}'`);
return -1;
}
@ -2265,7 +2265,7 @@ export class Bladeburner {
upgradeSkillNetscriptFn(skillName: string, count: number, workerScript: WorkerScript): boolean {
const errorLogText = `Invalid skill: '${skillName}'`;
if (!Skills.hasOwnProperty(skillName)) {
if (!Object.hasOwn(Skills, skillName)) {
workerScript.log("bladeburner.upgradeSkill", () => errorLogText);
return false;
}
@ -2316,9 +2316,9 @@ export class Bladeburner {
}
if (
actionId.type === ActionTypes["Operation"] ||
actionId.type === ActionTypes["BlackOp"] ||
actionId.type === ActionTypes["BlackOperation"]
actionId.type === ActionTypes.Operation ||
actionId.type === ActionTypes.BlackOp ||
actionId.type === ActionTypes.BlackOperation
) {
return actionObj.teamCount;
} else {
@ -2335,9 +2335,9 @@ export class Bladeburner {
}
if (
actionId.type !== ActionTypes["Operation"] &&
actionId.type !== ActionTypes["BlackOp"] &&
actionId.type !== ActionTypes["BlackOperation"]
actionId.type !== ActionTypes.Operation &&
actionId.type !== ActionTypes.BlackOp &&
actionId.type !== ActionTypes.BlackOperation
) {
workerScript.log("bladeburner.setTeamSize", () => "Only valid for 'Operations' and 'BlackOps'");
return -1;

@ -2,7 +2,7 @@ import { Action } from "./Action";
export const GeneralActions: Record<string, Action> = {};
const actionNames: Array<string> = [
const actionNames: string[] = [
"Training",
"Field Analysis",
"Recruitment",

@ -7,9 +7,7 @@ interface IBlackOp {
desc: JSX.Element;
}
export const BlackOperations: {
[key: string]: IBlackOp | undefined;
} = {
export const BlackOperations: Record<string, IBlackOp | undefined> = {
[BlackOperationNames.OperationTyphoon]: {
desc: (
<>

@ -4,9 +4,7 @@ interface IContract {
desc: JSX.Element;
}
export const Contracts: {
[key: string]: IContract | undefined;
} = {
export const Contracts: Record<string, IContract | undefined> = {
Tracking: {
desc: (
<>

@ -6,9 +6,7 @@ interface IGeneral {
exp: WorkStats;
}
export const GeneralActions: {
[key: string]: IGeneral | undefined;
} = {
export const GeneralActions: Record<string, IGeneral | undefined> = {
Training: {
desc: (
<>

@ -4,9 +4,7 @@ interface IOperation {
desc: JSX.Element;
}
export const Operations: {
[key: string]: IOperation | undefined;
} = {
export const Operations: Record<string, IOperation | undefined> = {
Investigation: {
desc: (
<>

@ -33,8 +33,7 @@ export function BlackOpElem(props: IProps): React.ReactElement {
}
const isActive =
props.bladeburner.action.type === ActionTypes["BlackOperation"] &&
props.action.name === props.bladeburner.action.name;
props.bladeburner.action.type === ActionTypes.BlackOperation && props.action.name === props.bladeburner.action.name;
const actionTime = props.action.getActionTime(props.bladeburner, Player);
const hasReqdRank = props.bladeburner.rank >= props.action.reqdRank;
const computedActionTimeCurrent = Math.min(

@ -11,7 +11,7 @@ interface IProps {
export function BlackOpList(props: IProps): React.ReactElement {
let blackops: BlackOperation[] = [];
for (const blackopName of Object.keys(BlackOperations)) {
if (BlackOperations.hasOwnProperty(blackopName)) {
if (Object.hasOwn(BlackOperations, blackopName)) {
blackops.push(BlackOperations[blackopName]);
}
}

@ -24,7 +24,7 @@ interface IProps {
export function ContractElem(props: IProps): React.ReactElement {
const rerender = useRerender();
const isActive =
props.bladeburner.action.type === ActionTypes["Contract"] && props.action.name === props.bladeburner.action.name;
props.bladeburner.action.type === ActionTypes.Contract && props.action.name === props.bladeburner.action.name;
const computedActionTimeCurrent = Math.min(
props.bladeburner.actionTimeCurrent + props.bladeburner.actionTimeOverflow,
props.bladeburner.actionTimeToComplete,

@ -11,7 +11,7 @@ interface IProps {
export function GeneralActionList(props: IProps): React.ReactElement {
const actions: Action[] = [];
for (const name of Object.keys(GeneralActions)) {
if (GeneralActions.hasOwnProperty(name)) {
if (Object.hasOwn(GeneralActions, name)) {
actions.push(GeneralActions[name]);
}
}

@ -25,7 +25,7 @@ interface IProps {
export function OperationElem(props: IProps): React.ReactElement {
const rerender = useRerender();
const isActive =
props.bladeburner.action.type === ActionTypes["Operation"] && props.action.name === props.bladeburner.action.name;
props.bladeburner.action.type === ActionTypes.Operation && props.action.name === props.bladeburner.action.name;
const computedActionTimeCurrent = Math.min(
props.bladeburner.actionTimeCurrent + props.bladeburner.actionTimeOverflow,
props.bladeburner.actionTimeToComplete,

@ -27,35 +27,35 @@ export function SkillPage(props: IProps): React.ReactElement {
Note that when upgrading a skill, the benefit for that skill is additive. However, the effects of different
skills with each other is multiplicative.
</Typography>
{valid(mults["successChanceAll"]) && (
<Typography>Total Success Chance: x{formatBigNumber(mults["successChanceAll"])}</Typography>
{valid(mults.successChanceAll) && (
<Typography>Total Success Chance: x{formatBigNumber(mults.successChanceAll)}</Typography>
)}
{valid(mults["successChanceStealth"]) && (
<Typography>Stealth Success Chance: x{formatBigNumber(mults["successChanceStealth"])}</Typography>
{valid(mults.successChanceStealth) && (
<Typography>Stealth Success Chance: x{formatBigNumber(mults.successChanceStealth)}</Typography>
)}
{valid(mults["successChanceKill"]) && (
<Typography>Retirement Success Chance: x{formatBigNumber(mults["successChanceKill"])}</Typography>
{valid(mults.successChanceKill) && (
<Typography>Retirement Success Chance: x{formatBigNumber(mults.successChanceKill)}</Typography>
)}
{valid(mults["successChanceContract"]) && (
<Typography>Contract Success Chance: x{formatBigNumber(mults["successChanceContract"])}</Typography>
{valid(mults.successChanceContract) && (
<Typography>Contract Success Chance: x{formatBigNumber(mults.successChanceContract)}</Typography>
)}
{valid(mults["successChanceOperation"]) && (
<Typography>Operation Success Chance: x{formatBigNumber(mults["successChanceOperation"])}</Typography>
{valid(mults.successChanceOperation) && (
<Typography>Operation Success Chance: x{formatBigNumber(mults.successChanceOperation)}</Typography>
)}
{valid(mults["successChanceEstimate"]) && (
<Typography>Synthoid Data Estimate: x{formatBigNumber(mults["successChanceEstimate"])}</Typography>
{valid(mults.successChanceEstimate) && (
<Typography>Synthoid Data Estimate: x{formatBigNumber(mults.successChanceEstimate)}</Typography>
)}
{valid(mults["actionTime"]) && <Typography>Action Time: x{formatBigNumber(mults["actionTime"])}</Typography>}
{valid(mults["effHack"]) && <Typography>Hacking Skill: x{formatBigNumber(mults["effHack"])}</Typography>}
{valid(mults["effStr"]) && <Typography>Strength: x{formatBigNumber(mults["effStr"])}</Typography>}
{valid(mults["effDef"]) && <Typography>Defense: x{formatBigNumber(mults["effDef"])}</Typography>}
{valid(mults["effDex"]) && <Typography>Dexterity: x{formatBigNumber(mults["effDex"])}</Typography>}
{valid(mults["effAgi"]) && <Typography>Agility: x{formatBigNumber(mults["effAgi"])}</Typography>}
{valid(mults["effCha"]) && <Typography>Charisma: x{formatBigNumber(mults["effCha"])}</Typography>}
{valid(mults["effInt"]) && <Typography>Intelligence: x{formatBigNumber(mults["effInt"])}</Typography>}
{valid(mults["stamina"]) && <Typography>Stamina: x{formatBigNumber(mults["stamina"])}</Typography>}
{valid(mults["money"]) && <Typography>Contract Money: x{formatBigNumber(mults["money"])}</Typography>}
{valid(mults["expGain"]) && <Typography>Exp Gain: x{formatBigNumber(mults["expGain"])}</Typography>}
{valid(mults.actionTime) && <Typography>Action Time: x{formatBigNumber(mults.actionTime)}</Typography>}
{valid(mults.effHack) && <Typography>Hacking Skill: x{formatBigNumber(mults.effHack)}</Typography>}
{valid(mults.effStr) && <Typography>Strength: x{formatBigNumber(mults.effStr)}</Typography>}
{valid(mults.effDef) && <Typography>Defense: x{formatBigNumber(mults.effDef)}</Typography>}
{valid(mults.effDex) && <Typography>Dexterity: x{formatBigNumber(mults.effDex)}</Typography>}
{valid(mults.effAgi) && <Typography>Agility: x{formatBigNumber(mults.effAgi)}</Typography>}
{valid(mults.effCha) && <Typography>Charisma: x{formatBigNumber(mults.effCha)}</Typography>}
{valid(mults.effInt) && <Typography>Intelligence: x{formatBigNumber(mults.effInt)}</Typography>}
{valid(mults.stamina) && <Typography>Stamina: x{formatBigNumber(mults.stamina)}</Typography>}
{valid(mults.money) && <Typography>Contract Money: x{formatBigNumber(mults.money)}</Typography>}
{valid(mults.expGain) && <Typography>Exp Gain: x{formatBigNumber(mults.expGain)}</Typography>}
<SkillList bladeburner={props.bladeburner} onUpgrade={() => setRerender((old) => !old)} />
</>
);

@ -33,7 +33,7 @@ export function TravelModal(props: IProps): React.ReactElement {
</Button>
))
) : (
<WorldMap currentCity={props.bladeburner.city as CityName} onTravel={travel} />
<WorldMap currentCity={props.bladeburner.city} onTravel={travel} />
)}
</>
</Modal>

@ -24,7 +24,7 @@ enum Result {
Tie = "Push! (Tie)",
}
type State = {
interface State {
playerHand: Hand;
dealerHand: Hand;
bet: number;
@ -34,7 +34,7 @@ type State = {
gains: number; // Track gains only for this session
wagerInvalid: boolean;
wagerInvalidHelperText: string;
};
}
export class Blackjack extends React.Component<Record<string, never>, State> {
deck: Deck;
@ -164,23 +164,15 @@ export class Blackjack extends React.Component<Record<string, never>, State> {
};
playerStay = (event: React.MouseEvent): void => {
if (!event.isTrusted) {
return;
}
if (!event.isTrusted) return;
// Determine if Dealer needs to hit. A dealer must hit if they have 16 or lower.
// If the dealer has a Soft 17 (Ace + 6), then they stay.
let newDealerHand = this.state.dealerHand;
while (true) {
// The dealer's "true" hand value is the 2nd one if its 21 or less (the 2nd value is always guaranteed
// to be equal or larger). Otherwise its the 1st.
const dealerHandValue = this.getTrueHandValue(newDealerHand);
if (dealerHandValue <= 16) {
newDealerHand = newDealerHand.addCards(this.deck.safeDrawCard());
} else {
break;
}
let dealerHandValue = this.getTrueHandValue(newDealerHand);
while (dealerHandValue <= 16) {
newDealerHand = newDealerHand.addCards(this.deck.safeDrawCard());
dealerHandValue = this.getTrueHandValue(newDealerHand);
}
this.setState({

@ -14,11 +14,9 @@ export class Deck {
}
drawCard(): Card {
if (this.cards.length == 0) {
throw new Error("Tried to draw card from empty deck");
}
return this.cards.shift() as Card; // Guaranteed to return a Card since we throw an Error if array is empty
if (this.cards.length == 0) throw new Error("Tried to draw card from empty deck");
// Guaranteed to return a Card since we throw an Error if array is empty
return this.cards.shift() as Card;
}
// Draws a card, resetting the deck beforehand if the Deck is empty

@ -5,10 +5,10 @@ import makeStyles from "@mui/styles/makeStyles";
import createStyles from "@mui/styles/createStyles";
import Paper from "@mui/material/Paper";
type Props = {
interface Props {
card: Card;
hidden?: boolean;
};
}
const useStyles = makeStyles(() =>
createStyles({

@ -15,10 +15,10 @@ function isRed(n: number): boolean {
return [1, 3, 5, 7, 9, 12, 14, 16, 18, 19, 21, 23, 25, 27, 30, 32, 34, 36].includes(n);
}
type Strategy = {
interface Strategy {
match: (n: number) => boolean;
payout: number;
};
}
const redNumbers: number[] = [1, 3, 5, 7, 9, 12, 14, 16, 18, 19, 21, 23, 25, 27, 30, 32, 34, 36];

@ -1,7 +1,7 @@
import * as React from "react";
export function trusted(f: () => void): (event: React.MouseEvent<HTMLElement, MouseEvent>) => void {
return function (event: React.MouseEvent<HTMLElement, MouseEvent>): void {
export function trusted(f: () => void): (event: React.MouseEvent<HTMLElement>) => void {
return function (event: React.MouseEvent<HTMLElement>): void {
if (!event.isTrusted) return;
f();
};

@ -4,8 +4,6 @@ import { Generic_fromJSON, Generic_toJSON, IReviverValue, constructorsForReviver
import { CodingContractEvent } from "./ui/React/CodingContractModal";
import { ContractFilePath, resolveContractFilePath } from "./Paths/ContractFilePath";
/* tslint:disable:no-magic-numbers completed-docs max-classes-per-file no-console */
/* Represents different types of problems that a Coding Contract can have */
class CodingContractType {
/** Function that generates a description of the problem */
@ -44,11 +42,9 @@ class CodingContractType {
}
/* Contract Types */
// tslint:disable-next-line
export const CodingContractTypes: Record<string, CodingContractType> = {};
for (const md of codingContractTypesMetadata) {
// tslint:disable-next-line
CodingContractTypes[md.name] = new CodingContractType(
md.name,
md.desc,

@ -3,8 +3,6 @@ import { CONSTANTS } from "../Constants";
import * as names from "./data/JobTracks";
import { JobName } from "../Enums";
/* tslint:disable:completed-docs */
export interface IConstructorParams {
name: JobName;
nextPosition: JobName | null;

@ -340,7 +340,7 @@ export class Corporation {
for (const city of Object.keys(industry.warehouses) as CityName[]) {
const warehouse = industry.warehouses[city];
if (warehouse === 0) continue;
if (industry.warehouses.hasOwnProperty(city) && warehouse) {
if (Object.hasOwn(industry.warehouses, city) && warehouse) {
warehouse.updateSize(this, industry);
}
}

@ -156,7 +156,7 @@ export class Industry {
warehouse.updateMaterialSizeUsed();
for (const prodName of Object.keys(this.products)) {
if (this.products.hasOwnProperty(prodName)) {
if (Object.hasOwn(this.products, prodName)) {
const prod = this.products[prodName];
if (prod === undefined) continue;
warehouse.sizeUsed += prod.data[warehouse.loc][0] * prod.siz;
@ -247,7 +247,7 @@ export class Industry {
if (this.warehouses[city]) {
const wh = this.warehouses[city] as Warehouse; // Warehouse type is known due to if check above
for (const name of Object.keys(reqMats) as CorpMaterialName[]) {
if (reqMats.hasOwnProperty(name)) {
if (Object.hasOwn(reqMats, name)) {
wh.materials[name].processMarket();
}
}
@ -268,7 +268,7 @@ export class Industry {
processProductMarket(marketCycles = 1): void {
// Demand gradually decreases, and competition gradually increases
for (const name of Object.keys(this.products)) {
if (this.products.hasOwnProperty(name)) {
if (Object.hasOwn(this.products, name)) {
const product = this.products[name];
if (product === undefined) continue;
let change = getRandomInt(0, 3) * 0.0004;
@ -308,7 +308,7 @@ export class Industry {
case "PURCHASE": {
/* Process purchase of materials */
for (const matName of Object.values(corpConstants.materialNames)) {
if (!warehouse.materials.hasOwnProperty(matName)) continue;
if (!Object.hasOwn(warehouse.materials, matName)) continue;
const mat = warehouse.materials[matName];
let buyAmt = 0;
let maxAmt = 0;
@ -331,7 +331,7 @@ export class Industry {
// smart supply
const smartBuy: Partial<Record<CorpMaterialName, number>> = {};
for (const matName of Object.values(corpConstants.materialNames)) {
if (!warehouse.materials.hasOwnProperty(matName)) continue;
if (!Object.hasOwn(warehouse.materials, matName)) continue;
if (!warehouse.smartSupplyEnabled || !Object.keys(this.reqMats).includes(matName)) continue;
const mat = warehouse.materials[matName];
@ -455,7 +455,7 @@ export class Industry {
// Make sure we have enough resource to make our materials
let producableFrac = 1;
for (const reqMatName of Object.keys(this.reqMats) as CorpMaterialName[]) {
if (this.reqMats.hasOwnProperty(reqMatName)) {
if (Object.hasOwn(this.reqMats, reqMatName)) {
const reqMat = this.reqMats[reqMatName];
if (reqMat === undefined) continue;
const req = reqMat * prod;
@ -504,7 +504,7 @@ export class Industry {
}
} else {
for (const reqMatName of Object.keys(this.reqMats) as CorpMaterialName[]) {
if (this.reqMats.hasOwnProperty(reqMatName)) {
if (Object.hasOwn(this.reqMats, reqMatName)) {
warehouse.materials[reqMatName].prd = 0;
}
}
@ -528,9 +528,9 @@ export class Industry {
case "SALE":
/* Process sale of materials */
for (const matName of Object.values(corpConstants.materialNames)) {
if (warehouse.materials.hasOwnProperty(matName)) {
if (Object.hasOwn(warehouse.materials, matName)) {
const mat = warehouse.materials[matName];
if (mat.sCost < 0 || mat.sllman[0] === false) {
if ((typeof mat.sCost === "number" && mat.sCost < 0) || !mat.sllman[0]) {
mat.sll = 0;
continue;
}
@ -547,7 +547,7 @@ export class Industry {
const adjustedQty = mat.qty / (corpConstants.secondsPerMarketCycle * marketCycles);
if (isString(mat.sllman[1])) {
//Dynamically evaluated
let tmp = (mat.sllman[1] as string).replace(/MAX/g, (adjustedQty + "").toUpperCase());
let tmp = mat.sllman[1].replace(/MAX/g, (adjustedQty + "").toUpperCase());
tmp = tmp.replace(/PROD/g, mat.prd + "");
try {
sellAmt = eval(tmp);
@ -562,7 +562,7 @@ export class Industry {
sellAmt = adjustedQty;
} else {
//Player's input value is just a number
sellAmt = mat.sllman[1] as number;
sellAmt = mat.sllman[1];
}
// Determine the cost that the material will be sold at
@ -603,7 +603,7 @@ export class Industry {
} else if (mat.marketTa1) {
sCost = mat.bCost + markupLimit;
} else if (isString(mat.sCost)) {
sCost = (mat.sCost as string).replace(/MP/g, mat.bCost + "");
sCost = mat.sCost.replace(/MP/g, mat.bCost + "");
sCost = eval(sCost);
} else {
sCost = mat.sCost;
@ -635,7 +635,7 @@ export class Industry {
this.getSalesMultiplier();
if (isString(mat.sllman[1])) {
//Dynamically evaluated
let tmp = (mat.sllman[1] as string).replace(/MAX/g, (mat.maxsll + "").toUpperCase());
let tmp = mat.sllman[1].replace(/MAX/g, (mat.maxsll + "").toUpperCase());
tmp = tmp.replace(/PROD/g, mat.prd + "");
try {
@ -653,7 +653,7 @@ export class Industry {
sellAmt = mat.maxsll;
} else {
//Player's input value is just a number
sellAmt = Math.min(mat.maxsll, mat.sllman[1] as number);
sellAmt = Math.min(mat.maxsll, mat.sllman[1]);
}
sellAmt = Math.min(mat.maxsll, sellAmt);
sellAmt = sellAmt * corpConstants.secondsPerMarketCycle * marketCycles;
@ -676,7 +676,7 @@ export class Industry {
case "EXPORT":
for (const matName of Object.values(corpConstants.materialNames)) {
if (warehouse.materials.hasOwnProperty(matName)) {
if (Object.hasOwn(warehouse.materials, matName)) {
const mat = warehouse.materials[matName];
mat.totalExp = 0; //Reset export
for (let expI = 0; expI < mat.exp.length; ++expI) {
@ -805,7 +805,7 @@ export class Industry {
//Produce Products
for (const prodName of Object.keys(this.products)) {
if (this.products.hasOwnProperty(prodName)) {
if (Object.hasOwn(this.products, prodName)) {
const prod = this.products[prodName];
if (prod && prod.fin) {
revenue += this.processProduct(marketCycles, prod, corporation);
@ -845,11 +845,8 @@ export class Industry {
//Calculate net change in warehouse storage making the Products will cost
let netStorageSize = product.siz;
for (const reqMatName of Object.keys(product.reqMats) as CorpMaterialName[]) {
if (product.reqMats.hasOwnProperty(reqMatName)) {
const normQty = product.reqMats[reqMatName] as number;
netStorageSize -= MaterialInfo[reqMatName].size * normQty;
}
for (const [reqMatName, reqQty] of Object.entries(product.reqMats) as [CorpMaterialName, number][]) {
netStorageSize -= MaterialInfo[reqMatName].size * reqQty;
}
//If there's not enough space in warehouse, limit the amount of Product
@ -1036,7 +1033,7 @@ export class Industry {
const warehouse = this.warehouses[city];
if (warehouse === 0) continue;
for (const matName of Object.values(corpConstants.materialNames)) {
if (warehouse.materials.hasOwnProperty(matName)) {
if (Object.hasOwn(warehouse.materials, matName)) {
const mat = warehouse.materials[matName];
mat.imp = 0;
}
@ -1047,7 +1044,7 @@ export class Industry {
discontinueProduct(product: Product): void {
for (const productName of Object.keys(this.products)) {
if (this.products.hasOwnProperty(productName)) {
if (Object.hasOwn(this.products, productName)) {
if (product === this.products[productName]) {
delete this.products[productName];
}

@ -258,7 +258,7 @@ export class OfficeSpace {
static fromJSON(value: IReviverValue): OfficeSpace {
// Convert employees from the old version
if (value.data.hasOwnProperty("employees")) {
if (Object.hasOwn(value.data, "employees")) {
const empCopy: [{ data: { mor: number; ene: number; exp: number } }] = value.data.employees;
delete value.data.employees;
const ret = Generic_fromJSON(OfficeSpace, value.data);

@ -58,7 +58,7 @@ export class Product {
advCost = 0; // How much money was invested into advertising this Product
// The average employee productivity and scientific research across the creation of the Product
creationProd: { [key: string]: number } = {
creationProd: Record<string, number> = {
[EmployeePositions.Operations]: 0,
[EmployeePositions.Engineer]: 0,
[EmployeePositions.Business]: 0,
@ -233,7 +233,7 @@ export class Product {
//Calculate the product's required materials
//For now, just set it to be the same as the requirements to make materials
for (const matName of Object.keys(industry.reqMats) as CorpMaterialName[]) {
if (industry.reqMats.hasOwnProperty(matName)) {
if (Object.hasOwn(industry.reqMats, matName)) {
const reqMat = industry.reqMats[matName];
if (reqMat === undefined) continue;
this.reqMats[matName] = reqMat;

@ -50,7 +50,7 @@ export function ExpandIndustryTab(props: IProps): React.ReactElement {
if (event.key === KEY.ENTER) newIndustry();
}
function onIndustryChange(event: SelectChangeEvent<string>): void {
function onIndustryChange(event: SelectChangeEvent): void {
setIndustry(event.target.value as IndustryType);
}

@ -22,7 +22,7 @@ export function ExpandNewCity(props: IProps): React.ReactElement {
const disabled = corp.funds < corpConstants.officeInitialCost;
function onCityChange(event: SelectChangeEvent<string>): void {
function onCityChange(event: SelectChangeEvent): void {
setCity(event.target.value as CityName);
}

@ -132,7 +132,7 @@ export function IndustryOverview(props: IProps): React.ReactElement {
["Popularity:", formatBigNumber(division.popularity)],
]}
/>
{advertisingInfo !== false && (
{advertisingInfo && (
<Tooltip
title={
<>

@ -122,7 +122,7 @@ function WarehouseRoot(props: IProps): React.ReactElement {
const breakdownItems: JSX.Element[] = [];
for (const matName of Object.values(corpConstants.materialNames)) {
const mat = props.warehouse.materials[matName];
if (!MaterialInfo.hasOwnProperty(matName)) continue;
if (!Object.hasOwn(MaterialInfo, matName)) continue;
if (mat.qty === 0) continue;
breakdownItems.push(
<>

@ -72,7 +72,7 @@ export function MaterialElem(props: IMaterialProps): React.ReactElement {
} else {
sellButtonText = (
<>
Sell ({formatBigNumber(mat.sll)}/{formatBigNumber(mat.sllman[1] as number)})
Sell ({formatBigNumber(mat.sll)}/{formatBigNumber(mat.sllman[1])})
</>
);
}
@ -91,7 +91,7 @@ export function MaterialElem(props: IMaterialProps): React.ReactElement {
);
} else if (mat.sCost) {
if (isString(mat.sCost)) {
const sCost = (mat.sCost as string).replace(/MP/g, mat.bCost + "");
const sCost = mat.sCost.replace(/MP/g, mat.bCost + "");
sellButtonText = (
<>
{sellButtonText} @ <Money money={eval(sCost)} />

@ -30,7 +30,7 @@ export function BribeFactionModal(props: IProps): React.ReactElement {
const [selectedFaction, setSelectedFaction] = useState(factions.length > 0 ? factions[0] : "");
const disabled = money === 0 || isNaN(money) || money < 0 || corp.funds < money;
function changeFaction(event: SelectChangeEvent<string>): void {
function changeFaction(event: SelectChangeEvent): void {
setSelectedFaction(event.target.value);
}

@ -35,11 +35,11 @@ export function ExportModal(props: IProps): React.ReactElement {
const [amt, setAmt] = useState("");
const rerender = useRerender();
function onCityChange(event: SelectChangeEvent<string>): void {
function onCityChange(event: SelectChangeEvent): void {
setCity(event.target.value as CityName);
}
function onIndustryChange(event: SelectChangeEvent<string>): void {
function onIndustryChange(event: SelectChangeEvent): void {
const div = event.target.value;
setIndustry(div);
setCity(Object.keys(corp.divisions[0].warehouses)[0] as CityName);

@ -52,7 +52,7 @@ export function MakeProductModal(props: IProps): React.ReactElement {
props.onClose();
}
function onCityChange(event: SelectChangeEvent<string>): void {
function onCityChange(event: SelectChangeEvent): void {
setCity(event.target.value as CityName);
}

@ -1,12 +1,13 @@
import React, { useState } from "react";
import type { Industry } from "src/Corporation/Industry";
import { Modal } from "../../../ui/React/Modal";
import Typography from "@mui/material/Typography";
import Button from "@mui/material/Button";
import MenuItem from "@mui/material/MenuItem";
import Select, { SelectChangeEvent } from "@mui/material/Select";
import { useCorporation } from "../../ui/Context";
import { Industry } from "src/Corporation/Industry";
import { CityName } from "@nsdefs";
import * as corpConstants from "../../data/Constants";
import { formatMoney, formatNumber } from "../../../ui/formatNumber";
@ -36,7 +37,7 @@ export function SellDivisionModal(props: IProps): React.ReactElement {
return price;
}
function onIndustryChange(event: SelectChangeEvent<string>): void {
function onIndustryChange(event: SelectChangeEvent): void {
setIndustry(corp.divisions.find((div) => div.name === event.target.value) as Industry);
}
@ -76,11 +77,11 @@ export function SellDivisionModal(props: IProps): React.ReactElement {
<br></br>- Profit: ${formatNumber((industry.lastCycleRevenue - industry.lastCycleExpenses) / 10)} / sec
<br></br>- Cities:{" "}
{Object.keys(industry.offices)
.map((city) => (!!industry.offices[city as CityName] ? 1 : 0))
.map((city) => (industry.offices[city as CityName] ? 1 : 0))
.reduce(sum, 0)}
<br></br>- Warehouses:{" "}
{Object.keys(industry.warehouses)
.map((city) => (!!industry.warehouses[city as CityName] ? 1 : 0))
.map((city) => (industry.warehouses[city as CityName] ? 1 : 0))
.reduce(sum, 0)}
{industry.makesProducts ?? (
<Typography>

@ -9,9 +9,9 @@ import Typography from "@mui/material/Typography";
import Table from "@mui/material/Table";
import { TableBody, TableCell, TableRow } from "@mui/material";
type IProps = {
interface IProps {
gift: StaneksGift;
};
}
function formatEffect(effect: number, type: FragmentType): string {
if (Effect(type).includes("+x%")) {

@ -23,11 +23,11 @@ export const TableCell: React.FC<TableCellProps> = (props: TableCellProps) => {
);
};
type IProps = {
interface IProps {
onMouseEnter?: () => void;
onClick?: () => void;
color: string;
};
}
export function Cell(cellProps: IProps): React.ReactElement {
return (

@ -7,12 +7,12 @@ import { formatPercent, formatStaneksGiftCharge, formatStaneksGiftPower } from "
import Paper from "@mui/material/Paper";
import Typography from "@mui/material/Typography";
type IProps = {
interface IProps {
gift: StaneksGift;
fragment: ActiveFragment | undefined;
x: number;
y: number;
};
}
export function FragmentInspector(props: IProps): React.ReactElement {
const [, setC] = useState(new Date());

@ -6,11 +6,11 @@ import TableRow from "@mui/material/TableRow";
import TableBody from "@mui/material/TableBody";
import { Table } from "../../ui/React/Table";
type IProps = {
interface IProps {
width: number;
height: number;
colorAt: (x: number, y: number) => string;
};
}
export function FragmentPreview(props: IProps): React.ReactElement {
// switch the width/length to make axis consistent.

@ -10,11 +10,11 @@ import MenuItem from "@mui/material/MenuItem";
import Typography from "@mui/material/Typography";
import Box from "@mui/material/Box";
type IOptionProps = {
interface IOptionProps {
gift: StaneksGift;
fragment: Fragment;
selectFragment: (fragment: Fragment) => void;
};
}
function FragmentOption(props: IOptionProps): React.ReactElement {
const left = props.fragment.limit - props.gift.count(props.fragment);
@ -45,10 +45,10 @@ function FragmentOption(props: IOptionProps): React.ReactElement {
);
}
type IProps = {
interface IProps {
gift: StaneksGift;
selectFragment: (fragment: Fragment) => void;
};
}
export function FragmentSelector(props: IProps): React.ReactElement {
const [value, setValue] = useState<string | number>("None");

@ -13,9 +13,9 @@ import { DummyGrid } from "./DummyGrid";
import Container from "@mui/material/Container";
import { useRerender } from "../../ui/React/hooks";
type IProps = {
interface IProps {
staneksGift: StaneksGift;
};
}
export function StaneksGiftRoot({ staneksGift }: IProps): React.ReactElement {
const rerender = useRerender();

@ -17,7 +17,7 @@ import { Player } from "@player";
export function Augmentations(): React.ReactElement {
const [augmentation, setAugmentation] = useState("Augmented Targeting I");
function setAugmentationDropdown(event: SelectChangeEvent<string>): void {
function setAugmentationDropdown(event: SelectChangeEvent): void {
setAugmentation(event.target.value);
}
function queueAug(): void {

@ -59,8 +59,8 @@ export function Bladeburner(): React.ReactElement {
};
// Skill functions
const [skill, setSkill] = useState(SkillNames.BladesIntuition as string);
function setSkillDropdown(event: SelectChangeEvent<string>): void {
const [skill, setSkill] = useState(SkillNames.BladesIntuition);
function setSkillDropdown(event: SelectChangeEvent): void {
setSkill(event.target.value);
}
const modifySkill = (modifier: number) => (levelchange: number) => {
@ -82,8 +82,8 @@ export function Bladeburner(): React.ReactElement {
// Contract functions
const AllContracts = bladeburner.contracts;
const [contractTarget, setContract] = useState(AllContracts.Tracking.name as string);
function setContractDropdown(event: SelectChangeEvent<string>): void {
const [contractTarget, setContract] = useState(AllContracts.Tracking.name);
function setContractDropdown(event: SelectChangeEvent): void {
setContract(event.target.value);
}
const modifyContractLevel = (modifier: number) => (levelchange: number) => {
@ -117,8 +117,8 @@ export function Bladeburner(): React.ReactElement {
// Operation functions
const AllOperations = bladeburner.operations;
const [operationTarget, setOperation] = useState(AllOperations.Investigation.name as string);
function setOperationDropdown(event: SelectChangeEvent<string>): void {
const [operationTarget, setOperation] = useState(AllOperations.Investigation.name);
function setOperationDropdown(event: SelectChangeEvent): void {
setOperation(event.target.value);
}
const modifyOperationLevel = (modifier: number) => (levelchange: number) => {

@ -14,7 +14,7 @@ import { CodingContractTypes } from "../../CodingContracts";
export function CodingContracts(): React.ReactElement {
const [codingcontract, setCodingcontract] = useState("Find Largest Prime Factor");
function setCodingcontractDropdown(event: SelectChangeEvent<string>): void {
function setCodingcontractDropdown(event: SelectChangeEvent): void {
setCodingcontract(event.target.value);
}

@ -17,7 +17,7 @@ const bigNumber = 1e12;
export function Companies(): React.ReactElement {
const [company, setCompany] = useState(FactionNames.ECorp as string);
function setCompanyDropdown(event: SelectChangeEvent<string>): void {
function setCompanyDropdown(event: SelectChangeEvent): void {
setCompany(event.target.value);
}
function resetCompanyRep(): void {

@ -24,7 +24,7 @@ const bigNumber = 1e12;
export function Factions(): React.ReactElement {
const [faction, setFaction] = useState(FactionNames.Illuminati as string);
function setFactionDropdown(event: SelectChangeEvent<string>): void {
function setFactionDropdown(event: SelectChangeEvent): void {
setFaction(event.target.value);
}

@ -71,7 +71,7 @@ export function General(): React.ReactElement {
// Rerender so the gang menu option will be removed immediately on the devmenu page selection
ThemeEvents.emit();
};
const setGangFactionDropdown = (event: SelectChangeEvent<string>) => setGangFaction(event.target.value);
const setGangFactionDropdown = (event: SelectChangeEvent) => setGangFaction(event.target.value);
// Misc functions
const checkMessages = () => checkForMessagesToSend();

@ -14,7 +14,7 @@ import { CompletedProgramName } from "../../Programs/Programs";
export function Programs(): React.ReactElement {
const [program, setProgram] = useState(CompletedProgramName.bruteSsh);
function setProgramDropdown(event: SelectChangeEvent<string>): void {
function setProgramDropdown(event: SelectChangeEvent): void {
setProgram(event.target.value as CompletedProgramName);
}
function addProgram(): void {

@ -14,7 +14,7 @@ import MenuItem from "@mui/material/MenuItem";
export function Servers(): React.ReactElement {
const [server, setServer] = useState("home");
function setServerDropdown(event: SelectChangeEvent<string>): void {
function setServerDropdown(event: SelectChangeEvent): void {
setServer(event.target.value);
}
function rootServer(): void {

@ -39,7 +39,7 @@ export function StockMarket(): React.ReactElement {
}
for (const name of Object.keys(SM)) {
if (SM.hasOwnProperty(name)) {
if (Object.hasOwn(SM, name)) {
const stock = SM[name];
if (stock instanceof Stock && match(stock.symbol)) {
sub(stock);

@ -44,7 +44,7 @@ declare global {
export function initElectron(): void {
const userAgent = navigator.userAgent.toLowerCase();
if (userAgent.indexOf(" electron/") > -1) {
if (userAgent.includes(" electron/")) {
// Electron-specific code
document.achievements = [];
initWebserver();

@ -27,9 +27,7 @@ export enum Exploit {
EditSaveFile = "EditSaveFile",
}
const names: {
[key: string]: string;
} = {
const names: Record<string, string> = {
Bypass: "by circumventing the ram cost of document.",
EditSaveFile: "by editing your save file.",
PrototypeTampering: "by tampering with Numbers prototype.",

@ -110,7 +110,7 @@ export function processPassiveFactionRepGain(numCycles: number): void {
if (Player.bitNodeN === 2) return;
for (const name of Object.keys(Factions)) {
if (isFactionWork(Player.currentWork) && name === Player.currentWork.factionName) continue;
if (!Factions.hasOwnProperty(name)) continue;
if (!Object.hasOwn(Factions, name)) continue;
const faction = Factions[name];
if (!faction.isMember) continue;
// No passive rep for special factions

@ -60,7 +60,6 @@ export class FactionInfo {
}
/** A map of all factions and associated info to them. */
// tslint:disable-next-line:variable-name
export const FactionInfos: Record<string, FactionInfo> = {
// Endgame
[FactionNames.Illuminati]: new FactionInfo({

@ -28,7 +28,7 @@ function AddToFactions(faction: Faction): void {
}
export function factionExists(name: string): boolean {
return Factions.hasOwnProperty(name);
return Object.hasOwn(Factions, name);
}
export function initFactions(): void {

@ -17,10 +17,10 @@ import { getFactionAugmentationsFiltered, hasAugmentationPrereqs, purchaseAugmen
import { CONSTANTS } from "../../Constants";
import { useRerender } from "../../ui/React/hooks";
type IProps = {
interface IProps {
faction: Faction;
routeToMainPage: () => void;
};
}
/** Root React Component for displaying a faction's "Purchase Augmentations" page */
export function AugmentationsPage(props: IProps): React.ReactElement {

@ -17,12 +17,12 @@ import Paper from "@mui/material/Paper";
import Button from "@mui/material/Button";
import { NumberInput } from "../../ui/React/NumberInput";
type IProps = {
interface IProps {
faction: Faction;
disabled: boolean;
favorToDonate: number;
rerender: () => void;
};
}
/** React component for a donate option on the Faction UI */
export function DonateOption(props: IProps): React.ReactElement {

@ -27,10 +27,10 @@ import { FactionWork } from "../../Work/FactionWork";
import { FactionWorkType } from "../../Enums";
import { useRerender } from "../../ui/React/hooks";
type IProps = {
interface IProps {
faction: Faction;
augPage: boolean;
};
}
// Info text for all options on the UI
const hackingContractsInfo =

@ -59,7 +59,7 @@ const FactionElement = (props: FactionElementProps): React.ReactElement => {
Router.toFaction(faction, true);
}
function acceptInvitation(event: React.MouseEvent<HTMLButtonElement, MouseEvent>, faction: string): void {
function acceptInvitation(event: React.MouseEvent<HTMLButtonElement>, faction: string): void {
if (!event.isTrusted) return;
joinFaction(Factions[faction]);
props.rerender();
@ -218,7 +218,7 @@ export function FactionsRoot(): React.ReactElement {
</Typography>
<Box>
{invitations.map((facName) => {
if (!Factions.hasOwnProperty(facName)) return null;
if (!Object.hasOwn(Factions, facName)) return null;
return <FactionElement key={facName} faction={Factions[facName]} joined={false} rerender={rerender} />;
})}
</Box>
@ -232,7 +232,7 @@ export function FactionsRoot(): React.ReactElement {
<Box>
{allJoinedFactions.length > 0 ? (
allJoinedFactions.map((facName) => {
if (!Factions.hasOwnProperty(facName)) return null;
if (!Object.hasOwn(Factions, facName)) return null;
return <FactionElement key={facName} faction={Factions[facName]} joined={true} rerender={rerender} />;
})
) : (

@ -7,9 +7,9 @@ import { Player } from "@player";
import { Faction } from "../Faction";
import { CreateGangModal } from "./CreateGangModal";
type IProps = {
interface IProps {
faction: Faction;
};
}
export function GangButton({ faction }: IProps): React.ReactElement {
const [gangOpen, setGangOpen] = useState(false);

@ -18,10 +18,10 @@ import Tooltip from "@mui/material/Tooltip";
import Box from "@mui/material/Box";
import { useRerender } from "../../ui/React/hooks";
type IProps = {
interface IProps {
faction: Faction;
factionInfo: FactionInfo;
};
}
const useStyles = makeStyles(() =>
createStyles({

@ -10,11 +10,11 @@ import Button from "@mui/material/Button";
import Paper from "@mui/material/Paper";
import Box from "@mui/material/Box";
type IProps = {
interface IProps {
buttonText: string;
infoText: string;
onClick: (e: React.MouseEvent<HTMLElement>) => void;
};
}
export function Option(props: IProps): React.ReactElement {
return (

@ -8,7 +8,7 @@ import { FormatsNeedToChange } from "../../ui/formatNumber";
export const NumericDisplayPage = (): React.ReactElement => {
const [locale, setLocale] = useState(Settings.Locale);
function handleLocaleChange(event: SelectChangeEvent<string>): void {
function handleLocaleChange(event: SelectChangeEvent): void {
setLocale(event.target.value);
Settings.Locale = event.target.value;
FormatsNeedToChange.emit();

@ -3,7 +3,7 @@ import React, { useState } from "react";
interface IProps {
initialValue: number;
callback: (event: Event | React.SyntheticEvent<Element, Event>, newValue: number | number[]) => void;
callback: (event: Event | React.SyntheticEvent, newValue: number | number[]) => void;
step: number;
min: number;
max: number;
@ -15,7 +15,7 @@ interface IProps {
export const OptionsSlider = (props: IProps): React.ReactElement => {
const [value, setValue] = useState(props.initialValue);
const onChange = (_evt: Event, newValue: number | Array<number>): void => {
const onChange = (_evt: Event, newValue: number | number[]): void => {
if (typeof newValue === "number") setValue(newValue);
};

@ -9,7 +9,7 @@ export const RemoteAPIPage = (): React.ReactElement => {
const [remoteFileApiPort, setRemoteFileApiPort] = useState(Settings.RemoteFileApiPort);
function handleRemoteFileApiPortChange(event: React.ChangeEvent<HTMLInputElement>): void {
setRemoteFileApiPort(Number(event.target.value) as number);
setRemoteFileApiPort(Number(event.target.value));
Settings.RemoteFileApiPort = Number(event.target.value);
}

@ -12,50 +12,32 @@ export const SystemPage = (): React.ReactElement => {
const [terminalSize, setTerminalSize] = useState(Settings.MaxTerminalCapacity);
const [autosaveInterval, setAutosaveInterval] = useState(Settings.AutosaveInterval);
function handlePortSizeChange(
_event: Event | React.SyntheticEvent<Element, Event>,
newValue: number | number[],
): void {
function handlePortSizeChange(_event: Event | React.SyntheticEvent, newValue: number | number[]): void {
setPortSize(newValue as number);
Settings.MaxPortCapacity = newValue as number;
}
function handleTerminalSizeChange(
_event: Event | React.SyntheticEvent<Element, Event>,
newValue: number | number[],
): void {
function handleTerminalSizeChange(_event: Event | React.SyntheticEvent, newValue: number | number[]): void {
setTerminalSize(newValue as number);
Settings.MaxTerminalCapacity = newValue as number;
}
function handleExecTimeChange(
_event: Event | React.SyntheticEvent<Element, Event>,
newValue: number | number[],
): void {
function handleExecTimeChange(_event: Event | React.SyntheticEvent, newValue: number | number[]): void {
setExecTime(newValue as number);
Settings.CodeInstructionRunTime = newValue as number;
}
function handleRecentScriptsSizeChange(
_event: Event | React.SyntheticEvent<Element, Event>,
newValue: number | number[],
): void {
function handleRecentScriptsSizeChange(_event: Event | React.SyntheticEvent, newValue: number | number[]): void {
setRecentScriptsSize(newValue as number);
Settings.MaxRecentScriptsCapacity = newValue as number;
}
function handleLogSizeChange(
_event: Event | React.SyntheticEvent<Element, Event>,
newValue: number | number[],
): void {
function handleLogSizeChange(_event: Event | React.SyntheticEvent, newValue: number | number[]): void {
setLogSize(newValue as number);
Settings.MaxLogCapacity = newValue as number;
}
function handleAutosaveIntervalChange(
_event: Event | React.SyntheticEvent<Element, Event>,
newValue: number | number[],
): void {
function handleAutosaveIntervalChange(_event: Event | React.SyntheticEvent, newValue: number | number[]): void {
setAutosaveInterval(newValue as number);
Settings.AutosaveInterval = newValue as number;
}

@ -6,9 +6,7 @@ interface GangTerritory {
territory: number;
}
export let AllGangs: {
[key: string]: GangTerritory;
} = {
export let AllGangs: Record<string, GangTerritory> = {
[FactionNames.SlumSnakes]: {
power: 1,
territory: 1 / 7,

@ -148,6 +148,12 @@ export class Gang {
}
processTerritoryAndPowerGains(numCycles = 1): void {
function calculateTerritoryGain(winGang: string, loseGang: string): number {
const powerBonus = Math.max(1, 1 + Math.log(AllGangs[winGang].power / AllGangs[loseGang].power) / Math.log(50));
const gains = Math.min(AllGangs[loseGang].territory, powerBonus * 0.0001 * (Math.random() + 0.5));
return gains;
}
this.storedTerritoryAndPowerCycles += numCycles;
if (this.storedTerritoryAndPowerCycles < GangConstants.CyclesPerTerritoryAndPowerUpdate) return;
this.storedTerritoryAndPowerCycles -= GangConstants.CyclesPerTerritoryAndPowerUpdate;
@ -155,7 +161,7 @@ export class Gang {
// Process power first
const gangName = this.facName;
for (const name of Object.keys(AllGangs)) {
if (AllGangs.hasOwnProperty(name)) {
if (Object.hasOwn(AllGangs, name)) {
if (name == gangName) {
AllGangs[name].power += this.calculatePower();
} else {
@ -208,15 +214,6 @@ export class Gang {
const otherPwr = AllGangs[otherGang].power;
const thisChance = thisPwr / (thisPwr + otherPwr);
function calculateTerritoryGain(winGang: string, loseGang: string): number {
const powerBonus = Math.max(
1,
1 + Math.log(AllGangs[winGang].power / AllGangs[loseGang].power) / Math.log(50),
);
const gains = Math.min(AllGangs[loseGang].territory, powerBonus * 0.0001 * (Math.random() + 0.5));
return gains;
}
if (Math.random() < thisChance) {
if (AllGangs[otherGang].territory <= 0) return;
const territoryGain = calculateTerritoryGain(thisGang, otherGang);
@ -320,8 +317,7 @@ export class Gang {
calculatePower(): number {
let memberTotal = 0;
for (let i = 0; i < this.members.length; ++i) {
if (!GangMemberTasks.hasOwnProperty(this.members[i].task) || this.members[i].task !== "Territory Warfare")
continue;
if (this.members[i].task !== "Territory Warfare") continue;
memberTotal += this.members[i].calculatePower();
}
return 0.015 * Math.max(0.002, this.getTerritory()) * memberTotal;

@ -86,7 +86,7 @@ export class GangMember {
}
assignToTask(taskName: string): boolean {
if (!GangMemberTasks.hasOwnProperty(taskName)) {
if (!Object.hasOwn(GangMemberTasks, taskName)) {
this.task = "Unassigned";
return false;
}
@ -105,10 +105,10 @@ export class GangMember {
this.task = (this.task as any).name;
}
if (GangMemberTasks.hasOwnProperty(this.task)) {
if (Object.hasOwn(GangMemberTasks, this.task)) {
return GangMemberTasks[this.task];
}
return GangMemberTasks["Unassigned"];
return GangMemberTasks.Unassigned;
}
calculateRespectGain(gang: Gang): number {
@ -154,7 +154,7 @@ export class GangMember {
gainExperience(numCycles = 1): void {
const task = this.getTask();
if (task === GangMemberTasks["Unassigned"]) return;
if (task === GangMemberTasks.Unassigned) return;
const difficultyMult = Math.pow(task.difficulty, 0.9);
const difficultyPerCycles = difficultyMult * numCycles;
const weightDivisor = 1500;

@ -1,9 +1,7 @@
import { gangMemberTasksMetadata } from "./data/tasks";
import { GangMemberTask } from "./GangMemberTask";
export const GangMemberTasks: {
[key: string]: GangMemberTask;
} = {};
export const GangMemberTasks: Record<string, GangMemberTask> = {};
(function () {
gangMemberTasksMetadata.forEach((e) => {

@ -1,9 +1,7 @@
import { gangMemberUpgradesMetadata } from "./data/upgrades";
import { GangMemberUpgrade } from "./GangMemberUpgrade";
export const GangMemberUpgrades: {
[key: string]: GangMemberUpgrade;
} = {};
export const GangMemberUpgrades: Record<string, GangMemberUpgrade> = {};
(function () {
gangMemberUpgradesMetadata.forEach((e) => {

@ -1,7 +1,5 @@
import { FactionNames } from "../../Faction/data/FactionNames";
export const PowerMultiplier: {
[key: string]: number | undefined;
} = {
export const PowerMultiplier: Record<string, number | undefined> = {
[FactionNames.SlumSnakes]: 1,
[FactionNames.Tetrads]: 2,
[FactionNames.TheSyndicate]: 2,

@ -1,5 +1,4 @@
import { ITaskParams } from "../ITaskParams";
/* tslint:disable:max-line-length */
/**
* Defines the parameters that can be used to initialize and describe a GangMemberTask

@ -102,7 +102,7 @@ function GangMemberUpgradePanel(props: IPanelProps): React.ReactElement {
.map((upgName: string) => GangMemberUpgrades[upgName]);
}
const onChange = (event: SelectChangeEvent<string>): void => {
const onChange = (event: SelectChangeEvent): void => {
setCurrentCategory(event.target.value);
rerender();
};
@ -113,7 +113,7 @@ function GangMemberUpgradePanel(props: IPanelProps): React.ReactElement {
const rootkitUpgrades = filterUpgrades(props.member.upgrades, UpgradeType.Rootkit);
const augUpgrades = filterUpgrades(props.member.augmentations, UpgradeType.Augmentation);
const categories: { [key: string]: (GangMemberUpgrade[] | UpgradeType)[] } = {
const categories: Record<string, (GangMemberUpgrade[] | UpgradeType)[]> = {
Weapons: [weaponUpgrades, UpgradeType.Weapon],
Armor: [armorUpgrades, UpgradeType.Armor],
Vehicles: [vehicleUpgrades, UpgradeType.Vehicle],

@ -13,7 +13,7 @@ interface IProps {
export function TaskDescription(props: IProps): React.ReactElement {
const task = GangMemberTasks[props.member.task];
const desc = task ? task.desc : GangMemberTasks["Unassigned"].desc;
const desc = task ? task.desc : GangMemberTasks.Unassigned.desc;
return <Typography dangerouslySetInnerHTML={{ __html: desc }} />;
}

@ -26,7 +26,7 @@ export function TaskSelector(props: IProps): React.ReactElement {
setCurrentTask(contextMember.task);
}
function onChange(event: SelectChangeEvent<string>): void {
function onChange(event: SelectChangeEvent): void {
const task = event.target.value;
props.member.assignToTask(task);
setCurrentTask(task);

@ -65,7 +65,6 @@ export function calculateHackingTime(server: IServer, person: IPerson): number {
const baseSkill = 50;
const diffFactor = 2.5;
let skillFactor = diffFactor * difficultyMult + baseDiff;
// tslint:disable-next-line
skillFactor /= person.skills.hacking + baseSkill;
const hackTimeMultiplier = 5;

@ -19,7 +19,7 @@ function baseCheck(server: Server, fnName: string): IReturnStatus {
};
}
if (server.hasAdminRights === false) {
if (!server.hasAdminRights) {
return {
res: false,
msg: `Cannot ${fnName} ${hostname} server because you do not have root access`,

@ -12,6 +12,7 @@ import {
calculateCacheUpgradeCost,
} from "./formulas/HacknetServers";
import { IPAddress } from "../Types/strings";
import { createRandomIp } from "../utils/IPAddress";
import { IReviverValue, constructorsForReviver } from "../utils/JSONReviver";
@ -20,7 +21,7 @@ import { Player } from "@player";
interface IConstructorParams {
adminRights?: boolean;
hostname: string;
ip?: string;
ip?: IPAddress;
isConnectedTo?: boolean;
maxRam?: number;
organizationName?: string;

@ -232,9 +232,6 @@ export function HacknetServerElem(props: IProps): React.ReactElement {
</Button>
</Tooltip>
);
if (Player.money < upgradeCacheCost) {
} else {
}
}
function upgradeCacheOnClick(): void {
let numUpgrades = purchaseMult;

@ -24,21 +24,21 @@ interface IProps {
rerender: () => void;
}
const serversMap: { [key: string]: string } = {};
const companiesMap: { [key: string]: string } = {};
const serversMap: Record<string, string> = {};
const companiesMap: Record<string, string> = {};
export function HacknetUpgradeElem(props: IProps): React.ReactElement {
const [selectedServer, setSelectedServer] = useState(
serversMap[props.upg.name] ? serversMap[props.upg.name] : FactionNames.ECorp.toLowerCase(),
);
function changeTargetServer(event: SelectChangeEvent<string>): void {
function changeTargetServer(event: SelectChangeEvent): void {
setSelectedServer(event.target.value);
serversMap[props.upg.name] = event.target.value;
}
const [selectedCompany, setSelectedCompany] = useState(
companiesMap[props.upg.name] ? companiesMap[props.upg.name] : companiesMetadata[0].name,
);
function changeTargetCompany(event: SelectChangeEvent<string>): void {
function changeTargetCompany(event: SelectChangeEvent): void {
setSelectedCompany(event.target.value);
companiesMap[props.upg.name] = event.target.value;
}

@ -1,6 +1,4 @@
interface DifficultySetting {
[key: string]: number;
}
type DifficultySetting = Record<string, number>;
interface DifficultySettings {
Trivial: DifficultySetting;

@ -48,7 +48,7 @@ export function Victory(props: IProps): React.ReactElement {
quitInfiltration();
}
function changeDropdown(event: SelectChangeEvent<string>): void {
function changeDropdown(event: SelectChangeEvent): void {
setFaction(event.target.value);
}

@ -1,7 +1,11 @@
import { FilePath, asFilePath } from "../Paths/FilePath";
import type { LiteratureName } from "./data/LiteratureNames";
type LiteratureConstructorParams = { title: string; filename: LiteratureName; text: string };
interface LiteratureConstructorParams {
title: string;
filename: LiteratureName;
text: string;
}
/**
* Lore / world building literature files that can be found on servers.
* These files can be read by the player

@ -8,12 +8,12 @@ import { Player } from "@player";
import Button from "@mui/material/Button";
import Tooltip from "@mui/material/Tooltip";
type IProps = {
interface IProps {
company: Company;
entryPosType: CompanyPosition;
onClick: (e: React.MouseEvent<HTMLElement>) => void;
text: string;
};
}
/** React Component for a button that's used to apply for a job */
export function ApplyToJobButton(props: IProps): React.ReactElement {

@ -22,9 +22,9 @@ import { Theme } from "@mui/material/styles";
import makeStyles from "@mui/styles/makeStyles";
import createStyles from "@mui/styles/createStyles";
type IProps = {
interface IProps {
city: City;
};
}
const useStyles = makeStyles((theme: Theme) =>
createStyles({
@ -70,9 +70,7 @@ function LocationLetter(location: Location, className: string): React.ReactEleme
function ASCIICity(props: IProps): React.ReactElement {
const locationLettersRegex = /[A-Z]/g;
const letterMap: {
[key: string]: number;
} = {
const letterMap: Record<string, number> = {
A: 0,
B: 1,
C: 2,

@ -27,9 +27,9 @@ import { QuitJobModal } from "../../Company/ui/QuitJobModal";
import { CompanyWork } from "../../Work/CompanyWork";
import { useRerender } from "../../ui/React/hooks";
type IProps = {
interface IProps {
locName: LocationName;
};
}
export function CompanyLocation(props: IProps): React.ReactElement {
const [quitOpen, setQuitOpen] = useState(false);

@ -8,9 +8,9 @@ import { Player } from "@player";
import { Money } from "../../ui/React/Money";
import { MathJax } from "better-react-mathjax";
type IProps = {
interface IProps {
rerender: () => void;
};
}
export function CoresButton(props: IProps): React.ReactElement {
const homeComputer = Player.getHomeComputer();

@ -32,9 +32,9 @@ import { Page } from "../../ui/Router";
import { serverMetadata } from "../../Server/data/servers";
import { Tooltip } from "@mui/material";
type IProps = {
interface IProps {
loc: Location;
};
}
export function GenericLocation({ loc }: IProps): React.ReactElement {
/**

@ -18,9 +18,9 @@ import { ClassWork, Classes } from "../../Work/ClassWork";
import { calculateCost } from "../../Work/Formulas";
import { GymType } from "../../Enums";
type IProps = {
interface IProps {
loc: Location;
};
}
export function GymLocation(props: IProps): React.ReactElement {
function train(stat: GymType): void {

@ -13,9 +13,9 @@ import { formatRam } from "../../ui/formatNumber";
import { MathJax } from "better-react-mathjax";
import { BitNodeMultipliers } from "../../BitNode/BitNodeMultipliers";
type IProps = {
interface IProps {
rerender: () => void;
};
}
export function RamButton(props: IProps): React.ReactElement {
const homeComputer = Player.getHomeComputer();

@ -38,9 +38,9 @@ import { ArcadeRoot } from "../../Arcade/ui/ArcadeRoot";
import { FactionNames } from "../../Faction/data/FactionNames";
import { BitNodeMultipliers } from "../../BitNode/BitNodeMultipliers";
type IProps = {
interface IProps {
loc: Location;
};
}
export function SpecialLocation(props: IProps): React.ReactElement {
const setRerender = useState(false)[1];

Some files were not shown because too many files have changed in this diff Show More