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 { DoubleArrow } from "@mui/icons-material";
import { List, ListItem, ListItemText, Paper, Typography } from "@mui/material"; import { List, ListItem, ListItemText, Paper, Typography } from "@mui/material";
import * as React from "react"; import * as React from "react";
@ -85,6 +82,7 @@ function MultiplierList(props: IMultiplierListProps): React.ReactElement {
return listItems.length > 0 ? <List disablePadding>{listItems}</List> : <></>; 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 { export function PlayerMultipliers(): React.ReactElement {
const mults = calculateAugmentedStats(); 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... * player toward the intended strategy. Unless they really want to play the long, slow game of waiting...
*/ */
export interface IBitNodeMultipliers { 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; AgilityLevelMultiplier: number;
/** /** Influences the base cost to purchase an augmentation. */
* Influences the base cost to purchase an augmentation.
*/
AugmentationMoneyCost: number; 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; AugmentationRepCost: number;
/** /** Influences how quickly the player can gain rank within Bladeburner. */
* Influences how quickly the player can gain rank within Bladeburner.
*/
BladeburnerRank: number; BladeburnerRank: number;
/** /** Influences the cost of skill levels from Bladeburner. */
* Influences the cost of skill levels from Bladeburner.
*/
BladeburnerSkillCost: number; 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; 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; ClassGymExpGain: number;
/** /**Influences the amount of money gained from completing Coding Contracts. */
* Influences the amount of money gained from completing Coding Contracts
**/
CodingContractMoney: number; 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; 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; CompanyWorkMoney: number;
/** /** Influences the valuation of corporations created by the player. */
* Influences the valuation of corporations created by the player.
*/
CorporationValuation: number; 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; 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; 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; 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; 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; 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; 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; 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; 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; 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; FourSigmaMarketDataCost: number;
/** /** Reduces gangs earning. */
* Reduces gangs earning.
*/
GangSoftcap: number; GangSoftcap: number;
/** /** Percentage of unique augs that the gang has. */
* Percentage of unique augs that the gang has.
*/
GangUniqueAugs: number; GangUniqueAugs: number;
/** /** Influences the experienced gained when hacking a server. */
* Influences the experienced gained when hacking a server.
*/
HackExpGain: number; 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; HackingLevelMultiplier: number;
/** /**
@ -137,19 +87,13 @@ export interface IBitNodeMultipliers {
*/ */
HacknetNodeMoney: number; 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; 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; 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; InfiltrationRep: number;
/** /**
@ -158,33 +102,22 @@ export interface IBitNodeMultipliers {
*/ */
ManualHackMoney: number; ManualHackMoney: number;
/** /** Influence how much it costs to purchase a server */
* Influence how much it costs to purchase a server
*/
PurchasedServerCost: number; PurchasedServerCost: number;
/** /** Influence how much it costs to purchase a server */
* Influence how much it costs to purchase a server
*/
PurchasedServerSoftcap: number; PurchasedServerSoftcap: number;
/** /** Influences the maximum number of purchased servers you can have */
* Influences the maximum number of purchased servers you can have
*/
PurchasedServerLimit: number; PurchasedServerLimit: number;
/** /** Influences the maximum allowed RAM for a purchased server */
* Influences the maximum allowed RAM for a purchased server
*/
PurchasedServerMaxRam: number; 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; 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; ScriptHackMoney: number;
/** /**
@ -194,62 +127,40 @@ export interface IBitNodeMultipliers {
*/ */
ScriptHackMoneyGain: number; ScriptHackMoneyGain: number;
/** /** Influences the growth percentage per cycle against a server. */
* Influences the growth percentage per cycle against a server.
*/
ServerGrowthRate: number; ServerGrowthRate: number;
/** /** Influences the maxmimum money that a server can grow to. */
* Influences the maxmimum money that a server can grow to.
*/
ServerMaxMoney: number; ServerMaxMoney: number;
/** /** Influences the initial money that a server starts with. */
* Influences the initial money that a server starts with.
*/
ServerStartingMoney: number; ServerStartingMoney: number;
/** /** Influences the initial security level (hackDifficulty) of a server. */
* Influences the initial security level (hackDifficulty) of a server.
*/
ServerStartingSecurity: number; ServerStartingSecurity: number;
/** /** Influences the weaken amount per invocation against a server. */
* Influences the weaken amount per invocation against a server.
*/
ServerWeakenRate: number; 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; StrengthLevelMultiplier: number;
/** /** Influences the power of the gift. */
* Influences the power of the gift.
*/
StaneksGiftPowerMultiplier: number; StaneksGiftPowerMultiplier: number;
/** /** Influences the size of the gift. */
* Influences the size of the gift.
*/
StaneksGiftExtraSize: number; StaneksGiftExtraSize: number;
/** /** Influences the hacking skill required to backdoor the world daemon. */
* Influences the hacking skill required to backdoor the world daemon.
*/
WorldDaemonDifficulty: number; WorldDaemonDifficulty: number;
/** /** Influences corporation dividends. */
* Influences corporation dividends.
*/
CorporationSoftcap: number; CorporationSoftcap: number;
// Index signature // Index signature
[key: string]: number; [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 // tslint:disable-next-line:variable-name
export const BitNodeMultipliers = Object.assign({}, defaultMultipliers); 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 { toJSON(): IReviverValue {
return Generic_toJSON("Bladeburner", this); 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 { static fromJSON(value: IReviverValue): Bladeburner {
return Generic_fromJSON(Bladeburner, value.data); 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"; import { addOffset } from "../utils/helpers/addOffset";
interface IChangePopulationByCountParams { interface IChangePopulationByCountParams {
/** How much the estimate should change by. */
estChange: number; estChange: number;
/** Add offset to estimate (offset by percentage). */
estOffset: number; estOffset: number;
} }
@ -14,29 +16,19 @@ interface IChangePopulationByPercentageParams {
} }
export class City { export class City {
/** /** Name of the city. */
* Name of the city.
*/
name = ""; name = "";
/** /** Population of the city. */
* Population of the city.
*/
pop = 0; pop = 0;
/** /** Population estimation of the city. */
* Population estimation of the city.
*/
popEst = 0; popEst = 0;
/** /** Number of communities in the city. */
* Number of communities in the city.
*/
comms = 0; comms = 0;
/** /** Chaos level of the city. */
* Chaos level of the city.
*/
chaos = 0; chaos = 0;
constructor(name: string = BladeburnerConstants.CityNames[2]) { constructor(name: string = BladeburnerConstants.CityNames[2]) {
@ -51,9 +43,7 @@ export class City {
this.chaos = 0; 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 { changeChaosByPercentage(p: number): void {
if (isNaN(p)) { if (isNaN(p)) {
throw new Error("NaN passed into City.chaosChaosByPercentage()"); 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 { improvePopulationEstimateByPercentage(p: number, skillMult = 1): void {
p = p * skillMult; p = p * skillMult;
if (isNaN(p)) { 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 { changePopulationByCount(n: number, params: IChangePopulationByCountParams = { estChange: 0, estOffset: 0 }): void {
if (isNaN(n)) { if (isNaN(n)) {
throw new Error("NaN passed into City.changePopulationByCount()"); 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 { toJSON(): IReviverValue {
return Generic_toJSON("City", this); 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 { static fromJSON(value: IReviverValue): City {
return Generic_fromJSON(City, value.data); 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 */ /* Represents different types of problems that a Coding Contract can have */
class CodingContractType { class CodingContractType {
/** /** Function that generates a description of the problem */
* Function that generates a description of the problem
*/
desc: DescriptionFunc; 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; 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; generate: GeneratorFunc;
/** /** Name of the type of problem */
* Name of the type of problem
*/
name: string; 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; 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; solver: SolverFunc;
constructor( 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 { export enum CodingContractRewardType {
FactionReputation, FactionReputation,
FactionReputationAll, FactionReputationAll,
@ -80,18 +66,14 @@ export enum CodingContractRewardType {
Money, // This must always be the last reward type 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 { export enum CodingContractResult {
Success, Success,
Failure, Failure,
Cancelled, 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 { export interface ICodingContractReward {
/* Name of Company/Faction name for reward, if applicable */ /* Name of Company/Faction name for reward, if applicable */
name?: string; name?: string;
@ -159,9 +141,7 @@ export class CodingContract {
return CodingContractTypes[this.type].solver(this.data, solution); 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> { async prompt(): Promise<CodingContractResult> {
return new Promise<CodingContractResult>((resolve) => { return new Promise<CodingContractResult>((resolve) => {
const props = { 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 { toJSON(): IReviverValue {
return Generic_toJSON("CodingContract", this); 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 { static fromJSON(value: IReviverValue): CodingContract {
return Generic_fromJSON(CodingContract, value.data); return Generic_fromJSON(CodingContract, value.data);
} }

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

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

@ -1,10 +1,7 @@
import { Company } from "./Company"; import { Company } from "./Company";
import { CompanyPosition } from "./CompanyPosition"; 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 { export function getJobRequirementText(company: Company, pos: CompanyPosition, tooltiptext = false): string {
let reqText = ""; let reqText = "";
const offset: number = company.jobStatReqOffset; const offset: number = company.jobStatReqOffset;

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

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

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

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

@ -7,7 +7,7 @@ import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
import Typography from "@mui/material/Typography"; import Typography from "@mui/material/Typography";
import { saveObject } from "../../SaveObject"; import { saveObject } from "../../SaveObject";
import { SnackbarEvents } from "../../ui/React/Snackbar"; import { SnackbarEvents, ToastVariant } from "../../ui/React/Snackbar";
import { Upload } from "@mui/icons-material"; import { Upload } from "@mui/icons-material";
import { Button } from "@mui/material"; import { Button } from "@mui/material";
import { OptionSwitch } from "../../ui/React/OptionSwitch"; import { OptionSwitch } from "../../ui/React/OptionSwitch";
@ -25,7 +25,7 @@ export function SaveFile(): React.ReactElement {
const save = atob(base64Save); const save = atob(base64Save);
setSaveFile(save); setSaveFile(save);
} catch (e: unknown) { } 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(); saveObject.exportGame();
} catch (error) { } catch (error) {
console.error(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()), triggerScriptsExport: (): void => exportScripts("*", Player.getHomeComputer()),
@ -203,7 +203,7 @@ function initElectronBridge(): void {
}) })
.catch((error: unknown) => { .catch((error: unknown) => {
console.error(error); 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", () => { bridge.receive("trigger-game-export", () => {
@ -211,7 +211,7 @@ function initElectronBridge(): void {
window.appSaveFns.triggerGameExport(); window.appSaveFns.triggerGameExport();
} catch (error) { } catch (error) {
console.error(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", () => { bridge.receive("trigger-scripts-export", () => {
@ -219,7 +219,7 @@ function initElectronBridge(): void {
window.appSaveFns.triggerScriptsExport(); window.appSaveFns.triggerScriptsExport();
} catch (error) { } catch (error) {
console.error(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; alreadyInvited = false;
/** /** Holds names of all augmentations that this Faction offers */
* Holds names of all augmentations that this Faction offers
*/
augmentations: string[] = []; augmentations: string[] = [];
/** /** Amount of favor the player has with this faction. */
* Amount of favor the player has with this faction.
*/
favor = 0; favor = 0;
/** /** Flag signalling whether player has been banned from this faction */
* Flag signalling whether player has been banned from this faction
*/
isBanned = false; isBanned = false;
/** /** Flag signalling whether player is a member of this faction */
* Flag signalling whether player is a member of this faction
*/
isMember = false; isMember = false;
/** /** Name of faction */
* Name of faction
*/
name = ""; name = "";
/** /** Amount of reputation player has with this faction */
* Amount of reputation player has with this faction
*/
playerReputation = 0; playerReputation = 0;
constructor(name = "") { constructor(name = "") {
@ -72,16 +60,12 @@ export class Faction {
return newFavor - this.favor; return newFavor - this.favor;
} }
/** /** Serialize the current object to a JSON save state. */
* Serialize the current object to a JSON save state.
*/
toJSON(): IReviverValue { toJSON(): IReviverValue {
return Generic_toJSON("Faction", this); 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 { static fromJSON(value: IReviverValue): Faction {
return Generic_fromJSON(Faction, value.data); return Generic_fromJSON(Faction, value.data);
} }

@ -15,48 +15,30 @@ interface FactionInfoParams {
assignment?: () => React.ReactElement; 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 { 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[]; 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; 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; 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; 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; offerSecurityWork: boolean;
/** /** Keep faction on install. */
* Keep faction on install.
*/
keep: boolean; keep: boolean;
/** /** Special faction */
* Special faction
*/
special: boolean; special: boolean;
/** /** The data to display on the faction screen. */
* The data to display on the faction screen.
*/
assignment?: () => React.ReactElement; assignment?: () => React.ReactElement;
constructor(params: FactionInfoParams) { 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 // tslint:disable-next-line:variable-name
export const FactionInfos: Record<string, FactionInfo> = { export const FactionInfos: Record<string, FactionInfo> = {
// Endgame // 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 { Box, Button, Tooltip, Typography, Paper, Container } from "@mui/material";
import React, { useState } from "react"; import React, { useState } from "react";
@ -23,6 +20,7 @@ type IProps = {
routeToMainPage: () => void; routeToMainPage: () => void;
}; };
/** Root React Component for displaying a faction's "Purchase Augmentations" page */
export function AugmentationsPage(props: IProps): React.ReactElement { export function AugmentationsPage(props: IProps): React.ReactElement {
const setRerender = useState(false)[1]; 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 React from "react";
import { Modal } from "../../ui/React/Modal"; import { Modal } from "../../ui/React/Modal";
import { Router } from "../../ui/GameRoot"; import { Router } from "../../ui/GameRoot";
@ -16,6 +13,7 @@ interface IProps {
facName: string; facName: string;
} }
/** React Component for the popup used to create a new gang. */
export function CreateGangModal(props: IProps): React.ReactElement { export function CreateGangModal(props: IProps): React.ReactElement {
const combatGangText = const combatGangText =
"This is a COMBAT gang. Members in this gang will have different tasks than HACKING gangs. " + "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 React, { useState } from "react";
import { CONSTANTS } from "../../Constants"; import { CONSTANTS } from "../../Constants";
@ -27,6 +24,7 @@ type IProps = {
rerender: () => void; rerender: () => void;
}; };
/** React component for a donate option on the Faction UI */
export function DonateOption(props: IProps): React.ReactElement { export function DonateOption(props: IProps): React.ReactElement {
const [donateAmt, setDonateAmt] = useState<number>(NaN); const [donateAmt, setDonateAmt] = useState<number>(NaN);
const digits = (CONSTANTS.DonateMoneyToRepDivisor + "").length - 1; const digits = (CONSTANTS.DonateMoneyToRepDivisor + "").length - 1;

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

@ -376,7 +376,7 @@ export class Gang {
return Math.max(1, discount); 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[] { getAllTaskNames(): string[] {
return Object.keys(GangMemberTasks).filter((taskName: string) => { return Object.keys(GangMemberTasks).filter((taskName: string) => {
const task = GangMemberTasks[taskName]; const task = GangMemberTasks[taskName];
@ -394,16 +394,12 @@ export class Gang {
return upg.cost / this.getDiscount(); 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 { toJSON(): IReviverValue {
return Generic_toJSON("Gang", this); 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 { static fromJSON(value: IReviverValue): Gang {
return Generic_fromJSON(Gang, value.data); return Generic_fromJSON(Gang, value.data);
} }

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

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

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

@ -1,6 +1,3 @@
/**
* React Component for a gang member on the management subpage.
*/
import React from "react"; import React from "react";
import { GangMember } from "../GangMember"; import { GangMember } from "../GangMember";
import { GangMemberCardContent } from "./GangMemberCardContent"; import { GangMemberCardContent } from "./GangMemberCardContent";
@ -14,6 +11,7 @@ interface IProps {
member: GangMember; member: GangMember;
} }
/** React Component for a gang member on the management subpage. */
export function GangMemberCard(props: IProps): React.ReactElement { export function GangMemberCard(props: IProps): React.ReactElement {
return ( return (
<Box component={Paper} sx={{ width: "auto" }}> <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 React, { useState } from "react";
import { GangMemberCard } from "./GangMemberCard"; import { GangMemberCard } from "./GangMemberCard";
import { RecruitButton } from "./RecruitButton"; import { RecruitButton } from "./RecruitButton";
@ -12,6 +9,7 @@ import SearchIcon from "@mui/icons-material/Search";
import { GangMember } from "../GangMember"; import { GangMember } from "../GangMember";
import { OptionSwitch } from "../../ui/React/OptionSwitch"; import { OptionSwitch } from "../../ui/React/OptionSwitch";
/** React Component for the list of gang members on the management subpage. */
export function GangMemberList(): React.ReactElement { export function GangMemberList(): React.ReactElement {
const gang = useGang(); const gang = useGang();
const setRerender = useState(false)[1]; const setRerender = useState(false)[1];

@ -1,6 +1,3 @@
/**
* React Component for all the gang stuff.
*/
import React, { useState, useEffect } from "react"; import React, { useState, useEffect } from "react";
import { ManagementSubpage } from "./ManagementSubpage"; import { ManagementSubpage } from "./ManagementSubpage";
import { TerritorySubpage } from "./TerritorySubpage"; import { TerritorySubpage } from "./TerritorySubpage";
@ -11,6 +8,7 @@ import { Context } from "./Context";
import Tabs from "@mui/material/Tabs"; import Tabs from "@mui/material/Tabs";
import Tab from "@mui/material/Tab"; import Tab from "@mui/material/Tab";
/** React Component for all the gang stuff. */
export function GangRoot(): React.ReactElement { export function GangRoot(): React.ReactElement {
const gang = (function () { const gang = (function () {
if (Player.gang === null) throw new Error("Gang should not be null"); 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 React from "react";
import { GangStats } from "./GangStats"; import { GangStats } from "./GangStats";
import { GangMemberList } from "./GangMemberList"; import { GangMemberList } from "./GangMemberList";
import { useGang } from "./Context"; import { useGang } from "./Context";
import Typography from "@mui/material/Typography"; import Typography from "@mui/material/Typography";
/** React Component for the subpage that manages gang members, the main page. */
export function ManagementSubpage(): React.ReactElement { export function ManagementSubpage(): React.ReactElement {
const gang = useGang(); const gang = useGang();
return ( return (

@ -1,6 +1,3 @@
/**
* React Component for the recruitment button and text on the gang main page.
*/
import React, { useState } from "react"; import React, { useState } from "react";
import { RecruitModal } from "./RecruitModal"; import { RecruitModal } from "./RecruitModal";
import { GangConstants } from "../data/Constants"; import { GangConstants } from "../data/Constants";
@ -14,6 +11,7 @@ interface IProps {
onRecruit: () => void; onRecruit: () => void;
} }
/** React Component for the recruitment button and text on the gang main page. */
export function RecruitButton(props: IProps): React.ReactElement { export function RecruitButton(props: IProps): React.ReactElement {
const gang = useGang(); const gang = useGang();
const [open, setOpen] = useState(false); 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 React, { useState } from "react";
import { Modal } from "../../ui/React/Modal"; import { Modal } from "../../ui/React/Modal";
import { dialogBoxCreate } from "../../ui/React/DialogBox"; import { dialogBoxCreate } from "../../ui/React/DialogBox";
@ -16,6 +13,7 @@ interface IRecruitPopupProps {
onRecruit: () => void; onRecruit: () => void;
} }
/** React Component for the popup used to recruit new gang members. */
export function RecruitModal(props: IRecruitPopupProps): React.ReactElement { export function RecruitModal(props: IRecruitPopupProps): React.ReactElement {
const gang = useGang(); const gang = useGang();
const [name, setName] = useState(""); const [name, setName] = useState("");

@ -1,6 +1,3 @@
/**
* React Component for the territory subpage.
*/
import React, { useState } from "react"; import React, { useState } from "react";
import { Container, Button, Paper, Box, Tooltip, Switch, FormControlLabel, Typography } from "@mui/material"; 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 { useGang } from "./Context";
import { TerritoryInfoModal } from "./TerritoryInfoModal"; import { TerritoryInfoModal } from "./TerritoryInfoModal";
/** React Component for the territory subpage. */
export function TerritorySubpage(): React.ReactElement { export function TerritorySubpage(): React.ReactElement {
const gang = useGang(); const gang = useGang();
const gangNames = Object.keys(AllGangs).filter((g) => g != gang.facName); 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 { calculateIntelligenceBonus } from "./PersonObjects/formulas/intelligence";
import { Server } from "./Server/Server"; 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 { export function calculateHackingChance(server: Server, person: Person): number {
const hackFactor = 1.75; const hackFactor = 1.75;
const difficultyMult = (100 - server.hackDifficulty) / 100; const difficultyMult = (100 - server.hackDifficulty) / 100;
@ -64,9 +62,7 @@ export function calculatePercentMoneyHacked(server: Server, person: Person): num
return percentMoneyHacked; 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 { export function calculateHackingTime(server: Server, person: Person): number {
const difficultyMult = server.requiredHackingSkill * server.hackDifficulty; const difficultyMult = server.requiredHackingSkill * server.hackDifficulty;
@ -85,18 +81,14 @@ export function calculateHackingTime(server: Server, person: Person): number {
return hackingTime; 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 { export function calculateGrowTime(server: Server, person: Person): number {
const growTimeMultiplier = 3.2; // Relative to hacking time. 16/5 = 3.2 const growTimeMultiplier = 3.2; // Relative to hacking time. 16/5 = 3.2
return growTimeMultiplier * calculateHackingTime(server, person); 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 { export function calculateWeakenTime(server: Server, person: Person): number {
const weakenTimeMultiplier = 4; // Relative to hacking time 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 { toJSON(): IReviverValue {
return Generic_toJSON("HacknetNode", this); 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 { static fromJSON(value: IReviverValue): HacknetNode {
return Generic_fromJSON(HacknetNode, value.data); return Generic_fromJSON(HacknetNode, value.data);
} }

@ -1,6 +1,3 @@
/**
* Hacknet Servers - Reworked Hacknet Node mechanic for BitNode-9
*/
import { CONSTANTS } from "../Constants"; import { CONSTANTS } from "../Constants";
import { IHacknetNode } from "./IHacknetNode"; import { IHacknetNode } from "./IHacknetNode";
@ -30,6 +27,7 @@ interface IConstructorParams {
organizationName?: string; organizationName?: string;
} }
/** Hacknet Servers - Reworked Hacknet Node mechanic for BitNode-9 */
export class HacknetServer extends BaseServer implements IHacknetNode { export class HacknetServer extends BaseServer implements IHacknetNode {
// Cache level. Affects hash Capacity // Cache level. Affects hash Capacity
cache = 1; 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 { getMult(upgName: string): number {
const upg = HashUpgrades[upgName]; const upg = HashUpgrades[upgName];
const currLevel = this.upgrades[upgName]; const currLevel = this.upgrades[upgName];
@ -42,18 +40,14 @@ export class HashManager {
return 1 + (upg.value * currLevel) / 100; 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 { getStudyMult(): number {
const upgName = "Improve Studying"; const upgName = "Improve Studying";
return this.getMult(upgName); 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 { getTrainingMult(): number {
const upgName = "Improve Gym Training"; const upgName = "Improve Gym Training";
@ -69,9 +63,7 @@ export class HashManager {
return upg; return upg;
} }
/** /** Get the cost (in hashes) of an upgrade */
* Get the cost (in hashes) of an upgrade
*/
getUpgradeCost(upgName: string, count = 1): number { getUpgradeCost(upgName: string, count = 1): number {
const upg = this.getUpgrade(upgName); const upg = this.getUpgrade(upgName);
const currLevel = this.upgrades[upgName]; const currLevel = this.upgrades[upgName];
@ -93,9 +85,7 @@ export class HashManager {
this.updateCapacity(0); 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 { refundUpgrade(upgName: string, count = 1): void {
const upg = HashUpgrades[upgName]; 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 { export interface IConstructorParams {
cost?: number; cost?: number;
costPerLevel: number; costPerLevel: number;
@ -26,9 +24,7 @@ export class HashUpgrade {
*/ */
costPerLevel = 0; costPerLevel = 0;
/** /** Description of what the upgrade does */
* Description of what the upgrade does
*/
desc = ""; desc = "";
/** /**
@ -37,7 +33,7 @@ export class HashUpgrade {
*/ */
hasTargetServer = false; hasTargetServer = false;
// Name of upgrade /** Name of upgrade */
name = ""; name = "";
// Generic value used to indicate the potency/amount of this upgrade's effect // 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 React, { useState, useEffect } from "react";
import { GeneralInfo } from "./GeneralInfo"; import { GeneralInfo } from "./GeneralInfo";
@ -29,6 +26,7 @@ import Grid from "@mui/material/Grid";
import Button from "@mui/material/Button"; import Button from "@mui/material/Button";
import { Box } from "@mui/material"; import { Box } from "@mui/material";
/** Root React Component for the Hacknet Node UI */
export function HacknetRoot(): React.ReactElement { export function HacknetRoot(): React.ReactElement {
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
const setRerender = useState(false)[1]; 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 React, { useState, useEffect } from "react";
import { HashUpgrades } from "../HashUpgrades"; import { HashUpgrades } from "../HashUpgrades";
@ -16,6 +13,7 @@ interface IProps {
onClose: () => void; onClose: () => void;
} }
/** Create the pop-up for purchasing upgrades with hashes */
export function HashUpgradeModal(props: IProps): React.ReactElement { export function HashUpgradeModal(props: IProps): React.ReactElement {
const setRerender = useState(false)[1]; const setRerender = useState(false)[1];
function rerender(): void { 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 React from "react";
import { hasHacknetServers, hasMaxNumberHacknetServers } from "../HacknetHelpers"; import { hasHacknetServers, hasMaxNumberHacknetServers } from "../HacknetHelpers";
@ -15,6 +12,7 @@ interface IProps {
cost: number; cost: number;
} }
/** React Component for the button that is used to purchase new Hacknet Nodes */
export function PurchaseButton(props: IProps): React.ReactElement { export function PurchaseButton(props: IProps): React.ReactElement {
const cost = props.cost; const cost = props.cost;
let text; let text;

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

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

@ -1,6 +1,4 @@
/** /** Names of all locations */
* Names of all locations
*/
export enum LocationName { export enum LocationName {
// Aevum Locations // Aevum Locations
AevumAeroCorp = "AeroCorp", 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 * as React from "react";
import { Company } from "../../Company/Company"; import { Company } from "../../Company/Company";
@ -18,6 +15,7 @@ type IProps = {
text: string; text: string;
}; };
/** React Component for a button that's used to apply for a job */
export function ApplyToJobButton(props: IProps): React.ReactElement { export function ApplyToJobButton(props: IProps): React.ReactElement {
function getJobRequirementTooltip(): string { function getJobRequirementTooltip(): string {
const pos = Player.getNextCompanyPosition(props.company, props.entryPosType); const pos = Player.getNextCompanyPosition(props.company, props.entryPosType);

@ -47,17 +47,13 @@ export function CompanyLocation(props: IProps): React.ReactElement {
const company = Companies[props.locName]; const company = Companies[props.locName];
if (company == null) throw new Error(`CompanyLocation component constructed with invalid company: ${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]; const location = Locations[props.locName];
if (location == null) { if (location == null) {
throw new Error(`CompanyLocation component constructed with invalid location: ${props.locName}`); 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; const jobTitle = Player.jobs[props.locName] ? Player.jobs[props.locName] : null;
/** /**

@ -19,9 +19,7 @@ type IState = {
//Todo: Make this a functional component //Todo: Make this a functional component
export class HospitalLocation extends React.Component<Record<string, never>, IState> { 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" }; btnStyle = { display: "block" };
constructor() { constructor() {

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

@ -25,7 +25,7 @@ import { Router } from "../../ui/GameRoot";
import { Player } from "../../Player"; import { Player } from "../../Player";
import { dialogBoxCreate } from "../../ui/React/DialogBox"; 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 { N00dles } from "../../utils/helpers/N00dles";
import { Exploit } from "../../Exploits/Exploit"; import { Exploit } from "../../Exploits/Exploit";
import { applyAugmentation } from "../../Augmentation/AugmentationHelpers"; import { applyAugmentation } from "../../Augmentation/AugmentationHelpers";
@ -45,9 +45,7 @@ export function SpecialLocation(props: IProps): React.ReactElement {
const setRerender = useState(false)[1]; const setRerender = useState(false)[1];
const inBladeburner = Player.inBladeburner(); 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 { function handleBladeburner(): void {
if (Player.inBladeburner()) { if (Player.inBladeburner()) {
// Enter Bladeburner division // 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 { function handleGrafting(): void {
Router.toGrafting(); Router.toGrafting();
} }
@ -95,7 +91,7 @@ export function SpecialLocation(props: IProps): React.ReactElement {
function renderNoodleBar(): React.ReactElement { function renderNoodleBar(): React.ReactElement {
function EatNoodles(): void { 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. N00dles(); // This is the true power of the noodles.
if (Player.sourceFiles.length > 0) Player.giveExploit(Exploit.N00dles); if (Player.sourceFiles.length > 0) Player.giveExploit(Exploit.N00dles);
if (Player.sourceFileLvl(5) > 0 || Player.bitNodeN === 5) { if (Player.sourceFileLvl(5) > 0 || Player.bitNodeN === 5) {

@ -10,9 +10,7 @@ import { Player } from "../../Player";
import { Money } from "../../ui/React/Money"; 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 { export function purchaseTorRouter(): void {
if (Player.hasTorRouter()) { if (Player.hasTorRouter()) {
dialogBoxCreate(`You already have a TOR Router!`); dialogBoxCreate(`You already have a TOR Router!`);

@ -5,19 +5,13 @@ import { NS } from "../ScriptEditor/NetscriptDefinitions";
* Netscript functions and arguments for that script. * Netscript functions and arguments for that script.
*/ */
export class Environment { 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; stopFlag = false;
/** /** The currently running function */
* The currently running function
*/
runningFn = ""; runningFn = "";
/** /** Environment variables (currently only Netscript functions) */
* Environment variables (currently only Netscript functions)
*/
vars: NS | null = null; vars: NS | null = null;
} }

@ -2,9 +2,7 @@ import { workerScripts } from "./WorkerScripts";
let pidCounter = 1; 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 { export function generateNextPid(): number {
let tempCounter = pidCounter; let tempCounter = pidCounter;

@ -18,14 +18,10 @@ import { ScriptDeath } from "./ScriptDeath";
import { ScriptArg } from "./ScriptArg"; import { ScriptArg } from "./ScriptArg";
export class WorkerScript { export class WorkerScript {
/** /** Script's arguments */
* Script's arguments
*/
args: ScriptArg[]; args: ScriptArg[];
/** /** Copy of the script's code */
* Copy of the script's code
*/
code = ""; code = "";
/** /**
@ -34,14 +30,10 @@ export class WorkerScript {
*/ */
delay: number | null = null; 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; 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> = {}; disableLogs: Record<string, boolean> = {};
/** /**
@ -51,19 +43,13 @@ export class WorkerScript {
*/ */
dynamicLoadedFns: Record<string, boolean> = {}; dynamicLoadedFns: Record<string, boolean> = {};
/** /** Tracks dynamic RAM usage */
* Tracks dynamic RAM usage
*/
dynamicRamUsage: number = RamCostConstants.ScriptBaseRamCost; dynamicRamUsage: number = RamCostConstants.ScriptBaseRamCost;
/** /** Netscript Environment for this script */
* Netscript Environment for this script
*/
env: Environment; env: Environment;
/** /** Status message in case of script error. */
* Status message in case of script error.
*/
errorMessage = ""; errorMessage = "";
/** /**
@ -72,14 +58,10 @@ export class WorkerScript {
*/ */
loadedFns: Record<string, boolean> = {}; loadedFns: Record<string, boolean> = {};
/** /** Filename of script */
* Filename of script
*/
name: string; name: string;
/** /** Script's output/return value. Currently not used or implemented */
* Script's output/return value. Currently not used or implemented
*/
output = ""; output = "";
/** /**
@ -88,24 +70,16 @@ export class WorkerScript {
*/ */
pid: number; 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; ramUsage = 0;
/** /** Reference to underlying RunningScript object */
* Reference to underlying RunningScript object
*/
scriptRef: RunningScript; scriptRef: RunningScript;
/** /** hostname on which this script is running */
* hostname on which this script is running
*/
hostname: string; hostname: string;
/** /** Function called when the script ends. */
* Function called when the script ends.
*/
atExit?: () => void; atExit?: () => void;
constructor(runningScriptObj: RunningScript, pid: number, nsFuncsGenerator?: (ws: WorkerScript) => NS) { 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 { getServer(): BaseServer {
const server = GetServer(this.hostname); const server = GetServer(this.hostname);
if (server == null) throw new Error(`Script ${this.name} pid ${this.pid} is running on non-existent server?`); 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"; import { EventEmitter } from "../utils/EventEmitter";
/** Event emitter that triggers when scripts are started/stopped */
export const WorkerScriptStartStopEventEmitter = new EventEmitter<[]>(); export const WorkerScriptStartStopEventEmitter = new EventEmitter<[]>();

@ -1,6 +1,4 @@
/**
* Global pool of all active scripts (scripts that are currently running)
*/
import { WorkerScript } from "./WorkerScript"; import { WorkerScript } from "./WorkerScript";
/** Global pool of all active scripts (scripts that are currently running) */
export const workerScripts: Map<number, WorkerScript> = new Map(); 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 { InternalAPI, NetscriptContext, wrapAPI } from "./Netscript/APIWrapper";
import { INetscriptExtra } from "./NetscriptFunctions/Extra"; import { INetscriptExtra } from "./NetscriptFunctions/Extra";
import { ScriptDeath } from "./Netscript/ScriptDeath"; import { ScriptDeath } from "./Netscript/ScriptDeath";
import { TypeEquality, ValuesFrom } from "./types";
// "Enums" as object // "Enums" as object
export const enums = { export const enums = {
toast: { toast: ToastVariant,
SUCCESS: "success", } as const;
WARNING: "warning",
ERROR: "error",
INFO: "info",
} as const,
};
export type NSFull = NS & INetscriptExtra; export type NSFull = NS & INetscriptExtra;
export function NetscriptFunctions(workerScript: WorkerScript): NSFull { export function NetscriptFunctions(workerScript: WorkerScript): NSFull {
@ -1796,7 +1790,7 @@ const base: InternalAPI<NS> = {
const duration = _duration === null ? null : helpers.number(ctx, "duration", _duration); const duration = _duration === null ? null : helpers.number(ctx, "duration", _duration);
if (!checkObjContainsValue(enums.toast, variant)) if (!checkObjContainsValue(enums.toast, variant))
throw new Error(`variant must be one of ${Object.values(enums.toast).join(", ")}`); 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: prompt:
(ctx: NetscriptContext) => (ctx: NetscriptContext) =>

@ -17,9 +17,7 @@ import { InternalAPI, NetscriptContext } from "../Netscript/APIWrapper";
import { helpers } from "../Netscript/NetscriptHelpers"; import { helpers } from "../Netscript/NetscriptHelpers";
export function NetscriptStockMarket(): InternalAPI<TIX> { 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 { const checkTixApiAccess = function (ctx: NetscriptContext): void {
if (!player.hasWseAccount) { if (!player.hasWseAccount) {
throw helpers.makeRuntimeErrorMsg(ctx, `You don't have WSE Access! Cannot use ${ctx.function}()`); 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; 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 { export function updateOnlineScriptTimes(numCycles = 1): void {
const time = (numCycles * CONSTANTS._idleSpeed) / 1000; //seconds const time = (numCycles * CONSTANTS._idleSpeed) / 1000; //seconds
for (const ws of workerScripts.values()) { 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( export function runScriptFromScript(
caller: string, caller: string,
server: BaseServer, server: BaseServer,

@ -159,16 +159,12 @@ export class PlayerObject extends Person {
return "Player"; return "Player";
} }
/** /** Serialize the current object to a JSON save state. */
* Serialize the current object to a JSON save state.
*/
toJSON(): IReviverValue { toJSON(): IReviverValue {
return Generic_toJSON("PlayerObject", this); 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 { static fromJSON(value: IReviverValue): PlayerObject {
return Generic_fromJSON(PlayerObject, value.data); 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 { PlayerObject } from "./PlayerObject";
import { calculateEntropy } from "../Grafting/EntropyAccumulation"; import { calculateEntropy } from "../Grafting/EntropyAccumulation";

@ -39,7 +39,7 @@ import { numeralWrapper } from "../../ui/numeralFormat";
import { MoneySourceTracker } from "../../utils/MoneySourceTracker"; import { MoneySourceTracker } from "../../utils/MoneySourceTracker";
import { dialogBoxCreate } from "../../ui/React/DialogBox"; 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 { achievements } from "../../Achievements/Achievements";
import { FactionNames } from "../../Faction/data/FactionNames"; import { FactionNames } from "../../Faction/data/FactionNames";
@ -257,7 +257,7 @@ export function takeDamage(this: PlayerObject, amt: number): boolean {
export function hospitalize(this: PlayerObject): number { export function hospitalize(this: PlayerObject): number {
const cost = getHospitalizationCost(); 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.loseMoney(cost, "hospitalization");
this.hp.current = this.hp.max; this.hp.current = this.hp.max;
@ -1193,7 +1193,7 @@ export function canAccessGrafting(this: PlayerObject): boolean {
export function giveExploit(this: PlayerObject, exploit: Exploit): void { export function giveExploit(this: PlayerObject, exploit: Exploit): void {
if (!this.exploits.includes(exploit)) { if (!this.exploits.includes(exploit)) {
this.exploits.push(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 (!achievement) return;
if (!this.achievements.map((a) => a.ID).includes(achievementId)) { if (!this.achievements.map((a) => a.ID).includes(achievementId)) {
this.achievements.push({ ID: achievementId, unlockedOn: new Date().getTime() }); 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 { PlayerObject } from "./PlayerObject";
import { CONSTANTS } from "../../Constants"; import { CONSTANTS } from "../../Constants";

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

@ -10,9 +10,7 @@ import { mergeMultipliers, Multipliers } from "../Multipliers";
import { AugmentationNames } from "../../Augmentation/data/AugmentationNames"; import { AugmentationNames } from "../../Augmentation/data/AugmentationNames";
import { getFactionAugmentationsFiltered } from "../../Faction/FactionHelpers"; 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 { export function applyAugmentation(this: Sleeve, aug: Augmentation): void {
this.mults = mergeMultipliers(this.mults, aug.mults); 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 { export enum SleeveTaskType {
// Same Order as selectable order in UI // Same Order as selectable order in UI
Idle, 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 { toJSON(): IReviverValue {
return Generic_toJSON("SleeveBladeburnerWork", this); 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 { static fromJSON(value: IReviverValue): SleeveBladeburnerWork {
return Generic_fromJSON(SleeveBladeburnerWork, value.data); return Generic_fromJSON(SleeveBladeburnerWork, value.data);
} }

@ -45,16 +45,12 @@ export class SleeveClassWork extends Work {
location: this.location, location: this.location,
}; };
} }
/** /** Serialize the current object to a JSON save state. */
* Serialize the current object to a JSON save state.
*/
toJSON(): IReviverValue { toJSON(): IReviverValue {
return Generic_toJSON("SleeveClassWork", this); 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 { static fromJSON(value: IReviverValue): SleeveClassWork {
return Generic_fromJSON(SleeveClassWork, value.data); 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 { toJSON(): IReviverValue {
return Generic_toJSON("SleeveCompanyWork", this); 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 { static fromJSON(value: IReviverValue): SleeveCompanyWork {
return Generic_fromJSON(SleeveCompanyWork, value.data); 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 { toJSON(): IReviverValue {
return Generic_toJSON("SleeveCrimeWork", this); 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 { static fromJSON(value: IReviverValue): SleeveCrimeWork {
return Generic_fromJSON(SleeveCrimeWork, value.data); 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 { toJSON(): IReviverValue {
return Generic_toJSON("SleeveFactionWork", this); 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 { static fromJSON(value: IReviverValue): SleeveFactionWork {
return Generic_fromJSON(SleeveFactionWork, value.data); 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 { toJSON(): IReviverValue {
return Generic_toJSON("SleeveInfiltrateWork", this); 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 { static fromJSON(value: IReviverValue): SleeveInfiltrateWork {
return Generic_fromJSON(SleeveInfiltrateWork, value.data); 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 { toJSON(): IReviverValue {
return Generic_toJSON("SleeveRecoveryWork", this); 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 { static fromJSON(value: IReviverValue): SleeveRecoveryWork {
return Generic_fromJSON(SleeveRecoveryWork, value.data); 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 { toJSON(): IReviverValue {
return Generic_toJSON("SleeveSupportWork", this); 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 { static fromJSON(value: IReviverValue): SleeveSupportWork {
return Generic_fromJSON(SleeveSupportWork, value.data); 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 { toJSON(): IReviverValue {
return Generic_toJSON("SleeveSynchroWork", this); 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 { static fromJSON(value: IReviverValue): SleeveSynchroWork {
return Generic_fromJSON(SleeveSynchroWork, value.data); return Generic_fromJSON(SleeveSynchroWork, value.data);
} }

@ -26,16 +26,12 @@ interface IProps {
export function CovenantPurchasesRoot(props: IProps): React.ReactElement { export function CovenantPurchasesRoot(props: IProps): React.ReactElement {
const [update, setUpdate] = useState(0); 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 { function purchaseCost(): number {
return Math.pow(10, Player.sleevesFromCovenant) * BaseCostPerSleeve; 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 { function rerender(): void {
setUpdate(update + 1); 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 React from "react";
import { Player } from "./Player"; import { Player } from "./Player";
import { prestigeSourceFile } from "./Prestige"; import { prestigeSourceFile } from "./Prestige";
@ -19,17 +17,9 @@ function giveSourceFile(bitNodeNumber: number): void {
} }
// Check if player already has this source file // Check if player already has this source file
let alreadyOwned = false; const ownedSourceFile = Player.sourceFiles.find(sourceFile=>sourceFile.n === bitNodeNumber)
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;
}
}
if (alreadyOwned && ownedSourceFile) { if (ownedSourceFile) {
if (ownedSourceFile.lvl >= 3 && ownedSourceFile.n !== 12) { if (ownedSourceFile.lvl >= 3 && ownedSourceFile.n !== 12) {
dialogBoxCreate( dialogBoxCreate(
`The Source-File for the BitNode you just destroyed, ${sourceFile.name}, is already at max level!`, `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 { } else {
const playerSrcFile = new PlayerOwnedSourceFile(bitNodeNumber, 1); const newSrcFile = new PlayerOwnedSourceFile(bitNodeNumber, 1);
Player.sourceFiles.push(playerSrcFile); Player.sourceFiles.push(newSrcFile);
if (bitNodeNumber === 5 && Player.skills.intelligence === 0) { if (bitNodeNumber === 5 && Player.skills.intelligence === 0) {
// Artificial Intelligence
Player.skills.intelligence = 1; Player.skills.intelligence = 1;
} }
dialogBoxCreate( dialogBoxCreate(

@ -1,6 +1,6 @@
import { RFAMessage } from "./MessageDefinitions"; import { RFAMessage } from "./MessageDefinitions";
import { RFARequestHandler } from "./MessageHandlers"; import { RFARequestHandler } from "./MessageHandlers";
import { SnackbarEvents } from "../ui/React/Snackbar"; import { SnackbarEvents, ToastVariant } from "../ui/React/Snackbar";
export class Remote { export class Remote {
connection?: WebSocket; connection?: WebSocket;
@ -22,18 +22,18 @@ export class Remote {
this.connection = new WebSocket(address); this.connection = new WebSocket(address);
this.connection.addEventListener("error", (e: Event) => 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("message", handleMessageEvent);
this.connection.addEventListener("open", () => this.connection.addEventListener("open", () =>
SnackbarEvents.emit( SnackbarEvents.emit(
`Remote API connection established on ${this.ipaddr}:${this.port}`, `Remote API connection established on ${this.ipaddr}:${this.port}`,
"success", ToastVariant.SUCCESS,
2000, 2000,
), ),
); );
this.connection.addEventListener("close", () => 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 { loadStockMarket, StockMarket } from "./StockMarket/StockMarket";
import { staneksGift, loadStaneksGift } from "./CotMG/Helper"; import { staneksGift, loadStaneksGift } from "./CotMG/Helper";
import { SnackbarEvents } from "./ui/React/Snackbar"; import { SnackbarEvents, ToastVariant } from "./ui/React/Snackbar";
import * as ExportBonus from "./ExportBonus"; import * as ExportBonus from "./ExportBonus";
@ -120,7 +120,7 @@ class BitburnerSaveObject {
pushGameSaved(saveData); pushGameSaved(saveData);
if (emitToastEvent) { if (emitToastEvent) {
SnackbarEvents.emit("Game Saved!", "info", 2000); SnackbarEvents.emit("Game Saved!", ToastVariant.INFO, 2000);
} }
return resolve(); return resolve();
}) })

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

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

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

@ -86,9 +86,7 @@ export class Server extends BaseServer {
this.numOpenPortsRequired = params.numOpenPortsRequired != null ? params.numOpenPortsRequired : 5; 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 { capDifficulty(): void {
if (this.hackDifficulty < this.minDifficulty) { if (this.hackDifficulty < this.minDifficulty) {
this.hackDifficulty = this.minDifficulty; this.hackDifficulty = this.minDifficulty;
@ -134,25 +132,19 @@ export class Server extends BaseServer {
this.moneyMax *= n; 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 { fortify(amt: number): void {
this.hackDifficulty += amt; this.hackDifficulty += amt;
this.capDifficulty(); 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 { weaken(amt: number): void {
this.hackDifficulty -= amt * BitNodeMultipliers.ServerWeakenRate; this.hackDifficulty -= amt * BitNodeMultipliers.ServerWeakenRate;
this.capDifficulty(); this.capDifficulty();
} }
/** /** Serialize the current object to a JSON save state */
* Serialize the current object to a JSON save state
*/
toJSON(): IReviverValue { toJSON(): IReviverValue {
return Generic_toJSON("Server", this); 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. * These values will be adjusted based on Bitnode multipliers when the Server objects are built out.
*/ */
interface IServerMetadata { interface IServerMetadata {
/** /** When populated, the base security level of the server. */
* When populated, the base security level of the server.
*/
hackDifficulty?: number | IMinMaxRange; hackDifficulty?: number | IMinMaxRange;
/** /** The DNS name of the server. */
* The DNS name of the server.
*/
hostname: string; 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[]; literature?: string[];
/** /**
@ -33,9 +27,7 @@ interface IServerMetadata {
*/ */
maxRamExponent?: number | IMinMaxRange; maxRamExponent?: number | IMinMaxRange;
/** /** How much money the server starts out with. */
* How much money the server starts out with.
*/
moneyAvailable: number | IMinMaxRange; moneyAvailable: number | IMinMaxRange;
/** /**
@ -45,35 +37,23 @@ interface IServerMetadata {
*/ */
networkLayer?: number | IMinMaxRange; 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; numOpenPortsRequired: number;
/** /** The organization that the server belongs to. */
* The organization that the server belongs to.
*/
organizationName: string; 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; requiredHackingSkill: number | IMinMaxRange;
/** /** The growth factor for the server. */
* The growth factor for the server.
*/
serverGrowth?: number | IMinMaxRange; 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; 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[] = [ export const serverMetadata: IServerMetadata[] = [
{ {
hackDifficulty: 99, 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 { export enum PurchaseAugmentationsOrderSetting {
Cost, Cost,
Default, Default,
@ -10,9 +6,7 @@ export enum PurchaseAugmentationsOrderSetting {
Purchasable, Purchasable,
} }
/** /** Allowed values for the 'OwnedAugmentationsOrder' setting */
* Allowed values for the 'OwnedAugmentationsOrder' setting
*/
export enum OwnedAugmentationsOrderSetting { export enum OwnedAugmentationsOrderSetting {
Alphabetically, Alphabetically,
AcquirementTime, AcquirementTime,

@ -23,9 +23,7 @@ import * as React from "react";
import { NetscriptContext } from "../Netscript/APIWrapper"; import { NetscriptContext } from "../Netscript/APIWrapper";
import { helpers } from "../Netscript/NetscriptHelpers"; 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 { interface IOptions {
rerenderFn?: () => void; rerenderFn?: () => void;
suppressDialog?: boolean; suppressDialog?: boolean;

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

@ -51,38 +51,24 @@ function toNumber(n: number | IMinMaxRange): number {
return value; 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 { 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; b: boolean;
/** /** Maximum price of a stock (per share) */
* Maximum price of a stock (per share)
*/
readonly cap: number; readonly cap: number;
/** /** Stocks previous share price */
* Stocks previous share price
*/
lastPrice: number; 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; readonly maxShares: number;
/** /** Maximum volatility */
* Maximum volatility
*/
readonly mv: number; readonly mv: number;
/** /** Name of the company that the stock is for */
* Name of the company that the stock is for
*/
readonly name: string; readonly name: string;
/** /**
@ -97,34 +83,22 @@ export class Stock {
*/ */
otlkMagForecast: number; 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; 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; playerAvgShortPx: number;
/** /** Number of shares the player owns in the LONG position */
* Number of shares the player owns in the LONG position
*/
playerShares: number; playerShares: number;
/** /** Number of shares the player owns in the SHORT position */
* Number of shares the player owns in the SHORT position
*/
playerShortShares: number; playerShortShares: number;
/** /** Stock's share price */
* Stock's share price
*/
price: number; 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; readonly shareTxForMovement: number;
/** /**
@ -139,9 +113,7 @@ export class Stock {
*/ */
readonly spreadPerc: number; readonly spreadPerc: number;
/** /** The stock's ticker symbol */
* The stock's ticker symbol
*/
readonly symbol: string; readonly symbol: string;
/** /**
@ -178,9 +150,7 @@ export class Stock {
this.maxShares = Math.round((this.totalShares * outstandingSharePercentage) / 1e5) * 1e5; 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 { changeForecastForecast(newff: number): void {
this.otlkMagForecast = newff; this.otlkMagForecast = newff;
if (this.otlkMagForecast > 100) { 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 { changePrice(newPrice: number): void {
this.lastPrice = this.price; this.lastPrice = this.price;
this.price = newPrice; this.price = newPrice;
@ -249,30 +217,22 @@ export class Stock {
this.otlkMagForecast = 50 + -1 * diff; 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 { getAbsoluteForecast(): number {
return this.b ? 50 + this.otlkMag : 50 - this.otlkMag; 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 { getAskPrice(): number {
return this.price * (1 + this.spreadPerc / 100); 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 { getBidPrice(): number {
return this.price * (1 - this.spreadPerc / 100); 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 { getForecastIncreaseChance(): number {
const diff = this.otlkMagForecast - this.getAbsoluteForecast(); 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 { toJSON(): IReviverValue {
return Generic_toJSON("Stock", this); 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 { static fromJSON(value: IReviverValue): Stock {
return Generic_fromJSON(Stock, value.data); return Generic_fromJSON(Stock, value.data);
} }

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

@ -1,6 +1,3 @@
/**
* Root React component for the Stock Market UI
*/
import React, { useState, useEffect } from "react"; import React, { useState, useEffect } from "react";
import { InfoAndPurchases } from "./InfoAndPurchases"; import { InfoAndPurchases } from "./InfoAndPurchases";
@ -14,6 +11,7 @@ type IProps = {
stockMarket: IStockMarket; stockMarket: IStockMarket;
}; };
/** Root React component for the Stock Market UI */
export function StockMarketRoot(props: IProps): React.ReactElement { export function StockMarketRoot(props: IProps): React.ReactElement {
const setRerender = useState(false)[1]; const setRerender = useState(false)[1];
function rerender(): void { 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 React, { useState } from "react";
import { StockTickerHeaderText } from "./StockTickerHeaderText"; import { StockTickerHeaderText } from "./StockTickerHeaderText";
@ -46,6 +43,7 @@ type IProps = {
stock: Stock; stock: Stock;
}; };
/** React Component for a single stock ticker in the Stock Market UI */
export function StockTicker(props: IProps): React.ReactElement { export function StockTicker(props: IProps): React.ReactElement {
const [orderType, setOrderType] = useState(SelectorOrderType.Market); const [orderType, setOrderType] = useState(SelectorOrderType.Market);
const [position, setPosition] = useState(PositionTypes.Long); 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 * as React from "react";
import { Order } from "../Order"; import { Order } from "../Order";
@ -17,6 +14,7 @@ type IProps = {
order: Order; order: Order;
}; };
/** React component for displaying a single order in a stock's order book */
export function StockTickerOrder(props: IProps): React.ReactElement { export function StockTickerOrder(props: IProps): React.ReactElement {
function handleCancelOrderClick(): void { function handleCancelOrderClick(): void {
cancelOrder({ order: props.order }); cancelOrder({ order: props.order });

@ -8,9 +8,7 @@
* found in ./DirectoryServerHelpers.ts * found in ./DirectoryServerHelpers.ts
*/ */
/** /** Removes leading forward slash ("/") from a string. */
* Removes leading forward slash ("/") from a string.
*/
export function removeLeadingSlash(s: string): string { export function removeLeadingSlash(s: string): string {
if (s.startsWith("/")) { if (s.startsWith("/")) {
return s.slice(1); return s.slice(1);
@ -210,9 +208,7 @@ export function getFileName(path: string): string {
return t_path.slice(lastSlash + 1); 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 { export function isInRootDirectory(path: string): boolean {
if (!isValidFilePath(path)) { if (!isValidFilePath(path)) {
return false; return false;

@ -52,9 +52,7 @@ export function getSubdirectories(serv: BaseServer, dir: string): string[] {
return res; 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 { export function containsFiles(server: BaseServer, dir: string): boolean {
const dirWithTrailingSlash = dir + (dir.slice(-1) === "/" ? "" : "/"); 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 { Generic_fromJSON, Generic_toJSON, IReviverValue, Reviver } from "./utils/JSONReviver";
import { removeLeadingSlash, isInRootDirectory } from "./Terminal/DirectoryHelpers"; 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 { export class TextFile {
/** /** The full file name. */
* The full file name.
*/
fn: string; fn: string;
/** /** The content of the file. */
* The content of the file.
*/
text: string; text: string;
/** //TODO: Why are we using getter/setter for fn as filename?
* The full file name. /** The full file name. */
*/
get filename(): string { get filename(): string {
return this.fn; return this.fn;
} }
/** /** The full file name. */
* The full file name.
*/
set filename(value: string) { set filename(value: string) {
this.fn = value; this.fn = value;
} }
@ -36,16 +27,12 @@ export class TextFile {
this.text = txt; 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 { append(txt: string): void {
this.text += txt; 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 { download(): void {
const file: Blob = new Blob([this.text], { type: "text/plain" }); const file: Blob = new Blob([this.text], { type: "text/plain" });
const a: HTMLAnchorElement = document.createElement("a"); const a: HTMLAnchorElement = document.createElement("a");
@ -60,37 +47,27 @@ export class TextFile {
}, 0); }, 0);
} }
/** /** Retrieve the content of the file. */
* Retrieve the content of the file.
*/
read(): string { read(): string {
return this.text; 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 { show(): void {
dialogBoxCreate(`${this.fn}<br /><br />${this.text}`); 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 { toJSON(): IReviverValue {
return Generic_toJSON("TextFile", this); 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 { write(txt: string): void {
this.text = txt; this.text = txt;
} }
/** /** Initiatizes a TextFile from a JSON save state. */
* Initiatizes a TextFile from a JSON save state.
*/
static fromJSON(value: IReviverValue): TextFile { static fromJSON(value: IReviverValue): TextFile {
return Generic_fromJSON(TextFile, value.data); return Generic_fromJSON(TextFile, value.data);
} }

@ -10,7 +10,7 @@ import { StyleEditorButton } from "./StyleEditorButton";
import { ThemeEntry } from "./ThemeEntry"; import { ThemeEntry } from "./ThemeEntry";
import { ThemeCollaborate } from "./ThemeCollaborate"; import { ThemeCollaborate } from "./ThemeCollaborate";
import { Modal } from "../../ui/React/Modal"; 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. // Everything dies when the theme gets reloaded, so we'll keep the current scroll to not jump around.
let previousScrollY = 0; let previousScrollY = 0;
@ -49,7 +49,7 @@ export function ThemeBrowser(): React.ReactElement {
UNDO UNDO
</Button> </Button>
</>, </>,
"info", ToastVariant.INFO,
30000, 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 { toJSON(): IReviverValue {
return Generic_toJSON("ClassWork", this); 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 { static fromJSON(value: IReviverValue): ClassWork {
return Generic_fromJSON(ClassWork, value.data); 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 { toJSON(): IReviverValue {
return Generic_toJSON("CompanyWork", this); 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 { static fromJSON(value: IReviverValue): CompanyWork {
return Generic_fromJSON(CompanyWork, value.data); 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 { toJSON(): IReviverValue {
return Generic_toJSON("CreateProgramWork", this); 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 { static fromJSON(value: IReviverValue): CreateProgramWork {
return Generic_fromJSON(CreateProgramWork, value.data); 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 { toJSON(): IReviverValue {
return Generic_toJSON("CrimeWork", this); 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 { static fromJSON(value: IReviverValue): CrimeWork {
return Generic_fromJSON(CrimeWork, value.data); 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 { toJSON(): IReviverValue {
return Generic_toJSON("FactionWork", this); 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 { static fromJSON(value: IReviverValue): FactionWork {
return Generic_fromJSON(FactionWork, value.data); return Generic_fromJSON(FactionWork, value.data);
} }

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