See description

Reverted ToastVariant back to an enum internally. Still exposed to player as just possible strings.
Changed all 1-line documentation comments to actually be 1-line. Moved some because they were not providing documentation for the thing they were trying to.
This commit is contained in:
Snarling 2022-10-04 06:40:10 -04:00
parent 50f14b4f58
commit aa80cf6451
109 changed files with 400 additions and 1096 deletions

@ -1,6 +1,3 @@
/**
* React component for displaying the player's multipliers on the Augmentation UI page
*/
import { DoubleArrow } from "@mui/icons-material";
import { List, ListItem, ListItemText, Paper, Typography } from "@mui/material";
import * as React from "react";
@ -85,6 +82,7 @@ function MultiplierList(props: IMultiplierListProps): React.ReactElement {
return listItems.length > 0 ? <List disablePadding>{listItems}</List> : <></>;
}
/** React component for displaying the player's multipliers on the Augmentation UI page */
export function PlayerMultipliers(): React.ReactElement {
const mults = calculateAugmentedStats();

@ -6,129 +6,79 @@ import { defaultMultipliers } from "./BitNode";
* player toward the intended strategy. Unless they really want to play the long, slow game of waiting...
*/
export interface IBitNodeMultipliers {
/**
* Influences how quickly the player's agility level (not exp) scales
*/
/** Influences how quickly the player's agility level (not exp) scales */
AgilityLevelMultiplier: number;
/**
* Influences the base cost to purchase an augmentation.
*/
/** Influences the base cost to purchase an augmentation. */
AugmentationMoneyCost: number;
/**
* Influences the base rep the player must have with a faction to purchase an augmentation.
*/
/** Influences the base rep the player must have with a faction to purchase an augmentation. */
AugmentationRepCost: number;
/**
* Influences how quickly the player can gain rank within Bladeburner.
*/
/** Influences how quickly the player can gain rank within Bladeburner. */
BladeburnerRank: number;
/**
* Influences the cost of skill levels from Bladeburner.
*/
/** Influences the cost of skill levels from Bladeburner. */
BladeburnerSkillCost: number;
/**
* Influences how quickly the player's charisma level (not exp) scales
*/
/** Influences how quickly the player's charisma level (not exp) scales */
CharismaLevelMultiplier: number;
/**
* Influences the experience gained for each ability when a player completes a class.
*/
/** Influences the experience gained for each ability when a player completes a class. */
ClassGymExpGain: number;
/**
* Influences the amount of money gained from completing Coding Contracts
**/
/**Influences the amount of money gained from completing Coding Contracts. */
CodingContractMoney: number;
/**
* Influences the experience gained for each ability when the player completes working their job.
*/
/** Influences the experience gained for each ability when the player completes working their job. */
CompanyWorkExpGain: number;
/**
* Influences how much money the player earns when completing working their job.
*/
/** Influences how much money the player earns when completing working their job. */
CompanyWorkMoney: number;
/**
* Influences the valuation of corporations created by the player.
*/
/** Influences the valuation of corporations created by the player. */
CorporationValuation: number;
/**
* Influences the base experience gained for each ability when the player commits a crime.
*/
/** Influences the base experience gained for each ability when the player commits a crime. */
CrimeExpGain: number;
/**
* Influences the base money gained when the player commits a crime.
*/
/** Influences the base money gained when the player commits a crime. */
CrimeMoney: number;
/**
* Influences how many Augmentations you need in order to get invited to the Daedalus faction
*/
/** Influences how many Augmentations you need in order to get invited to the Daedalus faction */
DaedalusAugsRequirement: number;
/**
* Influences how quickly the player's defense level (not exp) scales
*/
/** Influences how quickly the player's defense level (not exp) scales */
DefenseLevelMultiplier: number;
/**
* Influences how quickly the player's dexterity level (not exp) scales
*/
/** Influences how quickly the player's dexterity level (not exp) scales */
DexterityLevelMultiplier: number;
/**
* Influences how much rep the player gains in each faction simply by being a member.
*/
/** Influences how much rep the player gains in each faction simply by being a member. */
FactionPassiveRepGain: number;
/**
* Influences the experience gained for each ability when the player completes work for a Faction.
*/
/** Influences the experience gained for each ability when the player completes work for a Faction. */
FactionWorkExpGain: number;
/**
* Influences how much rep the player gains when performing work for a faction.
*/
/** Influences how much rep the player gains when performing work for a faction. */
FactionWorkRepGain: number;
/**
* Influences how much it costs to unlock the stock market's 4S Market Data API
*/
/** Influences how much it costs to unlock the stock market's 4S Market Data API */
FourSigmaMarketDataApiCost: number;
/**
* Influences how much it costs to unlock the stock market's 4S Market Data (NOT API)
*/
/** Influences how much it costs to unlock the stock market's 4S Market Data (NOT API) */
FourSigmaMarketDataCost: number;
/**
* Reduces gangs earning.
*/
/** Reduces gangs earning. */
GangSoftcap: number;
/**
* Percentage of unique augs that the gang has.
*/
/** Percentage of unique augs that the gang has. */
GangUniqueAugs: number;
/**
* Influences the experienced gained when hacking a server.
*/
/** Influences the experienced gained when hacking a server. */
HackExpGain: number;
/**
* Influences how quickly the player's hacking level (not experience) scales
*/
/** Influences how quickly the player's hacking level (not experience) scales */
HackingLevelMultiplier: number;
/**
@ -136,55 +86,38 @@ export interface IBitNodeMultipliers {
* Influeces the hash rate of Hacknet Servers (unlocked in BitNode-9)
*/
HacknetNodeMoney: number;
/**
* Influences how much money it costs to upgrade your home computer's RAM
*/
/** Influences how much money it costs to upgrade your home computer's RAM */
HomeComputerRamCost: number;
/**
* Influences how much money is gained when the player infiltrates a company.
*/
/** Influences how much money is gained when the player infiltrates a company. */
InfiltrationMoney: number;
/**
* Influences how much rep the player can gain from factions when selling stolen documents and secrets
*/
/** Influences how much rep the player can gain from factions when selling stolen documents and secrets */
InfiltrationRep: number;
/**
* Influences how much money can be stolen from a server when the player performs a hack against it through
* the Terminal.
*/
ManualHackMoney: number;
/**
* Influence how much it costs to purchase a server
*/
/** Influence how much it costs to purchase a server */
PurchasedServerCost: number;
/**
* Influence how much it costs to purchase a server
*/
/** Influence how much it costs to purchase a server */
PurchasedServerSoftcap: number;
/**
* Influences the maximum number of purchased servers you can have
*/
/** Influences the maximum number of purchased servers you can have */
PurchasedServerLimit: number;
/**
* Influences the maximum allowed RAM for a purchased server
*/
/** Influences the maximum allowed RAM for a purchased server */
PurchasedServerMaxRam: number;
/**
* Influences the minimum favor the player must have with a faction before they can donate to gain rep.
*/
/** Influences the minimum favor the player must have with a faction before they can donate to gain rep. */
RepToDonateToFaction: number;
/**
* Influences how much money can be stolen from a server when a script performs a hack against it.
*/
/** Influences how much money can be stolen from a server when a script performs a hack against it. */
ScriptHackMoney: number;
/**
@ -194,62 +127,40 @@ export interface IBitNodeMultipliers {
*/
ScriptHackMoneyGain: number;
/**
* Influences the growth percentage per cycle against a server.
*/
/** Influences the growth percentage per cycle against a server. */
ServerGrowthRate: number;
/**
* Influences the maxmimum money that a server can grow to.
*/
/** Influences the maxmimum money that a server can grow to. */
ServerMaxMoney: number;
/**
* Influences the initial money that a server starts with.
*/
/** Influences the initial money that a server starts with. */
ServerStartingMoney: number;
/**
* Influences the initial security level (hackDifficulty) of a server.
*/
/** Influences the initial security level (hackDifficulty) of a server. */
ServerStartingSecurity: number;
/**
* Influences the weaken amount per invocation against a server.
*/
/** Influences the weaken amount per invocation against a server. */
ServerWeakenRate: number;
/**
* Influences how quickly the player's strength level (not exp) scales
*/
/** Influences how quickly the player's strength level (not exp) scales */
StrengthLevelMultiplier: number;
/**
* Influences the power of the gift.
*/
/** Influences the power of the gift. */
StaneksGiftPowerMultiplier: number;
/**
* Influences the size of the gift.
*/
/** Influences the size of the gift. */
StaneksGiftExtraSize: number;
/**
* Influences the hacking skill required to backdoor the world daemon.
*/
/** Influences the hacking skill required to backdoor the world daemon. */
WorldDaemonDifficulty: number;
/**
* Influences corporation dividends.
*/
/** Influences corporation dividends. */
CorporationSoftcap: number;
// Index signature
[key: string]: number;
}
/**
* The multipliers that are influenced by current Bitnode progression.
*/
/** The multipliers that are influenced by current Bitnode progression. */
// tslint:disable-next-line:variable-name
export const BitNodeMultipliers = Object.assign({}, defaultMultipliers);

@ -2377,16 +2377,12 @@ export class Bladeburner {
}
}
/**
* Serialize the current object to a JSON save state.
*/
/** Serialize the current object to a JSON save state. */
toJSON(): IReviverValue {
return Generic_toJSON("Bladeburner", this);
}
/**
* Initiatizes a Bladeburner object from a JSON save state.
*/
/** Initiatizes a Bladeburner object from a JSON save state. */
static fromJSON(value: IReviverValue): Bladeburner {
return Generic_fromJSON(Bladeburner, value.data);
}

