mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-20 21:25:47 +01:00
unknown-ify the singularity API.
This commit is contained in:
parent
cccd39456c
commit
725c8234c9
@ -14,7 +14,13 @@ import { isString } from "../utils/helpers/isString";
|
|||||||
import { getRamCost } from "../Netscript/RamCostGenerator";
|
import { getRamCost } from "../Netscript/RamCostGenerator";
|
||||||
import { RunningScript } from "../Script/RunningScript";
|
import { RunningScript } from "../Script/RunningScript";
|
||||||
|
|
||||||
import { Singularity as ISingularity } from "../ScriptEditor/NetscriptDefinitions";
|
import {
|
||||||
|
AugmentationStats,
|
||||||
|
CharacterInfo,
|
||||||
|
CrimeStats,
|
||||||
|
PlayerSkills,
|
||||||
|
Singularity as ISingularity,
|
||||||
|
} from "../ScriptEditor/NetscriptDefinitions";
|
||||||
|
|
||||||
import { findCrime } from "../Crime/CrimeHelpers";
|
import { findCrime } from "../Crime/CrimeHelpers";
|
||||||
import { CompanyPosition } from "../Company/CompanyPosition";
|
import { CompanyPosition } from "../Company/CompanyPosition";
|
||||||
@ -49,7 +55,7 @@ export function NetscriptSingularity(
|
|||||||
workerScript: WorkerScript,
|
workerScript: WorkerScript,
|
||||||
helper: INetscriptHelper,
|
helper: INetscriptHelper,
|
||||||
): ISingularity {
|
): ISingularity {
|
||||||
const getAugmentation = function (func: any, name: any): Augmentation {
|
const getAugmentation = function (func: string, name: string): Augmentation {
|
||||||
if (!augmentationExists(name)) {
|
if (!augmentationExists(name)) {
|
||||||
throw helper.makeRuntimeErrorMsg(func, `Invalid augmentation: '${name}'`);
|
throw helper.makeRuntimeErrorMsg(func, `Invalid augmentation: '${name}'`);
|
||||||
}
|
}
|
||||||
@ -57,7 +63,7 @@ export function NetscriptSingularity(
|
|||||||
return Augmentations[name];
|
return Augmentations[name];
|
||||||
};
|
};
|
||||||
|
|
||||||
const getFaction = function (func: any, name: any): Faction {
|
const getFaction = function (func: string, name: string): Faction {
|
||||||
if (!factionExists(name)) {
|
if (!factionExists(name)) {
|
||||||
throw helper.makeRuntimeErrorMsg(func, `Invalid faction name: '${name}`);
|
throw helper.makeRuntimeErrorMsg(func, `Invalid faction name: '${name}`);
|
||||||
}
|
}
|
||||||
@ -65,7 +71,7 @@ export function NetscriptSingularity(
|
|||||||
return Factions[name];
|
return Factions[name];
|
||||||
};
|
};
|
||||||
|
|
||||||
const getCompany = function (func: any, name: any): Company {
|
const getCompany = function (func: string, name: string): Company {
|
||||||
const company = Companies[name];
|
const company = Companies[name];
|
||||||
if (company == null || !(company instanceof Company)) {
|
if (company == null || !(company instanceof Company)) {
|
||||||
throw helper.makeRuntimeErrorMsg(func, `Invalid company name: '${name}'`);
|
throw helper.makeRuntimeErrorMsg(func, `Invalid company name: '${name}'`);
|
||||||
@ -73,26 +79,26 @@ export function NetscriptSingularity(
|
|||||||
return company;
|
return company;
|
||||||
};
|
};
|
||||||
|
|
||||||
const runAfterReset = function (cbScript = null): void {
|
const runAfterReset = function (cbScript: string | null = null): void {
|
||||||
//Run a script after reset
|
//Run a script after reset
|
||||||
if (cbScript && isString(cbScript)) {
|
if (!cbScript) return;
|
||||||
const home = player.getHomeComputer();
|
const home = player.getHomeComputer();
|
||||||
for (const script of home.scripts) {
|
for (const script of home.scripts) {
|
||||||
if (script.filename === cbScript) {
|
if (script.filename === cbScript) {
|
||||||
const ramUsage = script.ramUsage;
|
const ramUsage = script.ramUsage;
|
||||||
const ramAvailable = home.maxRam - home.ramUsed;
|
const ramAvailable = home.maxRam - home.ramUsed;
|
||||||
if (ramUsage > ramAvailable) {
|
if (ramUsage > ramAvailable) {
|
||||||
return; // Not enough RAM
|
return; // Not enough RAM
|
||||||
}
|
|
||||||
const runningScriptObj = new RunningScript(script, []); // No args
|
|
||||||
runningScriptObj.threads = 1; // Only 1 thread
|
|
||||||
startWorkerScript(player, runningScriptObj, home);
|
|
||||||
}
|
}
|
||||||
|
const runningScriptObj = new RunningScript(script, []); // No args
|
||||||
|
runningScriptObj.threads = 1; // Only 1 thread
|
||||||
|
startWorkerScript(player, runningScriptObj, home);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
getOwnedAugmentations: function (purchased: any = false): any {
|
getOwnedAugmentations: function (_purchased: unknown = false): string[] {
|
||||||
|
const purchased = helper.boolean(_purchased);
|
||||||
helper.updateDynamicRam("getOwnedAugmentations", getRamCost(player, "getOwnedAugmentations"));
|
helper.updateDynamicRam("getOwnedAugmentations", getRamCost(player, "getOwnedAugmentations"));
|
||||||
helper.checkSingularityAccess("getOwnedAugmentations");
|
helper.checkSingularityAccess("getOwnedAugmentations");
|
||||||
const res = [];
|
const res = [];
|
||||||
@ -106,13 +112,14 @@ export function NetscriptSingularity(
|
|||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
getAugmentationsFromFaction: function (facname: any): any {
|
getAugmentationsFromFaction: function (_facName: unknown): string[] {
|
||||||
|
const facName = helper.string("getAugmentationsFromFaction", "facName", _facName);
|
||||||
helper.updateDynamicRam("getAugmentationsFromFaction", getRamCost(player, "getAugmentationsFromFaction"));
|
helper.updateDynamicRam("getAugmentationsFromFaction", getRamCost(player, "getAugmentationsFromFaction"));
|
||||||
helper.checkSingularityAccess("getAugmentationsFromFaction");
|
helper.checkSingularityAccess("getAugmentationsFromFaction");
|
||||||
const faction = getFaction("getAugmentationsFromFaction", facname);
|
const faction = getFaction("getAugmentationsFromFaction", facName);
|
||||||
|
|
||||||
// If player has a gang with this faction, return all augmentations.
|
// If player has a gang with this faction, return all augmentations.
|
||||||
if (player.hasGangWith(facname)) {
|
if (player.hasGangWith(facName)) {
|
||||||
let augs = Object.values(Augmentations);
|
let augs = Object.values(Augmentations);
|
||||||
|
|
||||||
// Remove special augs.
|
// Remove special augs.
|
||||||
@ -120,7 +127,7 @@ export function NetscriptSingularity(
|
|||||||
|
|
||||||
if (player.bitNodeN !== 2) {
|
if (player.bitNodeN !== 2) {
|
||||||
// Remove faction-unique augs outside BN2. (But keep the one for this faction.)
|
// Remove faction-unique augs outside BN2. (But keep the one for this faction.)
|
||||||
augs = augs.filter((a) => a.factions.length > 1 || Factions[facname].augmentations.includes(a.name));
|
augs = augs.filter((a) => a.factions.length > 1 || Factions[facName].augmentations.includes(a.name));
|
||||||
|
|
||||||
// Remove blacklisted augs.
|
// Remove blacklisted augs.
|
||||||
const blacklist = [AugmentationNames.NeuroFluxGovernor, AugmentationNames.TheRedPill];
|
const blacklist = [AugmentationNames.NeuroFluxGovernor, AugmentationNames.TheRedPill];
|
||||||
@ -132,44 +139,51 @@ export function NetscriptSingularity(
|
|||||||
|
|
||||||
return faction.augmentations.slice();
|
return faction.augmentations.slice();
|
||||||
},
|
},
|
||||||
getAugmentationCost: function (name: any): any {
|
getAugmentationCost: function (_augName: unknown): [number, number] {
|
||||||
|
const augName = helper.string("getAugmentationCost", "augName", _augName);
|
||||||
helper.updateDynamicRam("getAugmentationCost", getRamCost(player, "getAugmentationCost"));
|
helper.updateDynamicRam("getAugmentationCost", getRamCost(player, "getAugmentationCost"));
|
||||||
helper.checkSingularityAccess("getAugmentationCost");
|
helper.checkSingularityAccess("getAugmentationCost");
|
||||||
const aug = getAugmentation("getAugmentationCost", name);
|
const aug = getAugmentation("getAugmentationCost", augName);
|
||||||
return [aug.baseRepRequirement, aug.baseCost];
|
return [aug.baseRepRequirement, aug.baseCost];
|
||||||
},
|
},
|
||||||
getAugmentationPrereq: function (name: any): any {
|
getAugmentationPrereq: function (_augName: unknown): string[] {
|
||||||
|
const augName = helper.string("getAugmentationPrereq", "augName", _augName);
|
||||||
helper.updateDynamicRam("getAugmentationPrereq", getRamCost(player, "getAugmentationPrereq"));
|
helper.updateDynamicRam("getAugmentationPrereq", getRamCost(player, "getAugmentationPrereq"));
|
||||||
helper.checkSingularityAccess("getAugmentationPrereq");
|
helper.checkSingularityAccess("getAugmentationPrereq");
|
||||||
const aug = getAugmentation("getAugmentationPrereq", name);
|
const aug = getAugmentation("getAugmentationPrereq", augName);
|
||||||
return aug.prereqs.slice();
|
return aug.prereqs.slice();
|
||||||
},
|
},
|
||||||
getAugmentationPrice: function (name: any): any {
|
getAugmentationPrice: function (_augName: unknown): number {
|
||||||
|
const augName = helper.string("getAugmentationPrice", "augName", _augName);
|
||||||
helper.updateDynamicRam("getAugmentationPrice", getRamCost(player, "getAugmentationPrice"));
|
helper.updateDynamicRam("getAugmentationPrice", getRamCost(player, "getAugmentationPrice"));
|
||||||
helper.checkSingularityAccess("getAugmentationPrice");
|
helper.checkSingularityAccess("getAugmentationPrice");
|
||||||
const aug = getAugmentation("getAugmentationPrice", name);
|
const aug = getAugmentation("getAugmentationPrice", augName);
|
||||||
return aug.baseCost;
|
return aug.baseCost;
|
||||||
},
|
},
|
||||||
getAugmentationRepReq: function (name: any): any {
|
getAugmentationRepReq: function (_augName: unknown): number {
|
||||||
|
const augName = helper.string("getAugmentationRepReq", "augName", _augName);
|
||||||
helper.updateDynamicRam("getAugmentationRepReq", getRamCost(player, "getAugmentationRepReq"));
|
helper.updateDynamicRam("getAugmentationRepReq", getRamCost(player, "getAugmentationRepReq"));
|
||||||
helper.checkSingularityAccess("getAugmentationRepReq");
|
helper.checkSingularityAccess("getAugmentationRepReq");
|
||||||
const aug = getAugmentation("getAugmentationRepReq", name);
|
const aug = getAugmentation("getAugmentationRepReq", augName);
|
||||||
return aug.baseRepRequirement;
|
return aug.baseRepRequirement;
|
||||||
},
|
},
|
||||||
getAugmentationStats: function (name: any): any {
|
getAugmentationStats: function (_augName: unknown): AugmentationStats {
|
||||||
|
const augName = helper.string("getAugmentationStats", "augName", _augName);
|
||||||
helper.updateDynamicRam("getAugmentationStats", getRamCost(player, "getAugmentationStats"));
|
helper.updateDynamicRam("getAugmentationStats", getRamCost(player, "getAugmentationStats"));
|
||||||
helper.checkSingularityAccess("getAugmentationStats");
|
helper.checkSingularityAccess("getAugmentationStats");
|
||||||
const aug = getAugmentation("getAugmentationStats", name);
|
const aug = getAugmentation("getAugmentationStats", augName);
|
||||||
return Object.assign({}, aug.mults);
|
return Object.assign({}, aug.mults);
|
||||||
},
|
},
|
||||||
purchaseAugmentation: function (faction: any, name: any): any {
|
purchaseAugmentation: function (_facName: unknown, _augName: unknown): boolean {
|
||||||
|
const facName = helper.string("purchaseAugmentation", "facName", _facName);
|
||||||
|
const augName = helper.string("purchaseAugmentation", "augName", _augName);
|
||||||
helper.updateDynamicRam("purchaseAugmentation", getRamCost(player, "purchaseAugmentation"));
|
helper.updateDynamicRam("purchaseAugmentation", getRamCost(player, "purchaseAugmentation"));
|
||||||
helper.checkSingularityAccess("purchaseAugmentation");
|
helper.checkSingularityAccess("purchaseAugmentation");
|
||||||
const fac = getFaction("purchaseAugmentation", faction);
|
const fac = getFaction("purchaseAugmentation", facName);
|
||||||
const aug = getAugmentation("purchaseAugmentation", name);
|
const aug = getAugmentation("purchaseAugmentation", augName);
|
||||||
|
|
||||||
let augs = [];
|
let augs = [];
|
||||||
if (player.hasGangWith(faction)) {
|
if (player.hasGangWith(facName)) {
|
||||||
for (const augName of Object.keys(Augmentations)) {
|
for (const augName of Object.keys(Augmentations)) {
|
||||||
const aug = Augmentations[augName];
|
const aug = Augmentations[augName];
|
||||||
if (
|
if (
|
||||||
@ -187,10 +201,10 @@ export function NetscriptSingularity(
|
|||||||
augs = fac.augmentations;
|
augs = fac.augmentations;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!augs.includes(name)) {
|
if (!augs.includes(augName)) {
|
||||||
workerScript.log(
|
workerScript.log(
|
||||||
"purchaseAugmentation",
|
"purchaseAugmentation",
|
||||||
() => `Faction '${faction}' does not have the '${name}' augmentation.`,
|
() => `Faction '${facName}' does not have the '${augName}' augmentation.`,
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -199,13 +213,13 @@ export function NetscriptSingularity(
|
|||||||
if (!isNeuroflux) {
|
if (!isNeuroflux) {
|
||||||
for (let j = 0; j < player.queuedAugmentations.length; ++j) {
|
for (let j = 0; j < player.queuedAugmentations.length; ++j) {
|
||||||
if (player.queuedAugmentations[j].name === aug.name) {
|
if (player.queuedAugmentations[j].name === aug.name) {
|
||||||
workerScript.log("purchaseAugmentation", () => `You already have the '${name}' augmentation.`);
|
workerScript.log("purchaseAugmentation", () => `You already have the '${augName}' augmentation.`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (let j = 0; j < player.augmentations.length; ++j) {
|
for (let j = 0; j < player.augmentations.length; ++j) {
|
||||||
if (player.augmentations[j].name === aug.name) {
|
if (player.augmentations[j].name === aug.name) {
|
||||||
workerScript.log("purchaseAugmentation", () => `You already have the '${name}' augmentation.`);
|
workerScript.log("purchaseAugmentation", () => `You already have the '${augName}' augmentation.`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -225,7 +239,8 @@ export function NetscriptSingularity(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
softReset: function (cbScript: any): any {
|
softReset: function (_cbScript: unknown): void {
|
||||||
|
const cbScript = helper.string("softReset", "cbScript", _cbScript);
|
||||||
helper.updateDynamicRam("softReset", getRamCost(player, "softReset"));
|
helper.updateDynamicRam("softReset", getRamCost(player, "softReset"));
|
||||||
helper.checkSingularityAccess("softReset");
|
helper.checkSingularityAccess("softReset");
|
||||||
|
|
||||||
@ -239,7 +254,8 @@ export function NetscriptSingularity(
|
|||||||
workerScript.running = false;
|
workerScript.running = false;
|
||||||
killWorkerScript(workerScript);
|
killWorkerScript(workerScript);
|
||||||
},
|
},
|
||||||
installAugmentations: function (cbScript: any): any {
|
installAugmentations: function (_cbScript: unknown): boolean {
|
||||||
|
const cbScript = helper.string("installAugmentations", "cbScript", _cbScript);
|
||||||
helper.updateDynamicRam("installAugmentations", getRamCost(player, "installAugmentations"));
|
helper.updateDynamicRam("installAugmentations", getRamCost(player, "installAugmentations"));
|
||||||
helper.checkSingularityAccess("installAugmentations");
|
helper.checkSingularityAccess("installAugmentations");
|
||||||
|
|
||||||
@ -259,9 +275,11 @@ export function NetscriptSingularity(
|
|||||||
|
|
||||||
workerScript.running = false; // Prevent workerScript from "finishing execution naturally"
|
workerScript.running = false; // Prevent workerScript from "finishing execution naturally"
|
||||||
killWorkerScript(workerScript);
|
killWorkerScript(workerScript);
|
||||||
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
goToLocation: function (locationName: any): boolean {
|
goToLocation: function (_locationName: unknown): boolean {
|
||||||
|
const locationName = helper.string("goToLocation", "locationName", _locationName);
|
||||||
helper.updateDynamicRam("goToLocation", getRamCost(player, "goToLocation"));
|
helper.updateDynamicRam("goToLocation", getRamCost(player, "goToLocation"));
|
||||||
helper.checkSingularityAccess("goToLocation");
|
helper.checkSingularityAccess("goToLocation");
|
||||||
const location = Object.values(Locations).find((l) => l.name === locationName);
|
const location = Object.values(Locations).find((l) => l.name === locationName);
|
||||||
@ -277,7 +295,10 @@ export function NetscriptSingularity(
|
|||||||
player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain / 50000);
|
player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain / 50000);
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
universityCourse: function (universityName: any, className: any, focus = true): any {
|
universityCourse: function (_universityName: unknown, _className: unknown, _focus: unknown = true): boolean {
|
||||||
|
const universityName = helper.string("universityCourse", "universityName", _universityName);
|
||||||
|
const className = helper.string("universityCourse", "className", _className);
|
||||||
|
const focus = helper.boolean(_focus);
|
||||||
helper.updateDynamicRam("universityCourse", getRamCost(player, "universityCourse"));
|
helper.updateDynamicRam("universityCourse", getRamCost(player, "universityCourse"));
|
||||||
helper.checkSingularityAccess("universityCourse");
|
helper.checkSingularityAccess("universityCourse");
|
||||||
const wasFocusing = player.focus;
|
const wasFocusing = player.focus;
|
||||||
@ -365,7 +386,10 @@ export function NetscriptSingularity(
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
gymWorkout: function (gymName: any, stat: any, focus = true): any {
|
gymWorkout: function (_gymName: unknown, _stat: unknown, _focus: unknown = true): boolean {
|
||||||
|
const gymName = helper.string("gymWorkout", "gymName", _gymName);
|
||||||
|
const stat = helper.string("gymWorkout", "stat", _stat);
|
||||||
|
const focus = helper.boolean(_focus);
|
||||||
helper.updateDynamicRam("gymWorkout", getRamCost(player, "gymWorkout"));
|
helper.updateDynamicRam("gymWorkout", getRamCost(player, "gymWorkout"));
|
||||||
helper.checkSingularityAccess("gymWorkout");
|
helper.checkSingularityAccess("gymWorkout");
|
||||||
const wasFocusing = player.focus;
|
const wasFocusing = player.focus;
|
||||||
@ -477,11 +501,12 @@ export function NetscriptSingularity(
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
travelToCity: function (cityname: any): any {
|
travelToCity: function (_cityName: unknown): boolean {
|
||||||
|
const cityName = helper.string("travelToCity", "cityName", _cityName);
|
||||||
helper.updateDynamicRam("travelToCity", getRamCost(player, "travelToCity"));
|
helper.updateDynamicRam("travelToCity", getRamCost(player, "travelToCity"));
|
||||||
helper.checkSingularityAccess("travelToCity");
|
helper.checkSingularityAccess("travelToCity");
|
||||||
|
|
||||||
switch (cityname) {
|
switch (cityName) {
|
||||||
case CityName.Aevum:
|
case CityName.Aevum:
|
||||||
case CityName.Chongqing:
|
case CityName.Chongqing:
|
||||||
case CityName.Sector12:
|
case CityName.Sector12:
|
||||||
@ -493,16 +518,16 @@ export function NetscriptSingularity(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
player.loseMoney(CONSTANTS.TravelCost, "other");
|
player.loseMoney(CONSTANTS.TravelCost, "other");
|
||||||
player.city = cityname;
|
player.city = cityName;
|
||||||
workerScript.log("travelToCity", () => `Traveled to ${cityname}`);
|
workerScript.log("travelToCity", () => `Traveled to ${cityName}`);
|
||||||
player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain / 50000);
|
player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain / 50000);
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
throw helper.makeRuntimeErrorMsg("travelToCity", `Invalid city name: '${cityname}'.`);
|
throw helper.makeRuntimeErrorMsg("travelToCity", `Invalid city name: '${cityName}'.`);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
purchaseTor: function (): any {
|
purchaseTor: function (): boolean {
|
||||||
helper.updateDynamicRam("purchaseTor", getRamCost(player, "purchaseTor"));
|
helper.updateDynamicRam("purchaseTor", getRamCost(player, "purchaseTor"));
|
||||||
helper.checkSingularityAccess("purchaseTor");
|
helper.checkSingularityAccess("purchaseTor");
|
||||||
|
|
||||||
@ -534,7 +559,8 @@ export function NetscriptSingularity(
|
|||||||
workerScript.log("purchaseTor", () => "You have purchased a Tor router!");
|
workerScript.log("purchaseTor", () => "You have purchased a Tor router!");
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
purchaseProgram: function (programName: any): any {
|
purchaseProgram: function (_programName: unknown): boolean {
|
||||||
|
const programName = helper.string("purchaseProgram", "programName", _programName).toLowerCase();
|
||||||
helper.updateDynamicRam("purchaseProgram", getRamCost(player, "purchaseProgram"));
|
helper.updateDynamicRam("purchaseProgram", getRamCost(player, "purchaseProgram"));
|
||||||
helper.checkSingularityAccess("purchaseProgram");
|
helper.checkSingularityAccess("purchaseProgram");
|
||||||
|
|
||||||
@ -543,8 +569,6 @@ export function NetscriptSingularity(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
programName = programName.toLowerCase();
|
|
||||||
|
|
||||||
const item = Object.values(DarkWebItems).find((i) => i.program.toLowerCase() === programName);
|
const item = Object.values(DarkWebItems).find((i) => i.program.toLowerCase() === programName);
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
workerScript.log("purchaseProgram", () => `Invalid program name: '${programName}.`);
|
workerScript.log("purchaseProgram", () => `Invalid program name: '${programName}.`);
|
||||||
@ -573,12 +597,13 @@ export function NetscriptSingularity(
|
|||||||
player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain / 5000);
|
player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain / 5000);
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
getCurrentServer: function (): any {
|
getCurrentServer: function (): string {
|
||||||
helper.updateDynamicRam("getCurrentServer", getRamCost(player, "getCurrentServer"));
|
helper.updateDynamicRam("getCurrentServer", getRamCost(player, "getCurrentServer"));
|
||||||
helper.checkSingularityAccess("getCurrentServer");
|
helper.checkSingularityAccess("getCurrentServer");
|
||||||
return player.getCurrentServer().hostname;
|
return player.getCurrentServer().hostname;
|
||||||
},
|
},
|
||||||
connect: function (hostname: any): any {
|
connect: function (_hostname: unknown): boolean {
|
||||||
|
const hostname = helper.string("purchaseProgram", "hostname", _hostname);
|
||||||
helper.updateDynamicRam("connect", getRamCost(player, "connect"));
|
helper.updateDynamicRam("connect", getRamCost(player, "connect"));
|
||||||
helper.checkSingularityAccess("connect");
|
helper.checkSingularityAccess("connect");
|
||||||
if (!hostname) {
|
if (!hostname) {
|
||||||
@ -613,13 +638,13 @@ export function NetscriptSingularity(
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
manualHack: function (): any {
|
manualHack: function (): Promise<number> {
|
||||||
helper.updateDynamicRam("manualHack", getRamCost(player, "manualHack"));
|
helper.updateDynamicRam("manualHack", getRamCost(player, "manualHack"));
|
||||||
helper.checkSingularityAccess("manualHack");
|
helper.checkSingularityAccess("manualHack");
|
||||||
const server = player.getCurrentServer();
|
const server = player.getCurrentServer();
|
||||||
return helper.hack(server.hostname, true);
|
return helper.hack(server.hostname, true);
|
||||||
},
|
},
|
||||||
installBackdoor: function (): any {
|
installBackdoor: function (): Promise<void> {
|
||||||
helper.updateDynamicRam("installBackdoor", getRamCost(player, "installBackdoor"));
|
helper.updateDynamicRam("installBackdoor", getRamCost(player, "installBackdoor"));
|
||||||
helper.checkSingularityAccess("installBackdoor");
|
helper.checkSingularityAccess("installBackdoor");
|
||||||
const baseserver = player.getCurrentServer();
|
const baseserver = player.getCurrentServer();
|
||||||
@ -657,8 +682,8 @@ export function NetscriptSingularity(
|
|||||||
helper.checkSingularityAccess("isFocused");
|
helper.checkSingularityAccess("isFocused");
|
||||||
return player.focus;
|
return player.focus;
|
||||||
},
|
},
|
||||||
setFocus: function (afocus: any): boolean {
|
setFocus: function (_focus: unknown): boolean {
|
||||||
const focus = helper.boolean(afocus);
|
const focus = helper.boolean(_focus);
|
||||||
helper.updateDynamicRam("setFocus", getRamCost(player, "setFocus"));
|
helper.updateDynamicRam("setFocus", getRamCost(player, "setFocus"));
|
||||||
helper.checkSingularityAccess("setFocus");
|
helper.checkSingularityAccess("setFocus");
|
||||||
if (!player.isWorking) {
|
if (!player.isWorking) {
|
||||||
@ -686,7 +711,7 @@ export function NetscriptSingularity(
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
getStats: function (): any {
|
getStats: function (): PlayerSkills {
|
||||||
helper.updateDynamicRam("getStats", getRamCost(player, "getStats"));
|
helper.updateDynamicRam("getStats", getRamCost(player, "getStats"));
|
||||||
helper.checkSingularityAccess("getStats");
|
helper.checkSingularityAccess("getStats");
|
||||||
workerScript.log("getStats", () => `getStats is deprecated, please use getplayer`);
|
workerScript.log("getStats", () => `getStats is deprecated, please use getplayer`);
|
||||||
@ -701,7 +726,7 @@ export function NetscriptSingularity(
|
|||||||
intelligence: player.intelligence,
|
intelligence: player.intelligence,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
getCharacterInformation: function (): any {
|
getCharacterInformation: function (): CharacterInfo {
|
||||||
helper.updateDynamicRam("getCharacterInformation", getRamCost(player, "getCharacterInformation"));
|
helper.updateDynamicRam("getCharacterInformation", getRamCost(player, "getCharacterInformation"));
|
||||||
helper.checkSingularityAccess("getCharacterInformation");
|
helper.checkSingularityAccess("getCharacterInformation");
|
||||||
workerScript.log("getCharacterInformation", () => `getCharacterInformation is deprecated, please use getplayer`);
|
workerScript.log("getCharacterInformation", () => `getCharacterInformation is deprecated, please use getplayer`);
|
||||||
@ -749,21 +774,21 @@ export function NetscriptSingularity(
|
|||||||
charismaExp: player.charisma_exp,
|
charismaExp: player.charisma_exp,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
hospitalize: function (): any {
|
hospitalize: function (): void {
|
||||||
helper.updateDynamicRam("hospitalize", getRamCost(player, "hospitalize"));
|
helper.updateDynamicRam("hospitalize", getRamCost(player, "hospitalize"));
|
||||||
helper.checkSingularityAccess("hospitalize");
|
helper.checkSingularityAccess("hospitalize");
|
||||||
if (player.isWorking || Router.page() === Page.Infiltration || Router.page() === Page.BitVerse) {
|
if (player.isWorking || Router.page() === Page.Infiltration || Router.page() === Page.BitVerse) {
|
||||||
workerScript.log("hospitalize", () => "Cannot go to the hospital because the player is busy.");
|
workerScript.log("hospitalize", () => "Cannot go to the hospital because the player is busy.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return player.hospitalize();
|
player.hospitalize();
|
||||||
},
|
},
|
||||||
isBusy: function (): any {
|
isBusy: function (): boolean {
|
||||||
helper.updateDynamicRam("isBusy", getRamCost(player, "isBusy"));
|
helper.updateDynamicRam("isBusy", getRamCost(player, "isBusy"));
|
||||||
helper.checkSingularityAccess("isBusy");
|
helper.checkSingularityAccess("isBusy");
|
||||||
return player.isWorking || Router.page() === Page.Infiltration || Router.page() === Page.BitVerse;
|
return player.isWorking || Router.page() === Page.Infiltration || Router.page() === Page.BitVerse;
|
||||||
},
|
},
|
||||||
stopAction: function (): any {
|
stopAction: function (): boolean {
|
||||||
helper.updateDynamicRam("stopAction", getRamCost(player, "stopAction"));
|
helper.updateDynamicRam("stopAction", getRamCost(player, "stopAction"));
|
||||||
helper.checkSingularityAccess("stopAction");
|
helper.checkSingularityAccess("stopAction");
|
||||||
if (player.isWorking) {
|
if (player.isWorking) {
|
||||||
@ -777,7 +802,7 @@ export function NetscriptSingularity(
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
upgradeHomeCores: function (): any {
|
upgradeHomeCores: function (): boolean {
|
||||||
helper.updateDynamicRam("upgradeHomeCores", getRamCost(player, "upgradeHomeCores"));
|
helper.updateDynamicRam("upgradeHomeCores", getRamCost(player, "upgradeHomeCores"));
|
||||||
helper.checkSingularityAccess("upgradeHomeCores");
|
helper.checkSingularityAccess("upgradeHomeCores");
|
||||||
|
|
||||||
@ -807,13 +832,13 @@ export function NetscriptSingularity(
|
|||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
getUpgradeHomeCoresCost: function (): any {
|
getUpgradeHomeCoresCost: function (): number {
|
||||||
helper.updateDynamicRam("getUpgradeHomeCoresCost", getRamCost(player, "getUpgradeHomeCoresCost"));
|
helper.updateDynamicRam("getUpgradeHomeCoresCost", getRamCost(player, "getUpgradeHomeCoresCost"));
|
||||||
helper.checkSingularityAccess("getUpgradeHomeCoresCost");
|
helper.checkSingularityAccess("getUpgradeHomeCoresCost");
|
||||||
|
|
||||||
return player.getUpgradeHomeCoresCost();
|
return player.getUpgradeHomeCoresCost();
|
||||||
},
|
},
|
||||||
upgradeHomeRam: function (): any {
|
upgradeHomeRam: function (): boolean {
|
||||||
helper.updateDynamicRam("upgradeHomeRam", getRamCost(player, "upgradeHomeRam"));
|
helper.updateDynamicRam("upgradeHomeRam", getRamCost(player, "upgradeHomeRam"));
|
||||||
helper.checkSingularityAccess("upgradeHomeRam");
|
helper.checkSingularityAccess("upgradeHomeRam");
|
||||||
|
|
||||||
@ -846,13 +871,15 @@ export function NetscriptSingularity(
|
|||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
getUpgradeHomeRamCost: function (): any {
|
getUpgradeHomeRamCost: function (): number {
|
||||||
helper.updateDynamicRam("getUpgradeHomeRamCost", getRamCost(player, "getUpgradeHomeRamCost"));
|
helper.updateDynamicRam("getUpgradeHomeRamCost", getRamCost(player, "getUpgradeHomeRamCost"));
|
||||||
helper.checkSingularityAccess("getUpgradeHomeRamCost");
|
helper.checkSingularityAccess("getUpgradeHomeRamCost");
|
||||||
|
|
||||||
return player.getUpgradeHomeRamCost();
|
return player.getUpgradeHomeRamCost();
|
||||||
},
|
},
|
||||||
workForCompany: function (companyName: any, focus = true): any {
|
workForCompany: function (_companyName: unknown, _focus: unknown = true): boolean {
|
||||||
|
let companyName = helper.string("workForCompany", "companyName", _companyName);
|
||||||
|
const focus = helper.boolean(_focus);
|
||||||
helper.updateDynamicRam("workForCompany", getRamCost(player, "workForCompany"));
|
helper.updateDynamicRam("workForCompany", getRamCost(player, "workForCompany"));
|
||||||
helper.checkSingularityAccess("workForCompany");
|
helper.checkSingularityAccess("workForCompany");
|
||||||
|
|
||||||
@ -906,12 +933,14 @@ export function NetscriptSingularity(
|
|||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
applyToCompany: function (companyName: any, field: any): any {
|
applyToCompany: function (_companyName: unknown, _field: unknown): boolean {
|
||||||
|
const companyName = helper.string("applyToCompany", "companyName", _companyName);
|
||||||
|
const field = helper.string("applyToCompany", "field", _field);
|
||||||
helper.updateDynamicRam("applyToCompany", getRamCost(player, "applyToCompany"));
|
helper.updateDynamicRam("applyToCompany", getRamCost(player, "applyToCompany"));
|
||||||
helper.checkSingularityAccess("applyToCompany");
|
helper.checkSingularityAccess("applyToCompany");
|
||||||
getCompany("applyToCompany", companyName);
|
getCompany("applyToCompany", companyName);
|
||||||
|
|
||||||
player.location = companyName;
|
player.location = companyName as LocationName;
|
||||||
let res;
|
let res;
|
||||||
switch (field.toLowerCase()) {
|
switch (field.toLowerCase()) {
|
||||||
case "software":
|
case "software":
|
||||||
@ -976,66 +1005,73 @@ export function NetscriptSingularity(
|
|||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
getCompanyRep: function (companyName: any): any {
|
getCompanyRep: function (_companyName: unknown): number {
|
||||||
|
const companyName = helper.string("getCompanyRep", "companyName", _companyName);
|
||||||
helper.updateDynamicRam("getCompanyRep", getRamCost(player, "getCompanyRep"));
|
helper.updateDynamicRam("getCompanyRep", getRamCost(player, "getCompanyRep"));
|
||||||
helper.checkSingularityAccess("getCompanyRep");
|
helper.checkSingularityAccess("getCompanyRep");
|
||||||
const company = getCompany("getCompanyRep", companyName);
|
const company = getCompany("getCompanyRep", companyName);
|
||||||
return company.playerReputation;
|
return company.playerReputation;
|
||||||
},
|
},
|
||||||
getCompanyFavor: function (companyName: any): any {
|
getCompanyFavor: function (_companyName: unknown): number {
|
||||||
|
const companyName = helper.string("getCompanyFavor", "companyName", _companyName);
|
||||||
helper.updateDynamicRam("getCompanyFavor", getRamCost(player, "getCompanyFavor"));
|
helper.updateDynamicRam("getCompanyFavor", getRamCost(player, "getCompanyFavor"));
|
||||||
helper.checkSingularityAccess("getCompanyFavor");
|
helper.checkSingularityAccess("getCompanyFavor");
|
||||||
const company = getCompany("getCompanyFavor", companyName);
|
const company = getCompany("getCompanyFavor", companyName);
|
||||||
return company.favor;
|
return company.favor;
|
||||||
},
|
},
|
||||||
getCompanyFavorGain: function (companyName: any): any {
|
getCompanyFavorGain: function (_companyName: unknown): number {
|
||||||
|
const companyName = helper.string("getCompanyFavorGain", "companyName", _companyName);
|
||||||
helper.updateDynamicRam("getCompanyFavorGain", getRamCost(player, "getCompanyFavorGain"));
|
helper.updateDynamicRam("getCompanyFavorGain", getRamCost(player, "getCompanyFavorGain"));
|
||||||
helper.checkSingularityAccess("getCompanyFavorGain");
|
helper.checkSingularityAccess("getCompanyFavorGain");
|
||||||
const company = getCompany("getCompanyFavorGain", companyName);
|
const company = getCompany("getCompanyFavorGain", companyName);
|
||||||
return company.getFavorGain();
|
return company.getFavorGain();
|
||||||
},
|
},
|
||||||
checkFactionInvitations: function (): any {
|
checkFactionInvitations: function (): string[] {
|
||||||
helper.updateDynamicRam("checkFactionInvitations", getRamCost(player, "checkFactionInvitations"));
|
helper.updateDynamicRam("checkFactionInvitations", getRamCost(player, "checkFactionInvitations"));
|
||||||
helper.checkSingularityAccess("checkFactionInvitations");
|
helper.checkSingularityAccess("checkFactionInvitations");
|
||||||
// Make a copy of player.factionInvitations
|
// Make a copy of player.factionInvitations
|
||||||
return player.factionInvitations.slice();
|
return player.factionInvitations.slice();
|
||||||
},
|
},
|
||||||
joinFaction: function (name: any): any {
|
joinFaction: function (_facName: unknown): boolean {
|
||||||
|
const facName = helper.string("joinFaction", "facName", _facName);
|
||||||
helper.updateDynamicRam("joinFaction", getRamCost(player, "joinFaction"));
|
helper.updateDynamicRam("joinFaction", getRamCost(player, "joinFaction"));
|
||||||
helper.checkSingularityAccess("joinFaction");
|
helper.checkSingularityAccess("joinFaction");
|
||||||
getFaction("joinFaction", name);
|
getFaction("joinFaction", facName);
|
||||||
|
|
||||||
if (!player.factionInvitations.includes(name)) {
|
if (!player.factionInvitations.includes(facName)) {
|
||||||
workerScript.log("joinFaction", () => `You have not been invited by faction '${name}'`);
|
workerScript.log("joinFaction", () => `You have not been invited by faction '${facName}'`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const fac = Factions[name];
|
const fac = Factions[facName];
|
||||||
joinFaction(fac);
|
joinFaction(fac);
|
||||||
|
|
||||||
// Update Faction Invitation list to account for joined + banned factions
|
// Update Faction Invitation list to account for joined + banned factions
|
||||||
for (let i = 0; i < player.factionInvitations.length; ++i) {
|
for (let i = 0; i < player.factionInvitations.length; ++i) {
|
||||||
if (player.factionInvitations[i] == name || Factions[player.factionInvitations[i]].isBanned) {
|
if (player.factionInvitations[i] == facName || Factions[player.factionInvitations[i]].isBanned) {
|
||||||
player.factionInvitations.splice(i, 1);
|
player.factionInvitations.splice(i, 1);
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain * 5);
|
player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain * 5);
|
||||||
workerScript.log("joinFaction", () => `Joined the '${name}' faction.`);
|
workerScript.log("joinFaction", () => `Joined the '${facName}' faction.`);
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
workForFaction: function (name: any, type: any, focus = true): any {
|
workForFaction: function (_facName: unknown, _type: unknown, _focus: unknown = true): boolean {
|
||||||
|
const facName = helper.string("workForFaction", "facName", _facName);
|
||||||
|
const type = helper.string("workForFaction", "type", _type);
|
||||||
|
const focus = helper.boolean(_focus);
|
||||||
helper.updateDynamicRam("workForFaction", getRamCost(player, "workForFaction"));
|
helper.updateDynamicRam("workForFaction", getRamCost(player, "workForFaction"));
|
||||||
helper.checkSingularityAccess("workForFaction");
|
helper.checkSingularityAccess("workForFaction");
|
||||||
getFaction("workForFaction", name);
|
getFaction("workForFaction", facName);
|
||||||
|
|
||||||
// if the player is in a gang and the target faction is any of the gang faction, fail
|
// if the player is in a gang and the target faction is any of the gang faction, fail
|
||||||
if (player.inGang() && AllGangs[name] !== undefined) {
|
if (player.inGang() && AllGangs[facName] !== undefined) {
|
||||||
workerScript.log("workForFaction", () => `Faction '${name}' does not offer work at the moment.`);
|
workerScript.log("workForFaction", () => `Faction '${facName}' does not offer work at the moment.`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!player.factions.includes(name)) {
|
if (!player.factions.includes(facName)) {
|
||||||
workerScript.log("workForFaction", () => `You are not a member of '${name}'`);
|
workerScript.log("workForFaction", () => `You are not a member of '${facName}'`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1045,7 +1081,7 @@ export function NetscriptSingularity(
|
|||||||
workerScript.log("workForFaction", () => txt);
|
workerScript.log("workForFaction", () => txt);
|
||||||
}
|
}
|
||||||
|
|
||||||
const fac = Factions[name];
|
const fac = Factions[facName];
|
||||||
// Arrays listing factions that allow each time of work
|
// Arrays listing factions that allow each time of work
|
||||||
|
|
||||||
switch (type.toLowerCase()) {
|
switch (type.toLowerCase()) {
|
||||||
@ -1105,34 +1141,42 @@ export function NetscriptSingularity(
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
getFactionRep: function (name: any): any {
|
getFactionRep: function (_facName: unknown): number {
|
||||||
|
const facName = helper.string("getFactionRep", "facName", _facName);
|
||||||
helper.updateDynamicRam("getFactionRep", getRamCost(player, "getFactionRep"));
|
helper.updateDynamicRam("getFactionRep", getRamCost(player, "getFactionRep"));
|
||||||
helper.checkSingularityAccess("getFactionRep");
|
helper.checkSingularityAccess("getFactionRep");
|
||||||
const faction = getFaction("getFactionRep", name);
|
const faction = getFaction("getFactionRep", facName);
|
||||||
return faction.playerReputation;
|
return faction.playerReputation;
|
||||||
},
|
},
|
||||||
getFactionFavor: function (name: any): any {
|
getFactionFavor: function (_facName: unknown): number {
|
||||||
|
const facName = helper.string("getFactionRep", "facName", _facName);
|
||||||
helper.updateDynamicRam("getFactionFavor", getRamCost(player, "getFactionFavor"));
|
helper.updateDynamicRam("getFactionFavor", getRamCost(player, "getFactionFavor"));
|
||||||
helper.checkSingularityAccess("getFactionFavor");
|
helper.checkSingularityAccess("getFactionFavor");
|
||||||
const faction = getFaction("getFactionFavor", name);
|
const faction = getFaction("getFactionFavor", facName);
|
||||||
return faction.favor;
|
return faction.favor;
|
||||||
},
|
},
|
||||||
getFactionFavorGain: function (name: any): any {
|
getFactionFavorGain: function (_facName: unknown): number {
|
||||||
|
const facName = helper.string("getFactionFavorGain", "facName", _facName);
|
||||||
helper.updateDynamicRam("getFactionFavorGain", getRamCost(player, "getFactionFavorGain"));
|
helper.updateDynamicRam("getFactionFavorGain", getRamCost(player, "getFactionFavorGain"));
|
||||||
helper.checkSingularityAccess("getFactionFavorGain");
|
helper.checkSingularityAccess("getFactionFavorGain");
|
||||||
const faction = getFaction("getFactionFavorGain", name);
|
const faction = getFaction("getFactionFavorGain", facName);
|
||||||
return faction.getFavorGain();
|
return faction.getFavorGain();
|
||||||
},
|
},
|
||||||
donateToFaction: function (name: any, amt: any): any {
|
donateToFaction: function (_facName: unknown, _amt: unknown): boolean {
|
||||||
|
const facName = helper.string("donateToFaction", "facName", _facName);
|
||||||
|
const amt = helper.number("donateToFaction", "amt", _amt);
|
||||||
helper.updateDynamicRam("donateToFaction", getRamCost(player, "donateToFaction"));
|
helper.updateDynamicRam("donateToFaction", getRamCost(player, "donateToFaction"));
|
||||||
helper.checkSingularityAccess("donateToFaction");
|
helper.checkSingularityAccess("donateToFaction");
|
||||||
const faction = getFaction("donateToFaction", name);
|
const faction = getFaction("donateToFaction", facName);
|
||||||
if (!player.factions.includes(faction.name)) {
|
if (!player.factions.includes(faction.name)) {
|
||||||
workerScript.log("donateToFaction", () => `You can't donate to '${name}' because you aren't a member`);
|
workerScript.log("donateToFaction", () => `You can't donate to '${facName}' because you aren't a member`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (player.inGang() && faction.name === player.getGangFaction().name) {
|
if (player.inGang() && faction.name === player.getGangFaction().name) {
|
||||||
workerScript.log("donateToFaction", () => `You can't donate to '${name}' because youre managing a gang for it`);
|
workerScript.log(
|
||||||
|
"donateToFaction",
|
||||||
|
() => `You can't donate to '${facName}' because youre managing a gang for it`,
|
||||||
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (typeof amt !== "number" || amt <= 0 || isNaN(amt)) {
|
if (typeof amt !== "number" || amt <= 0 || isNaN(amt)) {
|
||||||
@ -1142,7 +1186,7 @@ export function NetscriptSingularity(
|
|||||||
if (player.money < amt) {
|
if (player.money < amt) {
|
||||||
workerScript.log(
|
workerScript.log(
|
||||||
"donateToFaction",
|
"donateToFaction",
|
||||||
() => `You do not have enough money to donate ${numeralWrapper.formatMoney(amt)} to '${name}'`,
|
() => `You do not have enough money to donate ${numeralWrapper.formatMoney(amt)} to '${facName}'`,
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1161,13 +1205,15 @@ export function NetscriptSingularity(
|
|||||||
workerScript.log(
|
workerScript.log(
|
||||||
"donateToFaction",
|
"donateToFaction",
|
||||||
() =>
|
() =>
|
||||||
`${numeralWrapper.formatMoney(amt)} donated to '${name}' for ${numeralWrapper.formatReputation(
|
`${numeralWrapper.formatMoney(amt)} donated to '${facName}' for ${numeralWrapper.formatReputation(
|
||||||
repGain,
|
repGain,
|
||||||
)} reputation`,
|
)} reputation`,
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
createProgram: function (name: any, focus = true): any {
|
createProgram: function (_programName: any, _focus: unknown = true): boolean {
|
||||||
|
const programName = helper.string("createProgram", "programName", _programName).toLowerCase();
|
||||||
|
const focus = helper.boolean(_focus);
|
||||||
helper.updateDynamicRam("createProgram", getRamCost(player, "createProgram"));
|
helper.updateDynamicRam("createProgram", getRamCost(player, "createProgram"));
|
||||||
helper.checkSingularityAccess("createProgram");
|
helper.checkSingularityAccess("createProgram");
|
||||||
|
|
||||||
@ -1177,12 +1223,10 @@ export function NetscriptSingularity(
|
|||||||
workerScript.log("createProgram", () => txt);
|
workerScript.log("createProgram", () => txt);
|
||||||
}
|
}
|
||||||
|
|
||||||
name = name.toLowerCase();
|
const p = Object.values(Programs).find((p) => p.name.toLowerCase() === programName);
|
||||||
|
|
||||||
const p = Object.values(Programs).find((p) => p.name.toLowerCase() === name);
|
|
||||||
|
|
||||||
if (p == null) {
|
if (p == null) {
|
||||||
workerScript.log("createProgram", () => `The specified program does not exist: '${name}`);
|
workerScript.log("createProgram", () => `The specified program does not exist: '${programName}`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1213,10 +1257,11 @@ export function NetscriptSingularity(
|
|||||||
player.stopFocusing();
|
player.stopFocusing();
|
||||||
Router.toTerminal();
|
Router.toTerminal();
|
||||||
}
|
}
|
||||||
workerScript.log("createProgram", () => `Began creating program: '${name}'`);
|
workerScript.log("createProgram", () => `Began creating program: '${programName}'`);
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
commitCrime: function (crimeRoughName: any): any {
|
commitCrime: function (_crimeRoughName: unknown): number {
|
||||||
|
const crimeRoughName = helper.string("commitCrime", "crimeRoughName", _crimeRoughName);
|
||||||
helper.updateDynamicRam("commitCrime", getRamCost(player, "commitCrime"));
|
helper.updateDynamicRam("commitCrime", getRamCost(player, "commitCrime"));
|
||||||
helper.checkSingularityAccess("commitCrime");
|
helper.checkSingularityAccess("commitCrime");
|
||||||
|
|
||||||
@ -1236,7 +1281,8 @@ export function NetscriptSingularity(
|
|||||||
workerScript.log("commitCrime", () => `Attempting to commit ${crime.name}...`);
|
workerScript.log("commitCrime", () => `Attempting to commit ${crime.name}...`);
|
||||||
return crime.commit(Router, player, 1, workerScript);
|
return crime.commit(Router, player, 1, workerScript);
|
||||||
},
|
},
|
||||||
getCrimeChance: function (crimeRoughName: any): any {
|
getCrimeChance: function (_crimeRoughName: unknown): number {
|
||||||
|
const crimeRoughName = helper.string("getCrimeChance", "crimeRoughName", _crimeRoughName);
|
||||||
helper.updateDynamicRam("getCrimeChance", getRamCost(player, "getCrimeChance"));
|
helper.updateDynamicRam("getCrimeChance", getRamCost(player, "getCrimeChance"));
|
||||||
helper.checkSingularityAccess("getCrimeChance");
|
helper.checkSingularityAccess("getCrimeChance");
|
||||||
|
|
||||||
@ -1247,7 +1293,8 @@ export function NetscriptSingularity(
|
|||||||
|
|
||||||
return crime.successRate(player);
|
return crime.successRate(player);
|
||||||
},
|
},
|
||||||
getCrimeStats: function (crimeRoughName: any): any {
|
getCrimeStats: function (_crimeRoughName: unknown): CrimeStats {
|
||||||
|
const crimeRoughName = helper.string("getCrimeStats", "crimeRoughName", _crimeRoughName);
|
||||||
helper.updateDynamicRam("getCrimeStats", getRamCost(player, "getCrimeStats"));
|
helper.updateDynamicRam("getCrimeStats", getRamCost(player, "getCrimeStats"));
|
||||||
helper.checkSingularityAccess("getCrimeStats");
|
helper.checkSingularityAccess("getCrimeStats");
|
||||||
|
|
||||||
@ -1269,7 +1316,8 @@ export function NetscriptSingularity(
|
|||||||
}
|
}
|
||||||
return Object.values(DarkWebItems).map((p) => p.program);
|
return Object.values(DarkWebItems).map((p) => p.program);
|
||||||
},
|
},
|
||||||
getDarkwebProgramCost: function (programName: any): any {
|
getDarkwebProgramCost: function (_programName: unknown): number {
|
||||||
|
const programName = helper.string("getDarkwebProgramCost", "programName", _programName).toLowerCase();
|
||||||
helper.updateDynamicRam("getDarkwebProgramCost", getRamCost(player, "getDarkwebProgramCost"));
|
helper.updateDynamicRam("getDarkwebProgramCost", getRamCost(player, "getDarkwebProgramCost"));
|
||||||
helper.checkSingularityAccess("getDarkwebProgramCost");
|
helper.checkSingularityAccess("getDarkwebProgramCost");
|
||||||
|
|
||||||
@ -1281,7 +1329,6 @@ export function NetscriptSingularity(
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
programName = programName.toLowerCase();
|
|
||||||
const item = Object.values(DarkWebItems).find((i) => i.program.toLowerCase() === programName);
|
const item = Object.values(DarkWebItems).find((i) => i.program.toLowerCase() === programName);
|
||||||
|
|
||||||
// If the program doesn't exist, throw an error. The reasoning here is that the 99% case is that
|
// If the program doesn't exist, throw an error. The reasoning here is that the 99% case is that
|
||||||
|
23
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
23
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
@ -707,10 +707,10 @@ export interface CharacterInfo {
|
|||||||
factions: string[];
|
factions: string[];
|
||||||
/** Current health points */
|
/** Current health points */
|
||||||
hp: number;
|
hp: number;
|
||||||
/** Array of all companies at which you have jobs */
|
/** Array of all jobs */
|
||||||
company: string[];
|
jobs: string[];
|
||||||
/** Array of job positions for all companies you are employed at. Same order as 'jobs' */
|
/** Array of job positions for all companies you are employed at. Same order as 'jobs' */
|
||||||
jobTitle: string[];
|
jobTitles: string[];
|
||||||
/** Maximum health points */
|
/** Maximum health points */
|
||||||
maxHp: number;
|
maxHp: number;
|
||||||
/** Boolean indicating whether or not you have a tor router */
|
/** Boolean indicating whether or not you have a tor router */
|
||||||
@ -735,6 +735,18 @@ export interface CharacterInfo {
|
|||||||
workRepGain: number;
|
workRepGain: number;
|
||||||
/** Money earned so far from work, if applicable */
|
/** Money earned so far from work, if applicable */
|
||||||
workMoneyGain: number;
|
workMoneyGain: number;
|
||||||
|
/** total hacking exp */
|
||||||
|
hackingExp: number;
|
||||||
|
/** total strength exp */
|
||||||
|
strengthExp: number;
|
||||||
|
/** total defense exp */
|
||||||
|
defenseExp: number;
|
||||||
|
/** total dexterity exp */
|
||||||
|
dexterityExp: number;
|
||||||
|
/** total agility exp */
|
||||||
|
agilityExp: number;
|
||||||
|
/** total charisma exp */
|
||||||
|
charismaExp: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2199,11 +2211,8 @@ export interface Singularity {
|
|||||||
* Hospitalize the player.
|
* Hospitalize the player.
|
||||||
* @remarks
|
* @remarks
|
||||||
* RAM cost: 0.25 GB * 16/4/1
|
* RAM cost: 0.25 GB * 16/4/1
|
||||||
*
|
|
||||||
*
|
|
||||||
* @returns The cost of the hospitalization.
|
|
||||||
*/
|
*/
|
||||||
hospitalize(): number;
|
hospitalize(): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Soft reset the game.
|
* Soft reset the game.
|
||||||
|
Loading…
Reference in New Issue
Block a user