format & lint

This commit is contained in:
Snarling 2022-09-13 12:37:24 -04:00
parent c9ee938bc6
commit 91a69d7d8f
39 changed files with 59 additions and 154 deletions

@ -88,13 +88,11 @@ const Exclusive = (props: IExclusiveProps): React.ReactElement => {
Certain <b>gangs</b>
</li>
)}
{Player.canAccessGrafting() &&
!props.aug.isSpecial &&
props.aug.name !== AugmentationNames.TheRedPill && (
<li>
<b>Grafting</b>
</li>
)}
{Player.canAccessGrafting() && !props.aug.isSpecial && props.aug.name !== AugmentationNames.TheRedPill && (
<li>
<b>Grafting</b>
</li>
)}
</Typography>
</ul>
</>
@ -209,8 +207,7 @@ export function PurchasableAugmentation(props: IPurchasableAugProps): React.Reac
<>
<Typography variant="h5">
{props.augName}
{props.augName === AugmentationNames.NeuroFluxGovernor &&
` - Level ${aug.getLevel()}`}
{props.augName === AugmentationNames.NeuroFluxGovernor && ` - Level ${aug.getLevel()}`}
</Typography>
<Typography>{description}</Typography>
</>
@ -223,9 +220,7 @@ export function PurchasableAugmentation(props: IPurchasableAugProps): React.Reac
whiteSpace: "nowrap",
overflow: "hidden",
color:
props.owned || !props.parent.canPurchase(aug)
? Settings.theme.disabled
: Settings.theme.primary,
props.owned || !props.parent.canPurchase(aug) ? Settings.theme.disabled : Settings.theme.primary,
}}
>
{aug.name}
@ -233,9 +228,7 @@ export function PurchasableAugmentation(props: IPurchasableAugProps): React.Reac
</Typography>
</Tooltip>
{aug.factions.length === 1 && !props.parent.sleeveAugs && (
<Exclusive aug={aug} />
)}
{aug.factions.length === 1 && !props.parent.sleeveAugs && <Exclusive aug={aug} />}
{aug.prereqs.length > 0 && !props.parent.sleeveAugs && <PreReqs aug={aug} />}
</Box>
</Box>

@ -120,5 +120,5 @@ export interface IBladeburner {
process(): void;
getActionStats(action: IAction, person: IPerson, success: boolean): ITaskTracker;
sleeveSupport(joining: boolean): void;
toJSON():IReviverValue;
toJSON(): IReviverValue;
}

