mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2025-03-10 12:22:34 +01:00
Merge branch 'dev' of github.com:danielyxie/bitburner into improvement/filter-helper-func
This commit is contained in:
42
dist/vendor.bundle.js
vendored
42
dist/vendor.bundle.js
vendored
File diff suppressed because one or more lines are too long
2
dist/vendor.bundle.js.map
vendored
2
dist/vendor.bundle.js.map
vendored
File diff suppressed because one or more lines are too long
1
letter_to_fandom.com
Normal file
1
letter_to_fandom.com
Normal file
@ -0,0 +1 @@
|
||||
I want the wiki here https://bitburner.fandom.com/wiki/Bitburner_Wiki taken down please.
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1939
src/Augmentation/AugmentationCreator.tsx
Normal file
1939
src/Augmentation/AugmentationCreator.tsx
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,234 +1,121 @@
|
||||
export const AugmentationNames: {
|
||||
Targeting1: string;
|
||||
Targeting2: string;
|
||||
Targeting3: string;
|
||||
SyntheticHeart: string;
|
||||
SynfibrilMuscle: string;
|
||||
CombatRib1: string;
|
||||
CombatRib2: string;
|
||||
CombatRib3: string;
|
||||
NanofiberWeave: string;
|
||||
SubdermalArmor: string;
|
||||
WiredReflexes: string;
|
||||
GrapheneBoneLacings: string;
|
||||
BionicSpine: string;
|
||||
GrapheneBionicSpine: string;
|
||||
BionicLegs: string;
|
||||
GrapheneBionicLegs: string;
|
||||
SpeechProcessor: string;
|
||||
TITN41Injection: string;
|
||||
EnhancedSocialInteractionImplant: string;
|
||||
BitWire: string;
|
||||
ArtificialBioNeuralNetwork: string;
|
||||
ArtificialSynapticPotentiation: string;
|
||||
EnhancedMyelinSheathing: string;
|
||||
SynapticEnhancement: string;
|
||||
NeuralRetentionEnhancement: string;
|
||||
DataJack: string;
|
||||
ENM: string;
|
||||
ENMCore: string;
|
||||
ENMCoreV2: string;
|
||||
ENMCoreV3: string;
|
||||
ENMAnalyzeEngine: string;
|
||||
ENMDMA: string;
|
||||
Neuralstimulator: string;
|
||||
NeuralAccelerator: string;
|
||||
CranialSignalProcessorsG1: string;
|
||||
CranialSignalProcessorsG2: string;
|
||||
CranialSignalProcessorsG3: string;
|
||||
CranialSignalProcessorsG4: string;
|
||||
CranialSignalProcessorsG5: string;
|
||||
NeuronalDensification: string;
|
||||
NeuroreceptorManager: string;
|
||||
NuoptimalInjectorImplant: string;
|
||||
SpeechEnhancement: string;
|
||||
FocusWire: string;
|
||||
PCDNI: string;
|
||||
PCDNIOptimizer: string;
|
||||
PCDNINeuralNetwork: string;
|
||||
PCMatrix: string;
|
||||
ADRPheromone1: string;
|
||||
ADRPheromone2: string;
|
||||
ShadowsSimulacrum: string;
|
||||
HacknetNodeCPUUpload: string;
|
||||
HacknetNodeCacheUpload: string;
|
||||
HacknetNodeNICUpload: string;
|
||||
HacknetNodeKernelDNI: string;
|
||||
HacknetNodeCoreDNI: string;
|
||||
NeuroFluxGovernor: string;
|
||||
Neurotrainer1: string;
|
||||
Neurotrainer2: string;
|
||||
Neurotrainer3: string;
|
||||
Hypersight: string;
|
||||
LuminCloaking1: string;
|
||||
LuminCloaking2: string;
|
||||
HemoRecirculator: string;
|
||||
SmartSonar: string;
|
||||
PowerRecirculator: string;
|
||||
QLink: string;
|
||||
TheRedPill: string;
|
||||
SPTN97: string;
|
||||
HiveMind: string;
|
||||
CordiARCReactor: string;
|
||||
SmartJaw: string;
|
||||
Neotra: string;
|
||||
Xanipher: string;
|
||||
nextSENS: string;
|
||||
OmniTekInfoLoad: string;
|
||||
PhotosyntheticCells: string;
|
||||
Neurolink: string;
|
||||
TheBlackHand: string;
|
||||
UnstableCircadianModulator: string;
|
||||
CRTX42AA: string;
|
||||
Neuregen: string;
|
||||
CashRoot: string;
|
||||
NutriGen: string;
|
||||
INFRARet: string;
|
||||
DermaForce: string;
|
||||
GrapheneBrachiBlades: string;
|
||||
GrapheneBionicArms: string;
|
||||
BrachiBlades: string;
|
||||
BionicArms: string;
|
||||
SNA: string;
|
||||
HydroflameLeftArm: string;
|
||||
EsperEyewear: string;
|
||||
EMS4Recombination: string;
|
||||
OrionShoulder: string;
|
||||
HyperionV1: string;
|
||||
HyperionV2: string;
|
||||
GolemSerum: string;
|
||||
VangelisVirus: string;
|
||||
VangelisVirus3: string;
|
||||
INTERLINKED: string;
|
||||
BladeRunner: string;
|
||||
BladeArmor: string;
|
||||
BladeArmorPowerCells: string;
|
||||
BladeArmorEnergyShielding: string;
|
||||
BladeArmorUnibeam: string;
|
||||
BladeArmorOmnibeam: string;
|
||||
BladeArmorIPU: string;
|
||||
BladesSimulacrum: string;
|
||||
StaneksGift1: string;
|
||||
StaneksGift2: string;
|
||||
StaneksGift3: string;
|
||||
} = {
|
||||
Targeting1: "Augmented Targeting I",
|
||||
Targeting2: "Augmented Targeting II",
|
||||
Targeting3: "Augmented Targeting III",
|
||||
SyntheticHeart: "Synthetic Heart",
|
||||
SynfibrilMuscle: "Synfibril Muscle",
|
||||
CombatRib1: "Combat Rib I",
|
||||
CombatRib2: "Combat Rib II",
|
||||
CombatRib3: "Combat Rib III",
|
||||
NanofiberWeave: "Nanofiber Weave",
|
||||
SubdermalArmor: "NEMEAN Subdermal Weave",
|
||||
WiredReflexes: "Wired Reflexes",
|
||||
GrapheneBoneLacings: "Graphene Bone Lacings",
|
||||
BionicSpine: "Bionic Spine",
|
||||
GrapheneBionicSpine: "Graphene Bionic Spine Upgrade",
|
||||
BionicLegs: "Bionic Legs",
|
||||
GrapheneBionicLegs: "Graphene Bionic Legs Upgrade",
|
||||
SpeechProcessor: "Speech Processor Implant",
|
||||
TITN41Injection: "TITN-41 Gene-Modification Injection",
|
||||
EnhancedSocialInteractionImplant: "Enhanced Social Interaction Implant",
|
||||
BitWire: "BitWire",
|
||||
ArtificialBioNeuralNetwork: "Artificial Bio-neural Network Implant",
|
||||
ArtificialSynapticPotentiation: "Artificial Synaptic Potentiation",
|
||||
EnhancedMyelinSheathing: "Enhanced Myelin Sheathing",
|
||||
SynapticEnhancement: "Synaptic Enhancement Implant",
|
||||
NeuralRetentionEnhancement: "Neural-Retention Enhancement",
|
||||
DataJack: "DataJack",
|
||||
ENM: "Embedded Netburner Module",
|
||||
ENMCore: "Embedded Netburner Module Core Implant",
|
||||
ENMCoreV2: "Embedded Netburner Module Core V2 Upgrade",
|
||||
ENMCoreV3: "Embedded Netburner Module Core V3 Upgrade",
|
||||
ENMAnalyzeEngine: "Embedded Netburner Module Analyze Engine",
|
||||
ENMDMA: "Embedded Netburner Module Direct Memory Access Upgrade",
|
||||
Neuralstimulator: "Neuralstimulator",
|
||||
NeuralAccelerator: "Neural Accelerator",
|
||||
CranialSignalProcessorsG1: "Cranial Signal Processors - Gen I",
|
||||
CranialSignalProcessorsG2: "Cranial Signal Processors - Gen II",
|
||||
CranialSignalProcessorsG3: "Cranial Signal Processors - Gen III",
|
||||
CranialSignalProcessorsG4: "Cranial Signal Processors - Gen IV",
|
||||
CranialSignalProcessorsG5: "Cranial Signal Processors - Gen V",
|
||||
NeuronalDensification: "Neuronal Densification",
|
||||
NeuroreceptorManager: "Neuroreceptor Management Implant",
|
||||
NuoptimalInjectorImplant: "Nuoptimal Nootropic Injector Implant",
|
||||
SpeechEnhancement: "Speech Enhancement",
|
||||
FocusWire: "FocusWire",
|
||||
PCDNI: "PC Direct-Neural Interface",
|
||||
PCDNIOptimizer: "PC Direct-Neural Interface Optimization Submodule",
|
||||
PCDNINeuralNetwork: "PC Direct-Neural Interface NeuroNet Injector",
|
||||
PCMatrix: "PCMatrix",
|
||||
ADRPheromone1: "ADR-V1 Pheromone Gene",
|
||||
ADRPheromone2: "ADR-V2 Pheromone Gene",
|
||||
ShadowsSimulacrum: "The Shadow's Simulacrum",
|
||||
HacknetNodeCPUUpload: "Hacknet Node CPU Architecture Neural-Upload",
|
||||
HacknetNodeCacheUpload: "Hacknet Node Cache Architecture Neural-Upload",
|
||||
HacknetNodeNICUpload: "Hacknet Node NIC Architecture Neural-Upload",
|
||||
HacknetNodeKernelDNI: "Hacknet Node Kernel Direct-Neural Interface",
|
||||
HacknetNodeCoreDNI: "Hacknet Node Core Direct-Neural Interface",
|
||||
NeuroFluxGovernor: "NeuroFlux Governor",
|
||||
Neurotrainer1: "Neurotrainer I",
|
||||
Neurotrainer2: "Neurotrainer II",
|
||||
Neurotrainer3: "Neurotrainer III",
|
||||
Hypersight: "HyperSight Corneal Implant",
|
||||
LuminCloaking1: "LuminCloaking-V1 Skin Implant",
|
||||
LuminCloaking2: "LuminCloaking-V2 Skin Implant",
|
||||
HemoRecirculator: "HemoRecirculator",
|
||||
SmartSonar: "SmartSonar Implant",
|
||||
PowerRecirculator: "Power Recirculation Core",
|
||||
QLink: "QLink",
|
||||
TheRedPill: "The Red Pill",
|
||||
SPTN97: "SPTN-97 Gene Modification",
|
||||
HiveMind: "ECorp HVMind Implant",
|
||||
CordiARCReactor: "CordiARC Fusion Reactor",
|
||||
SmartJaw: "SmartJaw",
|
||||
Neotra: "Neotra",
|
||||
Xanipher: "Xanipher",
|
||||
nextSENS: "nextSENS Gene Modification",
|
||||
OmniTekInfoLoad: "OmniTek InfoLoad",
|
||||
PhotosyntheticCells: "Photosynthetic Cells",
|
||||
Neurolink: "BitRunners Neurolink",
|
||||
TheBlackHand: "The Black Hand",
|
||||
UnstableCircadianModulator: "Unstable Circadian Modulator",
|
||||
CRTX42AA: "CRTX42-AA Gene Modification",
|
||||
Neuregen: "Neuregen Gene Modification",
|
||||
CashRoot: "CashRoot Starter Kit",
|
||||
NutriGen: "NutriGen Implant",
|
||||
INFRARet: "INFRARET Enhancement",
|
||||
DermaForce: "DermaForce Particle Barrier",
|
||||
GrapheneBrachiBlades: "Graphene BrachiBlades Upgrade",
|
||||
GrapheneBionicArms: "Graphene Bionic Arms Upgrade",
|
||||
BrachiBlades: "BrachiBlades",
|
||||
BionicArms: "Bionic Arms",
|
||||
SNA: "Social Negotiation Assistant (S.N.A)",
|
||||
HydroflameLeftArm: "Hydroflame Left Arm",
|
||||
EsperEyewear: "EsperTech Bladeburner Eyewear",
|
||||
EMS4Recombination: "EMS-4 Recombination",
|
||||
OrionShoulder: "ORION-MKIV Shoulder",
|
||||
HyperionV1: "Hyperion Plasma Cannon V1",
|
||||
HyperionV2: "Hyperion Plasma Cannon V2",
|
||||
GolemSerum: "GOLEM Serum",
|
||||
VangelisVirus: "Vangelis Virus",
|
||||
VangelisVirus3: "Vangelis Virus 3.0",
|
||||
INTERLINKED: "I.N.T.E.R.L.I.N.K.E.D",
|
||||
BladeRunner: "Blade's Runners",
|
||||
BladeArmor: "BLADE-51b Tesla Armor",
|
||||
BladeArmorPowerCells: "BLADE-51b Tesla Armor: Power Cells Upgrade",
|
||||
BladeArmorEnergyShielding: "BLADE-51b Tesla Armor: Energy Shielding Upgrade",
|
||||
BladeArmorUnibeam: "BLADE-51b Tesla Armor: Unibeam Upgrade",
|
||||
BladeArmorOmnibeam: "BLADE-51b Tesla Armor: Omnibeam Upgrade",
|
||||
BladeArmorIPU: "BLADE-51b Tesla Armor: IPU Upgrade",
|
||||
BladesSimulacrum: "The Blade's Simulacrum",
|
||||
export enum AugmentationNames {
|
||||
Targeting1 = "Augmented Targeting I",
|
||||
Targeting2 = "Augmented Targeting II",
|
||||
Targeting3 = "Augmented Targeting III",
|
||||
SyntheticHeart = "Synthetic Heart",
|
||||
SynfibrilMuscle = "Synfibril Muscle",
|
||||
CombatRib1 = "Combat Rib I",
|
||||
CombatRib2 = "Combat Rib II",
|
||||
CombatRib3 = "Combat Rib III",
|
||||
NanofiberWeave = "Nanofiber Weave",
|
||||
SubdermalArmor = "NEMEAN Subdermal Weave",
|
||||
WiredReflexes = "Wired Reflexes",
|
||||
GrapheneBoneLacings = "Graphene Bone Lacings",
|
||||
BionicSpine = "Bionic Spine",
|
||||
GrapheneBionicSpine = "Graphene Bionic Spine Upgrade",
|
||||
BionicLegs = "Bionic Legs",
|
||||
GrapheneBionicLegs = "Graphene Bionic Legs Upgrade",
|
||||
SpeechProcessor = "Speech Processor Implant",
|
||||
TITN41Injection = "TITN-41 Gene-Modification Injection",
|
||||
EnhancedSocialInteractionImplant = "Enhanced Social Interaction Implant",
|
||||
BitWire = "BitWire",
|
||||
ArtificialBioNeuralNetwork = "Artificial Bio-neural Network Implant",
|
||||
ArtificialSynapticPotentiation = "Artificial Synaptic Potentiation",
|
||||
EnhancedMyelinSheathing = "Enhanced Myelin Sheathing",
|
||||
SynapticEnhancement = "Synaptic Enhancement Implant",
|
||||
NeuralRetentionEnhancement = "Neural-Retention Enhancement",
|
||||
DataJack = "DataJack",
|
||||
ENM = "Embedded Netburner Module",
|
||||
ENMCore = "Embedded Netburner Module Core Implant",
|
||||
ENMCoreV2 = "Embedded Netburner Module Core V2 Upgrade",
|
||||
ENMCoreV3 = "Embedded Netburner Module Core V3 Upgrade",
|
||||
ENMAnalyzeEngine = "Embedded Netburner Module Analyze Engine",
|
||||
ENMDMA = "Embedded Netburner Module Direct Memory Access Upgrade",
|
||||
Neuralstimulator = "Neuralstimulator",
|
||||
NeuralAccelerator = "Neural Accelerator",
|
||||
CranialSignalProcessorsG1 = "Cranial Signal Processors - Gen I",
|
||||
CranialSignalProcessorsG2 = "Cranial Signal Processors - Gen II",
|
||||
CranialSignalProcessorsG3 = "Cranial Signal Processors - Gen III",
|
||||
CranialSignalProcessorsG4 = "Cranial Signal Processors - Gen IV",
|
||||
CranialSignalProcessorsG5 = "Cranial Signal Processors - Gen V",
|
||||
NeuronalDensification = "Neuronal Densification",
|
||||
NeuroreceptorManager = "Neuroreceptor Management Implant",
|
||||
NuoptimalInjectorImplant = "Nuoptimal Nootropic Injector Implant",
|
||||
SpeechEnhancement = "Speech Enhancement",
|
||||
FocusWire = "FocusWire",
|
||||
PCDNI = "PC Direct-Neural Interface",
|
||||
PCDNIOptimizer = "PC Direct-Neural Interface Optimization Submodule",
|
||||
PCDNINeuralNetwork = "PC Direct-Neural Interface NeuroNet Injector",
|
||||
PCMatrix = "PCMatrix",
|
||||
ADRPheromone1 = "ADR-V1 Pheromone Gene",
|
||||
ADRPheromone2 = "ADR-V2 Pheromone Gene",
|
||||
ShadowsSimulacrum = "The Shadow's Simulacrum",
|
||||
HacknetNodeCPUUpload = "Hacknet Node CPU Architecture Neural-Upload",
|
||||
HacknetNodeCacheUpload = "Hacknet Node Cache Architecture Neural-Upload",
|
||||
HacknetNodeNICUpload = "Hacknet Node NIC Architecture Neural-Upload",
|
||||
HacknetNodeKernelDNI = "Hacknet Node Kernel Direct-Neural Interface",
|
||||
HacknetNodeCoreDNI = "Hacknet Node Core Direct-Neural Interface",
|
||||
NeuroFluxGovernor = "NeuroFlux Governor",
|
||||
Neurotrainer1 = "Neurotrainer I",
|
||||
Neurotrainer2 = "Neurotrainer II",
|
||||
Neurotrainer3 = "Neurotrainer III",
|
||||
Hypersight = "HyperSight Corneal Implant",
|
||||
LuminCloaking1 = "LuminCloaking-V1 Skin Implant",
|
||||
LuminCloaking2 = "LuminCloaking-V2 Skin Implant",
|
||||
HemoRecirculator = "HemoRecirculator",
|
||||
SmartSonar = "SmartSonar Implant",
|
||||
PowerRecirculator = "Power Recirculation Core",
|
||||
QLink = "QLink",
|
||||
TheRedPill = "The Red Pill",
|
||||
SPTN97 = "SPTN-97 Gene Modification",
|
||||
HiveMind = "ECorp HVMind Implant",
|
||||
CordiARCReactor = "CordiARC Fusion Reactor",
|
||||
SmartJaw = "SmartJaw",
|
||||
Neotra = "Neotra",
|
||||
Xanipher = "Xanipher",
|
||||
nextSENS = "nextSENS Gene Modification",
|
||||
OmniTekInfoLoad = "OmniTek InfoLoad",
|
||||
PhotosyntheticCells = "Photosynthetic Cells",
|
||||
Neurolink = "BitRunners Neurolink",
|
||||
TheBlackHand = "The Black Hand",
|
||||
UnstableCircadianModulator = "Unstable Circadian Modulator",
|
||||
CRTX42AA = "CRTX42-AA Gene Modification",
|
||||
Neuregen = "Neuregen Gene Modification",
|
||||
CashRoot = "CashRoot Starter Kit",
|
||||
NutriGen = "NutriGen Implant",
|
||||
INFRARet = "INFRARET Enhancement",
|
||||
DermaForce = "DermaForce Particle Barrier",
|
||||
GrapheneBrachiBlades = "Graphene BrachiBlades Upgrade",
|
||||
GrapheneBionicArms = "Graphene Bionic Arms Upgrade",
|
||||
BrachiBlades = "BrachiBlades",
|
||||
BionicArms = "Bionic Arms",
|
||||
SNA = "Social Negotiation Assistant (S.N.A)",
|
||||
HydroflameLeftArm = "Hydroflame Left Arm",
|
||||
EsperEyewear = "EsperTech Bladeburner Eyewear",
|
||||
EMS4Recombination = "EMS-4 Recombination",
|
||||
OrionShoulder = "ORION-MKIV Shoulder",
|
||||
HyperionV1 = "Hyperion Plasma Cannon V1",
|
||||
HyperionV2 = "Hyperion Plasma Cannon V2",
|
||||
GolemSerum = "GOLEM Serum",
|
||||
VangelisVirus = "Vangelis Virus",
|
||||
VangelisVirus3 = "Vangelis Virus 3.0",
|
||||
INTERLINKED = "I.N.T.E.R.L.I.N.K.E.D",
|
||||
BladeRunner = "Blade's Runners",
|
||||
BladeArmor = "BLADE-51b Tesla Armor",
|
||||
BladeArmorPowerCells = "BLADE-51b Tesla Armor: Power Cells Upgrade",
|
||||
BladeArmorEnergyShielding = "BLADE-51b Tesla Armor: Energy Shielding Upgrade",
|
||||
BladeArmorUnibeam = "BLADE-51b Tesla Armor: Unibeam Upgrade",
|
||||
BladeArmorOmnibeam = "BLADE-51b Tesla Armor: Omnibeam Upgrade",
|
||||
BladeArmorIPU = "BLADE-51b Tesla Armor: IPU Upgrade",
|
||||
BladesSimulacrum = "The Blade's Simulacrum",
|
||||
|
||||
StaneksGift1: "Stanek's Gift - Genesis",
|
||||
StaneksGift2: "Stanek's Gift - Awakening",
|
||||
StaneksGift3: "Stanek's Gift - Serenity",
|
||||
StaneksGift1 = "Stanek's Gift - Genesis",
|
||||
StaneksGift2 = "Stanek's Gift - Awakening",
|
||||
StaneksGift3 = "Stanek's Gift - Serenity",
|
||||
|
||||
//Wasteland Augs
|
||||
//PepBoy: "P.E.P-Boy", Plasma Energy Projection System
|
||||
//PepBoyForceField Generates plasma force fields
|
||||
//PepBoyBlasts Generate high density plasma concussive blasts
|
||||
//PepBoyDataStorage STore more data on pep boy,
|
||||
};
|
||||
}
|
||||
|
@ -232,6 +232,11 @@ interface IBitNodeMultipliers {
|
||||
*/
|
||||
WorldDaemonDifficulty: number;
|
||||
|
||||
/**
|
||||
* Influences corporation dividends.
|
||||
*/
|
||||
CorporationSoftCap: number;
|
||||
|
||||
// Index signature
|
||||
[key: string]: number;
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ import { joinFaction } from "../Faction/FactionHelpers";
|
||||
import { WorkerScript } from "../Netscript/WorkerScript";
|
||||
import { FactionNames } from "../Faction/data/FactionNames";
|
||||
import { BlackOperationNames } from "./data/BlackOperationNames";
|
||||
import { KEY } from "../utils/helpers/keyCodes";
|
||||
|
||||
interface BlackOpsAttempt {
|
||||
error?: string;
|
||||
@ -793,7 +794,7 @@ export class Bladeburner implements IBladeburner {
|
||||
if (c === '"') {
|
||||
// Double quotes
|
||||
const endQuote = command.indexOf('"', i + 1);
|
||||
if (endQuote !== -1 && (endQuote === command.length - 1 || command.charAt(endQuote + 1) === " ")) {
|
||||
if (endQuote !== -1 && (endQuote === command.length - 1 || command.charAt(endQuote + 1) === KEY.SPACE)) {
|
||||
args.push(command.substr(i + 1, endQuote - i - 1));
|
||||
if (endQuote === command.length - 1) {
|
||||
start = i = endQuote + 1;
|
||||
@ -805,7 +806,7 @@ export class Bladeburner implements IBladeburner {
|
||||
} else if (c === "'") {
|
||||
// Single quotes, same thing as above
|
||||
const endQuote = command.indexOf("'", i + 1);
|
||||
if (endQuote !== -1 && (endQuote === command.length - 1 || command.charAt(endQuote + 1) === " ")) {
|
||||
if (endQuote !== -1 && (endQuote === command.length - 1 || command.charAt(endQuote + 1) === KEY.SPACE)) {
|
||||
args.push(command.substr(i + 1, endQuote - i - 1));
|
||||
if (endQuote === command.length - 1) {
|
||||
start = i = endQuote + 1;
|
||||
@ -814,7 +815,7 @@ export class Bladeburner implements IBladeburner {
|
||||
}
|
||||
continue;
|
||||
}
|
||||
} else if (c === " ") {
|
||||
} else if (c === KEY.SPACE) {
|
||||
args.push(command.substr(start, i - start));
|
||||
start = i + 1;
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ export function Console(props: IProps): React.ReactElement {
|
||||
|
||||
const consoleHistory = props.bladeburner.consoleHistory;
|
||||
|
||||
if (event.key === KEY.UPARROW) {
|
||||
if (event.key === KEY.UP_ARROW) {
|
||||
// up
|
||||
let i = consoleHistoryIndex;
|
||||
const len = consoleHistory.length;
|
||||
@ -109,7 +109,7 @@ export function Console(props: IProps): React.ReactElement {
|
||||
setCommand(prevCommand);
|
||||
}
|
||||
|
||||
if (event.key === KEY.DOWNARROW) {
|
||||
if (event.key === KEY.DOWN_ARROW) {
|
||||
const i = consoleHistoryIndex;
|
||||
const len = consoleHistory.length;
|
||||
|
||||
@ -140,14 +140,16 @@ export function Console(props: IProps): React.ReactElement {
|
||||
|
||||
return (
|
||||
<Paper sx={{ p: 1 }}>
|
||||
<Box sx={{
|
||||
height: '60vh',
|
||||
paddingBottom: '8px',
|
||||
display: 'flex',
|
||||
alignItems: 'stretch',
|
||||
whiteSpace: 'pre-wrap',
|
||||
}}
|
||||
onClick={handleClick}>
|
||||
<Box
|
||||
sx={{
|
||||
height: "60vh",
|
||||
paddingBottom: "8px",
|
||||
display: "flex",
|
||||
alignItems: "stretch",
|
||||
whiteSpace: "pre-wrap",
|
||||
}}
|
||||
onClick={handleClick}
|
||||
>
|
||||
<Box>
|
||||
<Logs entries={[...props.bladeburner.consoleLogs]} />
|
||||
</Box>
|
||||
@ -195,9 +197,7 @@ function Logs({ entries }: ILogProps): React.ReactElement {
|
||||
|
||||
return (
|
||||
<List sx={{ height: "100%", overflow: "auto", p: 1 }} ref={scrollHook}>
|
||||
{entries && entries.map((log: any, i: number) => (
|
||||
<Line key={i} content={log} />
|
||||
))}
|
||||
{entries && entries.map((log: any, i: number) => <Line key={i} content={log} />)}
|
||||
</List>
|
||||
);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { IPlayer } from 'src/PersonObjects/IPlayer';
|
||||
import { MaterialSizes } from './MaterialSizes';
|
||||
import { IPlayer } from "src/PersonObjects/IPlayer";
|
||||
import { MaterialSizes } from "./MaterialSizes";
|
||||
import { ICorporation } from "./ICorporation";
|
||||
import { IIndustry } from "./IIndustry";
|
||||
import { IndustryStartingCosts, IndustryResearchTrees } from "./IndustryData";
|
||||
@ -17,6 +17,7 @@ import { Employee } from "./Employee";
|
||||
import { IndustryUpgrades } from "./IndustryUpgrades";
|
||||
import { ResearchMap } from "./ResearchMap";
|
||||
import { isRelevantMaterial } from "./ui/Helpers";
|
||||
import { CityName } from "src/Locations/data/CityNames";
|
||||
|
||||
export function NewIndustry(corporation: ICorporation, industry: string, name: string): void {
|
||||
if (corporation.divisions.find(({ type }) => industry == type))
|
||||
@ -64,7 +65,7 @@ export function UnlockUpgrade(corporation: ICorporation, upgrade: CorporationUnl
|
||||
if (corporation.funds < upgrade[1]) {
|
||||
throw new Error("Insufficient funds");
|
||||
}
|
||||
if(corporation.unlockUpgrades[upgrade[0]] === 1){
|
||||
if (corporation.unlockUpgrades[upgrade[0]] === 1) {
|
||||
throw new Error(`You have already unlocked the ${upgrade[2]} upgrade!`);
|
||||
}
|
||||
corporation.unlock(upgrade);
|
||||
@ -222,15 +223,15 @@ export function SellProduct(product: Product, city: string, amt: string, price:
|
||||
product.sllman[city][1] = "";
|
||||
}
|
||||
} else if (all) {
|
||||
for (let i = 0; i < cities.length; ++i) {
|
||||
const tempCity = cities[i];
|
||||
product.sllman[tempCity][0] = true;
|
||||
product.sllman[tempCity][1] = qty;
|
||||
}
|
||||
} else {
|
||||
product.sllman[city][0] = true;
|
||||
product.sllman[city][1] = qty;
|
||||
for (let i = 0; i < cities.length; ++i) {
|
||||
const tempCity = cities[i];
|
||||
product.sllman[tempCity][0] = true;
|
||||
product.sllman[tempCity][1] = qty;
|
||||
}
|
||||
} else {
|
||||
product.sllman[city][0] = true;
|
||||
product.sllman[city][1] = qty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -257,7 +258,7 @@ export function BulkPurchase(corp: ICorporation, warehouse: Warehouse, material:
|
||||
if (isNaN(amt) || amt < 0) {
|
||||
throw new Error(`Invalid input amount`);
|
||||
}
|
||||
if (amt * matSize > maxAmount) {
|
||||
if (amt * matSize <= maxAmount) {
|
||||
throw new Error(`You do not have enough warehouse size to fit this purchase`);
|
||||
}
|
||||
const cost = amt * material.bCost;
|
||||
@ -295,7 +296,7 @@ export function BuyBackShares(corporation: ICorporation, player: IPlayer, numSha
|
||||
if (numShares > corporation.issuedShares) throw new Error("You don't have that many shares to buy!");
|
||||
if (!corporation.public) throw new Error("You haven't gone public!");
|
||||
const buybackPrice = corporation.sharePrice * 1.1;
|
||||
if (player.money < (numShares * buybackPrice)) throw new Error("You cant afford that many shares!");
|
||||
if (player.money < numShares * buybackPrice) throw new Error("You cant afford that many shares!");
|
||||
corporation.numShares += numShares;
|
||||
corporation.issuedShares -= numShares;
|
||||
player.loseMoney(numShares * buybackPrice, "corporation");
|
||||
@ -404,13 +405,13 @@ export function MakeProduct(
|
||||
if (corp.funds < designInvest + marketingInvest) {
|
||||
throw new Error("You don't have enough company funds to make this large of an investment");
|
||||
}
|
||||
let maxProducts = 3
|
||||
let maxProducts = 3;
|
||||
if (division.hasResearch("uPgrade: Capacity.II")) {
|
||||
maxProducts = 5
|
||||
maxProducts = 5;
|
||||
} else if (division.hasResearch("uPgrade: Capacity.I")) {
|
||||
maxProducts = 4
|
||||
maxProducts = 4;
|
||||
}
|
||||
const products = division.products
|
||||
const products = division.products;
|
||||
if (Object.keys(products).length >= maxProducts) {
|
||||
throw new Error(`You are already at the max products (${maxProducts}) for division: ${division.name}!`);
|
||||
}
|
||||
@ -445,7 +446,13 @@ export function Research(division: IIndustry, researchName: string): void {
|
||||
division.researched[researchName] = true;
|
||||
}
|
||||
|
||||
export function ExportMaterial(divisionName: string, cityName: string, material: Material, amt: string, division?: Industry): void {
|
||||
export function ExportMaterial(
|
||||
divisionName: string,
|
||||
cityName: string,
|
||||
material: Material,
|
||||
amt: string,
|
||||
division?: Industry,
|
||||
): void {
|
||||
// Sanitize amt
|
||||
let sanitizedAmt = amt.replace(/\s+/g, "").toUpperCase();
|
||||
sanitizedAmt = sanitizedAmt.replace(/[^-()\d/*+.MAX]/g, "");
|
||||
|
@ -23,7 +23,7 @@ import Typography from "@mui/material/Typography";
|
||||
import Tooltip from "@mui/material/Tooltip";
|
||||
import TableBody from "@mui/material/TableBody";
|
||||
import Table from "@mui/material/Table";
|
||||
import { CONSTANTS } from "../../Constants";
|
||||
import { getGenericAugmentationPriceMultiplier } from "../../Augmentation/AugmentationHelpers";
|
||||
|
||||
type IProps = {
|
||||
faction: Faction;
|
||||
@ -166,10 +166,7 @@ export function AugmentationsPage(props: IProps): React.ReactElement {
|
||||
</>
|
||||
);
|
||||
}
|
||||
const mult = Math.pow(
|
||||
CONSTANTS.MultipleAugMultiplier * [1, 0.96, 0.94, 0.93][player.sourceFileLvl(11)],
|
||||
player.queuedAugmentations.length,
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Button onClick={props.routeToMainPage}>Back</Button>
|
||||
@ -190,7 +187,9 @@ export function AugmentationsPage(props: IProps): React.ReactElement {
|
||||
</Typography>
|
||||
}
|
||||
>
|
||||
<Typography>Price multiplier: x {numeralWrapper.formatMultiplier(mult)}</Typography>
|
||||
<Typography>
|
||||
Price multiplier: x {numeralWrapper.formatMultiplier(getGenericAugmentationPriceMultiplier())}
|
||||
</Typography>
|
||||
</Tooltip>
|
||||
</Box>
|
||||
<Button onClick={() => switchSortOrder(PurchaseAugmentationsOrderSetting.Cost)}>Sort by Cost</Button>
|
||||
|
@ -7,6 +7,7 @@ import { random } from "../utils";
|
||||
import { interpolate } from "./Difficulty";
|
||||
import { BlinkingCursor } from "./BlinkingCursor";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import { KEY } from "../../utils/helpers/keyCodes";
|
||||
|
||||
interface Difficulty {
|
||||
[key: string]: number;
|
||||
@ -36,7 +37,7 @@ export function BackwardGame(props: IMinigameProps): React.ReactElement {
|
||||
|
||||
function press(this: Document, event: KeyboardEvent): void {
|
||||
event.preventDefault();
|
||||
if (event.key === "Backspace") return;
|
||||
if (event.key === KEY.BACKSPACE) return;
|
||||
const nextGuess = guess + event.key.toUpperCase();
|
||||
if (!answer.startsWith(nextGuess)) props.onFailure();
|
||||
else if (answer === nextGuess) props.onSuccess();
|
||||
|
@ -7,6 +7,7 @@ import { random } from "../utils";
|
||||
import { interpolate } from "./Difficulty";
|
||||
import { BlinkingCursor } from "./BlinkingCursor";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import { KEY } from "../../utils/helpers/keyCodes";
|
||||
|
||||
interface Difficulty {
|
||||
[key: string]: number;
|
||||
@ -29,28 +30,29 @@ const difficulties: {
|
||||
|
||||
function generateLeftSide(difficulty: Difficulty): string {
|
||||
let str = "";
|
||||
const options = [KEY.OPEN_BRACKET, KEY.LESS_THAN, KEY.OPEN_PARENTHESIS, KEY.OPEN_BRACE];
|
||||
const length = random(difficulty.min, difficulty.max);
|
||||
for (let i = 0; i < length; i++) {
|
||||
str += ["[", "<", "(", "{"][Math.floor(Math.random() * 4)];
|
||||
str += options[Math.floor(Math.random() * 4)];
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
function getChar(event: KeyboardEvent): string {
|
||||
if (event.key === ")") return ")";
|
||||
if (event.key === "]") return "]";
|
||||
if (event.key === "}") return "}";
|
||||
if (event.key === ">") return ">";
|
||||
if (event.key === KEY.CLOSE_PARENTHESIS) return KEY.CLOSE_PARENTHESIS;
|
||||
if (event.key === KEY.CLOSE_BRACKET) return KEY.CLOSE_BRACKET;
|
||||
if (event.key === KEY.CLOSE_BRACE) return KEY.CLOSE_BRACE;
|
||||
if (event.key === KEY.GREATER_THAN) return KEY.GREATER_THAN;
|
||||
return "";
|
||||
}
|
||||
|
||||
function match(left: string, right: string): boolean {
|
||||
return (
|
||||
(left === "[" && right === "]") ||
|
||||
(left === "<" && right === ">") ||
|
||||
(left === "(" && right === ")") ||
|
||||
(left === "{" && right === "}")
|
||||
(left === KEY.OPEN_BRACKET && right === KEY.CLOSE_BRACKET) ||
|
||||
(left === KEY.LESS_THAN && right === KEY.GREATER_THAN) ||
|
||||
(left === KEY.OPEN_PARENTHESIS && right === KEY.CLOSE_PARENTHESIS) ||
|
||||
(left === KEY.OPEN_BRACE && right === KEY.CLOSE_BRACE)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,8 @@ import { KeyHandler } from "./KeyHandler";
|
||||
import { GameTimer } from "./GameTimer";
|
||||
import { interpolate } from "./Difficulty";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import { KEY } from "../../utils/helpers/keyCodes";
|
||||
import { downArrowSymbol, upArrowSymbol } from "../utils";
|
||||
|
||||
interface Difficulty {
|
||||
[key: string]: number;
|
||||
@ -34,15 +36,15 @@ export function BribeGame(props: IMinigameProps): React.ReactElement {
|
||||
function press(this: Document, event: KeyboardEvent): void {
|
||||
event.preventDefault();
|
||||
const k = event.key;
|
||||
if (k === " ") {
|
||||
if (k === KEY.SPACE) {
|
||||
if (positive.includes(choices[index])) props.onSuccess();
|
||||
else props.onFailure();
|
||||
return;
|
||||
}
|
||||
|
||||
let newIndex = index;
|
||||
if (["ArrowUp", "w", "ArrowRight", "d"].includes(k)) newIndex++;
|
||||
if (["ArrowDown", "s", "ArrowLeft", "a"].includes(k)) newIndex--;
|
||||
if ([KEY.UP_ARROW, KEY.W, KEY.RIGHT_ARROW, KEY.D].map((key) => key as string).includes(k)) newIndex++;
|
||||
if ([KEY.DOWN_ARROW, KEY.S, KEY.LEFT_ARROW, KEY.A].map((key) => key as string).includes(k)) newIndex--;
|
||||
while (newIndex < 0) newIndex += choices.length;
|
||||
while (newIndex > choices.length - 1) newIndex -= choices.length;
|
||||
setIndex(newIndex);
|
||||
@ -57,13 +59,13 @@ export function BribeGame(props: IMinigameProps): React.ReactElement {
|
||||
</Grid>
|
||||
<Grid item xs={6}>
|
||||
<Typography variant="h5" color="primary">
|
||||
↑
|
||||
{upArrowSymbol}
|
||||
</Typography>
|
||||
<Typography variant="h5" color="primary">
|
||||
{choices[index]}
|
||||
</Typography>
|
||||
<Typography variant="h5" color="primary">
|
||||
↓
|
||||
{downArrowSymbol}
|
||||
</Typography>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
@ -3,7 +3,7 @@ import Grid from "@mui/material/Grid";
|
||||
import { IMinigameProps } from "./IMinigameProps";
|
||||
import { KeyHandler } from "./KeyHandler";
|
||||
import { GameTimer } from "./GameTimer";
|
||||
import { random, getArrow } from "../utils";
|
||||
import { random, getArrow, rightArrowSymbol, leftArrowSymbol, upArrowSymbol, downArrowSymbol } from "../utils";
|
||||
import { interpolate } from "./Difficulty";
|
||||
import Typography from "@mui/material/Typography";
|
||||
|
||||
@ -56,7 +56,7 @@ export function CheatCodeGame(props: IMinigameProps): React.ReactElement {
|
||||
}
|
||||
|
||||
function generateCode(difficulty: Difficulty): string {
|
||||
const arrows = ["←", "→", "↑", "↓"];
|
||||
const arrows = [leftArrowSymbol, rightArrowSymbol, upArrowSymbol, downArrowSymbol];
|
||||
let code = "";
|
||||
for (let i = 0; i < random(difficulty.min, difficulty.max); i++) {
|
||||
let arrow = arrows[Math.floor(4 * Math.random())];
|
||||
|
@ -4,8 +4,9 @@ import { IMinigameProps } from "./IMinigameProps";
|
||||
import { KeyHandler } from "./KeyHandler";
|
||||
import { GameTimer } from "./GameTimer";
|
||||
import { interpolate } from "./Difficulty";
|
||||
import { getArrow } from "../utils";
|
||||
import { downArrowSymbol, getArrow, leftArrowSymbol, rightArrowSymbol, upArrowSymbol } from "../utils";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import { KEY } from "../../utils/helpers/keyCodes";
|
||||
|
||||
interface Difficulty {
|
||||
[key: string]: number;
|
||||
@ -41,16 +42,16 @@ export function Cyberpunk2077Game(props: IMinigameProps): React.ReactElement {
|
||||
const move = [0, 0];
|
||||
const arrow = getArrow(event);
|
||||
switch (arrow) {
|
||||
case "↑":
|
||||
case upArrowSymbol:
|
||||
move[1]--;
|
||||
break;
|
||||
case "←":
|
||||
case leftArrowSymbol:
|
||||
move[0]--;
|
||||
break;
|
||||
case "↓":
|
||||
case downArrowSymbol:
|
||||
move[1]++;
|
||||
break;
|
||||
case "→":
|
||||
case rightArrowSymbol:
|
||||
move[0]++;
|
||||
break;
|
||||
}
|
||||
@ -59,7 +60,7 @@ export function Cyberpunk2077Game(props: IMinigameProps): React.ReactElement {
|
||||
next[1] = (next[1] + grid.length) % grid.length;
|
||||
setPos(next);
|
||||
|
||||
if (event.key === " ") {
|
||||
if (event.key === KEY.SPACE) {
|
||||
const selected = grid[pos[1]][pos[0]];
|
||||
const expected = answer[index];
|
||||
if (selected !== expected) {
|
||||
|
@ -4,8 +4,9 @@ import { IMinigameProps } from "./IMinigameProps";
|
||||
import { KeyHandler } from "./KeyHandler";
|
||||
import { GameTimer } from "./GameTimer";
|
||||
import { interpolate } from "./Difficulty";
|
||||
import { getArrow } from "../utils";
|
||||
import { downArrowSymbol, getArrow, leftArrowSymbol, rightArrowSymbol, upArrowSymbol } from "../utils";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import { KEY } from "../../utils/helpers/keyCodes";
|
||||
|
||||
interface Difficulty {
|
||||
[key: string]: number;
|
||||
@ -42,16 +43,16 @@ export function MinesweeperGame(props: IMinigameProps): React.ReactElement {
|
||||
const move = [0, 0];
|
||||
const arrow = getArrow(event);
|
||||
switch (arrow) {
|
||||
case "↑":
|
||||
case upArrowSymbol:
|
||||
move[1]--;
|
||||
break;
|
||||
case "←":
|
||||
case leftArrowSymbol:
|
||||
move[0]--;
|
||||
break;
|
||||
case "↓":
|
||||
case downArrowSymbol:
|
||||
move[1]++;
|
||||
break;
|
||||
case "→":
|
||||
case rightArrowSymbol:
|
||||
move[0]++;
|
||||
break;
|
||||
}
|
||||
@ -60,7 +61,7 @@ export function MinesweeperGame(props: IMinigameProps): React.ReactElement {
|
||||
next[1] = (next[1] + minefield.length) % minefield.length;
|
||||
setPos(next);
|
||||
|
||||
if (event.key == " ") {
|
||||
if (event.key == KEY.SPACE) {
|
||||
if (!minefield[pos[1]][pos[0]]) {
|
||||
props.onFailure();
|
||||
return;
|
||||
|
@ -5,6 +5,7 @@ import { KeyHandler } from "./KeyHandler";
|
||||
import { GameTimer } from "./GameTimer";
|
||||
import { interpolate } from "./Difficulty";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import { KEY } from "../../utils/helpers/keyCodes";
|
||||
|
||||
interface Difficulty {
|
||||
[key: string]: number;
|
||||
@ -30,7 +31,7 @@ export function SlashGame(props: IMinigameProps): React.ReactElement {
|
||||
|
||||
function press(this: Document, event: KeyboardEvent): void {
|
||||
event.preventDefault();
|
||||
if (event.key !== " ") return;
|
||||
if (event.key !== KEY.SPACE) return;
|
||||
if (phase !== 2) {
|
||||
props.onFailure();
|
||||
} else {
|
||||
|
@ -6,6 +6,7 @@ import { KeyHandler } from "./KeyHandler";
|
||||
import { GameTimer } from "./GameTimer";
|
||||
import { random } from "../utils";
|
||||
import { interpolate } from "./Difficulty";
|
||||
import { KEY } from "../../utils/helpers/keyCodes";
|
||||
|
||||
interface Difficulty {
|
||||
[key: string]: number;
|
||||
@ -27,7 +28,7 @@ const difficulties: {
|
||||
Impossible: { timer: 4000, wiresmin: 9, wiresmax: 9, rules: 4 },
|
||||
};
|
||||
|
||||
const types = ["|", ".", "/", "-", "█", "#"];
|
||||
const types = [KEY.PIPE, KEY.DOT, KEY.FORWARD_SLASH, KEY.HYPHEN, "█", KEY.HASH];
|
||||
|
||||
const colors = ["red", "#FFC107", "blue", "white"];
|
||||
|
||||
@ -61,6 +62,10 @@ export function WireCuttingGame(props: IMinigameProps): React.ReactElement {
|
||||
const [cutWires, setCutWires] = useState(new Array(wires.length).fill(false));
|
||||
const [questions] = useState(generateQuestion(wires, difficulty));
|
||||
|
||||
function checkWire(wireNum: number): boolean {
|
||||
return questions.some((q) => q.shouldCut(wires[wireNum - 1], wireNum - 1));
|
||||
}
|
||||
|
||||
function press(this: Document, event: KeyboardEvent): void {
|
||||
event.preventDefault();
|
||||
const wireNum = parseInt(event.key);
|
||||
@ -69,7 +74,7 @@ export function WireCuttingGame(props: IMinigameProps): React.ReactElement {
|
||||
setCutWires((old) => {
|
||||
const next = [...old];
|
||||
next[wireNum - 1] = true;
|
||||
if (!questions.some((q) => q.shouldCut(wires[wireNum - 1], wireNum - 1))) {
|
||||
if (checkWire(wireNum)) {
|
||||
props.onFailure();
|
||||
}
|
||||
|
||||
|
@ -1,21 +1,46 @@
|
||||
import { KEY } from "../utils/helpers/keyCodes";
|
||||
|
||||
export function random(min: number, max: number): number {
|
||||
return Math.random() * (max - min) + min;
|
||||
}
|
||||
|
||||
export const upArrowSymbol = "↑";
|
||||
export const downArrowSymbol = "↓";
|
||||
export const leftArrowSymbol = "←";
|
||||
export const rightArrowSymbol = "→";
|
||||
|
||||
export function getArrow(event: KeyboardEvent): string {
|
||||
switch (event.key) {
|
||||
case "ArrowUp":
|
||||
case "w":
|
||||
return "↑";
|
||||
case "ArrowLeft":
|
||||
case "a":
|
||||
return "←";
|
||||
case "ArrowDown":
|
||||
case "s":
|
||||
return "↓";
|
||||
case "ArrowRight":
|
||||
case "d":
|
||||
return "→";
|
||||
case KEY.UP_ARROW:
|
||||
case KEY.W:
|
||||
return upArrowSymbol;
|
||||
case KEY.LEFT_ARROW:
|
||||
case KEY.A:
|
||||
return leftArrowSymbol;
|
||||
case KEY.DOWN_ARROW:
|
||||
case KEY.S:
|
||||
return downArrowSymbol;
|
||||
case KEY.RIGHT_ARROW:
|
||||
case KEY.D:
|
||||
return rightArrowSymbol;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
export function getInverseArrow(event: KeyboardEvent): string {
|
||||
switch (event.key) {
|
||||
case KEY.DOWN_ARROW:
|
||||
case KEY.S:
|
||||
return upArrowSymbol;
|
||||
case KEY.RIGHT_ARROW:
|
||||
case KEY.D:
|
||||
return leftArrowSymbol;
|
||||
case KEY.UP_ARROW:
|
||||
case KEY.W:
|
||||
return downArrowSymbol;
|
||||
case KEY.LEFT_ARROW:
|
||||
case KEY.A:
|
||||
return rightArrowSymbol;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
@ -80,6 +80,13 @@ import {
|
||||
Bladeburner as IBladeburner,
|
||||
Stanek as IStanek,
|
||||
SourceFileLvl,
|
||||
BasicHGWOptions,
|
||||
ProcessInfo,
|
||||
HackingMultipliers,
|
||||
HacknetMultipliers,
|
||||
BitNodeMultipliers as IBNMults,
|
||||
Server as IServerDef,
|
||||
RunningScript as IRunningScriptDef,
|
||||
} from "./ScriptEditor/NetscriptDefinitions";
|
||||
import { NetscriptSingularity } from "./NetscriptFunctions/Singularity";
|
||||
|
||||
@ -91,6 +98,7 @@ import { SnackbarEvents } from "./ui/React/Snackbar";
|
||||
import { Flags } from "./NetscriptFunctions/Flags";
|
||||
import { calculateIntelligenceBonus } from "./PersonObjects/formulas/intelligence";
|
||||
import { CalculateShareMult, StartSharing } from "./NetworkShare/Share";
|
||||
import { CityName } from "./Locations/data/CityNames";
|
||||
|
||||
interface NS extends INS {
|
||||
[key: string]: any;
|
||||
@ -162,9 +170,9 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
* is not specified.
|
||||
*/
|
||||
const getRunningScript = function (
|
||||
fn: any,
|
||||
hostname: any,
|
||||
callingFnName: any,
|
||||
fn: string,
|
||||
hostname: string,
|
||||
callingFnName: string,
|
||||
scriptArgs: any,
|
||||
): RunningScript | null {
|
||||
if (typeof callingFnName !== "string" || callingFnName === "") {
|
||||
@ -193,7 +201,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
return workerScript.scriptRef;
|
||||
};
|
||||
|
||||
const getRunningScriptByPid = function (pid: any, callingFnName: any): RunningScript | null {
|
||||
const getRunningScriptByPid = function (pid: number, callingFnName: string): RunningScript | null {
|
||||
if (typeof callingFnName !== "string" || callingFnName === "") {
|
||||
callingFnName = "getRunningScriptgetRunningScriptByPid";
|
||||
}
|
||||
@ -213,7 +221,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
* @param {any[]} scriptArgs - Running script's arguments
|
||||
* @returns {string} Error message to print to logs
|
||||
*/
|
||||
const getCannotFindRunningScriptErrorMessage = function (fn: any, hostname: any, scriptArgs: any): string {
|
||||
const getCannotFindRunningScriptErrorMessage = function (fn: string, hostname: string, scriptArgs: any): string {
|
||||
if (!Array.isArray(scriptArgs)) {
|
||||
scriptArgs = [];
|
||||
}
|
||||
@ -228,7 +236,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
* @param {string} callingFn - Name of calling function. For logging purposes
|
||||
* @returns {boolean} True if the server is a Hacknet Server, false otherwise
|
||||
*/
|
||||
const failOnHacknetServer = function (server: any, callingFn: any = ""): boolean {
|
||||
const failOnHacknetServer = function (server: BaseServer, callingFn = ""): boolean {
|
||||
if (server instanceof HacknetServer) {
|
||||
workerScript.log(callingFn, () => `Does not work on Hacknet Servers`);
|
||||
return true;
|
||||
@ -316,7 +324,11 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
}
|
||||
};
|
||||
|
||||
const hack = function (hostname: any, manual: any, { threads: requestedThreads, stock }: any = {}): Promise<number> {
|
||||
const hack = function (
|
||||
hostname: string,
|
||||
manual: boolean,
|
||||
{ threads: requestedThreads, stock }: any = {},
|
||||
): Promise<number> {
|
||||
if (hostname === undefined) {
|
||||
throw makeRuntimeErrorMsg("hack", "Takes 1 argument.");
|
||||
}
|
||||
@ -429,25 +441,32 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
string: (funcName: string, argName: string, v: unknown): string => {
|
||||
if (typeof v === "string") return v;
|
||||
if (typeof v === "number") return v + ""; // cast to string;
|
||||
throw makeRuntimeErrorMsg(funcName, `${argName} should be a string`);
|
||||
throw makeRuntimeErrorMsg(funcName, `${argName} should be a string.`);
|
||||
},
|
||||
number: (funcName: string, argName: string, v: unknown): number => {
|
||||
if (typeof v === "string") {
|
||||
const x = parseFloat(v);
|
||||
if (!isNaN(x)) return x; // otherwise it wasn't even a string representing a number.
|
||||
} else if (typeof v === "number") {
|
||||
if (isNaN(v)) throw makeRuntimeErrorMsg(funcName, `${argName} is NaN`);
|
||||
if (isNaN(v)) throw makeRuntimeErrorMsg(funcName, `${argName} is NaN.`);
|
||||
return v;
|
||||
}
|
||||
throw makeRuntimeErrorMsg(funcName, `${argName} should be a number`);
|
||||
throw makeRuntimeErrorMsg(funcName, `${argName} should be a number.`);
|
||||
},
|
||||
boolean: (v: unknown): boolean => {
|
||||
return !!v; // Just convert it to boolean.
|
||||
},
|
||||
city: (funcName: string, argName: string, v: unknown): CityName => {
|
||||
if (typeof v !== "string") throw makeRuntimeErrorMsg(funcName, `${argName} should be a city name.`);
|
||||
const s = v as CityName;
|
||||
if (!Object.values(CityName).includes(s))
|
||||
throw makeRuntimeErrorMsg(funcName, `${argName} should be a city name.`);
|
||||
return s;
|
||||
},
|
||||
getServer: safeGetServer,
|
||||
checkSingularityAccess: checkSingularityAccess,
|
||||
hack: hack,
|
||||
getValidPort: (funcName: string, port: any): IPort => {
|
||||
getValidPort: (funcName: string, port: number): IPort => {
|
||||
if (isNaN(port)) {
|
||||
throw makeRuntimeErrorMsg(
|
||||
funcName,
|
||||
@ -501,7 +520,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
hacknet: hacknet,
|
||||
sprintf: sprintf,
|
||||
vsprintf: vsprintf,
|
||||
scan: function (hostname: any = workerScript.hostname): any {
|
||||
scan: function (_hostname: unknown = workerScript.hostname): string[] {
|
||||
const hostname = helper.string("scan", "hostname", _hostname);
|
||||
updateDynamicRam("scan", getRamCost(Player, "scan"));
|
||||
const server = safeGetServer(hostname, "scan");
|
||||
const out = [];
|
||||
@ -515,11 +535,14 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
workerScript.log("scan", () => `returned ${server.serversOnNetwork.length} connections for ${server.hostname}`);
|
||||
return out;
|
||||
},
|
||||
hack: function (hostname: any, { threads: requestedThreads, stock }: any = {}): any {
|
||||
hack: function (_hostname: unknown, { threads: requestedThreads, stock }: BasicHGWOptions = {}): Promise<number> {
|
||||
const hostname = helper.string("hack", "hostname", _hostname);
|
||||
updateDynamicRam("hack", getRamCost(Player, "hack"));
|
||||
return hack(hostname, false, { threads: requestedThreads, stock: stock });
|
||||
},
|
||||
hackAnalyzeThreads: function (hostname: any, hackAmount: any): any {
|
||||
hackAnalyzeThreads: function (_hostname: unknown, _hackAmount: unknown): number {
|
||||
const hostname = helper.string("hackAnalyzeThreads", "hostname", _hostname);
|
||||
const hackAmount = helper.number("hackAnalyzeThreads", "hackAmount", _hackAmount);
|
||||
updateDynamicRam("hackAnalyzeThreads", getRamCost(Player, "hackAnalyzeThreads"));
|
||||
|
||||
// Check argument validity
|
||||
@ -549,43 +572,48 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
|
||||
return hackAmount / Math.floor(server.moneyAvailable * percentHacked);
|
||||
},
|
||||
hackAnalyze: function (hostname: any): any {
|
||||
hackAnalyze: function (_hostname: unknown): number {
|
||||
const hostname = helper.string("hackAnalyze", "hostname", _hostname);
|
||||
updateDynamicRam("hackAnalyze", getRamCost(Player, "hackAnalyze"));
|
||||
|
||||
const server = safeGetServer(hostname, "hackAnalyze");
|
||||
if (!(server instanceof Server)) {
|
||||
workerScript.log("hackAnalyze", () => "Cannot be executed on this server.");
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return calculatePercentMoneyHacked(server, Player);
|
||||
},
|
||||
hackAnalyzeSecurity: function (threads: any): number {
|
||||
hackAnalyzeSecurity: function (_threads: unknown): number {
|
||||
const threads = helper.number("hackAnalyzeSecurity", "threads", _threads);
|
||||
updateDynamicRam("hackAnalyzeSecurity", getRamCost(Player, "hackAnalyzeSecurity"));
|
||||
return CONSTANTS.ServerFortifyAmount * threads;
|
||||
},
|
||||
hackAnalyzeChance: function (hostname: any): any {
|
||||
hackAnalyzeChance: function (_hostname: unknown): number {
|
||||
const hostname = helper.string("hackAnalyzeChance", "hostname", _hostname);
|
||||
updateDynamicRam("hackAnalyzeChance", getRamCost(Player, "hackAnalyzeChance"));
|
||||
|
||||
const server = safeGetServer(hostname, "hackAnalyzeChance");
|
||||
if (!(server instanceof Server)) {
|
||||
workerScript.log("hackAnalyzeChance", () => "Cannot be executed on this server.");
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return calculateHackingChance(server, Player);
|
||||
},
|
||||
sleep: function (time: any): any {
|
||||
sleep: async function (_time: unknown = 0): Promise<void> {
|
||||
const time = helper.number("sleep", "time", _time);
|
||||
updateDynamicRam("sleep", getRamCost(Player, "sleep"));
|
||||
if (time === undefined) {
|
||||
throw makeRuntimeErrorMsg("sleep", "Takes 1 argument.");
|
||||
}
|
||||
workerScript.log("sleep", () => `Sleeping for ${time} milliseconds`);
|
||||
return netscriptDelay(time, workerScript).then(function () {
|
||||
return Promise.resolve(true);
|
||||
return Promise.resolve();
|
||||
});
|
||||
},
|
||||
asleep: function (time: any): any {
|
||||
asleep: function (_time: unknown = 0): Promise<void> {
|
||||
const time = helper.number("asleep", "time", _time);
|
||||
updateDynamicRam("asleep", getRamCost(Player, "asleep"));
|
||||
if (time === undefined) {
|
||||
throw makeRuntimeErrorMsg("asleep", "Takes 1 argument.");
|
||||
@ -593,16 +621,24 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
workerScript.log("asleep", () => `Sleeping for ${time} milliseconds`);
|
||||
return new Promise((resolve) => setTimeout(resolve, time));
|
||||
},
|
||||
grow: function (hostname: any, { threads: requestedThreads, stock }: any = {}): any {
|
||||
grow: async function (
|
||||
_hostname: unknown,
|
||||
{ threads: requestedThreads, stock }: BasicHGWOptions = {},
|
||||
): Promise<number> {
|
||||
const hostname = helper.string("grow", "hostname", _hostname);
|
||||
updateDynamicRam("grow", getRamCost(Player, "grow"));
|
||||
const threads = resolveNetscriptRequestedThreads(workerScript, "grow", requestedThreads);
|
||||
const threads = resolveNetscriptRequestedThreads(
|
||||
workerScript,
|
||||
"grow",
|
||||
requestedThreads ?? workerScript.scriptRef.threads,
|
||||
);
|
||||
if (hostname === undefined) {
|
||||
throw makeRuntimeErrorMsg("grow", "Takes 1 argument.");
|
||||
}
|
||||
const server = safeGetServer(hostname, "grow");
|
||||
if (!(server instanceof Server)) {
|
||||
workerScript.log("grow", () => "Cannot be executed on this server.");
|
||||
return false;
|
||||
return Promise.resolve(0);
|
||||
}
|
||||
|
||||
const host = GetServer(workerScript.hostname);
|
||||
@ -648,14 +684,17 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
return Promise.resolve(moneyAfter / moneyBefore);
|
||||
});
|
||||
},
|
||||
growthAnalyze: function (hostname: any, growth: any, cores: any = 1): any {
|
||||
growthAnalyze: function (_hostname: unknown, _growth: unknown, _cores: unknown = 1): number {
|
||||
const hostname = helper.string("growthAnalyze", "hostname", _hostname);
|
||||
const growth = helper.number("growthAnalyze", "growth", _growth);
|
||||
const cores = helper.number("growthAnalyze", "cores", _cores);
|
||||
updateDynamicRam("growthAnalyze", getRamCost(Player, "growthAnalyze"));
|
||||
|
||||
// Check argument validity
|
||||
const server = safeGetServer(hostname, "growthAnalyze");
|
||||
if (!(server instanceof Server)) {
|
||||
workerScript.log("growthAnalyze", () => "Cannot be executed on this server.");
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
if (typeof growth !== "number" || isNaN(growth) || growth < 1 || !isFinite(growth)) {
|
||||
throw makeRuntimeErrorMsg("growthAnalyze", `Invalid argument: growth must be numeric and >= 1, is ${growth}.`);
|
||||
@ -663,20 +702,26 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
|
||||
return numCycleForGrowth(server, Number(growth), Player, cores);
|
||||
},
|
||||
growthAnalyzeSecurity: function (threads: any): number {
|
||||
growthAnalyzeSecurity: function (_threads: unknown): number {
|
||||
const threads = helper.number("growthAnalyzeSecurity", "threads", _threads);
|
||||
updateDynamicRam("growthAnalyzeSecurity", getRamCost(Player, "growthAnalyzeSecurity"));
|
||||
return 2 * CONSTANTS.ServerFortifyAmount * threads;
|
||||
},
|
||||
weaken: function (hostname: any, { threads: requestedThreads }: any = {}): any {
|
||||
weaken: async function (_hostname: unknown, { threads: requestedThreads }: BasicHGWOptions = {}): Promise<number> {
|
||||
const hostname = helper.string("weaken", "hostname", _hostname);
|
||||
updateDynamicRam("weaken", getRamCost(Player, "weaken"));
|
||||
const threads = resolveNetscriptRequestedThreads(workerScript, "weaken", requestedThreads);
|
||||
const threads = resolveNetscriptRequestedThreads(
|
||||
workerScript,
|
||||
"weaken",
|
||||
requestedThreads ?? workerScript.scriptRef.threads,
|
||||
);
|
||||
if (hostname === undefined) {
|
||||
throw makeRuntimeErrorMsg("weaken", "Takes 1 argument.");
|
||||
}
|
||||
const server = safeGetServer(hostname, "weaken");
|
||||
if (!(server instanceof Server)) {
|
||||
workerScript.log("weaken", () => "Cannot be executed on this server.");
|
||||
return false;
|
||||
return Promise.resolve(0);
|
||||
}
|
||||
|
||||
// No root access or skill level too low
|
||||
@ -716,12 +761,14 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
return Promise.resolve(CONSTANTS.ServerWeakenAmount * threads * coreBonus);
|
||||
});
|
||||
},
|
||||
weakenAnalyze: function (threads: any, cores: any = 1): number {
|
||||
weakenAnalyze: function (_threads: unknown, _cores: unknown = 1): number {
|
||||
const threads = helper.number("weakenAnalyze", "threads", _threads);
|
||||
const cores = helper.number("weakenAnalyze", "cores", _cores);
|
||||
updateDynamicRam("weakenAnalyze", getRamCost(Player, "weakenAnalyze"));
|
||||
const coreBonus = 1 + (cores - 1) / 16;
|
||||
return CONSTANTS.ServerWeakenAmount * threads * coreBonus * BitNodeMultipliers.ServerWeakenRate;
|
||||
},
|
||||
share: function (): Promise<void> {
|
||||
share: async function (): Promise<void> {
|
||||
updateDynamicRam("share", getRamCost(Player, "share"));
|
||||
workerScript.log("share", () => "Sharing this computer.");
|
||||
const end = StartSharing(workerScript.scriptRef.threads * calculateIntelligenceBonus(Player.intelligence, 2));
|
||||
@ -741,7 +788,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
}
|
||||
workerScript.print(argsToString(args));
|
||||
},
|
||||
printf: function (format: string, ...args: any[]): void {
|
||||
printf: function (_format: unknown, ...args: any[]): void {
|
||||
const format = helper.string("printf", "format", _format);
|
||||
updateDynamicRam("printf", getRamCost(Player, "printf"));
|
||||
if (typeof format !== "string") {
|
||||
throw makeRuntimeErrorMsg("printf", "First argument must be string for the format.");
|
||||
@ -772,7 +820,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
}
|
||||
Terminal.print(`${workerScript.scriptRef.filename}: ${str}`);
|
||||
},
|
||||
tprintf: function (format: any, ...args: any): any {
|
||||
tprintf: function (_format: unknown, ...args: any[]): void {
|
||||
const format = helper.string("printf", "format", _format);
|
||||
updateDynamicRam("tprintf", getRamCost(Player, "tprintf"));
|
||||
if (typeof format !== "string") {
|
||||
throw makeRuntimeErrorMsg("tprintf", "First argument must be string for the format.");
|
||||
@ -797,14 +846,15 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
}
|
||||
Terminal.print(`${str}`);
|
||||
},
|
||||
clearLog: function (): any {
|
||||
clearLog: function (): void {
|
||||
updateDynamicRam("clearLog", getRamCost(Player, "clearLog"));
|
||||
workerScript.scriptRef.clearLog();
|
||||
},
|
||||
disableLog: function (fn: any): any {
|
||||
disableLog: function (_fn: unknown): void {
|
||||
const fn = helper.string("disableLog", "fn", _fn);
|
||||
updateDynamicRam("disableLog", getRamCost(Player, "disableLog"));
|
||||
if (fn === "ALL") {
|
||||
for (fn of Object.keys(possibleLogs)) {
|
||||
for (const fn of Object.keys(possibleLogs)) {
|
||||
workerScript.disableLogs[fn] = true;
|
||||
}
|
||||
workerScript.log("disableLog", () => `Disabled logging for all functions`);
|
||||
@ -815,10 +865,11 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
workerScript.log("disableLog", () => `Disabled logging for ${fn}`);
|
||||
}
|
||||
},
|
||||
enableLog: function (fn: any): any {
|
||||
enableLog: function (_fn: unknown): void {
|
||||
const fn = helper.string("enableLog", "fn", _fn);
|
||||
updateDynamicRam("enableLog", getRamCost(Player, "enableLog"));
|
||||
if (fn === "ALL") {
|
||||
for (fn of Object.keys(possibleLogs)) {
|
||||
for (const fn of Object.keys(possibleLogs)) {
|
||||
delete workerScript.disableLogs[fn];
|
||||
}
|
||||
workerScript.log("enableLog", () => `Enabled logging for all functions`);
|
||||
@ -828,24 +879,27 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
delete workerScript.disableLogs[fn];
|
||||
workerScript.log("enableLog", () => `Enabled logging for ${fn}`);
|
||||
},
|
||||
isLogEnabled: function (fn: any): any {
|
||||
isLogEnabled: function (_fn: unknown): boolean {
|
||||
const fn = helper.string("isLogEnabled", "fn", _fn);
|
||||
updateDynamicRam("isLogEnabled", getRamCost(Player, "isLogEnabled"));
|
||||
if (possibleLogs[fn] === undefined) {
|
||||
throw makeRuntimeErrorMsg("isLogEnabled", `Invalid argument: ${fn}.`);
|
||||
}
|
||||
return !workerScript.disableLogs[fn];
|
||||
},
|
||||
getScriptLogs: function (fn: any, hostname: any, ...scriptArgs: any): any {
|
||||
getScriptLogs: function (_fn: unknown, _hostname: unknown, ...scriptArgs: any[]): string[] {
|
||||
const fn = helper.string("getScriptLogs", "fn", _fn);
|
||||
const hostname = helper.string("getScriptLogs", "hostname", _hostname);
|
||||
updateDynamicRam("getScriptLogs", getRamCost(Player, "getScriptLogs"));
|
||||
const runningScriptObj = getRunningScript(fn, hostname, "getScriptLogs", scriptArgs);
|
||||
if (runningScriptObj == null) {
|
||||
workerScript.log("getScriptLogs", () => getCannotFindRunningScriptErrorMessage(fn, hostname, scriptArgs));
|
||||
return "";
|
||||
return [];
|
||||
}
|
||||
|
||||
return runningScriptObj.logs.slice();
|
||||
},
|
||||
tail: function (fn: any, hostname: any = workerScript.hostname, ...scriptArgs: any): any {
|
||||
tail: function (fn: any, hostname: any = workerScript.hostname, ...scriptArgs: any[]): void {
|
||||
updateDynamicRam("tail", getRamCost(Player, "tail"));
|
||||
let runningScriptObj;
|
||||
if (arguments.length === 0) {
|
||||
@ -862,7 +916,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
|
||||
LogBoxEvents.emit(runningScriptObj);
|
||||
},
|
||||
nuke: function (hostname: any): boolean {
|
||||
nuke: function (_hostname: unknown): boolean {
|
||||
const hostname = helper.string("tail", "hostname", _hostname);
|
||||
updateDynamicRam("nuke", getRamCost(Player, "nuke"));
|
||||
if (hostname === undefined) {
|
||||
throw makeRuntimeErrorMsg("nuke", "Takes 1 argument.");
|
||||
@ -886,7 +941,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
workerScript.log("nuke", () => `Executed NUKE.exe virus on '${server.hostname}' to gain root access.`);
|
||||
return true;
|
||||
},
|
||||
brutessh: function (hostname: any): boolean {
|
||||
brutessh: function (_hostname: unknown): boolean {
|
||||
const hostname = helper.string("brutessh", "hostname", _hostname);
|
||||
updateDynamicRam("brutessh", getRamCost(Player, "brutessh"));
|
||||
if (hostname === undefined) {
|
||||
throw makeRuntimeErrorMsg("brutessh", "Takes 1 argument.");
|
||||
@ -908,7 +964,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
}
|
||||
return true;
|
||||
},
|
||||
ftpcrack: function (hostname: any): boolean {
|
||||
ftpcrack: function (_hostname: unknown): boolean {
|
||||
const hostname = helper.string("ftpcrack", "hostname", _hostname);
|
||||
updateDynamicRam("ftpcrack", getRamCost(Player, "ftpcrack"));
|
||||
if (hostname === undefined) {
|
||||
throw makeRuntimeErrorMsg("ftpcrack", "Takes 1 argument.");
|
||||
@ -930,7 +987,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
}
|
||||
return true;
|
||||
},
|
||||
relaysmtp: function (hostname: any): boolean {
|
||||
relaysmtp: function (_hostname: unknown): boolean {
|
||||
const hostname = helper.string("relaysmtp", "hostname", _hostname);
|
||||
updateDynamicRam("relaysmtp", getRamCost(Player, "relaysmtp"));
|
||||
if (hostname === undefined) {
|
||||
throw makeRuntimeErrorMsg("relaysmtp", "Takes 1 argument.");
|
||||
@ -952,7 +1010,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
}
|
||||
return true;
|
||||
},
|
||||
httpworm: function (hostname: any): boolean {
|
||||
httpworm: function (_hostname: unknown): boolean {
|
||||
const hostname = helper.string("httpworm", "hostname", _hostname);
|
||||
updateDynamicRam("httpworm", getRamCost(Player, "httpworm"));
|
||||
if (hostname === undefined) {
|
||||
throw makeRuntimeErrorMsg("httpworm", "Takes 1 argument");
|
||||
@ -974,7 +1033,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
}
|
||||
return true;
|
||||
},
|
||||
sqlinject: function (hostname: any): boolean {
|
||||
sqlinject: function (_hostname: unknown): boolean {
|
||||
const hostname = helper.string("sqlinject", "hostname", _hostname);
|
||||
updateDynamicRam("sqlinject", getRamCost(Player, "sqlinject"));
|
||||
if (hostname === undefined) {
|
||||
throw makeRuntimeErrorMsg("sqlinject", "Takes 1 argument.");
|
||||
@ -996,7 +1056,9 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
}
|
||||
return true;
|
||||
},
|
||||
run: function (scriptname: any, threads: any = 1, ...args: any[]): any {
|
||||
run: function (_scriptname: unknown, _threads: unknown = 1, ...args: any[]): number {
|
||||
const scriptname = helper.string("run", "scriptname", _scriptname);
|
||||
const threads = helper.number("run", "threads", _threads);
|
||||
updateDynamicRam("run", getRamCost(Player, "run"));
|
||||
if (scriptname === undefined) {
|
||||
throw makeRuntimeErrorMsg("run", "Usage: run(scriptname, [numThreads], [arg1], [arg2]...)");
|
||||
@ -1011,7 +1073,10 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
|
||||
return runScriptFromScript(Player, "run", scriptServer, scriptname, args, workerScript, threads);
|
||||
},
|
||||
exec: function (scriptname: any, hostname: any, threads: any = 1, ...args: any[]): any {
|
||||
exec: function (_scriptname: unknown, _hostname: unknown, _threads: unknown = 1, ...args: any[]): number {
|
||||
const scriptname = helper.string("exec", "scriptname", _scriptname);
|
||||
const hostname = helper.string("exec", "hostname", _hostname);
|
||||
const threads = helper.number("exec", "threads", _threads);
|
||||
updateDynamicRam("exec", getRamCost(Player, "exec"));
|
||||
if (scriptname === undefined || hostname === undefined) {
|
||||
throw makeRuntimeErrorMsg("exec", "Usage: exec(scriptname, server, [numThreads], [arg1], [arg2]...)");
|
||||
@ -1022,7 +1087,9 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
const server = safeGetServer(hostname, "exec");
|
||||
return runScriptFromScript(Player, "exec", server, scriptname, args, workerScript, threads);
|
||||
},
|
||||
spawn: function (scriptname: any, threads: any = 1, ...args: any[]): any {
|
||||
spawn: function (_scriptname: unknown, _threads: unknown = 1, ...args: any[]): void {
|
||||
const scriptname = helper.string("spawn", "scriptname", _scriptname);
|
||||
const threads = helper.number("spawn", "threads", _threads);
|
||||
updateDynamicRam("spawn", getRamCost(Player, "spawn"));
|
||||
if (!scriptname || !threads) {
|
||||
throw makeRuntimeErrorMsg("spawn", "Usage: spawn(scriptname, threads)");
|
||||
@ -1048,7 +1115,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
workerScript.log("spawn", () => "Exiting...");
|
||||
}
|
||||
},
|
||||
kill: function (filename: any, hostname?: any, ...scriptArgs: any): any {
|
||||
kill: function (filename: any, hostname?: any, ...scriptArgs: any[]): boolean {
|
||||
updateDynamicRam("kill", getRamCost(Player, "kill"));
|
||||
|
||||
let res;
|
||||
@ -1094,7 +1161,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
killall: function (hostname: any = workerScript.hostname): any {
|
||||
killall: function (_hostname: unknown = workerScript.hostname): boolean {
|
||||
const hostname = helper.string("killall", "hostname", _hostname);
|
||||
updateDynamicRam("killall", getRamCost(Player, "killall"));
|
||||
if (hostname === undefined) {
|
||||
throw makeRuntimeErrorMsg("killall", "Takes 1 argument");
|
||||
@ -1112,7 +1180,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
|
||||
return scriptsRunning;
|
||||
},
|
||||
exit: function (): any {
|
||||
exit: function (): void {
|
||||
updateDynamicRam("exit", getRamCost(Player, "exit"));
|
||||
workerScript.running = false; // Prevent workerScript from "finishing execution naturally"
|
||||
if (killWorkerScript(workerScript)) {
|
||||
@ -1121,7 +1189,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
workerScript.log("exit", () => "Failed. This is a bug. Report to dev.");
|
||||
}
|
||||
},
|
||||
scp: async function (scriptname: any, hostname1: any, hostname2?: any): Promise<boolean> {
|
||||
scp: async function (scriptname: any, _hostname1: unknown, hostname2?: any): Promise<boolean> {
|
||||
const hostname1 = helper.string("scp", "hostname1", _hostname1);
|
||||
updateDynamicRam("scp", getRamCost(Player, "scp"));
|
||||
if (arguments.length !== 2 && arguments.length !== 3) {
|
||||
throw makeRuntimeErrorMsg("scp", "Takes 2 or 3 arguments");
|
||||
@ -1278,7 +1347,9 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
newScript.updateRamUsage(Player, destServer.scripts).then(() => resolve(true));
|
||||
});
|
||||
},
|
||||
ls: function (hostname: any, grep: any): any {
|
||||
ls: function (_hostname: unknown, _grep: unknown = ""): string[] {
|
||||
const hostname = helper.string("ls", "hostname", _hostname);
|
||||
const grep = helper.string("ls", "grep", _grep);
|
||||
updateDynamicRam("ls", getRamCost(Player, "ls"));
|
||||
if (hostname === undefined) {
|
||||
throw makeRuntimeErrorMsg("ls", "Usage: ls(hostname/ip, [grep filter])");
|
||||
@ -1345,7 +1416,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
allFiles.sort();
|
||||
return allFiles;
|
||||
},
|
||||
ps: function (hostname: any = workerScript.hostname): any {
|
||||
ps: function (_hostname: unknown = workerScript.hostname): ProcessInfo[] {
|
||||
const hostname = helper.string("ps", "hostname", _hostname);
|
||||
updateDynamicRam("ps", getRamCost(Player, "ps"));
|
||||
const server = safeGetServer(hostname, "ps");
|
||||
const processes = [];
|
||||
@ -1359,7 +1431,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
}
|
||||
return processes;
|
||||
},
|
||||
hasRootAccess: function (hostname: any): any {
|
||||
hasRootAccess: function (_hostname: unknown): boolean {
|
||||
const hostname = helper.string("hasRootAccess", "hostname", _hostname);
|
||||
updateDynamicRam("hasRootAccess", getRamCost(Player, "hasRootAccess"));
|
||||
if (hostname === undefined) {
|
||||
throw makeRuntimeErrorMsg("hasRootAccess", "Takes 1 argument");
|
||||
@ -1367,7 +1440,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
const server = safeGetServer(hostname, "hasRootAccess");
|
||||
return server.hasAdminRights;
|
||||
},
|
||||
getHostname: function (): any {
|
||||
getHostname: function (): string {
|
||||
updateDynamicRam("getHostname", getRamCost(Player, "getHostname"));
|
||||
const scriptServer = GetServer(workerScript.hostname);
|
||||
if (scriptServer == null) {
|
||||
@ -1375,13 +1448,13 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
}
|
||||
return scriptServer.hostname;
|
||||
},
|
||||
getHackingLevel: function (): any {
|
||||
getHackingLevel: function (): number {
|
||||
updateDynamicRam("getHackingLevel", getRamCost(Player, "getHackingLevel"));
|
||||
Player.updateSkillLevels();
|
||||
workerScript.log("getHackingLevel", () => `returned ${Player.hacking}`);
|
||||
return Player.hacking;
|
||||
},
|
||||
getHackingMultipliers: function (): any {
|
||||
getHackingMultipliers: function (): HackingMultipliers {
|
||||
updateDynamicRam("getHackingMultipliers", getRamCost(Player, "getHackingMultipliers"));
|
||||
return {
|
||||
chance: Player.hacking_chance_mult,
|
||||
@ -1390,7 +1463,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
growth: Player.hacking_grow_mult,
|
||||
};
|
||||
},
|
||||
getHacknetMultipliers: function (): any {
|
||||
getHacknetMultipliers: function (): HacknetMultipliers {
|
||||
updateDynamicRam("getHacknetMultipliers", getRamCost(Player, "getHacknetMultipliers"));
|
||||
return {
|
||||
production: Player.hacknet_node_money_mult,
|
||||
@ -1400,7 +1473,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
levelCost: Player.hacknet_node_level_cost_mult,
|
||||
};
|
||||
},
|
||||
getBitNodeMultipliers: function (): any {
|
||||
getBitNodeMultipliers: function (): IBNMults {
|
||||
updateDynamicRam("getBitNodeMultipliers", getRamCost(Player, "getBitNodeMultipliers"));
|
||||
if (SourceFileFlags[5] <= 0 && Player.bitNodeN !== 5) {
|
||||
throw makeRuntimeErrorMsg("getBitNodeMultipliers", "Requires Source-File 5 to run.");
|
||||
@ -1408,7 +1481,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
const copy = Object.assign({}, BitNodeMultipliers);
|
||||
return copy;
|
||||
},
|
||||
getServer: function (hostname: any = workerScript.hostname): any {
|
||||
getServer: function (_hostname: unknown = workerScript.hostname): IServerDef {
|
||||
const hostname = helper.string("getServer", "hostname", _hostname);
|
||||
updateDynamicRam("getServer", getRamCost(Player, "getServer"));
|
||||
const server = safeGetServer(hostname, "getServer");
|
||||
const copy = Object.assign({}, server) as any;
|
||||
@ -1431,7 +1505,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
if (!copy.serverGrowth) copy.serverGrowth = 0;
|
||||
return copy;
|
||||
},
|
||||
getServerMoneyAvailable: function (hostname: any): any {
|
||||
getServerMoneyAvailable: function (_hostname: unknown): number {
|
||||
const hostname = helper.string("getServerMoneyAvailable", "hostname", _hostname);
|
||||
updateDynamicRam("getServerMoneyAvailable", getRamCost(Player, "getServerMoneyAvailable"));
|
||||
const server = safeGetServer(hostname, "getServerMoneyAvailable");
|
||||
if (!(server instanceof Server)) {
|
||||
@ -1455,7 +1530,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
);
|
||||
return server.moneyAvailable;
|
||||
},
|
||||
getServerSecurityLevel: function (hostname: any): any {
|
||||
getServerSecurityLevel: function (_hostname: unknown): number {
|
||||
const hostname = helper.string("getServerSecurityLevel", "hostname", _hostname);
|
||||
updateDynamicRam("getServerSecurityLevel", getRamCost(Player, "getServerSecurityLevel"));
|
||||
const server = safeGetServer(hostname, "getServerSecurityLevel");
|
||||
if (!(server instanceof Server)) {
|
||||
@ -1471,7 +1547,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
);
|
||||
return server.hackDifficulty;
|
||||
},
|
||||
getServerBaseSecurityLevel: function (hostname: any): any {
|
||||
getServerBaseSecurityLevel: function (_hostname: unknown): number {
|
||||
const hostname = helper.string("getServerBaseSecurityLevel", "hostname", _hostname);
|
||||
updateDynamicRam("getServerBaseSecurityLevel", getRamCost(Player, "getServerBaseSecurityLevel"));
|
||||
workerScript.log(
|
||||
"getServerBaseSecurityLevel",
|
||||
@ -1491,7 +1568,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
);
|
||||
return server.baseDifficulty;
|
||||
},
|
||||
getServerMinSecurityLevel: function (hostname: any): any {
|
||||
getServerMinSecurityLevel: function (_hostname: unknown): number {
|
||||
const hostname = helper.string("getServerMinSecurityLevel", "hostname", _hostname);
|
||||
updateDynamicRam("getServerMinSecurityLevel", getRamCost(Player, "getServerMinSecurityLevel"));
|
||||
const server = safeGetServer(hostname, "getServerMinSecurityLevel");
|
||||
if (!(server instanceof Server)) {
|
||||
@ -1507,7 +1585,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
);
|
||||
return server.minDifficulty;
|
||||
},
|
||||
getServerRequiredHackingLevel: function (hostname: any): any {
|
||||
getServerRequiredHackingLevel: function (_hostname: unknown): number {
|
||||
const hostname = helper.string("getServerRequiredHackingLevel", "hostname", _hostname);
|
||||
updateDynamicRam("getServerRequiredHackingLevel", getRamCost(Player, "getServerRequiredHackingLevel"));
|
||||
const server = safeGetServer(hostname, "getServerRequiredHackingLevel");
|
||||
if (!(server instanceof Server)) {
|
||||
@ -1523,7 +1602,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
);
|
||||
return server.requiredHackingSkill;
|
||||
},
|
||||
getServerMaxMoney: function (hostname: any): any {
|
||||
getServerMaxMoney: function (_hostname: unknown): number {
|
||||
const hostname = helper.string("getServerMaxMoney", "hostname", _hostname);
|
||||
updateDynamicRam("getServerMaxMoney", getRamCost(Player, "getServerMaxMoney"));
|
||||
const server = safeGetServer(hostname, "getServerMaxMoney");
|
||||
if (!(server instanceof Server)) {
|
||||
@ -1539,7 +1619,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
);
|
||||
return server.moneyMax;
|
||||
},
|
||||
getServerGrowth: function (hostname: any): any {
|
||||
getServerGrowth: function (_hostname: unknown): number {
|
||||
const hostname = helper.string("getServerGrowth", "hostname", _hostname);
|
||||
updateDynamicRam("getServerGrowth", getRamCost(Player, "getServerGrowth"));
|
||||
const server = safeGetServer(hostname, "getServerGrowth");
|
||||
if (!(server instanceof Server)) {
|
||||
@ -1552,7 +1633,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
workerScript.log("getServerGrowth", () => `returned ${server.serverGrowth} for '${server.hostname}'`);
|
||||
return server.serverGrowth;
|
||||
},
|
||||
getServerNumPortsRequired: function (hostname: any): any {
|
||||
getServerNumPortsRequired: function (_hostname: unknown): number {
|
||||
const hostname = helper.string("getServerNumPortsRequired", "hostname", _hostname);
|
||||
updateDynamicRam("getServerNumPortsRequired", getRamCost(Player, "getServerNumPortsRequired"));
|
||||
const server = safeGetServer(hostname, "getServerNumPortsRequired");
|
||||
if (!(server instanceof Server)) {
|
||||
@ -1568,7 +1650,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
);
|
||||
return server.numOpenPortsRequired;
|
||||
},
|
||||
getServerRam: function (hostname: any): any {
|
||||
getServerRam: function (_hostname: unknown): [number, number] {
|
||||
const hostname = helper.string("getServerRam", "hostname", _hostname);
|
||||
updateDynamicRam("getServerRam", getRamCost(Player, "getServerRam"));
|
||||
workerScript.log(
|
||||
"getServerRam",
|
||||
@ -1581,23 +1664,28 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
);
|
||||
return [server.maxRam, server.ramUsed];
|
||||
},
|
||||
getServerMaxRam: function (hostname: any): any {
|
||||
getServerMaxRam: function (_hostname: unknown): number {
|
||||
const hostname = helper.string("getServerMaxRam", "hostname", _hostname);
|
||||
updateDynamicRam("getServerMaxRam", getRamCost(Player, "getServerMaxRam"));
|
||||
const server = safeGetServer(hostname, "getServerMaxRam");
|
||||
workerScript.log("getServerMaxRam", () => `returned ${numeralWrapper.formatRAM(server.maxRam)}`);
|
||||
return server.maxRam;
|
||||
},
|
||||
getServerUsedRam: function (hostname: any): any {
|
||||
getServerUsedRam: function (_hostname: unknown): number {
|
||||
const hostname = helper.string("getServerUsedRam", "hostname", _hostname);
|
||||
updateDynamicRam("getServerUsedRam", getRamCost(Player, "getServerUsedRam"));
|
||||
const server = safeGetServer(hostname, "getServerUsedRam");
|
||||
workerScript.log("getServerUsedRam", () => `returned ${numeralWrapper.formatRAM(server.ramUsed)}`);
|
||||
return server.ramUsed;
|
||||
},
|
||||
serverExists: function (hostname: any): any {
|
||||
serverExists: function (_hostname: unknown): boolean {
|
||||
const hostname = helper.string("serverExists", "hostname", _hostname);
|
||||
updateDynamicRam("serverExists", getRamCost(Player, "serverExists"));
|
||||
return GetServer(hostname) !== null;
|
||||
},
|
||||
fileExists: function (filename: any, hostname: any = workerScript.hostname): any {
|
||||
fileExists: function (_filename: unknown, _hostname: unknown = workerScript.hostname): boolean {
|
||||
const filename = helper.string("fileExists", "filename", _filename);
|
||||
const hostname = helper.string("fileExists", "hostname", _hostname);
|
||||
updateDynamicRam("fileExists", getRamCost(Player, "fileExists"));
|
||||
if (filename === undefined) {
|
||||
throw makeRuntimeErrorMsg("fileExists", "Usage: fileExists(scriptname, [server])");
|
||||
@ -1621,7 +1709,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
const txtFile = getTextFile(filename, server);
|
||||
return txtFile != null;
|
||||
},
|
||||
isRunning: function (fn: any, hostname: any = workerScript.hostname, ...scriptArgs: any): any {
|
||||
isRunning: function (fn: any, hostname: any = workerScript.hostname, ...scriptArgs: any[]): boolean {
|
||||
updateDynamicRam("isRunning", getRamCost(Player, "isRunning"));
|
||||
if (fn === undefined || hostname === undefined) {
|
||||
throw makeRuntimeErrorMsg("isRunning", "Usage: isRunning(scriptname, server, [arg1], [arg2]...)");
|
||||
@ -1632,17 +1720,18 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
return getRunningScript(fn, hostname, "isRunning", scriptArgs) != null;
|
||||
}
|
||||
},
|
||||
getPurchasedServerLimit: function (): any {
|
||||
getPurchasedServerLimit: function (): number {
|
||||
updateDynamicRam("getPurchasedServerLimit", getRamCost(Player, "getPurchasedServerLimit"));
|
||||
|
||||
return getPurchaseServerLimit();
|
||||
},
|
||||
getPurchasedServerMaxRam: function (): any {
|
||||
getPurchasedServerMaxRam: function (): number {
|
||||
updateDynamicRam("getPurchasedServerMaxRam", getRamCost(Player, "getPurchasedServerMaxRam"));
|
||||
|
||||
return getPurchaseServerMaxRam();
|
||||
},
|
||||
getPurchasedServerCost: function (ram: any): any {
|
||||
getPurchasedServerCost: function (_ram: unknown): number {
|
||||
const ram = helper.number("getPurchasedServerCost", "ram", _ram);
|
||||
updateDynamicRam("getPurchasedServerCost", getRamCost(Player, "getPurchasedServerCost"));
|
||||
|
||||
const cost = getPurchaseServerCost(ram);
|
||||
@ -1653,10 +1742,10 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
|
||||
return cost;
|
||||
},
|
||||
purchaseServer: function (aname: any, aram: any): any {
|
||||
purchaseServer: function (_name: unknown, _ram: unknown): string {
|
||||
const name = helper.string("purchaseServer", "name", _name);
|
||||
const ram = helper.number("purchaseServer", "ram", _ram);
|
||||
if (arguments.length !== 2) throw makeRuntimeErrorMsg("purchaseServer", "Takes 2 arguments");
|
||||
const name = helper.string("purchaseServer", "name", aname);
|
||||
const ram = helper.number("purchaseServer", "ram", aram);
|
||||
updateDynamicRam("purchaseServer", getRamCost(Player, "purchaseServer"));
|
||||
let hostnameStr = String(name);
|
||||
hostnameStr = hostnameStr.replace(/\s+/g, "");
|
||||
@ -1717,7 +1806,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
);
|
||||
return newServ.hostname;
|
||||
},
|
||||
deleteServer: function (name: any): any {
|
||||
deleteServer: function (_name: unknown): boolean {
|
||||
const name = helper.string("purchaseServer", "name", _name);
|
||||
updateDynamicRam("deleteServer", getRamCost(Player, "deleteServer"));
|
||||
let hostnameStr = String(name);
|
||||
hostnameStr = hostnameStr.replace(/\s\s+/g, "");
|
||||
@ -1793,7 +1883,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
);
|
||||
return false;
|
||||
},
|
||||
getPurchasedServers: function (): any {
|
||||
getPurchasedServers: function (): string[] {
|
||||
updateDynamicRam("getPurchasedServers", getRamCost(Player, "getPurchasedServers"));
|
||||
const res: string[] = [];
|
||||
Player.purchasedServers.forEach(function (hostname) {
|
||||
@ -1801,7 +1891,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
});
|
||||
return res;
|
||||
},
|
||||
writePort: function (port: any, data: any = ""): any {
|
||||
writePort: function (_port: unknown, data: any = ""): Promise<any> {
|
||||
const port = helper.number("writePort", "port", _port);
|
||||
updateDynamicRam("writePort", getRamCost(Player, "writePort"));
|
||||
if (typeof data !== "string" && typeof data !== "number") {
|
||||
throw makeRuntimeErrorMsg(
|
||||
@ -1812,7 +1903,9 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
const iport = helper.getValidPort("writePort", port);
|
||||
return Promise.resolve(iport.write(data));
|
||||
},
|
||||
write: function (port: any, data: any = "", mode: any = "a"): any {
|
||||
write: function (_port: unknown, data: any = "", _mode: unknown = "a"): Promise<void> {
|
||||
const port = helper.string("write", "port", _port);
|
||||
const mode = helper.string("write", "mode", _mode);
|
||||
updateDynamicRam("write", getRamCost(Player, "write"));
|
||||
if (isString(port)) {
|
||||
// Write to script or text file
|
||||
@ -1865,7 +1958,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
throw makeRuntimeErrorMsg("write", `Invalid argument: ${port}`);
|
||||
}
|
||||
},
|
||||
tryWritePort: function (port: any, data: any = ""): any {
|
||||
tryWritePort: function (_port: unknown, data: any = ""): Promise<any> {
|
||||
let port = helper.number("tryWritePort", "port", _port);
|
||||
updateDynamicRam("tryWritePort", getRamCost(Player, "tryWritePort"));
|
||||
if (typeof data !== "string" && typeof data !== "number") {
|
||||
throw makeRuntimeErrorMsg(
|
||||
@ -1890,14 +1984,16 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
throw makeRuntimeErrorMsg("tryWritePort", `Invalid argument: ${port}`);
|
||||
}
|
||||
},
|
||||
readPort: function (port: any): any {
|
||||
readPort: function (_port: unknown): any {
|
||||
const port = helper.number("readPort", "port", _port);
|
||||
updateDynamicRam("readPort", getRamCost(Player, "readPort"));
|
||||
// Read from port
|
||||
const iport = helper.getValidPort("readPort", port);
|
||||
const x = iport.read();
|
||||
return x;
|
||||
},
|
||||
read: function (port: any): any {
|
||||
read: function (_port: unknown): string {
|
||||
const port = helper.string("read", "port", _port);
|
||||
updateDynamicRam("read", getRamCost(Player, "read"));
|
||||
if (isString(port)) {
|
||||
// Read from script or text file
|
||||
@ -1926,13 +2022,15 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
throw makeRuntimeErrorMsg("read", `Invalid argument: ${port}`);
|
||||
}
|
||||
},
|
||||
peek: function (port: any): any {
|
||||
peek: function (_port: unknown): any {
|
||||
const port = helper.number("peek", "port", _port);
|
||||
updateDynamicRam("peek", getRamCost(Player, "peek"));
|
||||
const iport = helper.getValidPort("peek", port);
|
||||
const x = iport.peek();
|
||||
return x;
|
||||
},
|
||||
clear: function (file: any): any {
|
||||
clear: function (_file: unknown): void {
|
||||
const file = helper.string("peek", "file", _file);
|
||||
updateDynamicRam("clear", getRamCost(Player, "clear"));
|
||||
if (isString(file)) {
|
||||
// Clear text file
|
||||
@ -1948,20 +2046,22 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
} else {
|
||||
throw makeRuntimeErrorMsg("clear", `Invalid argument: ${file}`);
|
||||
}
|
||||
return 0;
|
||||
},
|
||||
clearPort: function (port: any): any {
|
||||
clearPort: function (_port: unknown): void {
|
||||
const port = helper.number("clearPort", "port", _port);
|
||||
updateDynamicRam("clearPort", getRamCost(Player, "clearPort"));
|
||||
// Clear port
|
||||
const iport = helper.getValidPort("clearPort", port);
|
||||
return iport.clear();
|
||||
iport.clear();
|
||||
},
|
||||
getPortHandle: function (port: any): IPort {
|
||||
getPortHandle: function (_port: unknown): IPort {
|
||||
const port = helper.number("getPortHandle", "port", _port);
|
||||
updateDynamicRam("getPortHandle", getRamCost(Player, "getPortHandle"));
|
||||
const iport = helper.getValidPort("getPortHandle", port);
|
||||
return iport;
|
||||
},
|
||||
rm: function (fn: any, hostname: any): any {
|
||||
rm: function (_fn: unknown, hostname: any): boolean {
|
||||
const fn = helper.string("rm", "fn", _fn);
|
||||
updateDynamicRam("rm", getRamCost(Player, "rm"));
|
||||
|
||||
if (hostname == null || hostname === "") {
|
||||
@ -1976,7 +2076,9 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
|
||||
return status.res;
|
||||
},
|
||||
scriptRunning: function (scriptname: any, hostname: any): any {
|
||||
scriptRunning: function (_scriptname: unknown, _hostname: unknown): boolean {
|
||||
const scriptname = helper.string("scriptRunning", "scriptname", _scriptname);
|
||||
const hostname = helper.string("scriptRunning", "hostname", _hostname);
|
||||
updateDynamicRam("scriptRunning", getRamCost(Player, "scriptRunning"));
|
||||
const server = safeGetServer(hostname, "scriptRunning");
|
||||
for (let i = 0; i < server.runningScripts.length; ++i) {
|
||||
@ -1986,7 +2088,9 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
}
|
||||
return false;
|
||||
},
|
||||
scriptKill: function (scriptname: any, hostname: any): any {
|
||||
scriptKill: function (_scriptname: unknown, _hostname: unknown): boolean {
|
||||
const scriptname = helper.string("scriptKill", "scriptname", _scriptname);
|
||||
const hostname = helper.string("scriptKill", "hostname", _hostname);
|
||||
updateDynamicRam("scriptKill", getRamCost(Player, "scriptKill"));
|
||||
const server = safeGetServer(hostname, "scriptKill");
|
||||
let suc = false;
|
||||
@ -1999,11 +2103,13 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
}
|
||||
return suc;
|
||||
},
|
||||
getScriptName: function (): any {
|
||||
getScriptName: function (): string {
|
||||
updateDynamicRam("getScriptName", getRamCost(Player, "getScriptName"));
|
||||
return workerScript.name;
|
||||
},
|
||||
getScriptRam: function (scriptname: any, hostname: any = workerScript.hostname): any {
|
||||
getScriptRam: function (_scriptname: unknown, _hostname: unknown = workerScript.hostname): number {
|
||||
const scriptname = helper.string("getScriptRam", "scriptname", _scriptname);
|
||||
const hostname = helper.string("getScriptRam", "hostname", _hostname);
|
||||
updateDynamicRam("getScriptRam", getRamCost(Player, "getScriptRam"));
|
||||
const server = safeGetServer(hostname, "getScriptRam");
|
||||
for (let i = 0; i < server.scripts.length; ++i) {
|
||||
@ -2013,7 +2119,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
}
|
||||
return 0;
|
||||
},
|
||||
getRunningScript: function (fn: any, hostname: any, ...args: any[]): any {
|
||||
getRunningScript: function (fn: any, hostname: any, ...args: any[]): IRunningScriptDef | null {
|
||||
updateDynamicRam("getRunningScript", getRamCost(Player, "getRunningScript"));
|
||||
|
||||
let runningScript;
|
||||
@ -2041,7 +2147,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
threads: runningScript.threads,
|
||||
};
|
||||
},
|
||||
getHackTime: function (hostname: any): any {
|
||||
getHackTime: function (_hostname: unknown = workerScript.hostname): number {
|
||||
const hostname = helper.string("getHackTime", "hostname", _hostname);
|
||||
updateDynamicRam("getHackTime", getRamCost(Player, "getHackTime"));
|
||||
const server = safeGetServer(hostname, "getHackTime");
|
||||
if (!(server instanceof Server)) {
|
||||
@ -2054,7 +2161,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
|
||||
return calculateHackingTime(server, Player) * 1000;
|
||||
},
|
||||
getGrowTime: function (hostname: any): any {
|
||||
getGrowTime: function (_hostname: unknown = workerScript.hostname): number {
|
||||
const hostname = helper.string("getGrowTime", "hostname", _hostname);
|
||||
updateDynamicRam("getGrowTime", getRamCost(Player, "getGrowTime"));
|
||||
const server = safeGetServer(hostname, "getGrowTime");
|
||||
if (!(server instanceof Server)) {
|
||||
@ -2067,7 +2175,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
|
||||
return calculateGrowTime(server, Player) * 1000;
|
||||
},
|
||||
getWeakenTime: function (hostname: any = workerScript.hostname): any {
|
||||
getWeakenTime: function (_hostname: unknown = workerScript.hostname): number {
|
||||
const hostname = helper.string("getWeakenTime", "hostname", _hostname);
|
||||
updateDynamicRam("getWeakenTime", getRamCost(Player, "getWeakenTime"));
|
||||
const server = safeGetServer(hostname, "getWeakenTime");
|
||||
if (!(server instanceof Server)) {
|
||||
@ -2109,7 +2218,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
return runningScriptObj.onlineMoneyMade / runningScriptObj.onlineRunningTime;
|
||||
}
|
||||
},
|
||||
getScriptExpGain: function (scriptname?: any, hostname?: any, ...args: any[]): any {
|
||||
getScriptExpGain: function (scriptname?: any, hostname?: any, ...args: any[]): number {
|
||||
updateDynamicRam("getScriptExpGain", getRamCost(Player, "getScriptExpGain"));
|
||||
if (arguments.length === 0) {
|
||||
let total = 0;
|
||||
@ -2131,40 +2240,43 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
return runningScriptObj.onlineExpGained / runningScriptObj.onlineRunningTime;
|
||||
}
|
||||
},
|
||||
nFormat: function (n: any, format: any): any {
|
||||
nFormat: function (_n: unknown, _format: unknown): string {
|
||||
const n = helper.number("nFormat", "n", _n);
|
||||
const format = helper.string("nFormat", "format", _format);
|
||||
updateDynamicRam("nFormat", getRamCost(Player, "nFormat"));
|
||||
if (isNaN(n) || isNaN(parseFloat(n)) || typeof format !== "string") {
|
||||
if (isNaN(n)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return numeralWrapper.format(parseFloat(n), format);
|
||||
return numeralWrapper.format(n, format);
|
||||
},
|
||||
tFormat: function (milliseconds: any, milliPrecision: any = false): any {
|
||||
tFormat: function (_milliseconds: unknown, _milliPrecision: unknown = false): string {
|
||||
const milliseconds = helper.number("tFormat", "milliseconds", _milliseconds);
|
||||
const milliPrecision = helper.boolean(_milliPrecision);
|
||||
updateDynamicRam("tFormat", getRamCost(Player, "tFormat"));
|
||||
return convertTimeMsToTimeElapsedString(milliseconds, milliPrecision);
|
||||
},
|
||||
getTimeSinceLastAug: function (): any {
|
||||
getTimeSinceLastAug: function (): number {
|
||||
updateDynamicRam("getTimeSinceLastAug", getRamCost(Player, "getTimeSinceLastAug"));
|
||||
return Player.playtimeSinceLastAug;
|
||||
},
|
||||
alert: function (message: any): void {
|
||||
alert: function (_message: unknown): void {
|
||||
const message = helper.string("alert", "message", _message);
|
||||
updateDynamicRam("alert", getRamCost(Player, "alert"));
|
||||
message = argsToString([message]);
|
||||
dialogBoxCreate(message);
|
||||
},
|
||||
toast: function (message: any, variant: any = "success", duration: any = 2000): void {
|
||||
toast: function (_message: unknown, _variant: unknown = "success", _duration: unknown = 2000): void {
|
||||
const message = helper.string("toast", "message", _message);
|
||||
const variant = helper.string("toast", "variant", _variant);
|
||||
const duration = helper.number("toast", "duration", _duration);
|
||||
updateDynamicRam("toast", getRamCost(Player, "toast"));
|
||||
if (!["success", "info", "warning", "error"].includes(variant))
|
||||
throw new Error(`variant must be one of "success", "info", "warning", or "error"`);
|
||||
|
||||
message = argsToString([message]);
|
||||
SnackbarEvents.emit(message, variant, duration);
|
||||
SnackbarEvents.emit(message, variant as any, duration);
|
||||
},
|
||||
prompt: function (txt: any, options?: { type?: string; options?: string[] }): any {
|
||||
prompt: function (_txt: unknown, options?: { type?: string; options?: string[] }): Promise<boolean | string> {
|
||||
const txt = helper.string("toast", "txt", _txt);
|
||||
updateDynamicRam("prompt", getRamCost(Player, "prompt"));
|
||||
if (!isString(txt)) {
|
||||
txt = JSON.stringify(txt);
|
||||
}
|
||||
|
||||
return new Promise(function (resolve) {
|
||||
PromptEvent.emit({
|
||||
@ -2174,7 +2286,14 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
});
|
||||
});
|
||||
},
|
||||
wget: async function (url: any, target: any, hostname: any = workerScript.hostname): Promise<boolean> {
|
||||
wget: async function (
|
||||
_url: unknown,
|
||||
_target: unknown,
|
||||
_hostname: unknown = workerScript.hostname,
|
||||
): Promise<boolean> {
|
||||
const url = helper.string("wget", "url", _url);
|
||||
const target = helper.string("wget", "target", _target);
|
||||
const hostname = helper.string("wget", "hostname", _hostname);
|
||||
updateDynamicRam("wget", getRamCost(Player, "wget"));
|
||||
if (!isScriptFilename(target) && !target.endsWith(".txt")) {
|
||||
workerScript.log("wget", () => `Invalid target file: '${target}'. Must be a script or text file.`);
|
||||
@ -2212,7 +2331,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
});
|
||||
});
|
||||
},
|
||||
getFavorToDonate: function (): any {
|
||||
getFavorToDonate: function (): number {
|
||||
updateDynamicRam("getFavorToDonate", getRamCost(Player, "getFavorToDonate"));
|
||||
return Math.floor(CONSTANTS.BaseFavorToDonate * BitNodeMultipliers.RepToDonateToFaction);
|
||||
},
|
||||
@ -2333,11 +2452,12 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
f();
|
||||
}; // Wrap the user function to prevent WorkerScript leaking as 'this'
|
||||
},
|
||||
mv: function (host: string, source: string, destination: string): void {
|
||||
mv: function (_host: unknown, _source: unknown, _destination: unknown): void {
|
||||
const host = helper.string("mv", "host", _host);
|
||||
const source = helper.string("mv", "source", _source);
|
||||
const destination = helper.string("mv", "destination", _destination);
|
||||
updateDynamicRam("mv", getRamCost(Player, "mv"));
|
||||
|
||||
if (arguments.length != 3) throw makeRuntimeErrorMsg("mv", "Takes 3 argument.");
|
||||
|
||||
if (!isValidFilePath(source)) throw makeRuntimeErrorMsg("mv", `Invalid filename: '${source}'`);
|
||||
if (!isValidFilePath(destination)) throw makeRuntimeErrorMsg("mv", `Invalid filename: '${destination}'`);
|
||||
|
||||
|
@ -5,13 +5,14 @@ import { Bladeburner } from "../Bladeburner/Bladeburner";
|
||||
import { getRamCost } from "../Netscript/RamCostGenerator";
|
||||
import { BitNodeMultipliers } from "../BitNode/BitNodeMultipliers";
|
||||
import { Bladeburner as INetscriptBladeburner, BladeburnerCurAction } from "../ScriptEditor/NetscriptDefinitions";
|
||||
import { IAction } from "src/Bladeburner/IAction";
|
||||
|
||||
export function NetscriptBladeburner(
|
||||
player: IPlayer,
|
||||
workerScript: WorkerScript,
|
||||
helper: INetscriptHelper,
|
||||
): INetscriptBladeburner {
|
||||
const checkBladeburnerAccess = function (func: any, skipjoined: any = false): void {
|
||||
const checkBladeburnerAccess = function (func: string, skipjoined = false): void {
|
||||
const bladeburner = player.bladeburner;
|
||||
if (bladeburner === null) throw new Error("Must have joined bladeburner");
|
||||
const apiAccess =
|
||||
@ -32,7 +33,7 @@ export function NetscriptBladeburner(
|
||||
}
|
||||
};
|
||||
|
||||
const checkBladeburnerCity = function (func: any, city: any): void {
|
||||
const checkBladeburnerCity = function (func: string, city: string): void {
|
||||
const bladeburner = player.bladeburner;
|
||||
if (bladeburner === null) throw new Error("Must have joined bladeburner");
|
||||
if (!bladeburner.cities.hasOwnProperty(city)) {
|
||||
@ -40,7 +41,7 @@ export function NetscriptBladeburner(
|
||||
}
|
||||
};
|
||||
|
||||
const getBladeburnerActionObject = function (func: any, type: any, name: any): any {
|
||||
const getBladeburnerActionObject = function (func: string, type: string, name: string): IAction {
|
||||
const bladeburner = player.bladeburner;
|
||||
if (bladeburner === null) throw new Error("Must have joined bladeburner");
|
||||
const actionId = bladeburner.getActionIdFromTypeAndName(type, name);
|
||||
@ -77,10 +78,11 @@ export function NetscriptBladeburner(
|
||||
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
||||
return bladeburner.getBlackOpNamesNetscriptFn();
|
||||
},
|
||||
getBlackOpRank: function (name: any = ""): number {
|
||||
getBlackOpRank: function (_blackOpName: unknown): number {
|
||||
const blackOpName = helper.string("getBlackOpRank", "blackOpName", _blackOpName);
|
||||
helper.updateDynamicRam("getBlackOpRank", getRamCost(player, "bladeburner", "getBlackOpRank"));
|
||||
checkBladeburnerAccess("getBlackOpRank");
|
||||
const action: any = getBladeburnerActionObject("getBlackOpRank", "blackops", name);
|
||||
const action: any = getBladeburnerActionObject("getBlackOpRank", "blackops", blackOpName);
|
||||
return action.reqdRank;
|
||||
},
|
||||
getGeneralActionNames: function (): string[] {
|
||||
@ -97,7 +99,9 @@ export function NetscriptBladeburner(
|
||||
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
||||
return bladeburner.getSkillNamesNetscriptFn();
|
||||
},
|
||||
startAction: function (type: any = "", name: any = ""): boolean {
|
||||
startAction: function (_type: unknown, _name: unknown): boolean {
|
||||
const type = helper.string("startAction", "type", _type);
|
||||
const name = helper.string("startAction", "name", _name);
|
||||
helper.updateDynamicRam("startAction", getRamCost(player, "bladeburner", "startAction"));
|
||||
checkBladeburnerAccess("startAction");
|
||||
const bladeburner = player.bladeburner;
|
||||
@ -122,7 +126,9 @@ export function NetscriptBladeburner(
|
||||
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
||||
return bladeburner.getTypeAndNameFromActionId(bladeburner.action);
|
||||
},
|
||||
getActionTime: function (type: any = "", name: any = ""): number {
|
||||
getActionTime: function (_type: unknown, _name: unknown): number {
|
||||
const type = helper.string("getActionTime", "type", _type);
|
||||
const name = helper.string("getActionTime", "name", _name);
|
||||
helper.updateDynamicRam("getActionTime", getRamCost(player, "bladeburner", "getActionTime"));
|
||||
checkBladeburnerAccess("getActionTime");
|
||||
const bladeburner = player.bladeburner;
|
||||
@ -133,7 +139,9 @@ export function NetscriptBladeburner(
|
||||
throw helper.makeRuntimeErrorMsg("bladeburner.getActionTime", e);
|
||||
}
|
||||
},
|
||||
getActionEstimatedSuccessChance: function (type: any = "", name: any = ""): [number, number] {
|
||||
getActionEstimatedSuccessChance: function (_type: unknown, _name: unknown): [number, number] {
|
||||
const type = helper.string("getActionEstimatedSuccessChance", "type", _type);
|
||||
const name = helper.string("getActionEstimatedSuccessChance", "name", _name);
|
||||
helper.updateDynamicRam(
|
||||
"getActionEstimatedSuccessChance",
|
||||
getRamCost(player, "bladeburner", "getActionEstimatedSuccessChance"),
|
||||
@ -147,7 +155,10 @@ export function NetscriptBladeburner(
|
||||
throw helper.makeRuntimeErrorMsg("bladeburner.getActionEstimatedSuccessChance", e);
|
||||
}
|
||||
},
|
||||
getActionRepGain: function (type: any = "", name: any = "", level: any): number {
|
||||
getActionRepGain: function (_type: unknown, _name: unknown, _level: unknown): number {
|
||||
const type = helper.string("getActionRepGain", "type", _type);
|
||||
const name = helper.string("getActionRepGain", "name", _name);
|
||||
const level = helper.number("getActionRepGain", "level", _level);
|
||||
helper.updateDynamicRam("getActionRepGain", getRamCost(player, "bladeburner", "getActionRepGain"));
|
||||
checkBladeburnerAccess("getActionRepGain");
|
||||
const action = getBladeburnerActionObject("getActionRepGain", type, name);
|
||||
@ -160,7 +171,9 @@ export function NetscriptBladeburner(
|
||||
|
||||
return action.rankGain * rewardMultiplier * BitNodeMultipliers.BladeburnerRank;
|
||||
},
|
||||
getActionCountRemaining: function (type: any = "", name: any = ""): number {
|
||||
getActionCountRemaining: function (_type: unknown, _name: unknown): number {
|
||||
const type = helper.string("getActionCountRemaining", "type", _type);
|
||||
const name = helper.string("getActionCountRemaining", "name", _name);
|
||||
helper.updateDynamicRam("getActionCountRemaining", getRamCost(player, "bladeburner", "getActionCountRemaining"));
|
||||
checkBladeburnerAccess("getActionCountRemaining");
|
||||
const bladeburner = player.bladeburner;
|
||||
@ -171,31 +184,43 @@ export function NetscriptBladeburner(
|
||||
throw helper.makeRuntimeErrorMsg("bladeburner.getActionCountRemaining", e);
|
||||
}
|
||||
},
|
||||
getActionMaxLevel: function (type: any = "", name: any = ""): number {
|
||||
getActionMaxLevel: function (_type: unknown, _name: unknown): number {
|
||||
const type = helper.string("getActionMaxLevel", "type", _type);
|
||||
const name = helper.string("getActionMaxLevel", "name", _name);
|
||||
helper.updateDynamicRam("getActionMaxLevel", getRamCost(player, "bladeburner", "getActionMaxLevel"));
|
||||
checkBladeburnerAccess("getActionMaxLevel");
|
||||
const action = getBladeburnerActionObject("getActionMaxLevel", type, name);
|
||||
return action.maxLevel;
|
||||
},
|
||||
getActionCurrentLevel: function (type: any = "", name: any = ""): number {
|
||||
getActionCurrentLevel: function (_type: unknown, _name: unknown): number {
|
||||
const type = helper.string("getActionCurrentLevel", "type", _type);
|
||||
const name = helper.string("getActionCurrentLevel", "name", _name);
|
||||
helper.updateDynamicRam("getActionCurrentLevel", getRamCost(player, "bladeburner", "getActionCurrentLevel"));
|
||||
checkBladeburnerAccess("getActionCurrentLevel");
|
||||
const action = getBladeburnerActionObject("getActionCurrentLevel", type, name);
|
||||
return action.level;
|
||||
},
|
||||
getActionAutolevel: function (type: any = "", name: any = ""): boolean {
|
||||
getActionAutolevel: function (_type: unknown, _name: unknown): boolean {
|
||||
const type = helper.string("getActionAutolevel", "type", _type);
|
||||
const name = helper.string("getActionAutolevel", "name", _name);
|
||||
helper.updateDynamicRam("getActionAutolevel", getRamCost(player, "bladeburner", "getActionAutolevel"));
|
||||
checkBladeburnerAccess("getActionAutolevel");
|
||||
const action = getBladeburnerActionObject("getActionCurrentLevel", type, name);
|
||||
return action.autoLevel;
|
||||
},
|
||||
setActionAutolevel: function (type: any = "", name: any = "", autoLevel: any = true): void {
|
||||
setActionAutolevel: function (_type: unknown, _name: unknown, _autoLevel: unknown = true): void {
|
||||
const type = helper.string("setActionAutolevel", "type", _type);
|
||||
const name = helper.string("setActionAutolevel", "name", _name);
|
||||
const autoLevel = helper.boolean(_autoLevel);
|
||||
helper.updateDynamicRam("setActionAutolevel", getRamCost(player, "bladeburner", "setActionAutolevel"));
|
||||
checkBladeburnerAccess("setActionAutolevel");
|
||||
const action = getBladeburnerActionObject("setActionAutolevel", type, name);
|
||||
action.autoLevel = autoLevel;
|
||||
},
|
||||
setActionLevel: function (type: any = "", name: any = "", level: any = 1): void {
|
||||
setActionLevel: function (_type: unknown, _name: unknown, _level: unknown = 1): void {
|
||||
const type = helper.string("setActionLevel", "type", _type);
|
||||
const name = helper.string("setActionLevel", "name", _name);
|
||||
const level = helper.number("setActionLevel", "level", _level);
|
||||
helper.updateDynamicRam("setActionLevel", getRamCost(player, "bladeburner", "setActionLevel"));
|
||||
checkBladeburnerAccess("setActionLevel");
|
||||
const action = getBladeburnerActionObject("setActionLevel", type, name);
|
||||
@ -221,7 +246,8 @@ export function NetscriptBladeburner(
|
||||
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
||||
return bladeburner.skillPoints;
|
||||
},
|
||||
getSkillLevel: function (skillName: any = ""): number {
|
||||
getSkillLevel: function (_skillName: unknown): number {
|
||||
const skillName = helper.string("getSkillLevel", "skillName", _skillName);
|
||||
helper.updateDynamicRam("getSkillLevel", getRamCost(player, "bladeburner", "getSkillLevel"));
|
||||
checkBladeburnerAccess("getSkillLevel");
|
||||
const bladeburner = player.bladeburner;
|
||||
@ -232,7 +258,8 @@ export function NetscriptBladeburner(
|
||||
throw helper.makeRuntimeErrorMsg("bladeburner.getSkillLevel", e);
|
||||
}
|
||||
},
|
||||
getSkillUpgradeCost: function (skillName: any = ""): number {
|
||||
getSkillUpgradeCost: function (_skillName: unknown): number {
|
||||
const skillName = helper.string("getSkillUpgradeCost", "skillName", _skillName);
|
||||
helper.updateDynamicRam("getSkillUpgradeCost", getRamCost(player, "bladeburner", "getSkillUpgradeCost"));
|
||||
checkBladeburnerAccess("getSkillUpgradeCost");
|
||||
const bladeburner = player.bladeburner;
|
||||
@ -243,7 +270,8 @@ export function NetscriptBladeburner(
|
||||
throw helper.makeRuntimeErrorMsg("bladeburner.getSkillUpgradeCost", e);
|
||||
}
|
||||
},
|
||||
upgradeSkill: function (skillName: any): boolean {
|
||||
upgradeSkill: function (_skillName: unknown): boolean {
|
||||
const skillName = helper.string("upgradeSkill", "skillName", _skillName);
|
||||
helper.updateDynamicRam("upgradeSkill", getRamCost(player, "bladeburner", "upgradeSkill"));
|
||||
checkBladeburnerAccess("upgradeSkill");
|
||||
const bladeburner = player.bladeburner;
|
||||
@ -254,7 +282,9 @@ export function NetscriptBladeburner(
|
||||
throw helper.makeRuntimeErrorMsg("bladeburner.upgradeSkill", e);
|
||||
}
|
||||
},
|
||||
getTeamSize: function (type: any = "", name: any = ""): number {
|
||||
getTeamSize: function (_type: unknown, _name: unknown): number {
|
||||
const type = helper.string("getTeamSize", "type", _type);
|
||||
const name = helper.string("getTeamSize", "name", _name);
|
||||
helper.updateDynamicRam("getTeamSize", getRamCost(player, "bladeburner", "getTeamSize"));
|
||||
checkBladeburnerAccess("getTeamSize");
|
||||
const bladeburner = player.bladeburner;
|
||||
@ -265,7 +295,10 @@ export function NetscriptBladeburner(
|
||||
throw helper.makeRuntimeErrorMsg("bladeburner.getTeamSize", e);
|
||||
}
|
||||
},
|
||||
setTeamSize: function (type: any = "", name: any = "", size: any): number {
|
||||
setTeamSize: function (_type: unknown, _name: unknown, _size: unknown): number {
|
||||
const type = helper.string("setTeamSize", "type", _type);
|
||||
const name = helper.string("setTeamSize", "name", _name);
|
||||
const size = helper.number("setTeamSize", "size", _size);
|
||||
helper.updateDynamicRam("setTeamSize", getRamCost(player, "bladeburner", "setTeamSize"));
|
||||
checkBladeburnerAccess("setTeamSize");
|
||||
const bladeburner = player.bladeburner;
|
||||
@ -276,7 +309,8 @@ export function NetscriptBladeburner(
|
||||
throw helper.makeRuntimeErrorMsg("bladeburner.setTeamSize", e);
|
||||
}
|
||||
},
|
||||
getCityEstimatedPopulation: function (cityName: any): number {
|
||||
getCityEstimatedPopulation: function (_cityName: unknown): number {
|
||||
const cityName = helper.string("getCityEstimatedPopulation", "cityName", _cityName);
|
||||
helper.updateDynamicRam(
|
||||
"getCityEstimatedPopulation",
|
||||
getRamCost(player, "bladeburner", "getCityEstimatedPopulation"),
|
||||
@ -287,7 +321,8 @@ export function NetscriptBladeburner(
|
||||
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
||||
return bladeburner.cities[cityName].popEst;
|
||||
},
|
||||
getCityCommunities: function (cityName: any): number {
|
||||
getCityCommunities: function (_cityName: unknown): number {
|
||||
const cityName = helper.string("getCityCommunities", "cityName", _cityName);
|
||||
helper.updateDynamicRam("getCityCommunities", getRamCost(player, "bladeburner", "getCityCommunities"));
|
||||
checkBladeburnerAccess("getCityCommunities");
|
||||
checkBladeburnerCity("getCityCommunities", cityName);
|
||||
@ -295,7 +330,8 @@ export function NetscriptBladeburner(
|
||||
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
||||
return bladeburner.cities[cityName].comms;
|
||||
},
|
||||
getCityChaos: function (cityName: any): number {
|
||||
getCityChaos: function (_cityName: unknown): number {
|
||||
const cityName = helper.string("getCityChaos", "cityName", _cityName);
|
||||
helper.updateDynamicRam("getCityChaos", getRamCost(player, "bladeburner", "getCityChaos"));
|
||||
checkBladeburnerAccess("getCityChaos");
|
||||
checkBladeburnerCity("getCityChaos", cityName);
|
||||
@ -310,13 +346,14 @@ export function NetscriptBladeburner(
|
||||
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
||||
return bladeburner.city;
|
||||
},
|
||||
switchCity: function (cityName: any): boolean {
|
||||
switchCity: function (_cityName: unknown): boolean {
|
||||
const cityName = helper.string("switchCity", "cityName", _cityName);
|
||||
helper.updateDynamicRam("switchCity", getRamCost(player, "bladeburner", "switchCity"));
|
||||
checkBladeburnerAccess("switchCity");
|
||||
checkBladeburnerCity("switchCity", cityName);
|
||||
const bladeburner = player.bladeburner;
|
||||
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
||||
return (bladeburner.city = cityName);
|
||||
return bladeburner.city === cityName;
|
||||
},
|
||||
getStamina: function (): [number, number] {
|
||||
helper.updateDynamicRam("getStamina", getRamCost(player, "bladeburner", "getStamina"));
|
||||
@ -365,7 +402,7 @@ export function NetscriptBladeburner(
|
||||
checkBladeburnerAccess("getBonusTime");
|
||||
const bladeburner = player.bladeburner;
|
||||
if (bladeburner === null) throw new Error("Should not be called without Bladeburner");
|
||||
return (Math.round(bladeburner.storedCycles / 5))*1000;
|
||||
return Math.round(bladeburner.storedCycles / 5) * 1000;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -230,14 +230,14 @@ export function NetscriptCorporation(
|
||||
return corporation;
|
||||
}
|
||||
|
||||
function getDivision(divisionName: any): IIndustry {
|
||||
function getDivision(divisionName: string): IIndustry {
|
||||
const corporation = getCorporation();
|
||||
const division = corporation.divisions.find((div) => div.name === divisionName);
|
||||
if (division === undefined) throw new Error(`No division named '${divisionName}'`);
|
||||
return division;
|
||||
}
|
||||
|
||||
function getOffice(divisionName: any, cityName: any): OfficeSpace {
|
||||
function getOffice(divisionName: string, cityName: string): OfficeSpace {
|
||||
const division = getDivision(divisionName);
|
||||
if (!(cityName in division.offices)) throw new Error(`Invalid city name '${cityName}'`);
|
||||
const office = division.offices[cityName];
|
||||
@ -245,7 +245,7 @@ export function NetscriptCorporation(
|
||||
return office;
|
||||
}
|
||||
|
||||
function getWarehouse(divisionName: any, cityName: any): Warehouse {
|
||||
function getWarehouse(divisionName: string, cityName: string): Warehouse {
|
||||
const division = getDivision(divisionName);
|
||||
if (!(cityName in division.warehouses)) throw new Error(`Invalid city name '${cityName}'`);
|
||||
const warehouse = division.warehouses[cityName];
|
||||
@ -253,7 +253,7 @@ export function NetscriptCorporation(
|
||||
return warehouse;
|
||||
}
|
||||
|
||||
function getMaterial(divisionName: any, cityName: any, materialName: any): Material {
|
||||
function getMaterial(divisionName: string, cityName: string, materialName: string): Material {
|
||||
const warehouse = getWarehouse(divisionName, cityName);
|
||||
const matName = (materialName as string).replace(/ /g, "");
|
||||
const material = warehouse.materials[matName];
|
||||
@ -261,14 +261,14 @@ export function NetscriptCorporation(
|
||||
return material;
|
||||
}
|
||||
|
||||
function getProduct(divisionName: any, productName: any): Product {
|
||||
function getProduct(divisionName: string, productName: string): Product {
|
||||
const division = getDivision(divisionName);
|
||||
const product = division.products[productName];
|
||||
if (product === undefined) throw new Error(`Invalid product name: '${productName}'`);
|
||||
return product;
|
||||
}
|
||||
|
||||
function getEmployee(divisionName: any, cityName: any, employeeName: any): Employee {
|
||||
function getEmployee(divisionName: string, cityName: string, employeeName: string): Employee {
|
||||
const office = getOffice(divisionName, cityName);
|
||||
const employee = office.employees.find((e) => e.name === employeeName);
|
||||
if (employee === undefined) throw new Error(`Invalid employee name: '${employeeName}'`);
|
||||
@ -314,14 +314,14 @@ export function NetscriptCorporation(
|
||||
getUpgradeWarehouseCost: function (_divisionName: unknown, _cityName: unknown): number {
|
||||
checkAccess("upgradeWarehouse", 7);
|
||||
const divisionName = helper.string("getUpgradeWarehouseCost", "divisionName", _divisionName);
|
||||
const cityName = helper.string("getUpgradeWarehouseCost", "cityName", _cityName);
|
||||
const cityName = helper.city("getUpgradeWarehouseCost", "cityName", _cityName);
|
||||
const warehouse = getWarehouse(divisionName, cityName);
|
||||
return CorporationConstants.WarehouseUpgradeBaseCost * Math.pow(1.07, warehouse.level + 1);
|
||||
},
|
||||
hasWarehouse: function (_divisionName: unknown, _cityName: unknown): boolean {
|
||||
checkAccess("hasWarehouse", 7);
|
||||
const divisionName = helper.string("getWarehouse", "divisionName", _divisionName);
|
||||
const cityName = helper.string("getWarehouse", "cityName", _cityName);
|
||||
const cityName = helper.city("getWarehouse", "cityName", _cityName);
|
||||
const division = getDivision(divisionName);
|
||||
if (!(cityName in division.warehouses)) throw new Error(`Invalid city name '${cityName}'`);
|
||||
const warehouse = division.warehouses[cityName];
|
||||
@ -330,7 +330,7 @@ export function NetscriptCorporation(
|
||||
getWarehouse: function (_divisionName: unknown, _cityName: unknown): NSWarehouse {
|
||||
checkAccess("getWarehouse", 7);
|
||||
const divisionName = helper.string("getWarehouse", "divisionName", _divisionName);
|
||||
const cityName = helper.string("getWarehouse", "cityName", _cityName);
|
||||
const cityName = helper.city("getWarehouse", "cityName", _cityName);
|
||||
const warehouse = getWarehouse(divisionName, cityName);
|
||||
return {
|
||||
level: warehouse.level,
|
||||
@ -343,7 +343,7 @@ export function NetscriptCorporation(
|
||||
getMaterial: function (_divisionName: unknown, _cityName: unknown, _materialName: unknown): NSMaterial {
|
||||
checkAccess("getMaterial", 7);
|
||||
const divisionName = helper.string("getMaterial", "divisionName", _divisionName);
|
||||
const cityName = helper.string("getMaterial", "cityName", _cityName);
|
||||
const cityName = helper.city("getMaterial", "cityName", _cityName);
|
||||
const materialName = helper.string("getMaterial", "materialName", _materialName);
|
||||
const material = getMaterial(divisionName, cityName, materialName);
|
||||
return {
|
||||
@ -372,14 +372,14 @@ export function NetscriptCorporation(
|
||||
purchaseWarehouse: function (_divisionName: unknown, _cityName: unknown): void {
|
||||
checkAccess("purchaseWarehouse", 7);
|
||||
const divisionName = helper.string("purchaseWarehouse", "divisionName", _divisionName);
|
||||
const cityName = helper.string("purchaseWarehouse", "cityName", _cityName);
|
||||
const cityName = helper.city("purchaseWarehouse", "cityName", _cityName);
|
||||
const corporation = getCorporation();
|
||||
PurchaseWarehouse(corporation, getDivision(divisionName), cityName);
|
||||
},
|
||||
upgradeWarehouse: function (_divisionName: unknown, _cityName: unknown): void {
|
||||
checkAccess("upgradeWarehouse", 7);
|
||||
const divisionName = helper.string("upgradeWarehouse", "divisionName", _divisionName);
|
||||
const cityName = helper.string("upgradeWarehouse", "cityName", _cityName);
|
||||
const cityName = helper.city("upgradeWarehouse", "cityName", _cityName);
|
||||
const corporation = getCorporation();
|
||||
UpgradeWarehouse(corporation, getDivision(divisionName), getWarehouse(divisionName, cityName));
|
||||
},
|
||||
@ -392,7 +392,7 @@ export function NetscriptCorporation(
|
||||
): void {
|
||||
checkAccess("sellMaterial", 7);
|
||||
const divisionName = helper.string("sellMaterial", "divisionName", _divisionName);
|
||||
const cityName = helper.string("sellMaterial", "cityName", _cityName);
|
||||
const cityName = helper.city("sellMaterial", "cityName", _cityName);
|
||||
const materialName = helper.string("sellMaterial", "materialName", _materialName);
|
||||
const amt = helper.string("sellMaterial", "amt", _amt);
|
||||
const price = helper.string("sellMaterial", "price", _price);
|
||||
@ -409,7 +409,7 @@ export function NetscriptCorporation(
|
||||
): void {
|
||||
checkAccess("sellProduct", 7);
|
||||
const divisionName = helper.string("sellProduct", "divisionName", _divisionName);
|
||||
const cityName = helper.string("sellProduct", "cityName", _cityName);
|
||||
const cityName = helper.city("sellProduct", "cityName", _cityName);
|
||||
const productName = helper.string("sellProduct", "productName", _productName);
|
||||
const amt = helper.string("sellProduct", "amt", _amt);
|
||||
const price = helper.string("sellProduct", "price", _price);
|
||||
@ -426,7 +426,7 @@ export function NetscriptCorporation(
|
||||
setSmartSupply: function (_divisionName: unknown, _cityName: unknown, _enabled: unknown): void {
|
||||
checkAccess("setSmartSupply", 7);
|
||||
const divisionName = helper.string("setSmartSupply", "divisionName", _divisionName);
|
||||
const cityName = helper.string("sellProduct", "cityName", _cityName);
|
||||
const cityName = helper.city("sellProduct", "cityName", _cityName);
|
||||
const enabled = helper.boolean(_enabled);
|
||||
const warehouse = getWarehouse(divisionName, cityName);
|
||||
if (!hasUnlockUpgrade("Smart Supply"))
|
||||
@ -444,7 +444,7 @@ export function NetscriptCorporation(
|
||||
): void {
|
||||
checkAccess("setSmartSupplyUseLeftovers", 7);
|
||||
const divisionName = helper.string("setSmartSupply", "divisionName", _divisionName);
|
||||
const cityName = helper.string("sellProduct", "cityName", _cityName);
|
||||
const cityName = helper.city("sellProduct", "cityName", _cityName);
|
||||
const materialName = helper.string("sellProduct", "materialName", _materialName);
|
||||
const enabled = helper.boolean(_enabled);
|
||||
const warehouse = getWarehouse(divisionName, cityName);
|
||||
@ -459,7 +459,7 @@ export function NetscriptCorporation(
|
||||
buyMaterial: function (_divisionName: unknown, _cityName: unknown, _materialName: unknown, _amt: unknown): void {
|
||||
checkAccess("buyMaterial", 7);
|
||||
const divisionName = helper.string("buyMaterial", "divisionName", _divisionName);
|
||||
const cityName = helper.string("buyMaterial", "cityName", _cityName);
|
||||
const cityName = helper.city("buyMaterial", "cityName", _cityName);
|
||||
const materialName = helper.string("buyMaterial", "materialName", _materialName);
|
||||
const amt = helper.number("buyMaterial", "amt", _amt);
|
||||
if (amt < 0) throw new Error("Invalid value for amount field! Must be numeric and greater than 0");
|
||||
@ -469,10 +469,10 @@ export function NetscriptCorporation(
|
||||
bulkPurchase: function (_divisionName: unknown, _cityName: unknown, _materialName: unknown, _amt: unknown): void {
|
||||
checkAccess("bulkPurchase", 7);
|
||||
const divisionName = helper.string("bulkPurchase", "divisionName", _divisionName);
|
||||
if (!hasResearched(getDivision(_divisionName), "Bulk Purchasing"))
|
||||
if (!hasResearched(getDivision(divisionName), "Bulk Purchasing"))
|
||||
throw new Error(`You have not researched Bulk Purchasing in ${divisionName}`);
|
||||
const corporation = getCorporation();
|
||||
const cityName = helper.string("bulkPurchase", "cityName", _cityName);
|
||||
const cityName = helper.city("bulkPurchase", "cityName", _cityName);
|
||||
const materialName = helper.string("bulkPurchase", "materialName", _materialName);
|
||||
const amt = helper.number("bulkPurchase", "amt", _amt);
|
||||
const warehouse = getWarehouse(divisionName, cityName);
|
||||
@ -488,7 +488,7 @@ export function NetscriptCorporation(
|
||||
): void {
|
||||
checkAccess("makeProduct", 7);
|
||||
const divisionName = helper.string("makeProduct", "divisionName", _divisionName);
|
||||
const cityName = helper.string("makeProduct", "cityName", _cityName);
|
||||
const cityName = helper.city("makeProduct", "cityName", _cityName);
|
||||
const productName = helper.string("makeProduct", "productName", _productName);
|
||||
const designInvest = helper.number("makeProduct", "designInvest", _designInvest);
|
||||
const marketingInvest = helper.number("makeProduct", "marketingInvest", _marketingInvest);
|
||||
@ -543,7 +543,7 @@ export function NetscriptCorporation(
|
||||
): void {
|
||||
checkAccess("setMaterialMarketTA1", 7);
|
||||
const divisionName = helper.string("setMaterialMarketTA1", "divisionName", _divisionName);
|
||||
const cityName = helper.string("setMaterialMarketTA1", "cityName", _cityName);
|
||||
const cityName = helper.city("setMaterialMarketTA1", "cityName", _cityName);
|
||||
const materialName = helper.string("setMaterialMarketTA1", "materialName", _materialName);
|
||||
const on = helper.boolean(_on);
|
||||
if (!getDivision(divisionName).hasResearch("Market-TA.I"))
|
||||
@ -561,7 +561,7 @@ export function NetscriptCorporation(
|
||||
): void {
|
||||
checkAccess("setMaterialMarketTA2", 7);
|
||||
const divisionName = helper.string("setMaterialMarketTA2", "divisionName", _divisionName);
|
||||
const cityName = helper.string("setMaterialMarketTA2", "cityName", _cityName);
|
||||
const cityName = helper.city("setMaterialMarketTA2", "cityName", _cityName);
|
||||
const materialName = helper.string("setMaterialMarketTA2", "materialName", _materialName);
|
||||
const on = helper.boolean(_on);
|
||||
if (!getDivision(divisionName).hasResearch("Market-TA.II"))
|
||||
@ -631,7 +631,7 @@ export function NetscriptCorporation(
|
||||
): Promise<boolean> {
|
||||
checkAccess("setAutoJobAssignment", 8);
|
||||
const divisionName = helper.string("setAutoJobAssignment", "divisionName", _divisionName);
|
||||
const cityName = helper.string("setAutoJobAssignment", "cityName", _cityName);
|
||||
const cityName = helper.city("setAutoJobAssignment", "cityName", _cityName);
|
||||
const amount = helper.number("setAutoJobAssignment", "amount", _amount);
|
||||
const job = helper.string("setAutoJobAssignment", "job", _job);
|
||||
const office = getOffice(divisionName, cityName);
|
||||
@ -646,7 +646,7 @@ export function NetscriptCorporation(
|
||||
getOfficeSizeUpgradeCost: function (_divisionName: unknown, _cityName: unknown, _size: unknown): number {
|
||||
checkAccess("getOfficeSizeUpgradeCost", 8);
|
||||
const divisionName = helper.string("getOfficeSizeUpgradeCost", "divisionName", _divisionName);
|
||||
const cityName = helper.string("getOfficeSizeUpgradeCost", "cityName", _cityName);
|
||||
const cityName = helper.city("getOfficeSizeUpgradeCost", "cityName", _cityName);
|
||||
const size = helper.number("getOfficeSizeUpgradeCost", "size", _size);
|
||||
if (size < 0) throw new Error("Invalid value for size field! Must be numeric and greater than 0");
|
||||
const office = getOffice(divisionName, cityName);
|
||||
@ -666,7 +666,7 @@ export function NetscriptCorporation(
|
||||
): Promise<void> {
|
||||
checkAccess("assignJob", 8);
|
||||
const divisionName = helper.string("assignJob", "divisionName", _divisionName);
|
||||
const cityName = helper.string("assignJob", "cityName", _cityName);
|
||||
const cityName = helper.city("assignJob", "cityName", _cityName);
|
||||
const employeeName = helper.string("assignJob", "employeeName", _employeeName);
|
||||
const job = helper.string("assignJob", "job", _job);
|
||||
const employee = getEmployee(divisionName, cityName, employeeName);
|
||||
@ -677,14 +677,14 @@ export function NetscriptCorporation(
|
||||
hireEmployee: function (_divisionName: unknown, _cityName: unknown): any {
|
||||
checkAccess("hireEmployee", 8);
|
||||
const divisionName = helper.string("hireEmployee", "divisionName", _divisionName);
|
||||
const cityName = helper.string("hireEmployee", "cityName", _cityName);
|
||||
const cityName = helper.city("hireEmployee", "cityName", _cityName);
|
||||
const office = getOffice(divisionName, cityName);
|
||||
return office.hireRandomEmployee();
|
||||
},
|
||||
upgradeOfficeSize: function (_divisionName: unknown, _cityName: unknown, _size: unknown): void {
|
||||
checkAccess("upgradeOfficeSize", 8);
|
||||
const divisionName = helper.string("upgradeOfficeSize", "divisionName", _divisionName);
|
||||
const cityName = helper.string("upgradeOfficeSize", "cityName", _cityName);
|
||||
const cityName = helper.city("upgradeOfficeSize", "cityName", _cityName);
|
||||
const size = helper.number("upgradeOfficeSize", "size", _size);
|
||||
if (size < 0) throw new Error("Invalid value for size field! Must be numeric and greater than 0");
|
||||
const office = getOffice(divisionName, cityName);
|
||||
@ -694,7 +694,7 @@ export function NetscriptCorporation(
|
||||
throwParty: function (_divisionName: unknown, _cityName: unknown, _costPerEmployee: unknown): Promise<number> {
|
||||
checkAccess("throwParty", 8);
|
||||
const divisionName = helper.string("throwParty", "divisionName", _divisionName);
|
||||
const cityName = helper.string("throwParty", "cityName", _cityName);
|
||||
const cityName = helper.city("throwParty", "cityName", _cityName);
|
||||
const costPerEmployee = helper.number("throwParty", "costPerEmployee", _costPerEmployee);
|
||||
if (costPerEmployee < 0)
|
||||
throw new Error("Invalid value for Cost Per Employee field! Must be numeric and greater than 0");
|
||||
@ -710,7 +710,7 @@ export function NetscriptCorporation(
|
||||
buyCoffee: function (_divisionName: unknown, _cityName: unknown): Promise<void> {
|
||||
checkAccess("buyCoffee", 8);
|
||||
const divisionName = helper.string("buyCoffee", "divisionName", _divisionName);
|
||||
const cityName = helper.string("buyCoffee", "cityName", _cityName);
|
||||
const cityName = helper.city("buyCoffee", "cityName", _cityName);
|
||||
const corporation = getCorporation();
|
||||
return netscriptDelay(
|
||||
(60 * 1000) / (player.hacking_speed_mult * calculateIntelligenceBonus(player.intelligence, 1)),
|
||||
@ -734,7 +734,7 @@ export function NetscriptCorporation(
|
||||
getOffice: function (_divisionName: unknown, _cityName: unknown): any {
|
||||
checkAccess("getOffice", 8);
|
||||
const divisionName = helper.string("getOffice", "divisionName", _divisionName);
|
||||
const cityName = helper.string("getOffice", "cityName", _cityName);
|
||||
const cityName = helper.city("getOffice", "cityName", _cityName);
|
||||
const office = getOffice(divisionName, cityName);
|
||||
return {
|
||||
loc: office.loc,
|
||||
@ -758,7 +758,7 @@ export function NetscriptCorporation(
|
||||
getEmployee: function (_divisionName: unknown, _cityName: unknown, _employeeName: unknown): NSEmployee {
|
||||
checkAccess("getEmployee", 8);
|
||||
const divisionName = helper.string("getEmployee", "divisionName", _divisionName);
|
||||
const cityName = helper.string("getEmployee", "cityName", _cityName);
|
||||
const cityName = helper.city("getEmployee", "cityName", _cityName);
|
||||
const employeeName = helper.string("getEmployee", "employeeName", _employeeName);
|
||||
const employee = getEmployee(divisionName, cityName, employeeName);
|
||||
return {
|
||||
@ -791,7 +791,7 @@ export function NetscriptCorporation(
|
||||
expandCity: function (_divisionName: unknown, _cityName: unknown): void {
|
||||
checkAccess("expandCity");
|
||||
const divisionName = helper.string("expandCity", "divisionName", _divisionName);
|
||||
const cityName = helper.string("expandCity", "cityName", _cityName);
|
||||
const cityName = helper.city("expandCity", "cityName", _cityName);
|
||||
if (!CorporationConstants.Cities.includes(cityName)) throw new Error("Invalid city name");
|
||||
const corporation = getCorporation();
|
||||
const division = getDivision(divisionName);
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { CityName } from "src/Locations/data/CityNames";
|
||||
import { BaseServer } from "../Server/BaseServer";
|
||||
|
||||
export interface INetscriptHelper {
|
||||
@ -5,6 +6,7 @@ export interface INetscriptHelper {
|
||||
makeRuntimeErrorMsg(functionName: string, message: string): void;
|
||||
string(funcName: string, argName: string, v: unknown): string;
|
||||
number(funcName: string, argName: string, v: unknown): number;
|
||||
city(funcName: string, argName: string, v: unknown): CityName;
|
||||
boolean(v: unknown): boolean;
|
||||
getServer(ip: any, fn: any): BaseServer;
|
||||
checkSingularityAccess(func: string): void;
|
||||
|
@ -466,7 +466,7 @@ export function NetscriptSingularity(
|
||||
},
|
||||
|
||||
travelToCity: function (_cityName: unknown): boolean {
|
||||
const cityName = helper.string("travelToCity", "cityName", _cityName);
|
||||
const cityName = helper.city("travelToCity", "cityName", _cityName);
|
||||
helper.updateDynamicRam("travelToCity", getRamCost(player, "travelToCity"));
|
||||
helper.checkSingularityAccess("travelToCity");
|
||||
|
||||
|
@ -26,6 +26,6 @@ export class GraftableAugmentation {
|
||||
const antiLog = Math.max(sum(Object.values(this.augmentation.mults)), 1);
|
||||
|
||||
const mult = Math.log2(antiLog);
|
||||
return CONSTANTS.AugmentationGraftingTimeBase * mult + CONSTANTS.MillisecondsPerHalfHour;
|
||||
return (CONSTANTS.AugmentationGraftingTimeBase * mult + CONSTANTS.MillisecondsPerHalfHour) / 2;
|
||||
}
|
||||
}
|
||||
|
@ -2078,15 +2078,16 @@ export function reapplyAllAugmentations(this: IPlayer, resetMultipliers = true):
|
||||
this.augmentations[i].name = "Hacknet Node NIC Architecture Neural-Upload";
|
||||
}
|
||||
|
||||
const augName = this.augmentations[i].name;
|
||||
const playerAug = this.augmentations[i];
|
||||
const augName = playerAug.name;
|
||||
const aug = Augmentations[augName];
|
||||
if (aug == null) {
|
||||
console.warn(`Invalid augmentation name in Player.reapplyAllAugmentations(). Aug ${augName} will be skipped`);
|
||||
continue;
|
||||
}
|
||||
aug.owned = true;
|
||||
if (aug.name == AugmentationNames.NeuroFluxGovernor) {
|
||||
for (let j = 0; j < aug.level; ++j) {
|
||||
if (augName == AugmentationNames.NeuroFluxGovernor) {
|
||||
for (let j = 0; j < playerAug.level; ++j) {
|
||||
applyAugmentation(this.augmentations[i], true);
|
||||
}
|
||||
continue;
|
||||
|
4
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
4
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
@ -584,7 +584,7 @@ export interface BitNodeMultipliers {
|
||||
/** Influences the maximum allowed RAM for a purchased server */
|
||||
PurchasedServerMaxRam: number;
|
||||
/** Influences cost of any purchased server at or above 128GB */
|
||||
PurchasedServerSoftCap: number;
|
||||
PurchasedServerSoftcap: number;
|
||||
/** Influences the minimum favor the player must have with a faction before they can donate to gain rep. */
|
||||
RepToDonateToFaction: number;
|
||||
/** Influences how much the money on a server can be reduced when a script performs a hack against it. */
|
||||
@ -5649,7 +5649,7 @@ export interface NS extends Singularity {
|
||||
* @param args - Arguments to identify the script
|
||||
* @returns The info about the running script if found, and null otherwise.
|
||||
*/
|
||||
getRunningScript(filename?: FilenameOrPID, hostname?: string, ...args: (string | number)[]): RunningScript;
|
||||
getRunningScript(filename?: FilenameOrPID, hostname?: string, ...args: (string | number)[]): RunningScript | null;
|
||||
|
||||
/**
|
||||
* Get cost of purchasing a server.
|
||||
|
@ -276,7 +276,7 @@ export function SidebarRoot(props: IProps): React.ReactElement {
|
||||
function handleShortcuts(this: Document, event: KeyboardEvent): any {
|
||||
if (Settings.DisableHotkeys) return;
|
||||
if ((props.player.isWorking && props.player.focus) || redPillFlag) return;
|
||||
if (event.key === "t" && event.altKey) {
|
||||
if (event.key === KEY.T && event.altKey) {
|
||||
event.preventDefault();
|
||||
clickTerminal();
|
||||
} else if (event.key === KEY.C && event.altKey) {
|
||||
@ -522,7 +522,9 @@ export function SidebarRoot(props: IProps): React.ReactElement {
|
||||
<ListItemIcon>
|
||||
<Badge badgeContent={invitationsCount !== 0 ? invitationsCount : undefined} color="error">
|
||||
<Tooltip title={!open ? "Factions" : ""}>
|
||||
<ContactsIcon color={![Page.Factions, Page.Faction].includes(props.page) ? "secondary" : "primary"} />
|
||||
<ContactsIcon
|
||||
color={![Page.Factions, Page.Faction].includes(props.page) ? "secondary" : "primary"}
|
||||
/>
|
||||
</Tooltip>
|
||||
</Badge>
|
||||
</ListItemIcon>
|
||||
@ -570,7 +572,9 @@ export function SidebarRoot(props: IProps): React.ReactElement {
|
||||
>
|
||||
<ListItemIcon>
|
||||
<Tooltip title={!open ? "Hacknet" : ""}>
|
||||
<AccountTreeIcon color={flashHacknet ? "error" : props.page !== Page.Hacknet ? "secondary" : "primary"} />
|
||||
<AccountTreeIcon
|
||||
color={flashHacknet ? "error" : props.page !== Page.Hacknet ? "secondary" : "primary"}
|
||||
/>
|
||||
</Tooltip>
|
||||
</ListItemIcon>
|
||||
<ListItemText>
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { KEY } from "../utils/helpers/keyCodes";
|
||||
import { substituteAliases } from "../Alias";
|
||||
// Helper function that checks if an argument (which is a string) is a valid number
|
||||
function isNumber(str: string): boolean {
|
||||
@ -55,11 +56,11 @@ export function ParseCommand(command: string): (string | number | boolean)[] {
|
||||
}
|
||||
|
||||
const c = command.charAt(i);
|
||||
if (c === '"') {
|
||||
if (c === KEY.DOUBLE_QUOTE) {
|
||||
// Double quotes
|
||||
if (!escaped && prevChar === " ") {
|
||||
const endQuote = command.indexOf('"', i + 1);
|
||||
if (endQuote !== -1 && (endQuote === command.length - 1 || command.charAt(endQuote + 1) === " ")) {
|
||||
if (!escaped && prevChar === KEY.SPACE) {
|
||||
const endQuote = command.indexOf(KEY.DOUBLE_QUOTE, i + 1);
|
||||
if (endQuote !== -1 && (endQuote === command.length - 1 || command.charAt(endQuote + 1) === KEY.SPACE)) {
|
||||
args.push(command.substr(i + 1, endQuote - i - 1));
|
||||
if (endQuote === command.length - 1) {
|
||||
start = i = endQuote + 1;
|
||||
@ -69,15 +70,15 @@ export function ParseCommand(command: string): (string | number | boolean)[] {
|
||||
continue;
|
||||
}
|
||||
} else if (inQuote === ``) {
|
||||
inQuote = `"`;
|
||||
} else if (inQuote === `"`) {
|
||||
inQuote = ``;
|
||||
}
|
||||
} else if (c === "'") {
|
||||
inQuote = KEY.DOUBLE_QUOTE;
|
||||
} else if (inQuote === KEY.DOUBLE_QUOTE) {
|
||||
inQuote = ``;
|
||||
}
|
||||
} else if (c === KEY.QUOTE) {
|
||||
// Single quotes, same thing as above
|
||||
if (!escaped && prevChar === " ") {
|
||||
const endQuote = command.indexOf("'", i + 1);
|
||||
if (endQuote !== -1 && (endQuote === command.length - 1 || command.charAt(endQuote + 1) === " ")) {
|
||||
if (!escaped && prevChar === KEY.SPACE) {
|
||||
const endQuote = command.indexOf(KEY.QUOTE, i + 1);
|
||||
if (endQuote !== -1 && (endQuote === command.length - 1 || command.charAt(endQuote + 1) === KEY.SPACE)) {
|
||||
args.push(command.substr(i + 1, endQuote - i - 1));
|
||||
if (endQuote === command.length - 1) {
|
||||
start = i = endQuote + 1;
|
||||
@ -87,11 +88,11 @@ export function ParseCommand(command: string): (string | number | boolean)[] {
|
||||
continue;
|
||||
}
|
||||
} else if (inQuote === ``) {
|
||||
inQuote = `'`;
|
||||
} else if (inQuote === `'`) {
|
||||
inQuote = ``;
|
||||
}
|
||||
} else if (c === " " && inQuote === ``) {
|
||||
inQuote = KEY.QUOTE;
|
||||
} else if (inQuote === KEY.QUOTE) {
|
||||
inQuote = ``;
|
||||
}
|
||||
} else if (c === KEY.SPACE && inQuote === ``) {
|
||||
const arg = command.substr(start, i - start);
|
||||
|
||||
// If this is a number, convert it from a string to number
|
||||
|
@ -20,7 +20,7 @@ function isNs2(filename: string): boolean {
|
||||
return filename.endsWith(".ns") || filename.endsWith(".js");
|
||||
}
|
||||
|
||||
const newNs2Template = `/** @param {NS} ns **/
|
||||
const newNs2Template = `/** @param {NS} ns */
|
||||
export async function main(ns) {
|
||||
|
||||
}`;
|
||||
|
@ -97,7 +97,7 @@ export function TerminalInput({ terminal, router, player }: IProps): React.React
|
||||
break;
|
||||
case "deletewordbefore": // Delete rest of word before the cursor
|
||||
for (let delStart = start - 1; delStart > -2; --delStart) {
|
||||
if ((inputText.charAt(delStart) === " " || delStart === -1) && delStart !== start - 1) {
|
||||
if ((inputText.charAt(delStart) === KEY.SPACE || delStart === -1) && delStart !== start - 1) {
|
||||
saveValue(inputText.substr(0, delStart + 1) + inputText.substr(start), () => {
|
||||
// Move cursor to correct location
|
||||
// foo bar |baz bum --> foo |baz bum
|
||||
@ -110,7 +110,7 @@ export function TerminalInput({ terminal, router, player }: IProps): React.React
|
||||
break;
|
||||
case "deletewordafter": // Delete rest of word after the cursor, including trailing space
|
||||
for (let delStart = start + 1; delStart <= value.length + 1; ++delStart) {
|
||||
if (inputText.charAt(delStart) === " " || delStart === value.length + 1) {
|
||||
if (inputText.charAt(delStart) === KEY.SPACE || delStart === value.length + 1) {
|
||||
saveValue(inputText.substr(0, start) + inputText.substr(delStart + 1), () => {
|
||||
// Move cursor to correct location
|
||||
// foo bar |baz bum --> foo bar |bum
|
||||
@ -151,7 +151,7 @@ export function TerminalInput({ terminal, router, player }: IProps): React.React
|
||||
break;
|
||||
case "prevword":
|
||||
for (let i = start - 2; i >= 0; --i) {
|
||||
if (ref.value.charAt(i) === " ") {
|
||||
if (ref.value.charAt(i) === KEY.SPACE) {
|
||||
ref.setSelectionRange(i + 1, i + 1);
|
||||
return;
|
||||
}
|
||||
@ -163,7 +163,7 @@ export function TerminalInput({ terminal, router, player }: IProps): React.React
|
||||
break;
|
||||
case "nextword":
|
||||
for (let i = start + 1; i <= inputLength; ++i) {
|
||||
if (ref.value.charAt(i) === " ") {
|
||||
if (ref.value.charAt(i) === KEY.SPACE) {
|
||||
ref.setSelectionRange(i, i);
|
||||
return;
|
||||
}
|
||||
@ -262,7 +262,7 @@ export function TerminalInput({ terminal, router, player }: IProps): React.React
|
||||
}
|
||||
|
||||
// Select previous command.
|
||||
if (event.key === KEY.UPARROW || (Settings.EnableBashHotkeys && event.key === "p" && event.ctrlKey)) {
|
||||
if (event.key === KEY.UP_ARROW || (Settings.EnableBashHotkeys && event.key === KEY.P && event.ctrlKey)) {
|
||||
if (Settings.EnableBashHotkeys) {
|
||||
event.preventDefault();
|
||||
}
|
||||
@ -290,7 +290,7 @@ export function TerminalInput({ terminal, router, player }: IProps): React.React
|
||||
}
|
||||
|
||||
// Select next command
|
||||
if (event.key === KEY.DOWNARROW || (Settings.EnableBashHotkeys && event.key === "m" && event.ctrlKey)) {
|
||||
if (event.key === KEY.DOWN_ARROW || (Settings.EnableBashHotkeys && event.key === KEY.M && event.ctrlKey)) {
|
||||
if (Settings.EnableBashHotkeys) {
|
||||
event.preventDefault();
|
||||
}
|
||||
|
@ -8,10 +8,29 @@ export enum KEY {
|
||||
ENTER = "Enter",
|
||||
ESC = "Escape",
|
||||
TAB = "Tab",
|
||||
UPARROW = "ArrowUp",
|
||||
DOWNARROW = "ArrowDown",
|
||||
LEFTARROW = "ArrowLeft",
|
||||
RIGHTARROW = "ArrowRight",
|
||||
SPACE = " ",
|
||||
BACKSPACE = "Backspace",
|
||||
UP_ARROW = "ArrowUp",
|
||||
DOWN_ARROW = "ArrowDown",
|
||||
LEFT_ARROW = "ArrowLeft",
|
||||
RIGHT_ARROW = "ArrowRight",
|
||||
|
||||
QUOTE = "'",
|
||||
DOUBLE_QUOTE = '"',
|
||||
OPEN_BRACKET = "[",
|
||||
CLOSE_BRACKET = "]",
|
||||
LESS_THAN = "<",
|
||||
GREATER_THAN = ">",
|
||||
OPEN_PARENTHESIS = "(",
|
||||
CLOSE_PARENTHESIS = ")",
|
||||
OPEN_BRACE = "{",
|
||||
CLOSE_BRACE = "}",
|
||||
|
||||
PIPE = "|",
|
||||
DOT = ".",
|
||||
FORWARD_SLASH = "/",
|
||||
HYPHEN = "-",
|
||||
HASH = "#",
|
||||
|
||||
k0 = "0",
|
||||
k1 = "1",
|
||||
|
@ -8,7 +8,7 @@ jest.mock(`!!raw-loader!../NetscriptDefinitions.d.ts`, () => "", {
|
||||
virtual: true,
|
||||
});
|
||||
|
||||
const code = `/** @param {NS} ns **/
|
||||
const code = `/** @param {NS} ns */
|
||||
export async function main(ns) {
|
||||
ns.print(ns.getWeakenTime('n00dles'));
|
||||
}`;
|
||||
|
Reference in New Issue
Block a user