@ -4,7 +4,9 @@ import { Generic_fromJSON, Generic_toJSON, IReviverValue, Reviver } from "../uti
import { addOffset } from "../utils/helpers/addOffset";
interface IChangePopulationByCountParams {
/** How much the estimate should change by. */
estChange: number;
/** Add offset to estimate (offset by percentage). */
estOffset: number;
}
@ -14,29 +16,19 @@ interface IChangePopulationByPercentageParams {
}
export class City {
/**
* Name of the city.
*/
/** Name of the city. */
name = "";
/**
* Population of the city.
*/
/** Population of the city. */
pop = 0;
/**
* Population estimation of the city.
*/
/** Population estimation of the city. */
popEst = 0;
/**
* Number of communities in the city.
*/
/** Number of communities in the city. */
comms = 0;
/**
* Chaos level of the city.
*/
/** Chaos level of the city. */
chaos = 0;
constructor(name: string = BladeburnerConstants.CityNames[2]) {
@ -51,9 +43,7 @@ export class City {
this.chaos = 0;
}
/**
* p is the percentage, not the multiplier (e.g. pass in p = 5 for 5%)
*/
/** p is the percentage, not the multiplier (e.g. pass in p = 5 for 5%) */
changeChaosByPercentage(p: number): void {
if (isNaN(p)) {
throw new Error("NaN passed into City.chaosChaosByPercentage()");
@ -84,9 +74,7 @@ export class City {
}
}
/**
* p is the percentage, not the multiplier (e.g. pass in p = 5 for 5%)
*/
/** p is the percentage, not the multiplier (e.g. pass in p = 5 for 5%) */
improvePopulationEstimateByPercentage(p: number, skillMult = 1): void {
p = p * skillMult;
if (isNaN(p)) {
@ -106,11 +94,6 @@ export class City {
}
}
/**
* @params options:
* estChange(int): How much the estimate should change by
* estOffset(int): Add offset to estimate (offset by percentage)
*/
changePopulationByCount(n: number, params: IChangePopulationByCountParams = { estChange: 0, estOffset: 0 }): void {
if (isNaN(n)) {
throw new Error("NaN passed into City.changePopulationByCount()");
@ -174,16 +157,12 @@ export class City {
}
}
/**
* Serialize the current object to a JSON save state.
*/
/** Serialize the current object to a JSON save state. */
toJSON(): IReviverValue {
return Generic_toJSON("City", this);
}
/**
* Initiatizes a City object from a JSON save state.
*/
/** Initiatizes a City object from a JSON save state. */
static fromJSON(value: IReviverValue): City {
return Generic_fromJSON(City, value.data);
}

@ -7,34 +7,22 @@ import { CodingContractEvent } from "./ui/React/CodingContractModal";
/* Represents different types of problems that a Coding Contract can have */
class CodingContractType {
/**
* Function that generates a description of the problem
*/
/** Function that generates a description of the problem */
desc: DescriptionFunc;
/**
* Number that generally represents the problem's difficulty. Bigger numbers = harder
*/
/** Number that generally represents the problem's difficulty. Bigger numbers = harder */
difficulty: number;
/**
* A function that randomly generates a valid 'data' for the problem
*/
/** A function that randomly generates a valid 'data' for the problem */
generate: GeneratorFunc;
/**
* Name of the type of problem
*/
/** Name of the type of problem */
name: string;
/**
* The maximum number of tries the player gets on this kind of problem before it self-destructs
*/
/** The maximum number of tries the player gets on this kind of problem before it self-destructs */
numTries: number;
/**
* Stores a function that checks if the provided answer is correct
*/
/** Stores a function that checks if the provided answer is correct */
solver: SolverFunc;
constructor(
@ -70,9 +58,7 @@ for (const md of codingContractTypesMetadata) {
);
}
/**
* Enum representing the different types of rewards a Coding Contract can give
*/
/** Enum representing the different types of rewards a Coding Contract can give */
export enum CodingContractRewardType {
FactionReputation,
FactionReputationAll,
@ -80,18 +66,14 @@ export enum CodingContractRewardType {
Money, // This must always be the last reward type
}
/**
* Enum representing the result when trying to solve the Contract
*/
/** Enum representing the result when trying to solve the Contract */
export enum CodingContractResult {
Success,
Failure,
Cancelled,
}
/**
* A class that represents the type of reward a contract gives
*/
/** A class that represents the type of reward a contract gives */
export interface ICodingContractReward {
/* Name of Company/Faction name for reward, if applicable */
name?: string;
@ -159,9 +141,7 @@ export class CodingContract {
return CodingContractTypes[this.type].solver(this.data, solution);
}
/**
* Creates a popup to prompt the player to solve the problem
*/
/** Creates a popup to prompt the player to solve the problem */
async prompt(): Promise<CodingContractResult> {
return new Promise<CodingContractResult>((resolve) => {
const props = {
@ -181,16 +161,12 @@ export class CodingContract {
});
}
/**
* Serialize the current file to a JSON save state.
*/
/** Serialize the current file to a JSON save state. */
toJSON(): IReviverValue {
return Generic_toJSON("CodingContract", this);
}
/**
* Initiatizes a CodingContract from a JSON save state.
*/
/** Initiatizes a CodingContract from a JSON save state. */
static fromJSON(value: IReviverValue): CodingContract {
return Generic_fromJSON(CodingContract, value.data);
}

@ -24,19 +24,13 @@ const DefaultConstructorParams: IConstructorParams = {
};
export class Company {
/**
* Company name
*/
/** Company name */
name: string;
/**
* Description and general information about company
*/
/** Description and general information about company */
info: string;
/**
* Has faction associated.
*/
/** Has faction associated. */
isMegacorp: boolean;
/**
@ -48,9 +42,7 @@ export class Company {
*/
companyPositions: Record<string, boolean>;
/**
* Company-specific multiplier for earnings
*/
/** Company-specific multiplier for earnings */
expMultiplier: number;
salaryMultiplier: number;
@ -63,9 +55,7 @@ export class Company {
*/
jobStatReqOffset: number;
/**
* Properties to track the player's progress in this company
*/
/** Properties to track the player's progress in this company */
isPlayerEmployed: boolean;
playerReputation: number;
favor: number;
@ -142,16 +132,12 @@ export class Company {
return newFavor - this.favor;
}
/**
* Serialize the current object to a JSON save state.
*/
/** Serialize the current object to a JSON save state. */
toJSON(): IReviverValue {
return Generic_toJSON("Company", this);
}
/**
* Initiatizes a Company from a JSON save state.
*/
/** Initiatizes a Company from a JSON save state. */
static fromJSON(value: IReviverValue): Company {
return Generic_fromJSON(Company, value.data);
}

@ -33,14 +33,10 @@ export interface IConstructorParams {
}
export class CompanyPosition {
/**
* Position title
*/
/** Position title */
name: string;
/**
* Title of next position to be promoted to
*/
/** Title of next position to be promoted to */
nextPosition: string | null;
/**
@ -49,14 +45,10 @@ export class CompanyPosition {
*/
baseSalary: number;
/**
* Reputation multiplier
*/
/** Reputation multiplier */
repMultiplier: number;
/**
* Required stats to earn this position
*/
/** Required stats to earn this position */
requiredAgility: number;
requiredCharisma: number;
requiredDefense: number;
@ -64,14 +56,10 @@ export class CompanyPosition {
requiredHacking: number;
requiredStrength: number;
/**
* Required company reputation to earn this position
*/
/** Required company reputation to earn this position */
requiredReputation: number;
/**
* Effectiveness of each stat time for job performance
*/
/** Effectiveness of each stat time for job performance */
hackingEffectiveness: number;
strengthEffectiveness: number;
defenseEffectiveness: number;
@ -79,9 +67,7 @@ export class CompanyPosition {
agilityEffectiveness: number;
charismaEffectiveness: number;
/**
* Experience gain for performing job (per 200ms game cycle)
*/
/** Experience gain for performing job (per 200ms game cycle) */
hackingExpGain: number;
strengthExpGain: number;
defenseExpGain: number;

@ -1,10 +1,7 @@
import { Company } from "./Company";
import { CompanyPosition } from "./CompanyPosition";
/**
* Returns a string with the given CompanyPosition's stat requirements
*/
/** Returns a string with the given CompanyPosition's stat requirements */
export function getJobRequirementText(company: Company, pos: CompanyPosition, tooltiptext = false): string {
let reqText = "";
const offset: number = company.jobStatReqOffset;

@ -446,16 +446,12 @@ export class Corporation {
return;
}
/**
* Serialize the current object to a JSON save state.
*/
/** Serialize the current object to a JSON save state. */
toJSON(): IReviverValue {
return Generic_toJSON("Corporation", this);
}
/**
* Initiatizes a Corporation object from a JSON save state.
*/
/** Initiatizes a Corporation object from a JSON save state. */
static fromJSON(value: IReviverValue): Corporation {
return Generic_fromJSON(Corporation, value.data);
}

@ -1369,16 +1369,12 @@ export class Industry {
return researchTree.getStorageMultiplier();
}
/**
* Serialize the current object to a JSON save state.
*/
/** Serialize the current object to a JSON save state. */
toJSON(): IReviverValue {
return Generic_toJSON("Industry", this);
}
/**
* Initiatizes a Industry object from a JSON save state.
*/
/** Initiatizes a Industry object from a JSON save state. */
static fromJSON(value: IReviverValue): Industry {
return Generic_fromJSON(Industry, value.data);
}

@ -71,16 +71,12 @@ export class ActiveFragment {
return Object.assign({}, this);
}
/**
* Serialize an active fragment to a JSON save state.
*/
/** Serialize an active fragment to a JSON save state. */
toJSON(): IReviverValue {
return Generic_toJSON("ActiveFragment", this);
}
/**
* Initializes an acive fragment from a JSON save state
*/
/** Initializes an acive fragment from a JSON save state */
static fromJSON(value: IReviverValue): ActiveFragment {
return Generic_fromJSON(ActiveFragment, value.data);
}

@ -230,16 +230,12 @@ export class StaneksGift extends BaseGift {
this.storedCycles = 0;
}
/**
* Serialize Staneks Gift to a JSON save state.
*/
/** Serialize Staneks Gift to a JSON save state. */
toJSON(): IReviverValue {
return Generic_toJSON("StaneksGift", this);
}
/**
* Initializes Staneks Gift from a JSON save state
*/
/** Initializes Staneks Gift from a JSON save state */
static fromJSON(value: IReviverValue): StaneksGift {
return Generic_fromJSON(StaneksGift, value.data);
}

@ -7,7 +7,7 @@ import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
import Typography from "@mui/material/Typography";
import { saveObject } from "../../SaveObject";
import { SnackbarEvents } from "../../ui/React/Snackbar";
import { SnackbarEvents, ToastVariant } from "../../ui/React/Snackbar";
import { Upload } from "@mui/icons-material";
import { Button } from "@mui/material";
import { OptionSwitch } from "../../ui/React/OptionSwitch";
@ -25,7 +25,7 @@ export function SaveFile(): React.ReactElement {
const save = atob(base64Save);
setSaveFile(save);
} catch (e: unknown) {
SnackbarEvents.emit(String(e), "error", 5000);
SnackbarEvents.emit(String(e), ToastVariant.ERROR, 5000);
}
}

@ -151,7 +151,7 @@ function initSaveFunctions(): void {
saveObject.exportGame();
} catch (error) {
console.error(error);
SnackbarEvents.emit("Could not export game.", "error", 2000);
SnackbarEvents.emit("Could not export game.", ToastVariant.ERROR, 2000);
}
},
triggerScriptsExport: (): void => exportScripts("*", Player.getHomeComputer()),
@ -203,7 +203,7 @@ function initElectronBridge(): void {
})
.catch((error: unknown) => {
console.error(error);
SnackbarEvents.emit("Could not save game.", "error", 2000);
SnackbarEvents.emit("Could not save game.", ToastVariant.ERROR, 2000);
});
});
bridge.receive("trigger-game-export", () => {
@ -211,7 +211,7 @@ function initElectronBridge(): void {
window.appSaveFns.triggerGameExport();
} catch (error) {
console.error(error);
SnackbarEvents.emit("Could not export game.", "error", 2000);
SnackbarEvents.emit("Could not export game.", ToastVariant.ERROR, 2000);
}
});
bridge.receive("trigger-scripts-export", () => {
@ -219,7 +219,7 @@ function initElectronBridge(): void {
window.appSaveFns.triggerScriptsExport();
} catch (error) {
console.error(error);
SnackbarEvents.emit("Could not export scripts.", "error", 2000);
SnackbarEvents.emit("Could not export scripts.", ToastVariant.ERROR, 2000);
}
});
}

@ -9,34 +9,22 @@ export class Faction {
*/
alreadyInvited = false;
/**
* Holds names of all augmentations that this Faction offers
*/
/** Holds names of all augmentations that this Faction offers */
augmentations: string[] = [];
/**
* Amount of favor the player has with this faction.
*/
/** Amount of favor the player has with this faction. */
favor = 0;
/**
* Flag signalling whether player has been banned from this faction
*/
/** Flag signalling whether player has been banned from this faction */
isBanned = false;
/**
* Flag signalling whether player is a member of this faction
*/
/** Flag signalling whether player is a member of this faction */
isMember = false;
/**
* Name of faction
*/
/** Name of faction */
name = "";
/**
* Amount of reputation player has with this faction
*/
/** Amount of reputation player has with this faction */
playerReputation = 0;
constructor(name = "") {
@ -72,16 +60,12 @@ export class Faction {
return newFavor - this.favor;
}
/**
* Serialize the current object to a JSON save state.
*/
/** Serialize the current object to a JSON save state. */
toJSON(): IReviverValue {
return Generic_toJSON("Faction", this);
}
/**
* Initiatizes a Faction object from a JSON save state.
*/
/** Initiatizes a Faction object from a JSON save state. */
static fromJSON(value: IReviverValue): Faction {
return Generic_fromJSON(Faction, value.data);
}

@ -15,48 +15,30 @@ interface FactionInfoParams {
assignment?: () => React.ReactElement;
}
/**
* Contains the "information" property for all the Factions, which is just a description of each faction
*/
/** Contains the "information" property for all the Factions, which is just a description of each faction */
export class FactionInfo {
/**
* The names of all other factions considered to be enemies to this faction.
*/
/** The names of all other factions considered to be enemies to this faction. */
enemies: string[];
/**
* The descriptive text to show on the faction's page.
*/
/** The descriptive text to show on the faction's page. */
infoText: JSX.Element;
/**
* A flag indicating if the faction supports field work to earn reputation.
*/
/** A flag indicating if the faction supports field work to earn reputation. */
offerFieldWork: boolean;
/**
* A flag indicating if the faction supports hacking work to earn reputation.
*/
/** A flag indicating if the faction supports hacking work to earn reputation. */
offerHackingWork: boolean;
/**
* A flag indicating if the faction supports security work to earn reputation.
*/
/** A flag indicating if the faction supports security work to earn reputation. */
offerSecurityWork: boolean;
/**
* Keep faction on install.
*/
/** Keep faction on install. */
keep: boolean;
/**
* Special faction
*/
/** Special faction */
special: boolean;
/**
* The data to display on the faction screen.
*/
/** The data to display on the faction screen. */
assignment?: () => React.ReactElement;
constructor(params: FactionInfoParams) {
@ -76,9 +58,7 @@ export class FactionInfo {
}
}
/**
* A map of all factions and associated info to them.
*/
/** A map of all factions and associated info to them. */
// tslint:disable-next-line:variable-name
export const FactionInfos: Record<string, FactionInfo> = {
// Endgame

@ -1,6 +1,3 @@
/**
* Root React Component for displaying a faction's "Purchase Augmentations" page
*/
import { Box, Button, Tooltip, Typography, Paper, Container } from "@mui/material";
import React, { useState } from "react";
@ -23,6 +20,7 @@ type IProps = {
routeToMainPage: () => void;
};
/** Root React Component for displaying a faction's "Purchase Augmentations" page */
export function AugmentationsPage(props: IProps): React.ReactElement {
const setRerender = useState(false)[1];

@ -1,6 +1,3 @@
/**
* React Component for the popup used to create a new gang.
*/
import React from "react";
import { Modal } from "../../ui/React/Modal";
import { Router } from "../../ui/GameRoot";
@ -16,6 +13,7 @@ interface IProps {
facName: string;
}
/** React Component for the popup used to create a new gang. */
export function CreateGangModal(props: IProps): React.ReactElement {
const combatGangText =
"This is a COMBAT gang. Members in this gang will have different tasks than HACKING gangs. " +

@ -1,6 +1,3 @@
/**
* React component for a donate option on the Faction UI
*/
import React, { useState } from "react";
import { CONSTANTS } from "../../Constants";
@ -27,6 +24,7 @@ type IProps = {
rerender: () => void;
};
/** React component for a donate option on the Faction UI */
export function DonateOption(props: IProps): React.ReactElement {
const [donateAmt, setDonateAmt] = useState<number>(NaN);
const digits = (CONSTANTS.DonateMoneyToRepDivisor + "").length - 1;

@ -19,7 +19,7 @@ import { StyleEditorButton } from "../../Themes/ui/StyleEditorButton";
import { ThemeEditorButton } from "../../Themes/ui/ThemeEditorButton";
import { ConfirmationModal } from "../../ui/React/ConfirmationModal";
import { DeleteGameButton } from "../../ui/React/DeleteGameButton";
import { SnackbarEvents } from "../../ui/React/Snackbar";
import { SnackbarEvents, ToastVariant } from "../../ui/React/Snackbar";
import { SoftResetButton } from "../../ui/React/SoftResetButton";
import { Router } from "../../ui/GameRoot";
import { convertTimeMsToTimeElapsedString } from "../../utils/StringHelperFunctions";
@ -72,7 +72,7 @@ export const GameOptionsSidebar = (props: IProps): React.ReactElement => {
setImportData(data);
setImportSaveOpen(true);
} catch (e: unknown) {
SnackbarEvents.emit(String(e), "error", 5000);
SnackbarEvents.emit(String(e), ToastVariant.ERROR, 5000);
}
}
@ -82,7 +82,7 @@ export const GameOptionsSidebar = (props: IProps): React.ReactElement => {
try {
await saveObject.importGame(importData.base64);
} catch (e: unknown) {
SnackbarEvents.emit(String(e), "error", 5000);
SnackbarEvents.emit(String(e), ToastVariant.ERROR, 5000);
}
setImportSaveOpen(false);

@ -376,7 +376,7 @@ export class Gang {
return Math.max(1, discount);
}
// Returns only valid tasks for this gang. Excludes 'Unassigned'
/** Returns only valid tasks for this gang. Excludes 'Unassigned' */
getAllTaskNames(): string[] {
return Object.keys(GangMemberTasks).filter((taskName: string) => {
const task = GangMemberTasks[taskName];
@ -394,16 +394,12 @@ export class Gang {
return upg.cost / this.getDiscount();
}
/**
* Serialize the current object to a JSON save state.
*/
/** Serialize the current object to a JSON save state. */
toJSON(): IReviverValue {
return Generic_toJSON("Gang", this);
}
/**
* Initiatizes a Gang object from a JSON save state.
*/
/** Initiatizes a Gang object from a JSON save state. */
static fromJSON(value: IReviverValue): Gang {
return Generic_fromJSON(Gang, value.data);
}

@ -319,16 +319,12 @@ export class GangMember {
return true;
}
/**
* Serialize the current object to a JSON save state.
*/
/** Serialize the current object to a JSON save state. */
toJSON(): IReviverValue {
return Generic_toJSON("GangMember", this);
}
/**
* Initiatizes a GangMember object from a JSON save state.
*/
/** Initiatizes a GangMember object from a JSON save state. */
static fromJSON(value: IReviverValue): GangMember {
return Generic_fromJSON(GangMember, value.data);
}

@ -6,24 +6,16 @@ import { ITaskParams } from "../ITaskParams";
* (defined in Gang.js)
*/
interface IGangMemberTaskMetadata {
/**
* Description of the task
*/
/** Description of the task */
desc: string;
/**
* Whether or not this task is meant for Combat-type gangs
*/
/** Whether or not this task is meant for Combat-type gangs */
isCombat: boolean;
/**
* Whether or not this task is for Hacking-type gangs
*/
/** Whether or not this task is for Hacking-type gangs */
isHacking: boolean;
/**
* Name of the task
*/
/** Name of the task */
name: string;
/**

@ -1,6 +1,3 @@
/**
* React Component for displaying the bonus time remaining.
*/
import * as React from "react";
import { Gang } from "../Gang";
import { CONSTANTS } from "../../Constants";
@ -13,6 +10,7 @@ interface IProps {
gang: Gang;
}
/** React Component for displaying the bonus time remaining. */
export function BonusTime(props: IProps): React.ReactElement {
const CyclerPerSecond = 1000 / CONSTANTS._idleSpeed;
if ((props.gang.storedCycles / CyclerPerSecond) * 1000 <= 5000) return <></>;

@ -1,6 +1,3 @@
/**
* React Component for the popup that manages gang members upgrades
*/
import React, { useState } from "react";
import { useGang } from "./Context";
@ -244,6 +241,7 @@ function GangMemberUpgradePanel(props: IPanelProps): React.ReactElement {
);
}
/** React Component for the popup that manages gang members upgrades */
export function EquipmentsSubpage(): React.ReactElement {
const gang = useGang();
const [filter, setFilter] = useState("");

@ -1,6 +1,3 @@
/**
* React Component for a gang member on the management subpage.
*/
import React from "react";
import { GangMember } from "../GangMember";
import { GangMemberCardContent } from "./GangMemberCardContent";
@ -14,6 +11,7 @@ interface IProps {
member: GangMember;
}
/** React Component for a gang member on the management subpage. */
export function GangMemberCard(props: IProps): React.ReactElement {
return (
<Box component={Paper} sx={{ width: "auto" }}>

@ -1,6 +1,3 @@
/**
* React Component for the list of gang members on the management subpage.
*/
import React, { useState } from "react";
import { GangMemberCard } from "./GangMemberCard";
import { RecruitButton } from "./RecruitButton";
@ -12,6 +9,7 @@ import SearchIcon from "@mui/icons-material/Search";
import { GangMember } from "../GangMember";
import { OptionSwitch } from "../../ui/React/OptionSwitch";
/** React Component for the list of gang members on the management subpage. */
export function GangMemberList(): React.ReactElement {
const gang = useGang();
const setRerender = useState(false)[1];

@ -1,6 +1,3 @@
/**
* React Component for all the gang stuff.
*/
import React, { useState, useEffect } from "react";
import { ManagementSubpage } from "./ManagementSubpage";
import { TerritorySubpage } from "./TerritorySubpage";
@ -11,6 +8,7 @@ import { Context } from "./Context";
import Tabs from "@mui/material/Tabs";
import Tab from "@mui/material/Tab";
/** React Component for all the gang stuff. */
export function GangRoot(): React.ReactElement {
const gang = (function () {
if (Player.gang === null) throw new Error("Gang should not be null");

@ -1,12 +1,10 @@
/**
* React Component for the subpage that manages gang members, the main page.
*/
import React from "react";
import { GangStats } from "./GangStats";
import { GangMemberList } from "./GangMemberList";
import { useGang } from "./Context";
import Typography from "@mui/material/Typography";
/** React Component for the subpage that manages gang members, the main page. */
export function ManagementSubpage(): React.ReactElement {
const gang = useGang();
return (

@ -1,6 +1,3 @@
/**
* React Component for the recruitment button and text on the gang main page.
*/
import React, { useState } from "react";
import { RecruitModal } from "./RecruitModal";
import { GangConstants } from "../data/Constants";
@ -14,6 +11,7 @@ interface IProps {
onRecruit: () => void;
}
/** React Component for the recruitment button and text on the gang main page. */
export function RecruitButton(props: IProps): React.ReactElement {
const gang = useGang();
const [open, setOpen] = useState(false);

@ -1,6 +1,3 @@
/**
* React Component for the popup used to recruit new gang members.
*/
import React, { useState } from "react";
import { Modal } from "../../ui/React/Modal";
import { dialogBoxCreate } from "../../ui/React/DialogBox";
@ -16,6 +13,7 @@ interface IRecruitPopupProps {
onRecruit: () => void;
}
/** React Component for the popup used to recruit new gang members. */
export function RecruitModal(props: IRecruitPopupProps): React.ReactElement {
const gang = useGang();
const [name, setName] = useState("");

@ -1,6 +1,3 @@
/**
* React Component for the territory subpage.
*/
import React, { useState } from "react";
import { Container, Button, Paper, Box, Tooltip, Switch, FormControlLabel, Typography } from "@mui/material";
@ -14,6 +11,7 @@ import { AllGangs } from "../AllGangs";
import { useGang } from "./Context";
import { TerritoryInfoModal } from "./TerritoryInfoModal";
/** React Component for the territory subpage. */
export function TerritorySubpage(): React.ReactElement {
const gang = useGang();
const gangNames = Object.keys(AllGangs).filter((g) => g != gang.facName);

@ -3,9 +3,7 @@ import { Person } from "./PersonObjects/Person";
import { calculateIntelligenceBonus } from "./PersonObjects/formulas/intelligence";
import { Server } from "./Server/Server";
/**
* Returns the chance the person has to successfully hack a server
*/
/** Returns the chance the person has to successfully hack a server */
export function calculateHackingChance(server: Server, person: Person): number {
const hackFactor = 1.75;
const difficultyMult = (100 - server.hackDifficulty) / 100;
@ -64,9 +62,7 @@ export function calculatePercentMoneyHacked(server: Server, person: Person): num
return percentMoneyHacked;
}
/**
* Returns time it takes to complete a hack on a server, in seconds
*/
/** Returns time it takes to complete a hack on a server, in seconds */
export function calculateHackingTime(server: Server, person: Person): number {
const difficultyMult = server.requiredHackingSkill * server.hackDifficulty;
@ -85,18 +81,14 @@ export function calculateHackingTime(server: Server, person: Person): number {
return hackingTime;
}
/**
* Returns time it takes to complete a grow operation on a server, in seconds
*/
/** Returns time it takes to complete a grow operation on a server, in seconds */
export function calculateGrowTime(server: Server, person: Person): number {
const growTimeMultiplier = 3.2; // Relative to hacking time. 16/5 = 3.2
return growTimeMultiplier * calculateHackingTime(server, person);
}
/**
* Returns time it takes to complete a weaken operation on a server, in seconds
*/
/** Returns time it takes to complete a weaken operation on a server, in seconds */
export function calculateWeakenTime(server: Server, person: Person): number {
const weakenTimeMultiplier = 4; // Relative to hacking time

@ -120,16 +120,12 @@ export class HacknetNode implements IHacknetNode {
}
}
/**
* Serialize the current object to a JSON save state.
*/
/** Serialize the current object to a JSON save state. */
toJSON(): IReviverValue {
return Generic_toJSON("HacknetNode", this);
}
/**
* Initiatizes a HacknetNode object from a JSON save state.
*/
/** Initiatizes a HacknetNode object from a JSON save state. */
static fromJSON(value: IReviverValue): HacknetNode {
return Generic_fromJSON(HacknetNode, value.data);
}

@ -1,6 +1,3 @@
/**
* Hacknet Servers - Reworked Hacknet Node mechanic for BitNode-9
*/
import { CONSTANTS } from "../Constants";
import { IHacknetNode } from "./IHacknetNode";
@ -30,6 +27,7 @@ interface IConstructorParams {
organizationName?: string;
}
/** Hacknet Servers - Reworked Hacknet Node mechanic for BitNode-9 */
export class HacknetServer extends BaseServer implements IHacknetNode {
// Cache level. Affects hash Capacity
cache = 1;

@ -28,9 +28,7 @@ export class HashManager {
}
}
/**
* Generic helper function for getting a multiplier from a HashUpgrade
*/
/** Generic helper function for getting a multiplier from a HashUpgrade */
getMult(upgName: string): number {
const upg = HashUpgrades[upgName];
const currLevel = this.upgrades[upgName];
@ -42,18 +40,14 @@ export class HashManager {
return 1 + (upg.value * currLevel) / 100;
}
/**
* One of the Hash upgrades improves studying. This returns that multiplier
*/
/** One of the Hash upgrades improves studying. This returns that multiplier */
getStudyMult(): number {
const upgName = "Improve Studying";
return this.getMult(upgName);
}
/**
* One of the Hash upgrades improves gym training. This returns that multiplier
*/
/** One of the Hash upgrades improves gym training. This returns that multiplier */
getTrainingMult(): number {
const upgName = "Improve Gym Training";
@ -69,9 +63,7 @@ export class HashManager {
return upg;
}
/**
* Get the cost (in hashes) of an upgrade
*/
/** Get the cost (in hashes) of an upgrade */
getUpgradeCost(upgName: string, count = 1): number {
const upg = this.getUpgrade(upgName);
const currLevel = this.upgrades[upgName];
@ -93,9 +85,7 @@ export class HashManager {
this.updateCapacity(0);
}
/**
* Reverts an upgrade and refunds the hashes used to buy it
*/
/** Reverts an upgrade and refunds the hashes used to buy it */
refundUpgrade(upgName: string, count = 1): void {
const upg = HashUpgrades[upgName];

@ -1,6 +1,4 @@
/**
* Object representing an upgrade that can be purchased with hashes
*/
/** Object representing an upgrade that can be purchased with hashes */
export interface IConstructorParams {
cost?: number;
costPerLevel: number;
@ -26,9 +24,7 @@ export class HashUpgrade {
*/
costPerLevel = 0;
/**
* Description of what the upgrade does
*/
/** Description of what the upgrade does */
desc = "";
/**
@ -37,7 +33,7 @@ export class HashUpgrade {
*/
hasTargetServer = false;
// Name of upgrade
/** Name of upgrade */
name = "";
// Generic value used to indicate the potency/amount of this upgrade's effect

@ -1,6 +1,3 @@
/**
* Root React Component for the Hacknet Node UI
*/
import React, { useState, useEffect } from "react";
import { GeneralInfo } from "./GeneralInfo";
@ -29,6 +26,7 @@ import Grid from "@mui/material/Grid";
import Button from "@mui/material/Button";
import { Box } from "@mui/material";
/** Root React Component for the Hacknet Node UI */
export function HacknetRoot(): React.ReactElement {
const [open, setOpen] = useState(false);
const setRerender = useState(false)[1];

@ -1,6 +1,3 @@
/**
* Create the pop-up for purchasing upgrades with hashes
*/
import React, { useState, useEffect } from "react";
import { HashUpgrades } from "../HashUpgrades";
@ -16,6 +13,7 @@ interface IProps {
onClose: () => void;
}
/** Create the pop-up for purchasing upgrades with hashes */
export function HashUpgradeModal(props: IProps): React.ReactElement {
const setRerender = useState(false)[1];
function rerender(): void {

@ -1,6 +1,3 @@
/**
* React Component for the button that is used to purchase new Hacknet Nodes
*/
import React from "react";
import { hasHacknetServers, hasMaxNumberHacknetServers } from "../HacknetHelpers";
@ -15,6 +12,7 @@ interface IProps {
cost: number;
}
/** React Component for the button that is used to purchase new Hacknet Nodes */
export function PurchaseButton(props: IProps): React.ReactElement {
const cost = props.cost;
let text;

@ -1,23 +1,15 @@
/**
* Class representing a City in the game
*/
import { CityName } from "./data/CityNames";
import { LocationName } from "./data/LocationNames";
/** Class representing a City in the game */
export class City {
/**
* List of all locations in this city
*/
/** List of all locations in this city */
locations: LocationName[];
/**
* Name of this city
*/
/** Name of this city */
name: CityName;
/**
* Metro map ascii art
*/
/** Metro map ascii art */
asciiArt: string;
constructor(name: CityName, locations: LocationName[] = [], asciiArt = "") {

@ -1,6 +1,3 @@
/**
* Class representing a visitable location in the world
*/
import { CityName } from "./data/CityNames";
import { LocationName } from "./data/LocationNames";
import { LocationType } from "./LocationTypeEnum";
@ -21,6 +18,7 @@ export interface IConstructorParams {
techVendorMinRam?: number;
}
/** Class representing a visitable location in the world */
export class Location {
/**
* Name of city this location is in. If this property is null, it means this i
@ -28,14 +26,10 @@ export class Location {
*/
city: CityName | null = null;
/**
* Cost multiplier that influences how expensive a gym/university is
*/
/** Cost multiplier that influences how expensive a gym/university is */
costMult = 0;
/**
* Exp multiplier that influences how effective a gym/university is
*/
/** Exp multiplier that influences how effective a gym/university is */
expMult = 0;
/**
@ -44,9 +38,7 @@ export class Location {
*/
infiltrationData?: IInfiltrationMetadata;
/**
* Identifier for location
*/
/** Identifier for location */
name: LocationName = LocationName.Void;
/**

@ -1,6 +1,4 @@
/**
* Enum defining the different types of possible locations
*/
/** Enum defining the different types of possible locations */
export enum LocationType {
Company,
Gym,

@ -1,6 +1,4 @@
/**
* Names of all locations
*/
/** Names of all locations */
export enum LocationName {
// Aevum Locations
AevumAeroCorp = "AeroCorp",

@ -1,6 +1,3 @@
/**
* React Component for a button that's used to apply for a job
*/
import * as React from "react";
import { Company } from "../../Company/Company";
@ -18,6 +15,7 @@ type IProps = {
text: string;
};
/** React Component for a button that's used to apply for a job */
export function ApplyToJobButton(props: IProps): React.ReactElement {
function getJobRequirementTooltip(): string {
const pos = Player.getNextCompanyPosition(props.company, props.entryPosType);

@ -47,17 +47,13 @@ export function CompanyLocation(props: IProps): React.ReactElement {
const company = Companies[props.locName];
if (company == null) throw new Error(`CompanyLocation component constructed with invalid company: ${props.locName}`);
/**
* Reference to the Location that this component is being rendered for
*/
/** Reference to the Location that this component is being rendered for */
const location = Locations[props.locName];
if (location == null) {
throw new Error(`CompanyLocation component constructed with invalid location: ${props.locName}`);
}
/**
* Name of company position that player holds, if applicable
*/
/** Name of company position that player holds, if applicable */
const jobTitle = Player.jobs[props.locName] ? Player.jobs[props.locName] : null;
/**

@ -19,9 +19,7 @@ type IState = {
//Todo: Make this a functional component
export class HospitalLocation extends React.Component<Record<string, never>, IState> {
/**
* Stores button styling that sets them all to block display
*/
/** Stores button styling that sets them all to block display */
btnStyle = { display: "block" };
constructor() {

@ -1,6 +1,3 @@
/**
* React Component for the popup used to purchase a new server.
*/
import React, { useState } from "react";
import { purchaseServer } from "../../Server/ServerPurchases";
import { numeralWrapper } from "../../ui/numeralFormat";
@ -20,6 +17,7 @@ interface IProps {
rerender: () => void;
}
/** React Component for the popup used to purchase a new server. */
export function PurchaseServerModal(props: IProps): React.ReactElement {
const [hostname, setHostname] = useState("");

@ -25,7 +25,7 @@ import { Router } from "../../ui/GameRoot";
import { Player } from "../../Player";
import { dialogBoxCreate } from "../../ui/React/DialogBox";
import { SnackbarEvents } from "../../ui/React/Snackbar";
import { SnackbarEvents, ToastVariant } from "../../ui/React/Snackbar";
import { N00dles } from "../../utils/helpers/N00dles";
import { Exploit } from "../../Exploits/Exploit";
import { applyAugmentation } from "../../Augmentation/AugmentationHelpers";
@ -45,9 +45,7 @@ export function SpecialLocation(props: IProps): React.ReactElement {
const setRerender = useState(false)[1];
const inBladeburner = Player.inBladeburner();
/**
* Click handler for Bladeburner button at Sector-12 NSA
*/
/** Click handler for Bladeburner button at Sector-12 NSA */
function handleBladeburner(): void {
if (Player.inBladeburner()) {
// Enter Bladeburner division
@ -73,9 +71,7 @@ export function SpecialLocation(props: IProps): React.ReactElement {
}
}
/**
* Click handler for Resleeving button at New Tokyo VitaLife
*/
/** Click handler for Resleeving button at New Tokyo VitaLife */
function handleGrafting(): void {
Router.toGrafting();
}
@ -95,7 +91,7 @@ export function SpecialLocation(props: IProps): React.ReactElement {
function renderNoodleBar(): React.ReactElement {
function EatNoodles(): void {
SnackbarEvents.emit("You ate some delicious noodles and feel refreshed", "success", 2000);
SnackbarEvents.emit("You ate some delicious noodles and feel refreshed", ToastVariant.SUCCESS, 2000);
N00dles(); // This is the true power of the noodles.
if (Player.sourceFiles.length > 0) Player.giveExploit(Exploit.N00dles);
if (Player.sourceFileLvl(5) > 0 || Player.bitNodeN === 5) {

@ -10,9 +10,7 @@ import { Player } from "../../Player";
import { Money } from "../../ui/React/Money";
/**
* Attempt to purchase a TOR router using the button.
*/
/** Attempt to purchase a TOR router using the button. */
export function purchaseTorRouter(): void {
if (Player.hasTorRouter()) {
dialogBoxCreate(`You already have a TOR Router!`);

@ -5,19 +5,13 @@ import { NS } from "../ScriptEditor/NetscriptDefinitions";
* Netscript functions and arguments for that script.
*/
export class Environment {
/**
* Whether or not the script that uses this Environment should stop running
*/
/** Whether or not the script that uses this Environment should stop running */
stopFlag = false;
/**
* The currently running function
*/
/** The currently running function */
runningFn = "";
/**
* Environment variables (currently only Netscript functions)
*/
/** Environment variables (currently only Netscript functions) */
vars: NS | null = null;
}

@ -2,9 +2,7 @@ import { workerScripts } from "./WorkerScripts";
let pidCounter = 1;
/**
* Find and return the next availble PID for a script
*/
/** Find and return the next availble PID for a script */
export function generateNextPid(): number {
let tempCounter = pidCounter;

@ -18,14 +18,10 @@ import { ScriptDeath } from "./ScriptDeath";
import { ScriptArg } from "./ScriptArg";
export class WorkerScript {
/**
* Script's arguments
*/
/** Script's arguments */
args: ScriptArg[];
/**
* Copy of the script's code
*/
/** Copy of the script's code */
code = "";
/**
@ -34,14 +30,10 @@ export class WorkerScript {
*/
delay: number | null = null;
/**
* Holds the Promise reject() function while the script is "blocked" by an async op
*/
/** Holds the Promise reject() function while the script is "blocked" by an async op */
delayReject?: (reason?: ScriptDeath) => void;
/**
* Stores names of all functions that have logging disabled
*/
/** Stores names of all functions that have logging disabled */
disableLogs: Record<string, boolean> = {};
/**
@ -51,19 +43,13 @@ export class WorkerScript {
*/
dynamicLoadedFns: Record<string, boolean> = {};
/**
* Tracks dynamic RAM usage
*/
/** Tracks dynamic RAM usage */
dynamicRamUsage: number = RamCostConstants.ScriptBaseRamCost;
/**
* Netscript Environment for this script
*/
/** Netscript Environment for this script */
env: Environment;
/**
* Status message in case of script error.
*/
/** Status message in case of script error. */
errorMessage = "";
/**
@ -72,14 +58,10 @@ export class WorkerScript {
*/
loadedFns: Record<string, boolean> = {};
/**
* Filename of script
*/
/** Filename of script */
name: string;
/**
* Script's output/return value. Currently not used or implemented
*/
/** Script's output/return value. Currently not used or implemented */
output = "";
/**
@ -88,24 +70,16 @@ export class WorkerScript {
*/
pid: number;
/**
* Script's Static RAM usage. Equivalent to underlying script's RAM usage
*/
/** Script's Static RAM usage. Equivalent to underlying script's RAM usage */
ramUsage = 0;
/**
* Reference to underlying RunningScript object
*/
/** Reference to underlying RunningScript object */
scriptRef: RunningScript;
/**
* hostname on which this script is running
*/
/** hostname on which this script is running */
hostname: string;
/**
* Function called when the script ends.
*/
/** Function called when the script ends. */
atExit?: () => void;
constructor(runningScriptObj: RunningScript, pid: number, nsFuncsGenerator?: (ws: WorkerScript) => NS) {
@ -142,9 +116,7 @@ export class WorkerScript {
}
}
/**
* Returns the Server on which this script is running
*/
/** Returns the Server on which this script is running */
getServer(): BaseServer {
const server = GetServer(this.hostname);
if (server == null) throw new Error(`Script ${this.name} pid ${this.pid} is running on non-existent server?`);

@ -1,6 +1,4 @@
/**
* Event emitter that triggers when scripts are started/stopped
*/
import { EventEmitter } from "../utils/EventEmitter";
/** Event emitter that triggers when scripts are started/stopped */
export const WorkerScriptStartStopEventEmitter = new EventEmitter<[]>();

@ -1,6 +1,4 @@
/**
* Global pool of all active scripts (scripts that are currently running)
*/
import { WorkerScript } from "./WorkerScript";
/** Global pool of all active scripts (scripts that are currently running) */
export const workerScripts: Map<number, WorkerScript> = new Map();

@ -80,17 +80,11 @@ import { recentScripts } from "./Netscript/RecentScripts";
import { InternalAPI, NetscriptContext, wrapAPI } from "./Netscript/APIWrapper";
import { INetscriptExtra } from "./NetscriptFunctions/Extra";
import { ScriptDeath } from "./Netscript/ScriptDeath";
import { TypeEquality, ValuesFrom } from "./types";
// "Enums" as object
export const enums = {
toast: {
SUCCESS: "success",
WARNING: "warning",
ERROR: "error",
INFO: "info",
} as const,
};
toast: ToastVariant,
} as const;
export type NSFull = NS & INetscriptExtra;
export function NetscriptFunctions(workerScript: WorkerScript): NSFull {
@ -1796,7 +1790,7 @@ const base: InternalAPI<NS> = {
const duration = _duration === null ? null : helpers.number(ctx, "duration", _duration);
if (!checkObjContainsValue(enums.toast, variant))
throw new Error(`variant must be one of ${Object.values(enums.toast).join(", ")}`);
SnackbarEvents.emit(message, variant, duration);
SnackbarEvents.emit(message, variant as ToastVariant, duration);
},
prompt:
(ctx: NetscriptContext) =>

@ -17,9 +17,7 @@ import { InternalAPI, NetscriptContext } from "../Netscript/APIWrapper";
import { helpers } from "../Netscript/NetscriptHelpers";
export function NetscriptStockMarket(): InternalAPI<TIX> {
/**
* Checks if the player has TIX API access. Throws an error if the player does not
*/
/** Checks if the player has TIX API access. Throws an error if the player does not */
const checkTixApiAccess = function (ctx: NetscriptContext): void {
if (!player.hasWseAccount) {
throw helpers.makeRuntimeErrorMsg(ctx, `You don't have WSE Access! Cannot use ${ctx.function}()`);

@ -354,9 +354,7 @@ function createAndAddWorkerScript(runningScriptObj: RunningScript, server: BaseS
return true;
}
/**
* Updates the online running time stat of all running scripts
*/
/** Updates the online running time stat of all running scripts */
export function updateOnlineScriptTimes(numCycles = 1): void {
const time = (numCycles * CONSTANTS._idleSpeed) / 1000; //seconds
for (const ws of workerScripts.values()) {
@ -404,9 +402,7 @@ export function loadAllRunningScripts(): void {
}
}
/**
* Run a script from inside another script (run(), exec(), spawn(), etc.)
*/
/** Run a script from inside another script (run(), exec(), spawn(), etc.) */
export function runScriptFromScript(
caller: string,
server: BaseServer,

@ -159,16 +159,12 @@ export class PlayerObject extends Person {
return "Player";
}
/**
* Serialize the current object to a JSON save state.
*/
/** Serialize the current object to a JSON save state. */
toJSON(): IReviverValue {
return Generic_toJSON("PlayerObject", this);
}
/**
* Initiatizes a PlayerObject object from a JSON save state.
*/
/** Initiatizes a PlayerObject object from a JSON save state. */
static fromJSON(value: IReviverValue): PlayerObject {
return Generic_fromJSON(PlayerObject, value.data);
}

@ -1,6 +1,4 @@
/**
* Augmentation-related methods for the Player class (PlayerObject)
*/
/** Augmentation-related methods for the Player class (PlayerObject) */
import { PlayerObject } from "./PlayerObject";
import { calculateEntropy } from "../Grafting/EntropyAccumulation";

@ -39,7 +39,7 @@ import { numeralWrapper } from "../../ui/numeralFormat";
import { MoneySourceTracker } from "../../utils/MoneySourceTracker";
import { dialogBoxCreate } from "../../ui/React/DialogBox";
import { SnackbarEvents } from "../../ui/React/Snackbar";
import { SnackbarEvents, ToastVariant } from "../../ui/React/Snackbar";
import { achievements } from "../../Achievements/Achievements";
import { FactionNames } from "../../Faction/data/FactionNames";
@ -257,7 +257,7 @@ export function takeDamage(this: PlayerObject, amt: number): boolean {
export function hospitalize(this: PlayerObject): number {
const cost = getHospitalizationCost();
SnackbarEvents.emit(`You've been Hospitalized for ${numeralWrapper.formatMoney(cost)}`, "warning", 2000);
SnackbarEvents.emit(`You've been Hospitalized for ${numeralWrapper.formatMoney(cost)}`, ToastVariant.SUCCESS, 2000);
this.loseMoney(cost, "hospitalization");
this.hp.current = this.hp.max;
@ -1193,7 +1193,7 @@ export function canAccessGrafting(this: PlayerObject): boolean {
export function giveExploit(this: PlayerObject, exploit: Exploit): void {
if (!this.exploits.includes(exploit)) {
this.exploits.push(exploit);
SnackbarEvents.emit("SF -1 acquired!", "success", 2000);
SnackbarEvents.emit("SF -1 acquired!", ToastVariant.SUCCESS, 2000);
}
}
@ -1202,7 +1202,7 @@ export function giveAchievement(this: PlayerObject, achievementId: string): void
if (!achievement) return;
if (!this.achievements.map((a) => a.ID).includes(achievementId)) {
this.achievements.push({ ID: achievementId, unlockedOn: new Date().getTime() });
SnackbarEvents.emit(`Unlocked Achievement: "${achievement.Name}"`, "success", 2000);
SnackbarEvents.emit(`Unlocked Achievement: "${achievement.Name}"`, ToastVariant.SUCCESS, 2000);
}
}

@ -1,6 +1,4 @@
/**
* Server and HacknetServer-related methods for the Player class (PlayerObject)
*/
// Server and HacknetServer-related methods for the Player class (PlayerObject)
import { PlayerObject } from "./PlayerObject";
import { CONSTANTS } from "../../Constants";

@ -48,9 +48,7 @@ import * as sleeveMethods from "./SleeveMethods";
export class Sleeve extends Person {
currentWork: Work | null = null;
/**
* Clone retains 'memory' synchronization (and maybe exp?) upon prestige/installing Augs
*/
/** Clone retains 'memory' synchronization (and maybe exp?) upon prestige/installing Augs */
memory = 1;
/**
@ -62,9 +60,7 @@ export class Sleeve extends Person {
*/
shock = 1;
/**
* Stored number of game "loop" cycles
*/
/** Stored number of game "loop" cycles */
storedCycles = 0;
/**
@ -100,9 +96,7 @@ export class Sleeve extends Person {
this.currentWork = null;
}
/**
* Commit crimes
*/
/** Commit crimes */
commitCrime(crimeKey: string): boolean {
const crime: Crime | null = Crimes[crimeKey] || Object.values(Crimes).find((crime) => crime.name === crimeKey);
if (!crime) {
@ -113,9 +107,7 @@ export class Sleeve extends Person {
return true;
}
/**
* Returns the cost of upgrading this sleeve's memory by a certain amount
*/
/** Returns the cost of upgrading this sleeve's memory by a certain amount */
getMemoryUpgradeCost(n: number): number {
const amt = Math.round(n);
if (amt < 0) {
@ -150,9 +142,7 @@ export class Sleeve extends Person {
this.updateSkillLevels();
}
/**
* Called on every sleeve for a Source File Prestige
*/
/** Called on every sleeve for a Source File Prestige */
prestige(): void {
// Reset exp
this.exp.hacking = 0;
@ -211,9 +201,7 @@ export class Sleeve extends Person {
return true;
}
/**
* Take a course at a university
*/
/** Take a course at a university */
takeUniversityCourse(universityName: string, className: string): boolean {
// Set exp/money multipliers based on which university.
// Also check that the sleeve is in the right city
@ -270,9 +258,7 @@ export class Sleeve extends Person {
return true;
}
/**
* Travel to another City. Costs money from player
*/
/** Travel to another City. Costs money from player */
travel(newCity: CityName): boolean {
Player.loseMoney(CONSTANTS.TravelCost, "sleeves");
this.city = newCity;
@ -354,9 +340,7 @@ export class Sleeve extends Person {
return true;
}
/**
* Begin a gym workout task
*/
/** Begin a gym workout task */
workoutAtGym(gymName: string, stat: string): boolean {
// Set exp/money multipliers based on which university.
// Also check that the sleeve is in the right city
@ -420,9 +404,7 @@ export class Sleeve extends Person {
return true;
}
/**
* Begin a bladeburner task
*/
/** Begin a bladeburner task */
bladeburner(action: string, contract: string): boolean {
if (!Player.bladeburner) return false;
switch (action) {
@ -495,16 +477,12 @@ export class Sleeve extends Person {
return "Sleeve";
}
/**
* Serialize the current object to a JSON save state.
*/
/** Serialize the current object to a JSON save state. */
toJSON(): IReviverValue {
return Generic_toJSON("Sleeve", this);
}
/**
* Initiatizes a Sleeve object from a JSON save state.
*/
/** Initiatizes a Sleeve object from a JSON save state. */
static fromJSON(value: IReviverValue): Sleeve {
return Generic_fromJSON(Sleeve, value.data);
}

@ -10,9 +10,7 @@ import { mergeMultipliers, Multipliers } from "../Multipliers";
import { AugmentationNames } from "../../Augmentation/data/AugmentationNames";
import { getFactionAugmentationsFiltered } from "../../Faction/FactionHelpers";
/**
* Updates this object's multipliers for the given augmentation
*/
/** Updates this object's multipliers for the given augmentation */
export function applyAugmentation(this: Sleeve, aug: Augmentation): void {
this.mults = mergeMultipliers(this.mults, aug.mults);
}

@ -1,6 +1,4 @@
/**
* Enum for different types of tasks that a Sleeve can perform
*/
/** Enum for different types of tasks that a Sleeve can perform */
export enum SleeveTaskType {
// Same Order as selectable order in UI
Idle,

@ -75,16 +75,12 @@ export class SleeveBladeburnerWork extends Work {
};
}
/**
* Serialize the current object to a JSON save state.
*/
/** Serialize the current object to a JSON save state. */
toJSON(): IReviverValue {
return Generic_toJSON("SleeveBladeburnerWork", this);
}
/**
* Initiatizes a BladeburnerWork object from a JSON save state.
*/
/** Initiatizes a BladeburnerWork object from a JSON save state. */
static fromJSON(value: IReviverValue): SleeveBladeburnerWork {
return Generic_fromJSON(SleeveBladeburnerWork, value.data);
}

@ -45,16 +45,12 @@ export class SleeveClassWork extends Work {
location: this.location,
};
}
/**
* Serialize the current object to a JSON save state.
*/
/** Serialize the current object to a JSON save state. */
toJSON(): IReviverValue {
return Generic_toJSON("SleeveClassWork", this);
}
/**
* Initiatizes a ClassWork object from a JSON save state.
*/
/** Initiatizes a ClassWork object from a JSON save state. */
static fromJSON(value: IReviverValue): SleeveClassWork {
return Generic_fromJSON(SleeveClassWork, value.data);
}

@ -49,16 +49,12 @@ export class SleeveCompanyWork extends Work {
};
}
/**
* Serialize the current object to a JSON save state.
*/
/** Serialize the current object to a JSON save state. */
toJSON(): IReviverValue {
return Generic_toJSON("SleeveCompanyWork", this);
}
/**
* Initiatizes a CompanyWork object from a JSON save state.
*/
/** Initiatizes a CompanyWork object from a JSON save state. */
static fromJSON(value: IReviverValue): SleeveCompanyWork {
return Generic_fromJSON(SleeveCompanyWork, value.data);
}

@ -68,16 +68,12 @@ export class SleeveCrimeWork extends Work {
};
}
/**
* Serialize the current object to a JSON save state.
*/
/** Serialize the current object to a JSON save state. */
toJSON(): IReviverValue {
return Generic_toJSON("SleeveCrimeWork", this);
}
/**
* Initiatizes a RecoveryWork object from a JSON save state.
*/
/** Initiatizes a RecoveryWork object from a JSON save state. */
static fromJSON(value: IReviverValue): SleeveCrimeWork {
return Generic_fromJSON(SleeveCrimeWork, value.data);
}

@ -78,16 +78,12 @@ export class SleeveFactionWork extends Work {
};
}
/**
* Serialize the current object to a JSON save state.
*/
/** Serialize the current object to a JSON save state. */
toJSON(): IReviverValue {
return Generic_toJSON("SleeveFactionWork", this);
}
/**
* Initiatizes a FactionWork object from a JSON save state.
*/
/** Initiatizes a FactionWork object from a JSON save state. */
static fromJSON(value: IReviverValue): SleeveFactionWork {
return Generic_fromJSON(SleeveFactionWork, value.data);
}

@ -36,16 +36,12 @@ export class SleeveInfiltrateWork extends Work {
};
}
/**
* Serialize the current object to a JSON save state.
*/
/** Serialize the current object to a JSON save state. */
toJSON(): IReviverValue {
return Generic_toJSON("SleeveInfiltrateWork", this);
}
/**
* Initiatizes a BladeburnerWork object from a JSON save state.
*/
/** Initiatizes a BladeburnerWork object from a JSON save state. */
static fromJSON(value: IReviverValue): SleeveInfiltrateWork {
return Generic_fromJSON(SleeveInfiltrateWork, value.data);
}

@ -22,16 +22,12 @@ export class SleeveRecoveryWork extends Work {
};
}
/**
* Serialize the current object to a JSON save state.
*/
/** Serialize the current object to a JSON save state. */
toJSON(): IReviverValue {
return Generic_toJSON("SleeveRecoveryWork", this);
}
/**
* Initiatizes a RecoveryWork object from a JSON save state.
*/
/** Initiatizes a RecoveryWork object from a JSON save state. */
static fromJSON(value: IReviverValue): SleeveRecoveryWork {
return Generic_fromJSON(SleeveRecoveryWork, value.data);
}

@ -25,16 +25,12 @@ export class SleeveSupportWork extends Work {
};
}
/**
* Serialize the current object to a JSON save state.
*/
/** Serialize the current object to a JSON save state. */
toJSON(): IReviverValue {
return Generic_toJSON("SleeveSupportWork", this);
}
/**
* Initiatizes a BladeburnerWork object from a JSON save state.
*/
/** Initiatizes a BladeburnerWork object from a JSON save state. */
static fromJSON(value: IReviverValue): SleeveSupportWork {
return Generic_fromJSON(SleeveSupportWork, value.data);
}

@ -23,16 +23,12 @@ export class SleeveSynchroWork extends Work {
};
}
/**
* Serialize the current object to a JSON save state.
*/
/** Serialize the current object to a JSON save state. */
toJSON(): IReviverValue {
return Generic_toJSON("SleeveSynchroWork", this);
}
/**
* Initiatizes a SynchroWork object from a JSON save state.
*/
/** Initiatizes a SynchroWork object from a JSON save state. */
static fromJSON(value: IReviverValue): SleeveSynchroWork {
return Generic_fromJSON(SleeveSynchroWork, value.data);
}

@ -26,16 +26,12 @@ interface IProps {
export function CovenantPurchasesRoot(props: IProps): React.ReactElement {
const [update, setUpdate] = useState(0);
/**
* Get the cost to purchase a new Duplicate Sleeve
*/
/** Get the cost to purchase a new Duplicate Sleeve */
function purchaseCost(): number {
return Math.pow(10, Player.sleevesFromCovenant) * BaseCostPerSleeve;
}
/**
* Force a rerender by just changing an arbitrary state value
*/
/** Force a rerender by just changing an arbitrary state value */
function rerender(): void {
setUpdate(update + 1);
}

@ -1,6 +1,4 @@
/**
* Implementation for what happens when you destroy a BitNode
*/
/** Implementation for what happens when you destroy a BitNode */
import React from "react";
import { Player } from "./Player";
import { prestigeSourceFile } from "./Prestige";
@ -19,17 +17,9 @@ function giveSourceFile(bitNodeNumber: number): void {
}
// Check if player already has this source file
let alreadyOwned = false;
let ownedSourceFile = null;
for (let i = 0; i < Player.sourceFiles.length; ++i) {
if (Player.sourceFiles[i].n === bitNodeNumber) {
alreadyOwned = true;
ownedSourceFile = Player.sourceFiles[i];
break;
}
}
const ownedSourceFile = Player.sourceFiles.find(sourceFile=>sourceFile.n === bitNodeNumber)
if (alreadyOwned && ownedSourceFile) {
if (ownedSourceFile) {
if (ownedSourceFile.lvl >= 3 && ownedSourceFile.n !== 12) {
dialogBoxCreate(
`The Source-File for the BitNode you just destroyed, ${sourceFile.name}, is already at max level!`,
@ -45,10 +35,9 @@ function giveSourceFile(bitNodeNumber: number): void {
);
}
} else {
const playerSrcFile = new PlayerOwnedSourceFile(bitNodeNumber, 1);
Player.sourceFiles.push(playerSrcFile);
const newSrcFile = new PlayerOwnedSourceFile(bitNodeNumber, 1);
Player.sourceFiles.push(newSrcFile);
if (bitNodeNumber === 5 && Player.skills.intelligence === 0) {
// Artificial Intelligence
Player.skills.intelligence = 1;
}
dialogBoxCreate(

@ -1,6 +1,6 @@
import { RFAMessage } from "./MessageDefinitions";
import { RFARequestHandler } from "./MessageHandlers";
import { SnackbarEvents } from "../ui/React/Snackbar";
import { SnackbarEvents, ToastVariant } from "../ui/React/Snackbar";
export class Remote {
connection?: WebSocket;
@ -22,18 +22,18 @@ export class Remote {
this.connection = new WebSocket(address);
this.connection.addEventListener("error", (e: Event) =>
SnackbarEvents.emit(`Error with websocket ${address}, details: ${JSON.stringify(e)}`, "error", 5000),
SnackbarEvents.emit(`Error with websocket ${address}, details: ${JSON.stringify(e)}`, ToastVariant.ERROR, 5000),
);
this.connection.addEventListener("message", handleMessageEvent);
this.connection.addEventListener("open", () =>
SnackbarEvents.emit(
`Remote API connection established on ${this.ipaddr}:${this.port}`,
"success",
ToastVariant.SUCCESS,
2000,
),
);
this.connection.addEventListener("close", () =>
SnackbarEvents.emit("Remote API connection closed", "warning", 2000),
SnackbarEvents.emit("Remote API connection closed", ToastVariant.WARNING, 2000),
);
}
}

@ -16,7 +16,7 @@ import { Settings } from "./Settings/Settings";
import { loadStockMarket, StockMarket } from "./StockMarket/StockMarket";
import { staneksGift, loadStaneksGift } from "./CotMG/Helper";
import { SnackbarEvents } from "./ui/React/Snackbar";
import { SnackbarEvents, ToastVariant } from "./ui/React/Snackbar";
import * as ExportBonus from "./ExportBonus";
@ -120,7 +120,7 @@ class BitburnerSaveObject {
pushGameSaved(saveData);
if (emitToastEvent) {
SnackbarEvents.emit("Game Saved!", "info", 2000);
SnackbarEvents.emit("Game Saved!", ToastVariant.INFO, 2000);
}
return resolve();
})

@ -61,9 +61,7 @@ export class Script {
}
}
/**
* Download the script as a file
*/
/** Download the script as a file */
download(): void {
const filename = this.filename;
const file = new Blob([this.code], { type: "text/plain" });

@ -1,14 +1,12 @@
/**
* @public
*/
export type ValuesFrom<T> = T[keyof T];
/** @public */
export interface HP {
current: number;
max: number;
}
/**
* @public
*/
/** @public */
export interface Skills {
hacking: number;
strength: number;
@ -19,9 +17,7 @@ export interface Skills {
intelligence: number;
}
/**
* @public
*/
/** @public */
export interface PossibleInfiltrationLocation {
city: string;
name: string;
@ -33,24 +29,16 @@ export interface PossibleInfiltrationLocation {
*/
type CodingContractData = any;
/**
* @public
*/
/** @public */
type PortData = string | number;
/**
* @public
*/
/** @public */
type ScriptArg = string | number | boolean;
/**
* @public
*/
/** @public */
type FilenameOrPID = number | string;
/**
* @public
*/
/** @public */
interface Player {
hp: HP;
skills: Skills;
@ -72,9 +60,7 @@ interface Player {
entropy: number;
}
/**
* @public
*/
/** @public */
export interface Multipliers {
/** Multiplier to hacking skill */
hacking?: number;
@ -138,9 +124,7 @@ export interface Multipliers {
bladeburner_success_chance?: number;
}
/**
* @public
*/
/** @public */
export interface RunningScript {
/** Arguments the script was called with */
args: (string | number | boolean)[];
@ -173,9 +157,7 @@ export interface RunningScript {
threads: number;
}
/**
* @public
*/
/** @public */
export interface RecentScript extends RunningScript {
/** Timestamp of when the script was killed */
timeOfDeath: Date;
@ -259,17 +241,13 @@ export interface AugmentPair {
cost: number;
}
/**
* @public
*/
/** @public */
export enum PositionTypes {
Long = "L",
Short = "S",
}
/**
* @public
*/
/** @public */
export enum OrderTypes {
LimitBuy = "Limit Buy Order",
LimitSell = "Limit Sell Order",
@ -633,9 +611,7 @@ export interface NodeStats {
totalProduction: number;
}
/**
* @public
*/
/** @public */
export interface CharacterMult {
/** Agility stat */
agility: number;
@ -673,9 +649,7 @@ export interface CharacterMult {
workMoney: number;
}
/**
* @public
*/
/** @public */
export interface SleeveWorkGains {
/** Hacking exp gained from work */
workHackExpGain: number;
@ -693,9 +667,7 @@ export interface SleeveWorkGains {
workMoneyGain: number;
}
/**
* @public
*/
/** @public */
export interface SourceFileLvl {
/** The number of the source file */
n: number;
@ -745,9 +717,7 @@ export interface GangGenInfo {
wantedPenalty: number;
}
/**
* @public
*/
/** @public */
export interface GangOtherInfoObject {
/** Gang power */
power: number;
@ -755,9 +725,7 @@ export interface GangOtherInfoObject {
territory: number;
}
/**
* @public
*/
/** @public */
export interface GangOtherInfo {
[key: string]: GangOtherInfoObject;
}
@ -818,9 +786,7 @@ export interface EquipmentStats {
hack?: number;
}
/**
* @public
*/
/** @public */
export interface GangTerritory {
/** Money gain impact on task scaling */
money: number;
@ -830,9 +796,7 @@ export interface GangTerritory {
wanted: number;
}
/**
* @public
*/
/** @public */
export interface GangMemberInfo {
/** Name of the gang member */
name: string;
@ -913,9 +877,7 @@ export interface GangMemberInfo {
moneyGain: number;
}
/**
* @public
*/
/** @public */
export interface GangMemberAscension {
/** Amount of respect lost from ascending */
respect: number;
@ -3840,9 +3802,7 @@ interface SkillsFormulas {
calculateExp(skill: number, skillMult?: number): number;
}
/**
* @public
*/
/** @public */
export interface WorkStats {
money: number;
reputation: number;
@ -4152,9 +4112,7 @@ export interface Formulas {
work: WorkFormulas;
}
/**
* @public
*/
/** @public */
export interface Fragment {
id: number;
shape: boolean[][];
@ -4163,9 +4121,7 @@ export interface Fragment {
limit: number;
}
/**
* @public
*/
/** @public */
export interface ActiveFragment {
id: number;
highestCharge: number;
@ -4287,26 +4243,20 @@ interface Stanek {
acceptGift(): boolean;
}
/**
* @public
*/
/** @public */
export interface InfiltrationReward {
tradeRep: number;
sellCash: number;
SoARep: number;
}
/**
* @public
*/
/** @public */
export interface ILocation {
city: string;
name: string;
}
/**
* @public
*/
/** @public */
export interface InfiltrationLocation {
location: ILocation;
reward: InfiltrationReward;
@ -6385,7 +6335,7 @@ export interface NS {
* @param variant - Type of toast, must be one of success, info, warning, error. Defaults to success.
* @param duration - Duration of toast in ms. Can also be `null` to create a persistent toast. Defaults to 2000
*/
toast(msg: string, variant?: ToastVariantValues, duration?: number | null): void;
toast(msg: string, variant?: ToastVariant, duration?: number | null): void;
/**
* Download a file from the internet.
@ -6573,7 +6523,7 @@ export interface NS {
enums: NSEnums;
}
export const enums = {
declare const enums = {
toast: {
SUCCESS: "success",
WARNING: "warning",
@ -6581,12 +6531,14 @@ export const enums = {
INFO: "info",
},
} as const;
type ToastVariant = ValuesFrom<typeof enums.toast>;
export type NSEnums = typeof enums;
/**
* Corporation Office API
* @remarks
* Requires the Office API upgrade from your corporation.
* requires the Office API upgrade from your corporation.
* @public
*/
export interface OfficeAPI {

@ -1,6 +1,3 @@
/**
* Abstract Base Class for any Server object
*/
import { CodingContract } from "../CodingContracts";
import { RunningScript } from "../Script/RunningScript";
import { Script } from "../Script/Script";
@ -28,7 +25,8 @@ interface writeResult {
overwritten: boolean;
}
export class BaseServer {
/** Abstract Base Class for any Server object */
export abstract class BaseServer {
// Coding Contract files on this server
contracts: CodingContract[] = [];
@ -150,9 +148,7 @@ export class BaseServer {
return null;
}
/**
* Returns boolean indicating whether the given script is running on this server
*/
/** Returns boolean indicating whether the given script is running on this server */
isRunning(fn: string): boolean {
for (const runningScriptObj of this.runningScripts) {
if (runningScriptObj.filename === fn) {

@ -86,9 +86,7 @@ export class Server extends BaseServer {
this.numOpenPortsRequired = params.numOpenPortsRequired != null ? params.numOpenPortsRequired : 5;
}
/**
* Ensures that the server's difficulty (server security) doesn't get too high
*/
/** Ensures that the server's difficulty (server security) doesn't get too high */
capDifficulty(): void {
if (this.hackDifficulty < this.minDifficulty) {
this.hackDifficulty = this.minDifficulty;
@ -134,25 +132,19 @@ export class Server extends BaseServer {
this.moneyMax *= n;
}
/**
* Strengthens a server's security level (difficulty) by the specified amount
*/
/** Strengthens a server's security level (difficulty) by the specified amount */
fortify(amt: number): void {
this.hackDifficulty += amt;
this.capDifficulty();
}
/**
* Lowers the server's security level (difficulty) by the specified amount)
*/
/** Lowers the server's security level (difficulty) by the specified amount) */
weaken(amt: number): void {
this.hackDifficulty -= amt * BitNodeMultipliers.ServerWeakenRate;
this.capDifficulty();
}
/**
* Serialize the current object to a JSON save state
*/
/** Serialize the current object to a JSON save state */
toJSON(): IReviverValue {
return Generic_toJSON("Server", this);
}

@ -12,19 +12,13 @@ import { SpecialServers } from "./SpecialServers";
* These values will be adjusted based on Bitnode multipliers when the Server objects are built out.
*/
interface IServerMetadata {
/**
* When populated, the base security level of the server.
*/
/** When populated, the base security level of the server. */
hackDifficulty?: number | IMinMaxRange;
/**
* The DNS name of the server.
*/
/** The DNS name of the server. */
hostname: string;
/**
* When populated, the files will be added to the server when created.
*/
/** When populated, the files will be added to the server when created. */
literature?: string[];
/**
@ -33,9 +27,7 @@ interface IServerMetadata {
*/
maxRamExponent?: number | IMinMaxRange;
/**
* How much money the server starts out with.
*/
/** How much money the server starts out with. */
moneyAvailable: number | IMinMaxRange;
/**
@ -45,35 +37,23 @@ interface IServerMetadata {
*/
networkLayer?: number | IMinMaxRange;
/**
* The number of ports that must be opened before the player can execute NUKE.
*/
/** The number of ports that must be opened before the player can execute NUKE. */
numOpenPortsRequired: number;
/**
* The organization that the server belongs to.
*/
/** The organization that the server belongs to. */
organizationName: string;
/**
* The minimum hacking level before the player can run NUKE.
*/
/** The minimum hacking level before the player can run NUKE. */
requiredHackingSkill: number | IMinMaxRange;
/**
* The growth factor for the server.
*/
/** The growth factor for the server. */
serverGrowth?: number | IMinMaxRange;
/**
* A "unique" server that has special implications when the player manually hacks it.
*/
/** A "unique" server that has special implications when the player manually hacks it. */
specialName?: string;
}
/**
* The metadata for building up the servers on the network.
*/
/** The metadata for building up the servers on the network. */
export const serverMetadata: IServerMetadata[] = [
{
hackDifficulty: 99,

@ -1,8 +1,4 @@
// Enums that defined allowed values for setting configuration
/**
* Allowed values for the 'OwnedAugmentationsOrder' setting
*/
/** Allowed values for the 'OwnedAugmentationsOrder' setting */
export enum PurchaseAugmentationsOrderSetting {
Cost,
Default,
@ -10,9 +6,7 @@ export enum PurchaseAugmentationsOrderSetting {
Purchasable,
}
/**
* Allowed values for the 'OwnedAugmentationsOrder' setting
*/
/** Allowed values for the 'OwnedAugmentationsOrder' setting */
export enum OwnedAugmentationsOrderSetting {
Alphabetically,
AcquirementTime,

@ -23,9 +23,7 @@ import * as React from "react";
import { NetscriptContext } from "../Netscript/APIWrapper";
import { helpers } from "../Netscript/NetscriptHelpers";
/**
* Each function takes an optional config object as its last argument
*/
/** Each function takes an optional config object as its last argument */
interface IOptions {
rerenderFn?: () => void;
suppressDialog?: boolean;

@ -43,16 +43,12 @@ export class Order {
this.pos = pos;
}
/**
* Serialize the Order to a JSON save state.
*/
/** Serialize the Order to a JSON save state. */
toJSON(): IReviverValue {
return Generic_toJSON("Order", this);
}
/**
* Initializes a Order from a JSON save state
*/
/** Initializes a Order from a JSON save state */
static fromJSON(value: IReviverValue): Order {
return Generic_fromJSON(Order, value.data);
}

@ -51,38 +51,24 @@ function toNumber(n: number | IMinMaxRange): number {
return value;
}
/**
* Represents the valuation of a company in the World Stock Exchange.
*/
/** Represents the valuation of a company in the World Stock Exchange. */
export class Stock {
/**
* Bear or bull (more likely to go up or down, based on otlkMag)
*/
/** Bear or bull (more likely to go up or down, based on otlkMag) */
b: boolean;
/**
* Maximum price of a stock (per share)
*/
/** Maximum price of a stock (per share) */
readonly cap: number;
/**
* Stocks previous share price
*/
/** Stocks previous share price */
lastPrice: number;
/**
* Maximum number of shares that player can own (both long and short combined)
*/
/** Maximum number of shares that player can own (both long and short combined) */
readonly maxShares: number;
/**
* Maximum volatility
*/
/** Maximum volatility */
readonly mv: number;
/**
* Name of the company that the stock is for
*/
/** Name of the company that the stock is for */
readonly name: string;
/**
@ -97,34 +83,22 @@ export class Stock {
*/
otlkMagForecast: number;
/**
* Average price of stocks that the player owns in the LONG position
*/
/** Average price of stocks that the player owns in the LONG position */
playerAvgPx: number;
/**
* Average price of stocks that the player owns in the SHORT position
*/
/** Average price of stocks that the player owns in the SHORT position */
playerAvgShortPx: number;
/**
* Number of shares the player owns in the LONG position
*/
/** Number of shares the player owns in the LONG position */
playerShares: number;
/**
* Number of shares the player owns in the SHORT position
*/
/** Number of shares the player owns in the SHORT position */
playerShortShares: number;
/**
* Stock's share price
*/
/** Stock's share price */
price: number;
/**
* How many shares need to be transacted in order to trigger a price movement
*/
/** How many shares need to be transacted in order to trigger a price movement */
readonly shareTxForMovement: number;
/**
@ -139,9 +113,7 @@ export class Stock {
*/
readonly spreadPerc: number;
/**
* The stock's ticker symbol
*/
/** The stock's ticker symbol */
readonly symbol: string;
/**
@ -178,9 +150,7 @@ export class Stock {
this.maxShares = Math.round((this.totalShares * outstandingSharePercentage) / 1e5) * 1e5;
}
/**
* Safely set the stock's second-order forecast to a new value
*/
/** Safely set the stock's second-order forecast to a new value */
changeForecastForecast(newff: number): void {
this.otlkMagForecast = newff;
if (this.otlkMagForecast > 100) {
@ -190,9 +160,7 @@ export class Stock {
}
}
/**
* Set the stock to a new price. Also updates the stock's previous price tracker
*/
/** Set the stock to a new price. Also updates the stock's previous price tracker */
changePrice(newPrice: number): void {
this.lastPrice = this.price;
this.price = newPrice;
@ -249,30 +217,22 @@ export class Stock {
this.otlkMagForecast = 50 + -1 * diff;
}
/**
* Returns the stock's absolute forecast, which is a number between 0-100
*/
/** Returns the stock's absolute forecast, which is a number between 0-100 */
getAbsoluteForecast(): number {
return this.b ? 50 + this.otlkMag : 50 - this.otlkMag;
}
/**
* Return the price at which YOUR stock is bought (market ask price). Accounts for spread
*/
/** Return the price at which YOUR stock is bought (market ask price). Accounts for spread */
getAskPrice(): number {
return this.price * (1 + this.spreadPerc / 100);
}
/**
* Return the price at which YOUR stock is sold (market bid price). Accounts for spread
*/
/** Return the price at which YOUR stock is sold (market bid price). Accounts for spread */
getBidPrice(): number {
return this.price * (1 - this.spreadPerc / 100);
}
/**
* Returns the chance (0-1 decimal) that a stock has of having its forecast increase
*/
/** Returns the chance (0-1 decimal) that a stock has of having its forecast increase */
getForecastIncreaseChance(): number {
const diff = this.otlkMagForecast - this.getAbsoluteForecast();
@ -305,16 +265,12 @@ export class Stock {
}
}
/**
* Serialize the Stock to a JSON save state.
*/
/** Serialize the Stock to a JSON save state. */
toJSON(): IReviverValue {
return Generic_toJSON("Stock", this);
}
/**
* Initializes a Stock from a JSON save state
*/
/** Initializes a Stock from a JSON save state */
static fromJSON(value: IReviverValue): Stock {
return Generic_fromJSON(Stock, value.data);
}

@ -1,6 +1,3 @@
/**
* Stock Market Helper Functions
*/
import { Stock } from "./Stock";
import { PositionTypes } from "./data/PositionTypes";
import { CONSTANTS } from "../Constants";

@ -1,6 +1,3 @@
/**
* Root React component for the Stock Market UI
*/
import React, { useState, useEffect } from "react";
import { InfoAndPurchases } from "./InfoAndPurchases";
@ -14,6 +11,7 @@ type IProps = {
stockMarket: IStockMarket;
};
/** Root React component for the Stock Market UI */
export function StockMarketRoot(props: IProps): React.ReactElement {
const setRerender = useState(false)[1];
function rerender(): void {

@ -1,6 +1,3 @@
/**
* React Component for a single stock ticker in the Stock Market UI
*/
import React, { useState } from "react";
import { StockTickerHeaderText } from "./StockTickerHeaderText";
@ -46,6 +43,7 @@ type IProps = {
stock: Stock;
};
/** React Component for a single stock ticker in the Stock Market UI */
export function StockTicker(props: IProps): React.ReactElement {
const [orderType, setOrderType] = useState(SelectorOrderType.Market);
const [position, setPosition] = useState(PositionTypes.Long);

@ -1,6 +1,3 @@
/**
* React component for displaying a single order in a stock's order book
*/
import * as React from "react";
import { Order } from "../Order";
@ -17,6 +14,7 @@ type IProps = {
order: Order;
};
/** React component for displaying a single order in a stock's order book */
export function StockTickerOrder(props: IProps): React.ReactElement {
function handleCancelOrderClick(): void {
cancelOrder({ order: props.order });

@ -8,9 +8,7 @@
* found in ./DirectoryServerHelpers.ts
*/
/**
* Removes leading forward slash ("/") from a string.
*/
/** Removes leading forward slash ("/") from a string. */
export function removeLeadingSlash(s: string): string {
if (s.startsWith("/")) {
return s.slice(1);
@ -210,9 +208,7 @@ export function getFileName(path: string): string {
return t_path.slice(lastSlash + 1);
}
/**
* Checks if a file path refers to a file in the root directory.
*/
/** Checks if a file path refers to a file in the root directory. */
export function isInRootDirectory(path: string): boolean {
if (!isValidFilePath(path)) {
return false;

@ -52,9 +52,7 @@ export function getSubdirectories(serv: BaseServer, dir: string): string[] {
return res;
}
/**
* Returns true, if the server's directory itself or one of its subdirectory contains files.
*/
/** Returns true, if the server's directory itself or one of its subdirectory contains files. */
export function containsFiles(server: BaseServer, dir: string): boolean {
const dirWithTrailingSlash = dir + (dir.slice(-1) === "/" ? "" : "/");

@ -3,30 +3,21 @@ import { BaseServer } from "./Server/BaseServer";
import { Generic_fromJSON, Generic_toJSON, IReviverValue, Reviver } from "./utils/JSONReviver";
import { removeLeadingSlash, isInRootDirectory } from "./Terminal/DirectoryHelpers";
/**
* Represents a plain text file that is typically stored on a server.
*/
/** Represents a plain text file that is typically stored on a server. */
export class TextFile {
/**
* The full file name.
*/
/** The full file name. */
fn: string;
/**
* The content of the file.
*/
/** The content of the file. */
text: string;
/**
* The full file name.
*/
//TODO: Why are we using getter/setter for fn as filename?
/** The full file name. */
get filename(): string {
return this.fn;
}
/**
* The full file name.
*/
/** The full file name. */
set filename(value: string) {
this.fn = value;
}
@ -36,16 +27,12 @@ export class TextFile {
this.text = txt;
}
/**
* Concatenates the raw values to the end of current content.
*/
/** Concatenates the raw values to the end of current content. */
append(txt: string): void {
this.text += txt;
}
/**
* Serves the file to the user as a downloadable resource through the browser.
*/
/** Serves the file to the user as a downloadable resource through the browser. */
download(): void {
const file: Blob = new Blob([this.text], { type: "text/plain" });
const a: HTMLAnchorElement = document.createElement("a");
@ -60,37 +47,27 @@ export class TextFile {
}, 0);
}
/**
* Retrieve the content of the file.
*/
/** Retrieve the content of the file. */
read(): string {
return this.text;
}
/**
* Shows the content to the user via the game's dialog box.
*/
/** Shows the content to the user via the game's dialog box. */
show(): void {
dialogBoxCreate(`${this.fn}<br /><br />${this.text}`);
}
/**
* Serialize the current file to a JSON save state.
*/
/** Serialize the current file to a JSON save state. */
toJSON(): IReviverValue {
return Generic_toJSON("TextFile", this);
}
/**
* Replaces the current content with the text provided.
*/
/** Replaces the current content with the text provided. */
write(txt: string): void {
this.text = txt;
}
/**
* Initiatizes a TextFile from a JSON save state.
*/
/** Initiatizes a TextFile from a JSON save state. */
static fromJSON(value: IReviverValue): TextFile {
return Generic_fromJSON(TextFile, value.data);
}

@ -10,7 +10,7 @@ import { StyleEditorButton } from "./StyleEditorButton";
import { ThemeEntry } from "./ThemeEntry";
import { ThemeCollaborate } from "./ThemeCollaborate";
import { Modal } from "../../ui/React/Modal";
import { SnackbarEvents } from "../../ui/React/Snackbar";
import { SnackbarEvents, ToastVariant } from "../../ui/React/Snackbar";
// Everything dies when the theme gets reloaded, so we'll keep the current scroll to not jump around.
let previousScrollY = 0;
@ -49,7 +49,7 @@ export function ThemeBrowser(): React.ReactElement {
UNDO
</Button>
</>,
"info",
ToastVariant.INFO,
30000,
);
}

@ -188,16 +188,12 @@ export class ClassWork extends Work {
};
}
/**
* Serialize the current object to a JSON save state.
*/
/** Serialize the current object to a JSON save state. */
toJSON(): IReviverValue {
return Generic_toJSON("ClassWork", this);
}
/**
* Initiatizes a ClassWork object from a JSON save state.
*/
/** Initiatizes a ClassWork object from a JSON save state. */
static fromJSON(value: IReviverValue): ClassWork {
return Generic_fromJSON(ClassWork, value.data);
}

@ -70,16 +70,12 @@ export class CompanyWork extends Work {
};
}
/**
* Serialize the current object to a JSON save state.
*/
/** Serialize the current object to a JSON save state. */
toJSON(): IReviverValue {
return Generic_toJSON("CompanyWork", this);
}
/**
* Initiatizes a CompanyWork object from a JSON save state.
*/
/** Initiatizes a CompanyWork object from a JSON save state. */
static fromJSON(value: IReviverValue): CompanyWork {
return Generic_fromJSON(CompanyWork, value.data);
}

@ -107,16 +107,12 @@ export class CreateProgramWork extends Work {
};
}
/**
* Serialize the current object to a JSON save state.
*/
/** Serialize the current object to a JSON save state. */
toJSON(): IReviverValue {
return Generic_toJSON("CreateProgramWork", this);
}
/**
* Initiatizes a CreateProgramWork object from a JSON save state.
*/
/** Initiatizes a CreateProgramWork object from a JSON save state. */
static fromJSON(value: IReviverValue): CreateProgramWork {
return Generic_fromJSON(CreateProgramWork, value.data);
}

@ -136,16 +136,12 @@ export class CrimeWork extends Work {
};
}
/**
* Serialize the current object to a JSON save state.
*/
/** Serialize the current object to a JSON save state. */
toJSON(): IReviverValue {
return Generic_toJSON("CrimeWork", this);
}
/**
* Initiatizes a CrimeWork object from a JSON save state.
*/
/** Initiatizes a CrimeWork object from a JSON save state. */
static fromJSON(value: IReviverValue): CrimeWork {
return Generic_fromJSON(CrimeWork, value.data);
}

@ -85,16 +85,12 @@ export class FactionWork extends Work {
};
}
/**
* Serialize the current object to a JSON save state.
*/
/** Serialize the current object to a JSON save state. */
toJSON(): IReviverValue {
return Generic_toJSON("FactionWork", this);
}
/**
* Initiatizes a FactionWork object from a JSON save state.
*/
/** Initiatizes a FactionWork object from a JSON save state. */
static fromJSON(value: IReviverValue): FactionWork {
return Generic_fromJSON(FactionWork, value.data);
}

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