@ -36,7 +36,7 @@ type State = {
wagerInvalidHelperText: string;
};
export class Blackjack extends React.Component<{},State> {
export class Blackjack extends React.Component<Record<string, never>, State> {
deck: Deck;
constructor() {

@ -13,4 +13,4 @@ export function reachedLimit(): boolean {
dialogBoxCreate("Alright cheater get out of here. You're not allowed here anymore.");
}
return reached;
}
}

@ -4,7 +4,6 @@ import { Exploit } from "./Exploit";
const getComputedStyle = window.getComputedStyle;
export function Unclickable(): React.ReactElement {
function unclickable(event: React.MouseEvent<HTMLDivElement>): void {
if (!event.target || !(event.target instanceof Element)) return;
const display = getComputedStyle(event.target).display;

@ -153,10 +153,7 @@ export function getMaxNumberRamUpgrades(nodeObj: HacknetNode | HacknetServer, ma
}
// Calculate the maximum number of times the Player can afford to upgrade a Hacknet Node's cores
export function getMaxNumberCoreUpgrades(
nodeObj: HacknetNode | HacknetServer,
maxLevel: number,
): number {
export function getMaxNumberCoreUpgrades(nodeObj: HacknetNode | HacknetServer, maxLevel: number): number {
if (maxLevel == null) {
throw new Error(`getMaxNumberCoreUpgrades() called without maxLevel arg`);
}

@ -77,9 +77,7 @@ export function HacknetNodeElem(props: IProps): React.ReactElement {
}
function upgradeLevelOnClick(): void {
const numUpgrades =
purchaseMult === "MAX"
? getMaxNumberLevelUpgrades(node, HacknetNodeConstants.MaxLevel)
: purchaseMult;
purchaseMult === "MAX" ? getMaxNumberLevelUpgrades(node, HacknetNodeConstants.MaxLevel) : purchaseMult;
purchaseLevelUpgrade(node, numUpgrades);
rerender();
}
@ -128,9 +126,7 @@ export function HacknetNodeElem(props: IProps): React.ReactElement {
function upgradeCoresOnClick(): void {
const numUpgrades =
purchaseMult === "MAX"
? getMaxNumberCoreUpgrades(node, HacknetNodeConstants.MaxCores)
: purchaseMult;
purchaseMult === "MAX" ? getMaxNumberCoreUpgrades(node, HacknetNodeConstants.MaxCores) : purchaseMult;
purchaseCoreUpgrade(node, numUpgrades);
rerender();
}

@ -60,13 +60,8 @@ export function HacknetServerElem(props: IProps): React.ReactElement {
}
const base_increase =
calculateHashGainRate(
node.level + multiplier,
0,
node.maxRam,
node.cores,
Player.mults.hacknet_node_money,
) - calculateHashGainRate(node.level, 0, node.maxRam, node.cores, Player.mults.hacknet_node_money);
calculateHashGainRate(node.level + multiplier, 0, node.maxRam, node.cores, Player.mults.hacknet_node_money) -
calculateHashGainRate(node.level, 0, node.maxRam, node.cores, Player.mults.hacknet_node_money);
const modded_increase = (base_increase * (node.maxRam - node.ramUsed)) / node.maxRam;
const upgradeLevelCost = node.calculateLevelUpgradeCost(multiplier, Player.mults.hacknet_node_level_cost);
@ -136,8 +131,7 @@ export function HacknetServerElem(props: IProps): React.ReactElement {
node.maxRam * Math.pow(2, multiplier),
node.cores,
Player.mults.hacknet_node_money,
) -
calculateHashGainRate(node.level, node.ramUsed, node.maxRam, node.cores, Player.mults.hacknet_node_money);
) - calculateHashGainRate(node.level, node.ramUsed, node.maxRam, node.cores, Player.mults.hacknet_node_money);
const upgradeRamCost = node.calculateRamUpgradeCost(multiplier, Player.mults.hacknet_node_ram_cost);
upgradeRamButton = (
@ -183,13 +177,8 @@ export function HacknetServerElem(props: IProps): React.ReactElement {
}
const base_increase =
calculateHashGainRate(
node.level,
0,
node.maxRam,
node.cores + multiplier,
Player.mults.hacknet_node_money,
) - calculateHashGainRate(node.level, 0, node.maxRam, node.cores, Player.mults.hacknet_node_money);
calculateHashGainRate(node.level, 0, node.maxRam, node.cores + multiplier, Player.mults.hacknet_node_money) -
calculateHashGainRate(node.level, 0, node.maxRam, node.cores, Player.mults.hacknet_node_money);
const modded_increase = (base_increase * (node.maxRam - node.ramUsed)) / node.maxRam;
const upgradeCoreCost = node.calculateCoreUpgradeCost(multiplier, Player.mults.hacknet_node_core_cost);

@ -18,7 +18,7 @@ export function InfiltrationRoot(props: IProps): React.ReactElement {
const reward = calculateReward(Player, startingSecurityLevel);
function cancel(): void {
Router.toCity();
Router.toCity();
}
return (

@ -13,20 +13,18 @@ import { Money } from "../../ui/React/Money";
import { dialogBoxCreate } from "../../ui/React/DialogBox";
type IProps = {};
type IState = {
currHp: number;
};
export class HospitalLocation extends React.Component<IProps, IState> {
export class HospitalLocation extends React.Component<Record<string, never>, IState> {
/**
* Stores button styling that sets them all to block display
*/
btnStyle = { display: "block" };
constructor(props: IProps) {
super(props);
constructor() {
super({});
this.getCost = this.getCost.bind(this);
this.getHealed = this.getHealed.bind(this);

@ -5,7 +5,6 @@ import { dialogBoxCreate } from "../../ui/React/DialogBox";
import { GetServer } from "../../Server/AllServers";
import { SpecialServers } from "../../Server/data/SpecialServers";
import { CONSTANTS } from "../../Constants";
import { Player } from "../../Player";
@ -14,7 +13,7 @@ import { Money } from "../../ui/React/Money";
/**
* Attempt to purchase a TOR router using the button.
*/
export function purchaseTorRouter(): void {
export function purchaseTorRouter(): void {
if (Player.hasTorRouter()) {
dialogBoxCreate(`You already have a TOR Router!`);
return;

@ -124,9 +124,7 @@ export const GraftingRoot = (): React.ReactElement => {
<ListItemButton key={i + 1} onClick={() => setSelectedAug(k)} selected={selectedAug === k}>
<Typography
sx={{
color: canGraft(graftableAugmentations[k])
? Settings.theme.primary
: Settings.theme.disabled,
color: canGraft(graftableAugmentations[k]) ? Settings.theme.primary : Settings.theme.disabled,
}}
>
{k}

@ -1,4 +1,3 @@
import { IPlayer } from "../../IPlayer";
import { Generic_fromJSON, Generic_toJSON, IReviverValue, Reviver } from "../../../utils/JSONReviver";
import { applySleeveGains, Work, WorkType } from "./Work";
import { ClassType } from "../../../Work/ClassWork";
@ -25,11 +24,7 @@ export class SleeveClassWork extends Work {
}
calculateRates(sleeve: Sleeve): WorkStats {
return scaleWorkStats(
calculateClassEarnings(sleeve, this.classType, this.location),
sleeve.shockBonus(),
false,
);
return scaleWorkStats(calculateClassEarnings(sleeve, this.classType, this.location), sleeve.shockBonus(), false);
}
isGym(): boolean {

@ -1,4 +1,3 @@
import { IPlayer } from "../../IPlayer";
import { Generic_fromJSON, Generic_toJSON, IReviverValue, Reviver } from "../../../utils/JSONReviver";
import { Sleeve } from "../Sleeve";
import { applySleeveGains, Work, WorkType } from "./Work";

@ -200,9 +200,7 @@ export function SleeveElem(props: IProps): React.ReactElement {
<ProgressBar
variant="determinate"
value={
(props.sleeve.currentWork.cyclesWorked /
props.sleeve.currentWork.cyclesNeeded(props.sleeve)) *
100
(props.sleeve.currentWork.cyclesWorked / props.sleeve.currentWork.cyclesNeeded(props.sleeve)) * 100
}
color="primary"
/>

@ -243,8 +243,7 @@ const canDo: {
"Commit Crime": () => true,
"Take University Course": (sleeve: Sleeve) =>
[CityName.Aevum, CityName.Sector12, CityName.Volhaven].includes(sleeve.city),
"Workout at Gym": (sleeve: Sleeve) =>
[CityName.Aevum, CityName.Sector12, CityName.Volhaven].includes(sleeve.city),
"Workout at Gym": (sleeve: Sleeve) => [CityName.Aevum, CityName.Sector12, CityName.Volhaven].includes(sleeve.city),
"Perform Bladeburner Actions": () => Player.inBladeburner(),
"Shock Recovery": (sleeve: Sleeve) => sleeve.shock < 100,
Synchronize: (sleeve: Sleeve) => sleeve.sync < 100,
@ -343,9 +342,7 @@ export function TaskSelector(props: IProps): React.ReactElement {
const [s1, setS1] = useState(abc[1]);
const [s2, setS2] = useState(abc[2]);
const validActions = Object.keys(canDo).filter((k) =>
(canDo[k] as (sleeve: Sleeve) => boolean)(props.sleeve),
);
const validActions = Object.keys(canDo).filter((k) => (canDo[k] as (sleeve: Sleeve) => boolean)(props.sleeve));
const detailsF = tasks[s0];
if (detailsF === undefined) throw new Error(`No function for task '${s0}'`);

@ -14,7 +14,6 @@ import { joinFaction } from "./Faction/FactionHelpers";
import { updateHashManagerCapacity } from "./Hacknet/HacknetHelpers";
import { prestigeWorkerScripts } from "./NetscriptWorker";
import { Player } from "./Player";
import { Router } from "./ui/GameRoot";
import { recentScripts } from "./Netscript/RecentScripts";
import { resetPidCounter } from "./Netscript/Pid";
import { LiteratureNames } from "./Literature/data/LiteratureNames";

@ -12,11 +12,7 @@ export class Program {
create: IProgramCreate | null;
run: (args: string[], server: BaseServer) => void;
constructor(
name: string,
create: IProgramCreate | null,
run: (args: string[], server: BaseServer) => void,
) {
constructor(name: string, create: IProgramCreate | null, run: (args: string[], server: BaseServer) => void) {
this.name = name;
this.create = create;
this.run = run;

@ -41,7 +41,7 @@ export const programsMetadata: IProgramCreationParams[] = [
req: requireHackingLevel(1),
time: CONSTANTS.MillisecondsPerFiveMinutes,
},
run: (_args:string[], server: BaseServer): void => {
run: (_args: string[], server: BaseServer): void => {
if (!(server instanceof Server)) {
Terminal.error("Cannot nuke this kind of server.");
return;
@ -70,7 +70,7 @@ export const programsMetadata: IProgramCreationParams[] = [
req: requireHackingLevel(50),
time: CONSTANTS.MillisecondsPerFiveMinutes * 2,
},
run: (_args:string[], server: BaseServer): void => {
run: (_args: string[], server: BaseServer): void => {
if (!(server instanceof Server)) {
Terminal.error("Cannot run BruteSSH.exe on this kind of server.");
return;
@ -94,7 +94,7 @@ export const programsMetadata: IProgramCreationParams[] = [
req: requireHackingLevel(100),
time: CONSTANTS.MillisecondsPerHalfHour,
},
run: (_args:string[], server: BaseServer): void => {
run: (_args: string[], server: BaseServer): void => {
if (!(server instanceof Server)) {
Terminal.error("Cannot run FTPCrack.exe on this kind of server.");
return;
@ -118,7 +118,7 @@ export const programsMetadata: IProgramCreationParams[] = [
req: requireHackingLevel(250),
time: CONSTANTS.MillisecondsPer2Hours,
},
run: (_args:string[], server: BaseServer): void => {
run: (_args: string[], server: BaseServer): void => {
if (!(server instanceof Server)) {
Terminal.error("Cannot run relaySMTP.exe on this kind of server.");
return;
@ -142,7 +142,7 @@ export const programsMetadata: IProgramCreationParams[] = [
req: requireHackingLevel(500),
time: CONSTANTS.MillisecondsPer4Hours,
},
run: (_args:string[], server: BaseServer): void => {
run: (_args: string[], server: BaseServer): void => {
if (!(server instanceof Server)) {
Terminal.error("Cannot run HTTPWorm.exe on this kind of server.");
return;
@ -166,7 +166,7 @@ export const programsMetadata: IProgramCreationParams[] = [
req: requireHackingLevel(750),
time: CONSTANTS.MillisecondsPer8Hours,
},
run: (_args:string[], server: BaseServer): void => {
run: (_args: string[], server: BaseServer): void => {
if (!(server instanceof Server)) {
Terminal.error("Cannot run SQLInject.exe on this kind of server.");
return;

@ -97,9 +97,7 @@ export function ProgramsRoot(): React.ReactElement {
sx={{ my: 1, width: "100%" }}
onClick={(event) => {
if (!event.isTrusted) return;
Player.startWork(
new CreateProgramWork({singularity: false, programName: program.name }),
);
Player.startWork(new CreateProgramWork({ singularity: false, programName: program.name }));
Player.startFocusing();
Router.toWork();
}}

@ -463,12 +463,7 @@ export function Root(props: IProps): React.ReactElement {
//If the current script already exists on the server, overwrite it
for (let i = 0; i < server.scripts.length; i++) {
if (scriptToSave.fileName == server.scripts[i].filename) {
server.scripts[i].saveScript(
scriptToSave.fileName,
scriptToSave.code,
Player.currentServer,
server.scripts,
);
server.scripts[i].saveScript(scriptToSave.fileName, scriptToSave.code, Player.currentServer, server.scripts);
if (Settings.SaveGameOnFileSave) saveObject.saveGame();
Router.toTerminal();
return;

@ -151,9 +151,7 @@ export function SidebarRoot(props: IProps): React.ReactElement {
Player.sourceFiles.length > 0;
const canOpenAugmentations =
Player.augmentations.length > 0 ||
Player.queuedAugmentations.length > 0 ||
Player.sourceFiles.length > 0;
Player.augmentations.length > 0 || Player.queuedAugmentations.length > 0 || Player.sourceFiles.length > 0;
const canOpenSleeves = Player.sleeves.length > 0;

@ -784,10 +784,7 @@ export class Terminal implements ITerminal {
}
const commands: {
[key: string]: (
args: (string | number | boolean)[],
server: BaseServer,
) => void;
[key: string]: (args: (string | number | boolean)[], server: BaseServer) => void;
} = {
"scan-analyze": scananalyze,
alias: alias,

@ -3,10 +3,7 @@ import { BaseServer } from "../../Server/BaseServer";
import { isScriptFilename } from "../../Script/isScriptFilename";
import { getDestinationFilepath, areFilesEqual } from "../DirectoryHelpers";
export function cp(
args: (string | number | boolean)[],
server: BaseServer,
): void {
export function cp(args: (string | number | boolean)[], server: BaseServer): void {
try {
if (args.length !== 2) {
Terminal.error("Incorrect usage of cp command. Usage: cp [src] [dst]");

@ -3,10 +3,7 @@ import { Player } from "../../Player";
import { BaseServer } from "../../Server/BaseServer";
import { Server } from "../../Server/Server";
export function grow(
args: (string | number | boolean)[],
server: BaseServer,
): void {
export function grow(args: (string | number | boolean)[], server: BaseServer): void {
if (args.length !== 0) {
Terminal.error("Incorrect usage of grow command. Usage: grow");
return;

@ -3,10 +3,7 @@ import { Player } from "../../Player";
import { BaseServer } from "../../Server/BaseServer";
import { Server } from "../../Server/Server";
export function hack(
args: (string | number | boolean)[],
server: BaseServer,
): void {
export function hack(args: (string | number | boolean)[], server: BaseServer): void {
if (args.length !== 0) {
Terminal.error("Incorrect usage of hack command. Usage: hack");
return;

@ -1,9 +1,7 @@
import { Terminal } from "../../Terminal";
import { Player } from "../../Player";
export function home(
args: (string | number | boolean)[],
): void {
export function home(args: (string | number | boolean)[]): void {
if (args.length !== 0) {
Terminal.error("Incorrect usage of home command. Usage: home");
return;

@ -4,10 +4,7 @@ import { isScriptFilename } from "../../Script/isScriptFilename";
import { runScript } from "./runScript";
import { runProgram } from "./runProgram";
export function run(
args: (string | number | boolean)[],
server: BaseServer,
): void {
export function run(args: (string | number | boolean)[], server: BaseServer): void {
// Run a program or a script
if (args.length < 1) {
Terminal.error("Incorrect number of arguments. Usage: run [program/script] [-t] [num threads] [arg1] [arg2]...");

@ -7,10 +7,7 @@ import { findRunningScript } from "../../Script/ScriptHelpers";
import * as libarg from "arg";
import { numeralWrapper } from "../../ui/numeralFormat";
export function runScript(
commandArgs: (string | number | boolean)[],
server: BaseServer,
): void {
export function runScript(commandArgs: (string | number | boolean)[], server: BaseServer): void {
if (commandArgs.length < 1) {
Terminal.error(
`Bug encountered with Terminal.runScript(). Command array has a length of less than 1: ${commandArgs}`,

@ -1,10 +1,7 @@
import { Terminal } from "../../Terminal";
import { BaseServer } from "../../Server/BaseServer";
export function sudov(
args: (string | number | boolean)[],
server: BaseServer,
): void {
export function sudov(args: (string | number | boolean)[], server: BaseServer): void {
if (args.length !== 0) {
Terminal.error("Incorrect number of arguments. Usage: sudov");
return;

@ -3,10 +3,7 @@ import { BaseServer } from "../../Server/BaseServer";
import { getRamUsageFromRunningScript } from "../../Script/RunningScriptHelpers";
import { numeralWrapper } from "../../ui/numeralFormat";
export function top(
args: (string | number | boolean)[],
server: BaseServer,
): void {
export function top(args: (string | number | boolean)[], server: BaseServer): void {
if (args.length !== 0) {
Terminal.error("Incorrect usage of top command. Usage: top");
return;

@ -1,9 +1,7 @@
import { Terminal } from "../../Terminal";
import { removeAlias } from "../../Alias";
export function unalias(
args: (string | number | boolean)[],
): void {
export function unalias(args: (string | number | boolean)[]): void {
if (args.length !== 1) {
Terminal.error("Incorrect usage of unalias name. Usage: unalias [alias]");
return;

@ -4,10 +4,7 @@ import { Terminal } from "../../Terminal";
import { BaseServer } from "../../Server/BaseServer";
import { isScriptFilename } from "../../Script/isScriptFilename";
export function wget(
args: (string | number | boolean)[],
server: BaseServer,
): void {
export function wget(args: (string | number | boolean)[], server: BaseServer): void {
if (args.length !== 2) {
Terminal.error("Incorrect usage of wget command. Usage: wget [url] [target file]");
return;

@ -9,7 +9,6 @@ import TextField from "@mui/material/TextField";
import { KEY, KEYCODE } from "../../utils/helpers/keyCodes";
import { Terminal } from "../../Terminal";
import { Router } from "../../ui/GameRoot";
import { Player } from "../../Player";
import { determineAllPossibilitiesForTabCompletion } from "../determineAllPossibilitiesForTabCompletion";
import { tabCompletion } from "../tabCompletion";

@ -68,12 +68,7 @@ export const scaleWorkStats = (w: WorkStats, n: number, scaleMoney = true): Work
};
};
export const applyWorkStats = (
target: IPerson,
workStats: WorkStats,
cycles: number,
source: string,
): WorkStats => {
export const applyWorkStats = (target: IPerson, workStats: WorkStats, cycles: number, source: string): WorkStats => {
const expStats = applyWorkStatsExp(target, workStats, cycles);
const gains = {
money: workStats.money * cycles,

@ -20,11 +20,7 @@ export function calculateCost(classs: Class, location: Location): number {
return classs.earnings.money * location.costMult * discount;
}
export function calculateClassEarnings(
person: IPerson,
type: ClassType,
locationName: LocationName,
): WorkStats {
export function calculateClassEarnings(person: IPerson, type: ClassType, locationName: LocationName): WorkStats {
//Find cost and exp gain per game cycle
const hashManager = Player.hashManager;
const classs = Classes[type];

@ -21,7 +21,7 @@ import ClearAllIcon from "@mui/icons-material/ClearAll";
import { Settings } from "../../Settings/Settings";
import { Router } from "../GameRoot";
import { Player } from "../../Player";
import { Player } from "../../Player";
import { StatsProgressOverviewCell } from "./StatsProgressBar";
import { BitNodeMultipliers } from "../../BitNode/BitNodeMultipliers";

@ -22,9 +22,11 @@ interface IProps {
}
export function Money(props: IProps): React.ReactElement {
const classes = useStyles();
if (props.forPurchase){
if (typeof props.money !== "number") throw new Error("if value is for a purchase, money should be number, contact dev");
if (!Player.canAfford(props.money)) return <span className={classes.unbuyable}>{numeralWrapper.formatMoney(props.money)}</span>;
if (props.forPurchase) {
if (typeof props.money !== "number")
throw new Error("if value is for a purchase, money should be number, contact dev");
if (!Player.canAfford(props.money))
return <span className={classes.unbuyable}>{numeralWrapper.formatMoney(props.money)}</span>;
}
return (
<span className={classes.money}>

@ -11,7 +11,7 @@ import { Locations } from "../Locations/Locations";
import { Settings } from "../Settings/Settings";
import { convertTimeMsToTimeElapsedString } from "../utils/StringHelperFunctions";
import { Player } from "../Player";
import { Router } from "./GameRoot"
import { Router } from "./GameRoot";
import { numeralWrapper } from "./numeralFormat";
import { Money } from "./React/Money";
import { MoneyRate } from "./React/MoneyRate";