mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-21 00:32:51 +02:00
Merge branch 'dev' into fix/grafting-pre-reqs
This commit is contained in:
@@ -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;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -4,14 +4,14 @@ import { IPlayer } from "../PersonObjects/IPlayer";
|
||||
import { getRamCost } from "../Netscript/RamCostGenerator";
|
||||
import { is2DArray } from "../utils/helpers/is2DArray";
|
||||
import { CodingContract } from "../CodingContracts";
|
||||
import { CodingContract as ICodingContract } from "../ScriptEditor/NetscriptDefinitions";
|
||||
import { CodingAttemptOptions, CodingContract as ICodingContract } from "../ScriptEditor/NetscriptDefinitions";
|
||||
|
||||
export function NetscriptCodingContract(
|
||||
player: IPlayer,
|
||||
workerScript: WorkerScript,
|
||||
helper: INetscriptHelper,
|
||||
): ICodingContract {
|
||||
const getCodingContract = function (func: any, hostname: any, filename: any): CodingContract {
|
||||
const getCodingContract = function (func: string, hostname: string, filename: string): CodingContract {
|
||||
const server = helper.getServer(hostname, func);
|
||||
const contract = server.getContract(filename);
|
||||
if (contract == null) {
|
||||
@@ -27,10 +27,12 @@ export function NetscriptCodingContract(
|
||||
return {
|
||||
attempt: function (
|
||||
answer: any,
|
||||
filename: any,
|
||||
hostname: any = workerScript.hostname,
|
||||
{ returnReward }: any = {},
|
||||
_filename: unknown,
|
||||
_hostname: unknown = workerScript.hostname,
|
||||
{ returnReward }: CodingAttemptOptions = { returnReward: false },
|
||||
): boolean | string {
|
||||
const filename = helper.string("attempt", "filename", _filename);
|
||||
const hostname = helper.string("attempt", "hostname", _hostname);
|
||||
helper.updateDynamicRam("attempt", getRamCost(player, "codingcontract", "attempt"));
|
||||
const contract = getCodingContract("attempt", hostname, filename);
|
||||
|
||||
@@ -53,7 +55,10 @@ export function NetscriptCodingContract(
|
||||
const serv = helper.getServer(hostname, "codingcontract.attempt");
|
||||
if (contract.isSolution(answer)) {
|
||||
const reward = player.gainCodingContractReward(creward, contract.getDifficulty());
|
||||
workerScript.log("codingcontract.attempt", () => `Successfully completed Coding Contract '${filename}'. Reward: ${reward}`);
|
||||
workerScript.log(
|
||||
"codingcontract.attempt",
|
||||
() => `Successfully completed Coding Contract '${filename}'. Reward: ${reward}`,
|
||||
);
|
||||
serv.removeContract(filename);
|
||||
return returnReward ? reward : true;
|
||||
} else {
|
||||
@@ -68,7 +73,8 @@ export function NetscriptCodingContract(
|
||||
workerScript.log(
|
||||
"codingcontract.attempt",
|
||||
() =>
|
||||
`Coding Contract attempt '${filename}' failed. ${contract.getMaxNumTries() - contract.tries
|
||||
`Coding Contract attempt '${filename}' failed. ${
|
||||
contract.getMaxNumTries() - contract.tries
|
||||
} attempts remaining.`,
|
||||
);
|
||||
}
|
||||
@@ -76,12 +82,16 @@ export function NetscriptCodingContract(
|
||||
return returnReward ? "" : false;
|
||||
}
|
||||
},
|
||||
getContractType: function (filename: any, hostname: any = workerScript.hostname): string {
|
||||
getContractType: function (_filename: unknown, _hostname: unknown = workerScript.hostname): string {
|
||||
const filename = helper.string("getContractType", "filename", _filename);
|
||||
const hostname = helper.string("getContractType", "hostname", _hostname);
|
||||
helper.updateDynamicRam("getContractType", getRamCost(player, "codingcontract", "getContractType"));
|
||||
const contract = getCodingContract("getContractType", hostname, filename);
|
||||
return contract.getType();
|
||||
},
|
||||
getData: function (filename: any, hostname: any = workerScript.hostname): any {
|
||||
getData: function (_filename: unknown, _hostname: unknown = workerScript.hostname): any {
|
||||
const filename = helper.string("getContractType", "filename", _filename);
|
||||
const hostname = helper.string("getContractType", "hostname", _hostname);
|
||||
helper.updateDynamicRam("getData", getRamCost(player, "codingcontract", "getData"));
|
||||
const contract = getCodingContract("getData", hostname, filename);
|
||||
const data = contract.getData();
|
||||
@@ -101,12 +111,16 @@ export function NetscriptCodingContract(
|
||||
return data;
|
||||
}
|
||||
},
|
||||
getDescription: function (filename: any, hostname: any = workerScript.hostname): string {
|
||||
getDescription: function (_filename: unknown, _hostname: unknown = workerScript.hostname): string {
|
||||
const filename = helper.string("getDescription", "filename", _filename);
|
||||
const hostname = helper.string("getDescription", "hostname", _hostname);
|
||||
helper.updateDynamicRam("getDescription", getRamCost(player, "codingcontract", "getDescription"));
|
||||
const contract = getCodingContract("getDescription", hostname, filename);
|
||||
return contract.getDescription();
|
||||
},
|
||||
getNumTriesRemaining: function (filename: any, hostname: any = workerScript.hostname): number {
|
||||
getNumTriesRemaining: function (_filename: unknown, _hostname: unknown = workerScript.hostname): number {
|
||||
const filename = helper.string("getNumTriesRemaining", "filename", _filename);
|
||||
const hostname = helper.string("getNumTriesRemaining", "hostname", _hostname);
|
||||
helper.updateDynamicRam("getNumTriesRemaining", getRamCost(player, "codingcontract", "getNumTriesRemaining"));
|
||||
const contract = getCodingContract("getNumTriesRemaining", hostname, filename);
|
||||
return contract.getMaxNumTries() - contract.tries;
|
||||
|
||||
@@ -21,7 +21,7 @@ import {
|
||||
Division as NSDivision,
|
||||
WarehouseAPI,
|
||||
OfficeAPI,
|
||||
InvestmentOffer
|
||||
InvestmentOffer,
|
||||
} from "../ScriptEditor/NetscriptDefinitions";
|
||||
|
||||
import {
|
||||
@@ -100,8 +100,8 @@ export function NetscriptCorporation(
|
||||
return upgrade[1];
|
||||
}
|
||||
|
||||
function getUpgradeLevel(aupgradeName: string): number {
|
||||
const upgradeName = helper.string("levelUpgrade", "upgradeName", aupgradeName);
|
||||
function getUpgradeLevel(_upgradeName: string): number {
|
||||
const upgradeName = helper.string("levelUpgrade", "upgradeName", _upgradeName);
|
||||
const corporation = getCorporation();
|
||||
const upgrade = Object.values(CorporationUpgrades).find((upgrade) => upgrade[4] === upgradeName);
|
||||
if (upgrade === undefined) throw new Error(`No upgrade named '${upgradeName}'`);
|
||||
@@ -109,8 +109,8 @@ export function NetscriptCorporation(
|
||||
return corporation.upgrades[upgN];
|
||||
}
|
||||
|
||||
function getUpgradeLevelCost(aupgradeName: string): number {
|
||||
const upgradeName = helper.string("levelUpgrade", "upgradeName", aupgradeName);
|
||||
function getUpgradeLevelCost(_upgradeName: string): number {
|
||||
const upgradeName = helper.string("levelUpgrade", "upgradeName", _upgradeName);
|
||||
const corporation = getCorporation();
|
||||
const upgrade = Object.values(CorporationUpgrades).find((upgrade) => upgrade[4] === upgradeName);
|
||||
if (upgrade === undefined) throw new Error(`No upgrade named '${upgradeName}'`);
|
||||
@@ -135,11 +135,15 @@ export function NetscriptCorporation(
|
||||
|
||||
function getInvestmentOffer(): InvestmentOffer {
|
||||
const corporation = getCorporation();
|
||||
if (corporation.fundingRound >= CorporationConstants.FundingRoundShares.length || corporation.fundingRound >= CorporationConstants.FundingRoundMultiplier.length || corporation.public)
|
||||
if (
|
||||
corporation.fundingRound >= CorporationConstants.FundingRoundShares.length ||
|
||||
corporation.fundingRound >= CorporationConstants.FundingRoundMultiplier.length ||
|
||||
corporation.public
|
||||
)
|
||||
return {
|
||||
funds: 0,
|
||||
shares: 0,
|
||||
round: corporation.fundingRound + 1 // Make more readable
|
||||
round: corporation.fundingRound + 1, // Make more readable
|
||||
}; // Don't throw an error here, no reason to have a second function to check if you can get investment.
|
||||
const val = corporation.determineValuation();
|
||||
const percShares = CorporationConstants.FundingRoundShares[corporation.fundingRound];
|
||||
@@ -149,13 +153,18 @@ export function NetscriptCorporation(
|
||||
return {
|
||||
funds: funding,
|
||||
shares: investShares,
|
||||
round: corporation.fundingRound + 1 // Make more readable
|
||||
round: corporation.fundingRound + 1, // Make more readable
|
||||
};
|
||||
}
|
||||
|
||||
function acceptInvestmentOffer(): boolean {
|
||||
const corporation = getCorporation();
|
||||
if (corporation.fundingRound >= CorporationConstants.FundingRoundShares.length || corporation.fundingRound >= CorporationConstants.FundingRoundMultiplier.length || corporation.public) return false;
|
||||
if (
|
||||
corporation.fundingRound >= CorporationConstants.FundingRoundShares.length ||
|
||||
corporation.fundingRound >= CorporationConstants.FundingRoundMultiplier.length ||
|
||||
corporation.public
|
||||
)
|
||||
return false;
|
||||
const val = corporation.determineValuation();
|
||||
const percShares = CorporationConstants.FundingRoundShares[corporation.fundingRound];
|
||||
const roundMultiplier = CorporationConstants.FundingRoundMultiplier[corporation.fundingRound];
|
||||
@@ -181,7 +190,6 @@ export function NetscriptCorporation(
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function getResearchCost(division: IIndustry, researchName: string): number {
|
||||
const researchTree = IndustryResearchTrees[division.type];
|
||||
if (researchTree === undefined) throw new Error(`No research tree for industry '${division.type}'`);
|
||||
@@ -192,17 +200,18 @@ export function NetscriptCorporation(
|
||||
}
|
||||
|
||||
function hasResearched(division: IIndustry, researchName: string): boolean {
|
||||
return division.researched[researchName] === undefined ? false : division.researched[researchName] as boolean;
|
||||
return division.researched[researchName] === undefined ? false : (division.researched[researchName] as boolean);
|
||||
}
|
||||
|
||||
function bribe(factionName: string, amountCash: number, amountShares: number): boolean {
|
||||
if (!player.factions.includes(factionName)) throw new Error("Invalid faction name");
|
||||
if (isNaN(amountCash) || amountCash < 0 || isNaN(amountShares) || amountShares < 0) throw new Error("Invalid value for amount field! Must be numeric, grater than 0.");
|
||||
if (isNaN(amountCash) || amountCash < 0 || isNaN(amountShares) || amountShares < 0)
|
||||
throw new Error("Invalid value for amount field! Must be numeric, grater than 0.");
|
||||
|
||||
const corporation = getCorporation();
|
||||
if (corporation.funds < amountCash) return false;
|
||||
if (corporation.numShares < amountShares) return false;
|
||||
const faction = Factions[factionName]
|
||||
const faction = Factions[factionName];
|
||||
const info = faction.getInfo();
|
||||
if (!info.offersWork()) return false;
|
||||
if (player.hasGangWith(factionName)) return false;
|
||||
@@ -221,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];
|
||||
@@ -236,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];
|
||||
@@ -244,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];
|
||||
@@ -252,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}'`);
|
||||
@@ -302,40 +311,40 @@ export function NetscriptCorporation(
|
||||
checkAccess("getPurchaseWarehouseCost", 7);
|
||||
return CorporationConstants.WarehouseInitialCost;
|
||||
},
|
||||
getUpgradeWarehouseCost: function (adivisionName: any, acityName: any): number {
|
||||
getUpgradeWarehouseCost: function (_divisionName: unknown, _cityName: unknown): number {
|
||||
checkAccess("upgradeWarehouse", 7);
|
||||
const divisionName = helper.string("getUpgradeWarehouseCost", "divisionName", adivisionName);
|
||||
const cityName = helper.string("getUpgradeWarehouseCost", "cityName", acityName);
|
||||
const divisionName = helper.string("getUpgradeWarehouseCost", "divisionName", _divisionName);
|
||||
const cityName = helper.city("getUpgradeWarehouseCost", "cityName", _cityName);
|
||||
const warehouse = getWarehouse(divisionName, cityName);
|
||||
return CorporationConstants.WarehouseUpgradeBaseCost * Math.pow(1.07, warehouse.level + 1);
|
||||
},
|
||||
hasWarehouse: function (adivisionName: any, acityName: any): boolean {
|
||||
hasWarehouse: function (_divisionName: unknown, _cityName: unknown): boolean {
|
||||
checkAccess("hasWarehouse", 7);
|
||||
const divisionName = helper.string("getWarehouse", "divisionName", adivisionName);
|
||||
const cityName = helper.string("getWarehouse", "cityName", acityName);
|
||||
const divisionName = helper.string("getWarehouse", "divisionName", _divisionName);
|
||||
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];
|
||||
return warehouse !== 0;
|
||||
},
|
||||
getWarehouse: function (adivisionName: any, acityName: any): NSWarehouse {
|
||||
getWarehouse: function (_divisionName: unknown, _cityName: unknown): NSWarehouse {
|
||||
checkAccess("getWarehouse", 7);
|
||||
const divisionName = helper.string("getWarehouse", "divisionName", adivisionName);
|
||||
const cityName = helper.string("getWarehouse", "cityName", acityName);
|
||||
const divisionName = helper.string("getWarehouse", "divisionName", _divisionName);
|
||||
const cityName = helper.city("getWarehouse", "cityName", _cityName);
|
||||
const warehouse = getWarehouse(divisionName, cityName);
|
||||
return {
|
||||
level: warehouse.level,
|
||||
loc: warehouse.loc,
|
||||
size: warehouse.size,
|
||||
sizeUsed: warehouse.sizeUsed,
|
||||
smartSupplyEnabled: warehouse.smartSupplyEnabled
|
||||
smartSupplyEnabled: warehouse.smartSupplyEnabled,
|
||||
};
|
||||
},
|
||||
getMaterial: function (adivisionName: any, acityName: any, amaterialName: any): NSMaterial {
|
||||
getMaterial: function (_divisionName: unknown, _cityName: unknown, _materialName: unknown): NSMaterial {
|
||||
checkAccess("getMaterial", 7);
|
||||
const divisionName = helper.string("getMaterial", "divisionName", adivisionName);
|
||||
const cityName = helper.string("getMaterial", "cityName", acityName);
|
||||
const materialName = helper.string("getMaterial", "materialName", amaterialName);
|
||||
const divisionName = helper.string("getMaterial", "divisionName", _divisionName);
|
||||
const cityName = helper.city("getMaterial", "cityName", _cityName);
|
||||
const materialName = helper.string("getMaterial", "materialName", _materialName);
|
||||
const material = getMaterial(divisionName, cityName, materialName);
|
||||
return {
|
||||
name: material.name,
|
||||
@@ -345,10 +354,10 @@ export function NetscriptCorporation(
|
||||
sell: material.sll,
|
||||
};
|
||||
},
|
||||
getProduct: function (adivisionName: any, aproductName: any): NSProduct {
|
||||
getProduct: function (_divisionName: unknown, _productName: unknown): NSProduct {
|
||||
checkAccess("getProduct", 7);
|
||||
const divisionName = helper.string("getProduct", "divisionName", adivisionName);
|
||||
const productName = helper.string("getProduct", "productName", aproductName);
|
||||
const divisionName = helper.string("getProduct", "divisionName", _divisionName);
|
||||
const productName = helper.string("getProduct", "productName", _productName);
|
||||
const product = getProduct(divisionName, productName);
|
||||
return {
|
||||
name: product.name,
|
||||
@@ -360,220 +369,271 @@ export function NetscriptCorporation(
|
||||
developmentProgress: product.prog,
|
||||
};
|
||||
},
|
||||
purchaseWarehouse: function (adivisionName: any, acityName: any): void {
|
||||
purchaseWarehouse: function (_divisionName: unknown, _cityName: unknown): void {
|
||||
checkAccess("purchaseWarehouse", 7);
|
||||
const divisionName = helper.string("purchaseWarehouse", "divisionName", adivisionName);
|
||||
const cityName = helper.string("purchaseWarehouse", "cityName", acityName);
|
||||
const divisionName = helper.string("purchaseWarehouse", "divisionName", _divisionName);
|
||||
const cityName = helper.city("purchaseWarehouse", "cityName", _cityName);
|
||||
const corporation = getCorporation();
|
||||
PurchaseWarehouse(corporation, getDivision(divisionName), cityName);
|
||||
},
|
||||
upgradeWarehouse: function (adivisionName: any, acityName: any): void {
|
||||
upgradeWarehouse: function (_divisionName: unknown, _cityName: unknown): void {
|
||||
checkAccess("upgradeWarehouse", 7);
|
||||
const divisionName = helper.string("upgradeWarehouse", "divisionName", adivisionName);
|
||||
const cityName = helper.string("upgradeWarehouse", "cityName", acityName);
|
||||
const divisionName = helper.string("upgradeWarehouse", "divisionName", _divisionName);
|
||||
const cityName = helper.city("upgradeWarehouse", "cityName", _cityName);
|
||||
const corporation = getCorporation();
|
||||
UpgradeWarehouse(corporation, getDivision(divisionName), getWarehouse(divisionName, cityName));
|
||||
},
|
||||
sellMaterial: function (adivisionName: any, acityName: any, amaterialName: any, aamt: any, aprice: any): void {
|
||||
sellMaterial: function (
|
||||
_divisionName: unknown,
|
||||
_cityName: unknown,
|
||||
_materialName: unknown,
|
||||
_amt: unknown,
|
||||
_price: unknown,
|
||||
): void {
|
||||
checkAccess("sellMaterial", 7);
|
||||
const divisionName = helper.string("sellMaterial", "divisionName", adivisionName);
|
||||
const cityName = helper.string("sellMaterial", "cityName", acityName);
|
||||
const materialName = helper.string("sellMaterial", "materialName", amaterialName);
|
||||
const amt = helper.string("sellMaterial", "amt", aamt);
|
||||
const price = helper.string("sellMaterial", "price", aprice);
|
||||
const divisionName = helper.string("sellMaterial", "divisionName", _divisionName);
|
||||
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);
|
||||
const material = getMaterial(divisionName, cityName, materialName);
|
||||
SellMaterial(material, amt, price);
|
||||
},
|
||||
sellProduct: function (
|
||||
adivisionName: any,
|
||||
acityName: any,
|
||||
aproductName: any,
|
||||
aamt: any,
|
||||
aprice: any,
|
||||
aall: any,
|
||||
_divisionName: unknown,
|
||||
_cityName: unknown,
|
||||
_productName: unknown,
|
||||
_amt: unknown,
|
||||
_price: unknown,
|
||||
_all: unknown,
|
||||
): void {
|
||||
checkAccess("sellProduct", 7);
|
||||
const divisionName = helper.string("sellProduct", "divisionName", adivisionName);
|
||||
const cityName = helper.string("sellProduct", "cityName", acityName);
|
||||
const productName = helper.string("sellProduct", "productName", aproductName);
|
||||
const amt = helper.string("sellProduct", "amt", aamt);
|
||||
const price = helper.string("sellProduct", "price", aprice);
|
||||
const all = helper.boolean(aall);
|
||||
const divisionName = helper.string("sellProduct", "divisionName", _divisionName);
|
||||
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);
|
||||
const all = helper.boolean(_all);
|
||||
const product = getProduct(divisionName, productName);
|
||||
SellProduct(product, cityName, amt, price, all);
|
||||
},
|
||||
discontinueProduct: function (adivisionName: any, aproductName: any): void {
|
||||
discontinueProduct: function (_divisionName: unknown, _productName: unknown): void {
|
||||
checkAccess("discontinueProduct", 7);
|
||||
const divisionName = helper.string("discontinueProduct", "divisionName", adivisionName);
|
||||
const productName = helper.string("discontinueProduct", "productName", aproductName);
|
||||
const divisionName = helper.string("discontinueProduct", "divisionName", _divisionName);
|
||||
const productName = helper.string("discontinueProduct", "productName", _productName);
|
||||
getDivision(divisionName).discontinueProduct(getProduct(divisionName, productName));
|
||||
},
|
||||
setSmartSupply: function (adivisionName: any, acityName: any, aenabled: any): void {
|
||||
setSmartSupply: function (_divisionName: unknown, _cityName: unknown, _enabled: unknown): void {
|
||||
checkAccess("setSmartSupply", 7);
|
||||
const divisionName = helper.string("setSmartSupply", "divisionName", adivisionName);
|
||||
const cityName = helper.string("sellProduct", "cityName", acityName);
|
||||
const enabled = helper.boolean(aenabled);
|
||||
const divisionName = helper.string("setSmartSupply", "divisionName", _divisionName);
|
||||
const cityName = helper.city("sellProduct", "cityName", _cityName);
|
||||
const enabled = helper.boolean(_enabled);
|
||||
const warehouse = getWarehouse(divisionName, cityName);
|
||||
if (!hasUnlockUpgrade("Smart Supply"))
|
||||
throw helper.makeRuntimeErrorMsg(`corporation.setSmartSupply`, `You have not purchased the Smart Supply upgrade!`);
|
||||
throw helper.makeRuntimeErrorMsg(
|
||||
`corporation.setSmartSupply`,
|
||||
`You have not purchased the Smart Supply upgrade!`,
|
||||
);
|
||||
SetSmartSupply(warehouse, enabled);
|
||||
},
|
||||
setSmartSupplyUseLeftovers: function (adivisionName: any, acityName: any, amaterialName: any, aenabled: any): void {
|
||||
setSmartSupplyUseLeftovers: function (
|
||||
_divisionName: unknown,
|
||||
_cityName: unknown,
|
||||
_materialName: unknown,
|
||||
_enabled: unknown,
|
||||
): void {
|
||||
checkAccess("setSmartSupplyUseLeftovers", 7);
|
||||
const divisionName = helper.string("setSmartSupply", "divisionName", adivisionName);
|
||||
const cityName = helper.string("sellProduct", "cityName", acityName);
|
||||
const materialName = helper.string("sellProduct", "materialName", amaterialName);
|
||||
const enabled = helper.boolean(aenabled);
|
||||
const divisionName = helper.string("setSmartSupply", "divisionName", _divisionName);
|
||||
const cityName = helper.city("sellProduct", "cityName", _cityName);
|
||||
const materialName = helper.string("sellProduct", "materialName", _materialName);
|
||||
const enabled = helper.boolean(_enabled);
|
||||
const warehouse = getWarehouse(divisionName, cityName);
|
||||
const material = getMaterial(divisionName, cityName, materialName);
|
||||
if (!hasUnlockUpgrade("Smart Supply"))
|
||||
throw helper.makeRuntimeErrorMsg(`corporation.setSmartSupply`, `You have not purchased the Smart Supply upgrade!`);
|
||||
throw helper.makeRuntimeErrorMsg(
|
||||
`corporation.setSmartSupply`,
|
||||
`You have not purchased the Smart Supply upgrade!`,
|
||||
);
|
||||
SetSmartSupplyUseLeftovers(warehouse, material, enabled);
|
||||
},
|
||||
buyMaterial: function (adivisionName: any, acityName: any, amaterialName: any, aamt: any): void {
|
||||
buyMaterial: function (_divisionName: unknown, _cityName: unknown, _materialName: unknown, _amt: unknown): void {
|
||||
checkAccess("buyMaterial", 7);
|
||||
const divisionName = helper.string("buyMaterial", "divisionName", adivisionName);
|
||||
const cityName = helper.string("buyMaterial", "cityName", acityName);
|
||||
const materialName = helper.string("buyMaterial", "materialName", amaterialName);
|
||||
const amt = helper.number("buyMaterial", "amt", aamt);
|
||||
const divisionName = helper.string("buyMaterial", "divisionName", _divisionName);
|
||||
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");
|
||||
const material = getMaterial(divisionName, cityName, materialName);
|
||||
BuyMaterial(material, amt);
|
||||
},
|
||||
bulkPurchase: function (adivisionName: any, acityName: any, amaterialName: any, aamt: any): void {
|
||||
bulkPurchase: function (_divisionName: unknown, _cityName: unknown, _materialName: unknown, _amt: unknown): void {
|
||||
checkAccess("bulkPurchase", 7);
|
||||
const divisionName = helper.string("bulkPurchase", "divisionName", adivisionName);
|
||||
if (!hasResearched(getDivision(adivisionName), "Bulk Purchasing")) throw new Error(`You have not researched Bulk Purchasing in ${divisionName}`)
|
||||
const divisionName = helper.string("bulkPurchase", "divisionName", _divisionName);
|
||||
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", acityName);
|
||||
const materialName = helper.string("bulkPurchase", "materialName", amaterialName);
|
||||
const amt = helper.number("bulkPurchase", "amt", aamt);
|
||||
const warehouse = getWarehouse(divisionName, 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);
|
||||
const material = getMaterial(divisionName, cityName, materialName);
|
||||
BulkPurchase(corporation, warehouse, material, amt);
|
||||
},
|
||||
makeProduct: function (
|
||||
adivisionName: any,
|
||||
acityName: any,
|
||||
aproductName: any,
|
||||
adesignInvest: any,
|
||||
amarketingInvest: any,
|
||||
_divisionName: unknown,
|
||||
_cityName: unknown,
|
||||
_productName: unknown,
|
||||
_designInvest: unknown,
|
||||
_marketingInvest: unknown,
|
||||
): void {
|
||||
checkAccess("makeProduct", 7);
|
||||
const divisionName = helper.string("makeProduct", "divisionName", adivisionName);
|
||||
const cityName = helper.string("makeProduct", "cityName", acityName);
|
||||
const productName = helper.string("makeProduct", "productName", aproductName);
|
||||
const designInvest = helper.number("makeProduct", "designInvest", adesignInvest);
|
||||
const marketingInvest = helper.number("makeProduct", "marketingInvest", amarketingInvest);
|
||||
const divisionName = helper.string("makeProduct", "divisionName", _divisionName);
|
||||
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);
|
||||
const corporation = getCorporation();
|
||||
MakeProduct(corporation, getDivision(divisionName), cityName, productName, designInvest, marketingInvest);
|
||||
},
|
||||
exportMaterial: function (
|
||||
asourceDivision: any,
|
||||
asourceCity: any,
|
||||
atargetDivision: any,
|
||||
atargetCity: any,
|
||||
amaterialName: any,
|
||||
aamt: any,
|
||||
_sourceDivision: unknown,
|
||||
_sourceCity: unknown,
|
||||
_targetDivision: unknown,
|
||||
_targetCity: unknown,
|
||||
_materialName: unknown,
|
||||
_amt: unknown,
|
||||
): void {
|
||||
checkAccess("exportMaterial", 7);
|
||||
const sourceDivision = helper.string("exportMaterial", "sourceDivision", asourceDivision);
|
||||
const sourceCity = helper.string("exportMaterial", "sourceCity", asourceCity);
|
||||
const targetDivision = helper.string("exportMaterial", "targetDivision", atargetDivision);
|
||||
const targetCity = helper.string("exportMaterial", "targetCity", atargetCity);
|
||||
const materialName = helper.string("exportMaterial", "materialName", amaterialName);
|
||||
const amt = helper.string("exportMaterial", "amt", aamt);
|
||||
ExportMaterial(targetDivision, targetCity, getMaterial(sourceDivision, sourceCity, materialName), amt + "", getDivision(targetDivision));
|
||||
const sourceDivision = helper.string("exportMaterial", "sourceDivision", _sourceDivision);
|
||||
const sourceCity = helper.string("exportMaterial", "sourceCity", _sourceCity);
|
||||
const targetDivision = helper.string("exportMaterial", "targetDivision", _targetDivision);
|
||||
const targetCity = helper.string("exportMaterial", "targetCity", _targetCity);
|
||||
const materialName = helper.string("exportMaterial", "materialName", _materialName);
|
||||
const amt = helper.string("exportMaterial", "amt", _amt);
|
||||
ExportMaterial(
|
||||
targetDivision,
|
||||
targetCity,
|
||||
getMaterial(sourceDivision, sourceCity, materialName),
|
||||
amt + "",
|
||||
getDivision(targetDivision),
|
||||
);
|
||||
},
|
||||
cancelExportMaterial: function (
|
||||
asourceDivision: any,
|
||||
asourceCity: any,
|
||||
atargetDivision: any,
|
||||
atargetCity: any,
|
||||
amaterialName: any,
|
||||
aamt: any,
|
||||
_sourceDivision: unknown,
|
||||
_sourceCity: unknown,
|
||||
_targetDivision: unknown,
|
||||
_targetCity: unknown,
|
||||
_materialName: unknown,
|
||||
_amt: unknown,
|
||||
): void {
|
||||
checkAccess("cancelExportMaterial", 7);
|
||||
const sourceDivision = helper.string("cancelExportMaterial", "sourceDivision", asourceDivision);
|
||||
const sourceCity = helper.string("cancelExportMaterial", "sourceCity", asourceCity);
|
||||
const targetDivision = helper.string("cancelExportMaterial", "targetDivision", atargetDivision);
|
||||
const targetCity = helper.string("cancelExportMaterial", "targetCity", atargetCity);
|
||||
const materialName = helper.string("cancelExportMaterial", "materialName", amaterialName);
|
||||
const amt = helper.string("cancelExportMaterial", "amt", aamt);
|
||||
const sourceDivision = helper.string("cancelExportMaterial", "sourceDivision", _sourceDivision);
|
||||
const sourceCity = helper.string("cancelExportMaterial", "sourceCity", _sourceCity);
|
||||
const targetDivision = helper.string("cancelExportMaterial", "targetDivision", _targetDivision);
|
||||
const targetCity = helper.string("cancelExportMaterial", "targetCity", _targetCity);
|
||||
const materialName = helper.string("cancelExportMaterial", "materialName", _materialName);
|
||||
const amt = helper.string("cancelExportMaterial", "amt", _amt);
|
||||
CancelExportMaterial(targetDivision, targetCity, getMaterial(sourceDivision, sourceCity, materialName), amt + "");
|
||||
},
|
||||
setMaterialMarketTA1: function (adivisionName: any, acityName: any, amaterialName: any, aon: any): void {
|
||||
setMaterialMarketTA1: function (
|
||||
_divisionName: unknown,
|
||||
_cityName: unknown,
|
||||
_materialName: unknown,
|
||||
_on: unknown,
|
||||
): void {
|
||||
checkAccess("setMaterialMarketTA1", 7);
|
||||
const divisionName = helper.string("setMaterialMarketTA1", "divisionName", adivisionName);
|
||||
const cityName = helper.string("setMaterialMarketTA1", "cityName", acityName);
|
||||
const materialName = helper.string("setMaterialMarketTA1", "materialName", amaterialName);
|
||||
const on = helper.boolean(aon);
|
||||
const divisionName = helper.string("setMaterialMarketTA1", "divisionName", _divisionName);
|
||||
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"))
|
||||
throw helper.makeRuntimeErrorMsg(`corporation.setMaterialMarketTA1`, `You have not researched MarketTA.I for division: ${divisionName}`);
|
||||
throw helper.makeRuntimeErrorMsg(
|
||||
`corporation.setMaterialMarketTA1`,
|
||||
`You have not researched MarketTA.I for division: ${divisionName}`,
|
||||
);
|
||||
SetMaterialMarketTA1(getMaterial(divisionName, cityName, materialName), on);
|
||||
},
|
||||
setMaterialMarketTA2: function (adivisionName: any, acityName: any, amaterialName: any, aon: any): void {
|
||||
setMaterialMarketTA2: function (
|
||||
_divisionName: unknown,
|
||||
_cityName: unknown,
|
||||
_materialName: unknown,
|
||||
_on: unknown,
|
||||
): void {
|
||||
checkAccess("setMaterialMarketTA2", 7);
|
||||
const divisionName = helper.string("setMaterialMarketTA2", "divisionName", adivisionName);
|
||||
const cityName = helper.string("setMaterialMarketTA2", "cityName", acityName);
|
||||
const materialName = helper.string("setMaterialMarketTA2", "materialName", amaterialName);
|
||||
const on = helper.boolean(aon);
|
||||
const divisionName = helper.string("setMaterialMarketTA2", "divisionName", _divisionName);
|
||||
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"))
|
||||
throw helper.makeRuntimeErrorMsg(`corporation.setMaterialMarketTA2`, `You have not researched MarketTA.II for division: ${divisionName}`);
|
||||
throw helper.makeRuntimeErrorMsg(
|
||||
`corporation.setMaterialMarketTA2`,
|
||||
`You have not researched MarketTA.II for division: ${divisionName}`,
|
||||
);
|
||||
SetMaterialMarketTA2(getMaterial(divisionName, cityName, materialName), on);
|
||||
},
|
||||
setProductMarketTA1: function (adivisionName: any, aproductName: any, aon: any): void {
|
||||
setProductMarketTA1: function (_divisionName: unknown, _productName: unknown, _on: unknown): void {
|
||||
checkAccess("setProductMarketTA1", 7);
|
||||
const divisionName = helper.string("setProductMarketTA1", "divisionName", adivisionName);
|
||||
const productName = helper.string("setProductMarketTA1", "productName", aproductName);
|
||||
const on = helper.boolean(aon);
|
||||
const divisionName = helper.string("setProductMarketTA1", "divisionName", _divisionName);
|
||||
const productName = helper.string("setProductMarketTA1", "productName", _productName);
|
||||
const on = helper.boolean(_on);
|
||||
if (!getDivision(divisionName).hasResearch("Market-TA.I"))
|
||||
throw helper.makeRuntimeErrorMsg(`corporation.setProductMarketTA1`, `You have not researched MarketTA.I for division: ${divisionName}`);
|
||||
throw helper.makeRuntimeErrorMsg(
|
||||
`corporation.setProductMarketTA1`,
|
||||
`You have not researched MarketTA.I for division: ${divisionName}`,
|
||||
);
|
||||
SetProductMarketTA1(getProduct(divisionName, productName), on);
|
||||
},
|
||||
setProductMarketTA2: function (adivisionName: any, aproductName: any, aon: any): void {
|
||||
setProductMarketTA2: function (_divisionName: unknown, _productName: unknown, _on: unknown): void {
|
||||
checkAccess("setProductMarketTA2", 7);
|
||||
const divisionName = helper.string("setProductMarketTA2", "divisionName", adivisionName);
|
||||
const productName = helper.string("setProductMarketTA2", "productName", aproductName);
|
||||
const on = helper.boolean(aon);
|
||||
const divisionName = helper.string("setProductMarketTA2", "divisionName", _divisionName);
|
||||
const productName = helper.string("setProductMarketTA2", "productName", _productName);
|
||||
const on = helper.boolean(_on);
|
||||
if (!getDivision(divisionName).hasResearch("Market-TA.II"))
|
||||
throw helper.makeRuntimeErrorMsg(`corporation.setProductMarketTA2`, `You have not researched MarketTA.II for division: ${divisionName}`);
|
||||
throw helper.makeRuntimeErrorMsg(
|
||||
`corporation.setProductMarketTA2`,
|
||||
`You have not researched MarketTA.II for division: ${divisionName}`,
|
||||
);
|
||||
SetProductMarketTA2(getProduct(divisionName, productName), on);
|
||||
},
|
||||
};
|
||||
|
||||
const officeAPI: OfficeAPI = {
|
||||
getHireAdVertCost: function (adivisionName: any): number {
|
||||
getHireAdVertCost: function (_divisionName: unknown): number {
|
||||
checkAccess("getHireAdVertCost", 8);
|
||||
const divisionName = helper.string("getHireAdVertCost", "divisionName", adivisionName);
|
||||
const divisionName = helper.string("getHireAdVertCost", "divisionName", _divisionName);
|
||||
const division = getDivision(divisionName);
|
||||
const upgrade = IndustryUpgrades[1];
|
||||
return upgrade[1] * Math.pow(upgrade[2], division.upgrades[1]);
|
||||
},
|
||||
getHireAdVertCount: function (adivisionName: any): number {
|
||||
getHireAdVertCount: function (_divisionName: unknown): number {
|
||||
checkAccess("getHireAdVertCount", 8);
|
||||
const divisionName = helper.string("getHireAdVertCount", "divisionName", adivisionName);
|
||||
const divisionName = helper.string("getHireAdVertCount", "divisionName", _divisionName);
|
||||
const division = getDivision(divisionName);
|
||||
return division.upgrades[1]
|
||||
return division.upgrades[1];
|
||||
},
|
||||
getResearchCost: function (adivisionName: any, aresearchName: any): number {
|
||||
getResearchCost: function (_divisionName: unknown, _researchName: unknown): number {
|
||||
checkAccess("getResearchCost", 8);
|
||||
const divisionName = helper.string("getResearchCost", "divisionName", adivisionName);
|
||||
const researchName = helper.string("getResearchCost", "researchName", aresearchName);
|
||||
const divisionName = helper.string("getResearchCost", "divisionName", _divisionName);
|
||||
const researchName = helper.string("getResearchCost", "researchName", _researchName);
|
||||
return getResearchCost(getDivision(divisionName), researchName);
|
||||
},
|
||||
hasResearched: function (adivisionName: any, aresearchName: any): boolean {
|
||||
hasResearched: function (_divisionName: unknown, _researchName: unknown): boolean {
|
||||
checkAccess("hasResearched", 8);
|
||||
const divisionName = helper.string("hasResearched", "divisionName", adivisionName);
|
||||
const researchName = helper.string("hasResearched", "researchName", aresearchName);
|
||||
const divisionName = helper.string("hasResearched", "divisionName", _divisionName);
|
||||
const researchName = helper.string("hasResearched", "researchName", _researchName);
|
||||
return hasResearched(getDivision(divisionName), researchName);
|
||||
},
|
||||
setAutoJobAssignment: function (adivisionName: any, acityName: any, ajob: any, aamount: any): Promise<boolean> {
|
||||
setAutoJobAssignment: function (
|
||||
_divisionName: unknown,
|
||||
_cityName: unknown,
|
||||
_job: unknown,
|
||||
_amount: unknown,
|
||||
): Promise<boolean> {
|
||||
checkAccess("setAutoJobAssignment", 8);
|
||||
const divisionName = helper.string("setAutoJobAssignment", "divisionName", adivisionName);
|
||||
const cityName = helper.string("setAutoJobAssignment", "cityName", acityName);
|
||||
const amount = helper.number("setAutoJobAssignment", "amount", aamount);
|
||||
const job = helper.string("setAutoJobAssignment", "job", ajob);
|
||||
const divisionName = helper.string("setAutoJobAssignment", "divisionName", _divisionName);
|
||||
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);
|
||||
if (!Object.values(EmployeePositions).includes(job)) throw new Error(`'${job}' is not a valid job.`);
|
||||
return netscriptDelay(1000, workerScript).then(function () {
|
||||
@@ -583,11 +643,11 @@ export function NetscriptCorporation(
|
||||
return Promise.resolve(office.setEmployeeToJob(job, amount));
|
||||
});
|
||||
},
|
||||
getOfficeSizeUpgradeCost: function (adivisionName: any, acityName: any, asize: any): number {
|
||||
getOfficeSizeUpgradeCost: function (_divisionName: unknown, _cityName: unknown, _size: unknown): number {
|
||||
checkAccess("getOfficeSizeUpgradeCost", 8);
|
||||
const divisionName = helper.string("getOfficeSizeUpgradeCost", "divisionName", adivisionName);
|
||||
const cityName = helper.string("getOfficeSizeUpgradeCost", "cityName", acityName);
|
||||
const size = helper.number("getOfficeSizeUpgradeCost", "size", asize);
|
||||
const divisionName = helper.string("getOfficeSizeUpgradeCost", "divisionName", _divisionName);
|
||||
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);
|
||||
const initialPriceMult = Math.round(office.size / CorporationConstants.OfficeInitialSize);
|
||||
@@ -598,40 +658,46 @@ export function NetscriptCorporation(
|
||||
}
|
||||
return CorporationConstants.OfficeInitialCost * mult;
|
||||
},
|
||||
assignJob: function (adivisionName: any, acityName: any, aemployeeName: any, ajob: any): Promise<void> {
|
||||
assignJob: function (
|
||||
_divisionName: unknown,
|
||||
_cityName: unknown,
|
||||
_employeeName: unknown,
|
||||
_job: unknown,
|
||||
): Promise<void> {
|
||||
checkAccess("assignJob", 8);
|
||||
const divisionName = helper.string("assignJob", "divisionName", adivisionName);
|
||||
const cityName = helper.string("assignJob", "cityName", acityName);
|
||||
const employeeName = helper.string("assignJob", "employeeName", aemployeeName);
|
||||
const job = helper.string("assignJob", "job", ajob);
|
||||
const divisionName = helper.string("assignJob", "divisionName", _divisionName);
|
||||
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);
|
||||
return netscriptDelay(1000, workerScript).then(function () {
|
||||
return Promise.resolve(AssignJob(employee, job));
|
||||
});
|
||||
},
|
||||
hireEmployee: function (adivisionName: any, acityName: any): any {
|
||||
hireEmployee: function (_divisionName: unknown, _cityName: unknown): any {
|
||||
checkAccess("hireEmployee", 8);
|
||||
const divisionName = helper.string("hireEmployee", "divisionName", adivisionName);
|
||||
const cityName = helper.string("hireEmployee", "cityName", acityName);
|
||||
const divisionName = helper.string("hireEmployee", "divisionName", _divisionName);
|
||||
const cityName = helper.city("hireEmployee", "cityName", _cityName);
|
||||
const office = getOffice(divisionName, cityName);
|
||||
return office.hireRandomEmployee();
|
||||
},
|
||||
upgradeOfficeSize: function (adivisionName: any, acityName: any, asize: any): void {
|
||||
upgradeOfficeSize: function (_divisionName: unknown, _cityName: unknown, _size: unknown): void {
|
||||
checkAccess("upgradeOfficeSize", 8);
|
||||
const divisionName = helper.string("upgradeOfficeSize", "divisionName", adivisionName);
|
||||
const cityName = helper.string("upgradeOfficeSize", "cityName", acityName);
|
||||
const size = helper.number("upgradeOfficeSize", "size", asize);
|
||||
const divisionName = helper.string("upgradeOfficeSize", "divisionName", _divisionName);
|
||||
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);
|
||||
const corporation = getCorporation();
|
||||
UpgradeOfficeSize(corporation, office, size);
|
||||
},
|
||||
throwParty: function (adivisionName: any, acityName: any, acostPerEmployee: any): Promise<number> {
|
||||
throwParty: function (_divisionName: unknown, _cityName: unknown, _costPerEmployee: unknown): Promise<number> {
|
||||
checkAccess("throwParty", 8);
|
||||
const divisionName = helper.string("throwParty", "divisionName", adivisionName);
|
||||
const cityName = helper.string("throwParty", "cityName", acityName);
|
||||
const costPerEmployee = helper.number("throwParty", "costPerEmployee", acostPerEmployee);
|
||||
if (costPerEmployee < 0) throw new Error("Invalid value for Cost Per Employee field! Must be numeric and greater than 0");
|
||||
const divisionName = helper.string("throwParty", "divisionName", _divisionName);
|
||||
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");
|
||||
const office = getOffice(divisionName, cityName);
|
||||
const corporation = getCorporation();
|
||||
return netscriptDelay(
|
||||
@@ -641,10 +707,10 @@ export function NetscriptCorporation(
|
||||
return Promise.resolve(ThrowParty(corporation, office, costPerEmployee));
|
||||
});
|
||||
},
|
||||
buyCoffee: function (adivisionName: any, acityName: any): Promise<void> {
|
||||
buyCoffee: function (_divisionName: unknown, _cityName: unknown): Promise<void> {
|
||||
checkAccess("buyCoffee", 8);
|
||||
const divisionName = helper.string("buyCoffee", "divisionName", adivisionName);
|
||||
const cityName = helper.string("buyCoffee", "cityName", acityName);
|
||||
const divisionName = helper.string("buyCoffee", "divisionName", _divisionName);
|
||||
const cityName = helper.city("buyCoffee", "cityName", _cityName);
|
||||
const corporation = getCorporation();
|
||||
return netscriptDelay(
|
||||
(60 * 1000) / (player.hacking_speed_mult * calculateIntelligenceBonus(player.intelligence, 1)),
|
||||
@@ -653,22 +719,22 @@ export function NetscriptCorporation(
|
||||
return Promise.resolve(BuyCoffee(corporation, getDivision(divisionName), getOffice(divisionName, cityName)));
|
||||
});
|
||||
},
|
||||
hireAdVert: function (adivisionName: any): void {
|
||||
hireAdVert: function (_divisionName: unknown): void {
|
||||
checkAccess("hireAdVert", 8);
|
||||
const divisionName = helper.string("hireAdVert", "divisionName", adivisionName);
|
||||
const divisionName = helper.string("hireAdVert", "divisionName", _divisionName);
|
||||
const corporation = getCorporation();
|
||||
HireAdVert(corporation, getDivision(divisionName), getOffice(divisionName, "Sector-12"));
|
||||
},
|
||||
research: function (adivisionName: any, aresearchName: any): void {
|
||||
research: function (_divisionName: unknown, _researchName: unknown): void {
|
||||
checkAccess("research", 8);
|
||||
const divisionName = helper.string("research", "divisionName", adivisionName);
|
||||
const researchName = helper.string("research", "researchName", aresearchName);
|
||||
const divisionName = helper.string("research", "divisionName", _divisionName);
|
||||
const researchName = helper.string("research", "researchName", _researchName);
|
||||
Research(getDivision(divisionName), researchName);
|
||||
},
|
||||
getOffice: function (adivisionName: any, acityName: any): any {
|
||||
getOffice: function (_divisionName: unknown, _cityName: unknown): any {
|
||||
checkAccess("getOffice", 8);
|
||||
const divisionName = helper.string("getOffice", "divisionName", adivisionName);
|
||||
const cityName = helper.string("getOffice", "cityName", acityName);
|
||||
const divisionName = helper.string("getOffice", "divisionName", _divisionName);
|
||||
const cityName = helper.city("getOffice", "cityName", _cityName);
|
||||
const office = getOffice(divisionName, cityName);
|
||||
return {
|
||||
loc: office.loc,
|
||||
@@ -689,11 +755,11 @@ export function NetscriptCorporation(
|
||||
},
|
||||
};
|
||||
},
|
||||
getEmployee: function (adivisionName: any, acityName: any, aemployeeName: any): NSEmployee {
|
||||
getEmployee: function (_divisionName: unknown, _cityName: unknown, _employeeName: unknown): NSEmployee {
|
||||
checkAccess("getEmployee", 8);
|
||||
const divisionName = helper.string("getEmployee", "divisionName", adivisionName);
|
||||
const cityName = helper.string("getEmployee", "cityName", acityName);
|
||||
const employeeName = helper.string("getEmployee", "employeeName", aemployeeName);
|
||||
const divisionName = helper.string("getEmployee", "divisionName", _divisionName);
|
||||
const cityName = helper.city("getEmployee", "cityName", _cityName);
|
||||
const employeeName = helper.string("getEmployee", "employeeName", _employeeName);
|
||||
const employee = getEmployee(divisionName, cityName, employeeName);
|
||||
return {
|
||||
name: employee.name,
|
||||
@@ -715,42 +781,43 @@ export function NetscriptCorporation(
|
||||
return {
|
||||
...warehouseAPI,
|
||||
...officeAPI,
|
||||
expandIndustry: function (aindustryName: any, adivisionName: any): void {
|
||||
expandIndustry: function (_industryName: unknown, _divisionName: unknown): void {
|
||||
checkAccess("expandIndustry");
|
||||
const industryName = helper.string("expandIndustry", "industryName", aindustryName);
|
||||
const divisionName = helper.string("expandIndustry", "divisionName", adivisionName);
|
||||
const industryName = helper.string("expandIndustry", "industryName", _industryName);
|
||||
const divisionName = helper.string("expandIndustry", "divisionName", _divisionName);
|
||||
const corporation = getCorporation();
|
||||
NewIndustry(corporation, industryName, divisionName);
|
||||
},
|
||||
expandCity: function (adivisionName: any, acityName: any): void {
|
||||
expandCity: function (_divisionName: unknown, _cityName: unknown): void {
|
||||
checkAccess("expandCity");
|
||||
const divisionName = helper.string("expandCity", "divisionName", adivisionName);
|
||||
const cityName = helper.string("expandCity", "cityName", acityName);
|
||||
const divisionName = helper.string("expandCity", "divisionName", _divisionName);
|
||||
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);
|
||||
NewCity(corporation, division, cityName);
|
||||
},
|
||||
unlockUpgrade: function (aupgradeName: any): void {
|
||||
unlockUpgrade: function (_upgradeName: unknown): void {
|
||||
checkAccess("unlockUpgrade");
|
||||
const upgradeName = helper.string("unlockUpgrade", "upgradeName", aupgradeName);
|
||||
const upgradeName = helper.string("unlockUpgrade", "upgradeName", _upgradeName);
|
||||
const corporation = getCorporation();
|
||||
const upgrade = Object.values(CorporationUnlockUpgrades).find((upgrade) => upgrade[2] === upgradeName);
|
||||
if (upgrade === undefined) throw new Error(`No upgrade named '${upgradeName}'`);
|
||||
UnlockUpgrade(corporation, upgrade);
|
||||
},
|
||||
levelUpgrade: function (aupgradeName: any): void {
|
||||
levelUpgrade: function (_upgradeName: unknown): void {
|
||||
checkAccess("levelUpgrade");
|
||||
const upgradeName = helper.string("levelUpgrade", "upgradeName", aupgradeName);
|
||||
const upgradeName = helper.string("levelUpgrade", "upgradeName", _upgradeName);
|
||||
const corporation = getCorporation();
|
||||
const upgrade = Object.values(CorporationUpgrades).find((upgrade) => upgrade[4] === upgradeName);
|
||||
if (upgrade === undefined) throw new Error(`No upgrade named '${upgradeName}'`);
|
||||
LevelUpgrade(corporation, upgrade);
|
||||
},
|
||||
issueDividends: function (apercent: any): void {
|
||||
issueDividends: function (_percent: unknown): void {
|
||||
checkAccess("issueDividends");
|
||||
const percent = helper.number("issueDividends", "percent", apercent);
|
||||
if (percent < 0 || percent > 100) throw new Error("Invalid value for percent field! Must be numeric, greater than 0, and less than 100");
|
||||
const percent = helper.number("issueDividends", "percent", _percent);
|
||||
if (percent < 0 || percent > 100)
|
||||
throw new Error("Invalid value for percent field! Must be numeric, greater than 0, and less than 100");
|
||||
const corporation = getCorporation();
|
||||
if (!corporation.public)
|
||||
throw helper.makeRuntimeErrorMsg(`corporation.issueDividends`, `Your company has not gone public!`);
|
||||
@@ -759,9 +826,9 @@ export function NetscriptCorporation(
|
||||
|
||||
// If you modify these objects you will affect them for real, it's not
|
||||
// copies.
|
||||
getDivision: function (adivisionName: any): NSDivision {
|
||||
getDivision: function (_divisionName: unknown): NSDivision {
|
||||
checkAccess("getDivision");
|
||||
const divisionName = helper.string("getDivision", "divisionName", adivisionName);
|
||||
const divisionName = helper.string("getDivision", "divisionName", _divisionName);
|
||||
const division = getDivision(divisionName);
|
||||
return getSafeDivision(division);
|
||||
},
|
||||
@@ -783,33 +850,34 @@ export function NetscriptCorporation(
|
||||
divisions: corporation.divisions.map((division): NSDivision => getSafeDivision(division)),
|
||||
};
|
||||
},
|
||||
createCorporation: function (acorporationName: string, selfFund = true): boolean {
|
||||
const corporationName = helper.string("createCorporation", "corporationName", acorporationName);
|
||||
createCorporation: function (_corporationName: unknown, _selfFund: unknown = true): boolean {
|
||||
const corporationName = helper.string("createCorporation", "corporationName", _corporationName);
|
||||
const selfFund = helper.boolean(_selfFund);
|
||||
return createCorporation(corporationName, selfFund);
|
||||
},
|
||||
hasUnlockUpgrade: function (aupgradeName: any): boolean {
|
||||
hasUnlockUpgrade: function (_upgradeName: unknown): boolean {
|
||||
checkAccess("hasUnlockUpgrade");
|
||||
const upgradeName = helper.string("hasUnlockUpgrade", "upgradeName", aupgradeName);
|
||||
const upgradeName = helper.string("hasUnlockUpgrade", "upgradeName", _upgradeName);
|
||||
return hasUnlockUpgrade(upgradeName);
|
||||
},
|
||||
getUnlockUpgradeCost: function (aupgradeName: any): number {
|
||||
getUnlockUpgradeCost: function (_upgradeName: unknown): number {
|
||||
checkAccess("getUnlockUpgradeCost");
|
||||
const upgradeName = helper.string("getUnlockUpgradeCost", "upgradeName", aupgradeName);
|
||||
const upgradeName = helper.string("getUnlockUpgradeCost", "upgradeName", _upgradeName);
|
||||
return getUnlockUpgradeCost(upgradeName);
|
||||
},
|
||||
getUpgradeLevel: function (aupgradeName: any): number {
|
||||
getUpgradeLevel: function (_upgradeName: unknown): number {
|
||||
checkAccess("hasUnlockUpgrade");
|
||||
const upgradeName = helper.string("getUpgradeLevel", "upgradeName", aupgradeName);
|
||||
const upgradeName = helper.string("getUpgradeLevel", "upgradeName", _upgradeName);
|
||||
return getUpgradeLevel(upgradeName);
|
||||
},
|
||||
getUpgradeLevelCost: function (aupgradeName: any): number {
|
||||
getUpgradeLevelCost: function (_upgradeName: unknown): number {
|
||||
checkAccess("getUpgradeLevelCost");
|
||||
const upgradeName = helper.string("getUpgradeLevelCost", "upgradeName", aupgradeName);
|
||||
const upgradeName = helper.string("getUpgradeLevelCost", "upgradeName", _upgradeName);
|
||||
return getUpgradeLevelCost(upgradeName);
|
||||
},
|
||||
getExpandIndustryCost: function (aindustryName: any): number {
|
||||
getExpandIndustryCost: function (_industryName: unknown): number {
|
||||
checkAccess("getExpandIndustryCost");
|
||||
const industryName = helper.string("getExpandIndustryCost", "industryName", aindustryName);
|
||||
const industryName = helper.string("getExpandIndustryCost", "industryName", _industryName);
|
||||
return getExpandIndustryCost(industryName);
|
||||
},
|
||||
getExpandCityCost: function (): number {
|
||||
@@ -824,31 +892,31 @@ export function NetscriptCorporation(
|
||||
checkAccess("acceptInvestmentOffer");
|
||||
return acceptInvestmentOffer();
|
||||
},
|
||||
goPublic: function (anumShares: any): boolean {
|
||||
goPublic: function (_numShares: unknown): boolean {
|
||||
checkAccess("acceptInvestmentOffer");
|
||||
const numShares = helper.number("goPublic", "numShares", anumShares);
|
||||
const numShares = helper.number("goPublic", "numShares", _numShares);
|
||||
return goPublic(numShares);
|
||||
},
|
||||
sellShares: function (anumShares: any): number {
|
||||
sellShares: function (_numShares: unknown): number {
|
||||
checkAccess("acceptInvestmentOffer");
|
||||
const numShares = helper.number("sellStock", "numShares", anumShares);
|
||||
const numShares = helper.number("sellStock", "numShares", _numShares);
|
||||
return SellShares(getCorporation(), player, numShares);
|
||||
},
|
||||
buyBackShares: function (anumShares: any): boolean {
|
||||
buyBackShares: function (_numShares: unknown): boolean {
|
||||
checkAccess("acceptInvestmentOffer");
|
||||
const numShares = helper.number("buyStock", "numShares", anumShares);
|
||||
const numShares = helper.number("buyStock", "numShares", _numShares);
|
||||
return BuyBackShares(getCorporation(), player, numShares);
|
||||
},
|
||||
bribe: function (afactionName: string, aamountCash: any, aamountShares: any): boolean {
|
||||
bribe: function (_factionName: unknown, _amountCash: unknown, _amountShares: unknown): boolean {
|
||||
checkAccess("bribe");
|
||||
const factionName = helper.string("bribe", "factionName", afactionName);
|
||||
const amountCash = helper.number("bribe", "amountCash", aamountCash);
|
||||
const amountShares = helper.number("bribe", "amountShares", aamountShares);
|
||||
const factionName = helper.string("bribe", "factionName", _factionName);
|
||||
const amountCash = helper.number("bribe", "amountCash", _amountCash);
|
||||
const amountShares = helper.number("bribe", "amountShares", _amountShares);
|
||||
return bribe(factionName, amountCash, amountShares);
|
||||
},
|
||||
getBonusTime: function (): number {
|
||||
checkAccess("getBonusTime");
|
||||
return Math.round(getCorporation().storedCycles / 5) * 1000;
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { FactionNames } from '../Faction/data/FactionNames';
|
||||
import { GangConstants } from '../Gang/data/Constants';
|
||||
import { FactionNames } from "../Faction/data/FactionNames";
|
||||
import { GangConstants } from "../Gang/data/Constants";
|
||||
import { INetscriptHelper } from "./INetscriptHelper";
|
||||
import { IPlayer } from "../PersonObjects/IPlayer";
|
||||
import { getRamCost } from "../Netscript/RamCostGenerator";
|
||||
@@ -48,7 +48,8 @@ export function NetscriptGang(player: IPlayer, workerScript: WorkerScript, helpe
|
||||
};
|
||||
|
||||
return {
|
||||
createGang: function (faction: string): boolean {
|
||||
createGang: function (_faction: unknown): boolean {
|
||||
const faction = helper.string("createGang", "faction", _faction);
|
||||
helper.updateDynamicRam("createGang", getRamCost(player, "gang", "createGang"));
|
||||
// this list is copied from Faction/ui/Root.tsx
|
||||
|
||||
@@ -101,12 +102,13 @@ export function NetscriptGang(player: IPlayer, workerScript: WorkerScript, helpe
|
||||
|
||||
return cpy;
|
||||
},
|
||||
getMemberInformation: function (name: any): GangMemberInfo {
|
||||
getMemberInformation: function (_memberName: unknown): GangMemberInfo {
|
||||
const memberName = helper.string("getMemberInformation", "memberName", _memberName);
|
||||
helper.updateDynamicRam("getMemberInformation", getRamCost(player, "gang", "getMemberInformation"));
|
||||
checkGangApiAccess("getMemberInformation");
|
||||
const gang = player.gang;
|
||||
if (gang === null) throw new Error("Should not be called without Gang");
|
||||
const member = getGangMember("getMemberInformation", name);
|
||||
const member = getGangMember("getMemberInformation", memberName);
|
||||
return {
|
||||
name: member.name,
|
||||
task: member.task,
|
||||
@@ -161,16 +163,17 @@ export function NetscriptGang(player: IPlayer, workerScript: WorkerScript, helpe
|
||||
if (gang === null) throw new Error("Should not be called without Gang");
|
||||
return gang.canRecruitMember();
|
||||
},
|
||||
recruitMember: function (name: any): boolean {
|
||||
recruitMember: function (_memberName: unknown): boolean {
|
||||
const memberName = helper.string("recruitMember", "memberName", _memberName);
|
||||
helper.updateDynamicRam("recruitMember", getRamCost(player, "gang", "recruitMember"));
|
||||
checkGangApiAccess("recruitMember");
|
||||
const gang = player.gang;
|
||||
if (gang === null) throw new Error("Should not be called without Gang");
|
||||
const recruited = gang.recruitMember(name);
|
||||
const recruited = gang.recruitMember(memberName);
|
||||
if (recruited) {
|
||||
workerScript.log("gang.recruitMember", () => `Successfully recruited Gang Member '${name}'`);
|
||||
workerScript.log("gang.recruitMember", () => `Successfully recruited Gang Member '${memberName}'`);
|
||||
} else {
|
||||
workerScript.log("gang.recruitMember", () => `Failed to recruit Gang Member '${name}'`);
|
||||
workerScript.log("gang.recruitMember", () => `Failed to recruit Gang Member '${memberName}'`);
|
||||
}
|
||||
|
||||
return recruited;
|
||||
@@ -184,7 +187,9 @@ export function NetscriptGang(player: IPlayer, workerScript: WorkerScript, helpe
|
||||
tasks.unshift("Unassigned");
|
||||
return tasks;
|
||||
},
|
||||
setMemberTask: function (memberName: any, taskName: any): boolean {
|
||||
setMemberTask: function (_memberName: unknown, _taskName: unknown): boolean {
|
||||
const memberName = helper.string("setMemberTask", "memberName", _memberName);
|
||||
const taskName = helper.string("setMemberTask", "taskName", _taskName);
|
||||
helper.updateDynamicRam("setMemberTask", getRamCost(player, "gang", "setMemberTask"));
|
||||
checkGangApiAccess("setMemberTask");
|
||||
const member = getGangMember("setMemberTask", memberName);
|
||||
@@ -193,9 +198,10 @@ export function NetscriptGang(player: IPlayer, workerScript: WorkerScript, helpe
|
||||
if (!gang.getAllTaskNames().includes(taskName)) {
|
||||
workerScript.log(
|
||||
"gang.setMemberTask",
|
||||
() => `Failed to assign Gang Member '${memberName}' to Invalid task '${taskName}'. '${memberName}' is now Unassigned`,
|
||||
() =>
|
||||
`Failed to assign Gang Member '${memberName}' to Invalid task '${taskName}'. '${memberName}' is now Unassigned`,
|
||||
);
|
||||
return member.assignToTask('Unassigned');
|
||||
return member.assignToTask("Unassigned");
|
||||
}
|
||||
const success = member.assignToTask(taskName);
|
||||
if (success) {
|
||||
@@ -212,7 +218,8 @@ export function NetscriptGang(player: IPlayer, workerScript: WorkerScript, helpe
|
||||
|
||||
return success;
|
||||
},
|
||||
getTaskStats: function (taskName: any): GangTaskStats {
|
||||
getTaskStats: function (_taskName: unknown): GangTaskStats {
|
||||
const taskName = helper.string("getTaskStats", "taskName", _taskName);
|
||||
helper.updateDynamicRam("getTaskStats", getRamCost(player, "gang", "getTaskStats"));
|
||||
checkGangApiAccess("getTaskStats");
|
||||
const task = getGangTask("getTaskStats", taskName);
|
||||
@@ -225,7 +232,8 @@ export function NetscriptGang(player: IPlayer, workerScript: WorkerScript, helpe
|
||||
checkGangApiAccess("getEquipmentNames");
|
||||
return Object.keys(GangMemberUpgrades);
|
||||
},
|
||||
getEquipmentCost: function (equipName: any): number {
|
||||
getEquipmentCost: function (_equipName: any): number {
|
||||
const equipName = helper.string("getEquipmentCost", "equipName", _equipName);
|
||||
helper.updateDynamicRam("getEquipmentCost", getRamCost(player, "gang", "getEquipmentCost"));
|
||||
checkGangApiAccess("getEquipmentCost");
|
||||
const gang = player.gang;
|
||||
@@ -234,14 +242,16 @@ export function NetscriptGang(player: IPlayer, workerScript: WorkerScript, helpe
|
||||
if (upg === null) return Infinity;
|
||||
return gang.getUpgradeCost(upg);
|
||||
},
|
||||
getEquipmentType: function (equipName: any): string {
|
||||
getEquipmentType: function (_equipName: unknown): string {
|
||||
const equipName = helper.string("getEquipmentType", "equipName", _equipName);
|
||||
helper.updateDynamicRam("getEquipmentType", getRamCost(player, "gang", "getEquipmentType"));
|
||||
checkGangApiAccess("getEquipmentType");
|
||||
const upg = GangMemberUpgrades[equipName];
|
||||
if (upg == null) return "";
|
||||
return upg.getType();
|
||||
},
|
||||
getEquipmentStats: function (equipName: any): EquipmentStats {
|
||||
getEquipmentStats: function (_equipName: unknown): EquipmentStats {
|
||||
const equipName = helper.string("getEquipmentStats", "equipName", _equipName);
|
||||
helper.updateDynamicRam("getEquipmentStats", getRamCost(player, "gang", "getEquipmentStats"));
|
||||
checkGangApiAccess("getEquipmentStats");
|
||||
const equipment = GangMemberUpgrades[equipName];
|
||||
@@ -251,7 +261,9 @@ export function NetscriptGang(player: IPlayer, workerScript: WorkerScript, helpe
|
||||
const typecheck: EquipmentStats = equipment.mults;
|
||||
return Object.assign({}, typecheck) as any;
|
||||
},
|
||||
purchaseEquipment: function (memberName: any, equipName: any): boolean {
|
||||
purchaseEquipment: function (_memberName: unknown, _equipName: unknown): boolean {
|
||||
const memberName = helper.string("purchaseEquipment", "memberName", _memberName);
|
||||
const equipName = helper.string("purchaseEquipment", "equipName", _equipName);
|
||||
helper.updateDynamicRam("purchaseEquipment", getRamCost(player, "gang", "purchaseEquipment"));
|
||||
checkGangApiAccess("purchaseEquipment");
|
||||
const gang = player.gang;
|
||||
@@ -271,28 +283,31 @@ export function NetscriptGang(player: IPlayer, workerScript: WorkerScript, helpe
|
||||
|
||||
return res;
|
||||
},
|
||||
ascendMember: function (name: any): GangMemberAscension | undefined {
|
||||
ascendMember: function (_memberName: unknown): GangMemberAscension | undefined {
|
||||
const memberName = helper.string("ascendMember", "memberName", _memberName);
|
||||
helper.updateDynamicRam("ascendMember", getRamCost(player, "gang", "ascendMember"));
|
||||
checkGangApiAccess("ascendMember");
|
||||
const gang = player.gang;
|
||||
if (gang === null) throw new Error("Should not be called without Gang");
|
||||
const member = getGangMember("ascendMember", name);
|
||||
const member = getGangMember("ascendMember", memberName);
|
||||
if (!member.canAscend()) return;
|
||||
return gang.ascendMember(member, workerScript);
|
||||
},
|
||||
getAscensionResult: function (name: any): GangMemberAscension | undefined {
|
||||
getAscensionResult: function (_memberName: unknown): GangMemberAscension | undefined {
|
||||
const memberName = helper.string("getAscensionResult", "memberName", _memberName);
|
||||
helper.updateDynamicRam("getAscensionResult", getRamCost(player, "gang", "getAscensionResult"));
|
||||
checkGangApiAccess("getAscensionResult");
|
||||
const gang = player.gang;
|
||||
if (gang === null) throw new Error("Should not be called without Gang");
|
||||
const member = getGangMember("getAscensionResult", name);
|
||||
const member = getGangMember("getAscensionResult", memberName);
|
||||
if (!member.canAscend()) return;
|
||||
return {
|
||||
respect: member.earnedRespect,
|
||||
...member.getAscensionResults(),
|
||||
};
|
||||
},
|
||||
setTerritoryWarfare: function (engage: any): void {
|
||||
setTerritoryWarfare: function (_engage: unknown): void {
|
||||
const engage = helper.boolean(_engage);
|
||||
helper.updateDynamicRam("setTerritoryWarfare", getRamCost(player, "gang", "setTerritoryWarfare"));
|
||||
checkGangApiAccess("setTerritoryWarfare");
|
||||
const gang = player.gang;
|
||||
@@ -305,7 +320,8 @@ export function NetscriptGang(player: IPlayer, workerScript: WorkerScript, helpe
|
||||
workerScript.log("gang.setTerritoryWarfare", () => "Disengaging in Gang Territory Warfare");
|
||||
}
|
||||
},
|
||||
getChanceToWinClash: function (otherGang: any): number {
|
||||
getChanceToWinClash: function (_otherGang: unknown): number {
|
||||
const otherGang = helper.string("getChanceToWinClash", "otherGang", _otherGang);
|
||||
helper.updateDynamicRam("getChanceToWinClash", getRamCost(player, "gang", "getChanceToWinClash"));
|
||||
checkGangApiAccess("getChanceToWinClash");
|
||||
const gang = player.gang;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { INetscriptHelper } from "./INetscriptHelper";
|
||||
import { WorkerScript } from "../Netscript/WorkerScript";
|
||||
import { IPlayer } from "../PersonObjects/IPlayer";
|
||||
import { purchaseAugmentation, joinFaction } from "../Faction/FactionHelpers";
|
||||
import { purchaseAugmentation, joinFaction, getFactionAugmentationsFiltered } from "../Faction/FactionHelpers";
|
||||
import { startWorkerScript } from "../NetscriptWorker";
|
||||
import { Augmentation } from "../Augmentation/Augmentation";
|
||||
import { Augmentations } from "../Augmentation/Augmentations";
|
||||
@@ -14,7 +14,13 @@ import { isString } from "../utils/helpers/isString";
|
||||
import { getRamCost } from "../Netscript/RamCostGenerator";
|
||||
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 { CompanyPosition } from "../Company/CompanyPosition";
|
||||
@@ -49,7 +55,7 @@ export function NetscriptSingularity(
|
||||
workerScript: WorkerScript,
|
||||
helper: INetscriptHelper,
|
||||
): ISingularity {
|
||||
const getAugmentation = function (func: any, name: any): Augmentation {
|
||||
const getAugmentation = function (func: string, name: string): Augmentation {
|
||||
if (!augmentationExists(name)) {
|
||||
throw helper.makeRuntimeErrorMsg(func, `Invalid augmentation: '${name}'`);
|
||||
}
|
||||
@@ -57,7 +63,7 @@ export function NetscriptSingularity(
|
||||
return Augmentations[name];
|
||||
};
|
||||
|
||||
const getFaction = function (func: any, name: any): Faction {
|
||||
const getFaction = function (func: string, name: string): Faction {
|
||||
if (!factionExists(name)) {
|
||||
throw helper.makeRuntimeErrorMsg(func, `Invalid faction name: '${name}`);
|
||||
}
|
||||
@@ -65,7 +71,7 @@ export function NetscriptSingularity(
|
||||
return Factions[name];
|
||||
};
|
||||
|
||||
const getCompany = function (func: any, name: any): Company {
|
||||
const getCompany = function (func: string, name: string): Company {
|
||||
const company = Companies[name];
|
||||
if (company == null || !(company instanceof Company)) {
|
||||
throw helper.makeRuntimeErrorMsg(func, `Invalid company name: '${name}'`);
|
||||
@@ -73,26 +79,26 @@ export function NetscriptSingularity(
|
||||
return company;
|
||||
};
|
||||
|
||||
const runAfterReset = function (cbScript = null): void {
|
||||
const runAfterReset = function (cbScript: string | null = null): void {
|
||||
//Run a script after reset
|
||||
if (cbScript && isString(cbScript)) {
|
||||
const home = player.getHomeComputer();
|
||||
for (const script of home.scripts) {
|
||||
if (script.filename === cbScript) {
|
||||
const ramUsage = script.ramUsage;
|
||||
const ramAvailable = home.maxRam - home.ramUsed;
|
||||
if (ramUsage > ramAvailable) {
|
||||
return; // Not enough RAM
|
||||
}
|
||||
const runningScriptObj = new RunningScript(script, []); // No args
|
||||
runningScriptObj.threads = 1; // Only 1 thread
|
||||
startWorkerScript(player, runningScriptObj, home);
|
||||
if (!cbScript) return;
|
||||
const home = player.getHomeComputer();
|
||||
for (const script of home.scripts) {
|
||||
if (script.filename === cbScript) {
|
||||
const ramUsage = script.ramUsage;
|
||||
const ramAvailable = home.maxRam - home.ramUsed;
|
||||
if (ramUsage > ramAvailable) {
|
||||
return; // Not enough RAM
|
||||
}
|
||||
const runningScriptObj = new RunningScript(script, []); // No args
|
||||
runningScriptObj.threads = 1; // Only 1 thread
|
||||
startWorkerScript(player, runningScriptObj, home);
|
||||
}
|
||||
}
|
||||
};
|
||||
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.checkSingularityAccess("getOwnedAugmentations");
|
||||
const res = [];
|
||||
@@ -106,91 +112,63 @@ export function NetscriptSingularity(
|
||||
}
|
||||
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.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.hasGangWith(facname)) {
|
||||
let augs = Object.values(Augmentations);
|
||||
|
||||
// Remove blacklisted augs.
|
||||
const blacklist = [AugmentationNames.NeuroFluxGovernor, AugmentationNames.TheRedPill];
|
||||
augs = augs.filter((a) => !blacklist.includes(a.name));
|
||||
|
||||
// Remove special augs.
|
||||
augs = augs.filter((a) => !a.isSpecial);
|
||||
|
||||
// Remove faction-unique augs outside BN2. (But keep the one for this faction.)
|
||||
if (player.bitNodeN !== 2) {
|
||||
augs = augs.filter((a) => a.factions.length > 1 || Factions[facname].augmentations.includes(a.name));
|
||||
}
|
||||
|
||||
return augs.map((a) => a.name);
|
||||
}
|
||||
|
||||
return faction.augmentations.slice();
|
||||
return getFactionAugmentationsFiltered(player, faction);
|
||||
},
|
||||
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.checkSingularityAccess("getAugmentationCost");
|
||||
const aug = getAugmentation("getAugmentationCost", name);
|
||||
const aug = getAugmentation("getAugmentationCost", augName);
|
||||
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.checkSingularityAccess("getAugmentationPrereq");
|
||||
const aug = getAugmentation("getAugmentationPrereq", name);
|
||||
const aug = getAugmentation("getAugmentationPrereq", augName);
|
||||
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.checkSingularityAccess("getAugmentationPrice");
|
||||
const aug = getAugmentation("getAugmentationPrice", name);
|
||||
const aug = getAugmentation("getAugmentationPrice", augName);
|
||||
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.checkSingularityAccess("getAugmentationRepReq");
|
||||
const aug = getAugmentation("getAugmentationRepReq", name);
|
||||
const aug = getAugmentation("getAugmentationRepReq", augName);
|
||||
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.checkSingularityAccess("getAugmentationStats");
|
||||
const aug = getAugmentation("getAugmentationStats", name);
|
||||
const aug = getAugmentation("getAugmentationStats", augName);
|
||||
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.checkSingularityAccess("purchaseAugmentation");
|
||||
const fac = getFaction("purchaseAugmentation", faction);
|
||||
const aug = getAugmentation("purchaseAugmentation", name);
|
||||
const fac = getFaction("purchaseAugmentation", facName);
|
||||
const aug = getAugmentation("purchaseAugmentation", augName);
|
||||
|
||||
let augs = [];
|
||||
if (player.hasGangWith(faction)) {
|
||||
for (const augName of Object.keys(Augmentations)) {
|
||||
const aug = Augmentations[augName];
|
||||
if (
|
||||
augName === AugmentationNames.NeuroFluxGovernor ||
|
||||
(augName === AugmentationNames.TheRedPill && player.bitNodeN !== 2) ||
|
||||
// Special augs (i.e. Bladeburner augs)
|
||||
aug.isSpecial ||
|
||||
// Exclusive augs (i.e. QLink)
|
||||
(aug.factions.length <= 1 && !fac.augmentations.includes(augName) && player.bitNodeN !== 2)
|
||||
)
|
||||
continue;
|
||||
augs.push(augName);
|
||||
}
|
||||
} else {
|
||||
augs = fac.augmentations;
|
||||
}
|
||||
const augs = getFactionAugmentationsFiltered(player, fac);
|
||||
|
||||
if (!augs.includes(name)) {
|
||||
if (!augs.includes(augName)) {
|
||||
workerScript.log(
|
||||
"purchaseAugmentation",
|
||||
() => `Faction '${faction}' does not have the '${name}' augmentation.`,
|
||||
() => `Faction '${facName}' does not have the '${augName}' augmentation.`,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
@@ -199,13 +177,13 @@ export function NetscriptSingularity(
|
||||
if (!isNeuroflux) {
|
||||
for (let j = 0; j < player.queuedAugmentations.length; ++j) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
for (let j = 0; j < player.augmentations.length; ++j) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -225,7 +203,8 @@ export function NetscriptSingularity(
|
||||
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.checkSingularityAccess("softReset");
|
||||
|
||||
@@ -239,7 +218,8 @@ export function NetscriptSingularity(
|
||||
workerScript.running = false;
|
||||
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.checkSingularityAccess("installAugmentations");
|
||||
|
||||
@@ -259,9 +239,11 @@ export function NetscriptSingularity(
|
||||
|
||||
workerScript.running = false; // Prevent workerScript from "finishing execution naturally"
|
||||
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.checkSingularityAccess("goToLocation");
|
||||
const location = Object.values(Locations).find((l) => l.name === locationName);
|
||||
@@ -277,7 +259,10 @@ export function NetscriptSingularity(
|
||||
player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain / 50000);
|
||||
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.checkSingularityAccess("universityCourse");
|
||||
const wasFocusing = player.focus;
|
||||
@@ -365,7 +350,10 @@ export function NetscriptSingularity(
|
||||
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.checkSingularityAccess("gymWorkout");
|
||||
const wasFocusing = player.focus;
|
||||
@@ -477,11 +465,12 @@ export function NetscriptSingularity(
|
||||
return true;
|
||||
},
|
||||
|
||||
travelToCity: function (cityname: any): any {
|
||||
travelToCity: function (_cityName: unknown): boolean {
|
||||
const cityName = helper.city("travelToCity", "cityName", _cityName);
|
||||
helper.updateDynamicRam("travelToCity", getRamCost(player, "travelToCity"));
|
||||
helper.checkSingularityAccess("travelToCity");
|
||||
|
||||
switch (cityname) {
|
||||
switch (cityName) {
|
||||
case CityName.Aevum:
|
||||
case CityName.Chongqing:
|
||||
case CityName.Sector12:
|
||||
@@ -493,16 +482,16 @@ export function NetscriptSingularity(
|
||||
return false;
|
||||
}
|
||||
player.loseMoney(CONSTANTS.TravelCost, "other");
|
||||
player.city = cityname;
|
||||
workerScript.log("travelToCity", () => `Traveled to ${cityname}`);
|
||||
player.city = cityName;
|
||||
workerScript.log("travelToCity", () => `Traveled to ${cityName}`);
|
||||
player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain / 50000);
|
||||
return true;
|
||||
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.checkSingularityAccess("purchaseTor");
|
||||
|
||||
@@ -534,7 +523,8 @@ export function NetscriptSingularity(
|
||||
workerScript.log("purchaseTor", () => "You have purchased a Tor router!");
|
||||
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.checkSingularityAccess("purchaseProgram");
|
||||
|
||||
@@ -543,8 +533,6 @@ export function NetscriptSingularity(
|
||||
return false;
|
||||
}
|
||||
|
||||
programName = programName.toLowerCase();
|
||||
|
||||
const item = Object.values(DarkWebItems).find((i) => i.program.toLowerCase() === programName);
|
||||
if (item == null) {
|
||||
workerScript.log("purchaseProgram", () => `Invalid program name: '${programName}.`);
|
||||
@@ -573,12 +561,13 @@ export function NetscriptSingularity(
|
||||
player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain / 5000);
|
||||
return true;
|
||||
},
|
||||
getCurrentServer: function (): any {
|
||||
getCurrentServer: function (): string {
|
||||
helper.updateDynamicRam("getCurrentServer", getRamCost(player, "getCurrentServer"));
|
||||
helper.checkSingularityAccess("getCurrentServer");
|
||||
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.checkSingularityAccess("connect");
|
||||
if (!hostname) {
|
||||
@@ -613,13 +602,13 @@ export function NetscriptSingularity(
|
||||
|
||||
return false;
|
||||
},
|
||||
manualHack: function (): any {
|
||||
manualHack: function (): Promise<number> {
|
||||
helper.updateDynamicRam("manualHack", getRamCost(player, "manualHack"));
|
||||
helper.checkSingularityAccess("manualHack");
|
||||
const server = player.getCurrentServer();
|
||||
return helper.hack(server.hostname, true);
|
||||
},
|
||||
installBackdoor: function (): any {
|
||||
installBackdoor: function (): Promise<void> {
|
||||
helper.updateDynamicRam("installBackdoor", getRamCost(player, "installBackdoor"));
|
||||
helper.checkSingularityAccess("installBackdoor");
|
||||
const baseserver = player.getCurrentServer();
|
||||
@@ -657,8 +646,8 @@ export function NetscriptSingularity(
|
||||
helper.checkSingularityAccess("isFocused");
|
||||
return player.focus;
|
||||
},
|
||||
setFocus: function (afocus: any): boolean {
|
||||
const focus = helper.boolean(afocus);
|
||||
setFocus: function (_focus: unknown): boolean {
|
||||
const focus = helper.boolean(_focus);
|
||||
helper.updateDynamicRam("setFocus", getRamCost(player, "setFocus"));
|
||||
helper.checkSingularityAccess("setFocus");
|
||||
if (!player.isWorking) {
|
||||
@@ -686,7 +675,7 @@ export function NetscriptSingularity(
|
||||
}
|
||||
return false;
|
||||
},
|
||||
getStats: function (): any {
|
||||
getStats: function (): PlayerSkills {
|
||||
helper.updateDynamicRam("getStats", getRamCost(player, "getStats"));
|
||||
helper.checkSingularityAccess("getStats");
|
||||
workerScript.log("getStats", () => `getStats is deprecated, please use getplayer`);
|
||||
@@ -701,7 +690,7 @@ export function NetscriptSingularity(
|
||||
intelligence: player.intelligence,
|
||||
};
|
||||
},
|
||||
getCharacterInformation: function (): any {
|
||||
getCharacterInformation: function (): CharacterInfo {
|
||||
helper.updateDynamicRam("getCharacterInformation", getRamCost(player, "getCharacterInformation"));
|
||||
helper.checkSingularityAccess("getCharacterInformation");
|
||||
workerScript.log("getCharacterInformation", () => `getCharacterInformation is deprecated, please use getplayer`);
|
||||
@@ -717,6 +706,8 @@ export function NetscriptSingularity(
|
||||
mult: {
|
||||
agility: player.agility_mult,
|
||||
agilityExp: player.agility_exp_mult,
|
||||
charisma: player.charisma,
|
||||
charismaExp: player.charisma_exp,
|
||||
companyRep: player.company_rep_mult,
|
||||
crimeMoney: player.crime_money_mult,
|
||||
crimeSuccess: player.crime_success_mult,
|
||||
@@ -749,21 +740,21 @@ export function NetscriptSingularity(
|
||||
charismaExp: player.charisma_exp,
|
||||
};
|
||||
},
|
||||
hospitalize: function (): any {
|
||||
hospitalize: function (): void {
|
||||
helper.updateDynamicRam("hospitalize", getRamCost(player, "hospitalize"));
|
||||
helper.checkSingularityAccess("hospitalize");
|
||||
if (player.isWorking || Router.page() === Page.Infiltration || Router.page() === Page.BitVerse) {
|
||||
workerScript.log("hospitalize", () => "Cannot go to the hospital because the player is busy.");
|
||||
return;
|
||||
}
|
||||
return player.hospitalize();
|
||||
player.hospitalize();
|
||||
},
|
||||
isBusy: function (): any {
|
||||
isBusy: function (): boolean {
|
||||
helper.updateDynamicRam("isBusy", getRamCost(player, "isBusy"));
|
||||
helper.checkSingularityAccess("isBusy");
|
||||
return player.isWorking || Router.page() === Page.Infiltration || Router.page() === Page.BitVerse;
|
||||
},
|
||||
stopAction: function (): any {
|
||||
stopAction: function (): boolean {
|
||||
helper.updateDynamicRam("stopAction", getRamCost(player, "stopAction"));
|
||||
helper.checkSingularityAccess("stopAction");
|
||||
if (player.isWorking) {
|
||||
@@ -777,7 +768,7 @@ export function NetscriptSingularity(
|
||||
}
|
||||
return false;
|
||||
},
|
||||
upgradeHomeCores: function (): any {
|
||||
upgradeHomeCores: function (): boolean {
|
||||
helper.updateDynamicRam("upgradeHomeCores", getRamCost(player, "upgradeHomeCores"));
|
||||
helper.checkSingularityAccess("upgradeHomeCores");
|
||||
|
||||
@@ -807,13 +798,13 @@ export function NetscriptSingularity(
|
||||
);
|
||||
return true;
|
||||
},
|
||||
getUpgradeHomeCoresCost: function (): any {
|
||||
getUpgradeHomeCoresCost: function (): number {
|
||||
helper.updateDynamicRam("getUpgradeHomeCoresCost", getRamCost(player, "getUpgradeHomeCoresCost"));
|
||||
helper.checkSingularityAccess("getUpgradeHomeCoresCost");
|
||||
|
||||
return player.getUpgradeHomeCoresCost();
|
||||
},
|
||||
upgradeHomeRam: function (): any {
|
||||
upgradeHomeRam: function (): boolean {
|
||||
helper.updateDynamicRam("upgradeHomeRam", getRamCost(player, "upgradeHomeRam"));
|
||||
helper.checkSingularityAccess("upgradeHomeRam");
|
||||
|
||||
@@ -846,13 +837,15 @@ export function NetscriptSingularity(
|
||||
);
|
||||
return true;
|
||||
},
|
||||
getUpgradeHomeRamCost: function (): any {
|
||||
getUpgradeHomeRamCost: function (): number {
|
||||
helper.updateDynamicRam("getUpgradeHomeRamCost", getRamCost(player, "getUpgradeHomeRamCost"));
|
||||
helper.checkSingularityAccess("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.checkSingularityAccess("workForCompany");
|
||||
|
||||
@@ -906,12 +899,14 @@ export function NetscriptSingularity(
|
||||
);
|
||||
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.checkSingularityAccess("applyToCompany");
|
||||
getCompany("applyToCompany", companyName);
|
||||
|
||||
player.location = companyName;
|
||||
player.location = companyName as LocationName;
|
||||
let res;
|
||||
switch (field.toLowerCase()) {
|
||||
case "software":
|
||||
@@ -976,66 +971,73 @@ export function NetscriptSingularity(
|
||||
}
|
||||
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.checkSingularityAccess("getCompanyRep");
|
||||
const company = getCompany("getCompanyRep", companyName);
|
||||
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.checkSingularityAccess("getCompanyFavor");
|
||||
const company = getCompany("getCompanyFavor", companyName);
|
||||
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.checkSingularityAccess("getCompanyFavorGain");
|
||||
const company = getCompany("getCompanyFavorGain", companyName);
|
||||
return company.getFavorGain();
|
||||
},
|
||||
checkFactionInvitations: function (): any {
|
||||
checkFactionInvitations: function (): string[] {
|
||||
helper.updateDynamicRam("checkFactionInvitations", getRamCost(player, "checkFactionInvitations"));
|
||||
helper.checkSingularityAccess("checkFactionInvitations");
|
||||
// Make a copy of player.factionInvitations
|
||||
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.checkSingularityAccess("joinFaction");
|
||||
getFaction("joinFaction", name);
|
||||
getFaction("joinFaction", facName);
|
||||
|
||||
if (!player.factionInvitations.includes(name)) {
|
||||
workerScript.log("joinFaction", () => `You have not been invited by faction '${name}'`);
|
||||
if (!player.factionInvitations.includes(facName)) {
|
||||
workerScript.log("joinFaction", () => `You have not been invited by faction '${facName}'`);
|
||||
return false;
|
||||
}
|
||||
const fac = Factions[name];
|
||||
const fac = Factions[facName];
|
||||
joinFaction(fac);
|
||||
|
||||
// Update Faction Invitation list to account for joined + banned factions
|
||||
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);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain * 5);
|
||||
workerScript.log("joinFaction", () => `Joined the '${name}' faction.`);
|
||||
workerScript.log("joinFaction", () => `Joined the '${facName}' faction.`);
|
||||
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.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 (player.inGang() && AllGangs[name] !== undefined) {
|
||||
workerScript.log("workForFaction", () => `Faction '${name}' does not offer work at the moment.`);
|
||||
if (player.inGang() && AllGangs[facName] !== undefined) {
|
||||
workerScript.log("workForFaction", () => `Faction '${facName}' does not offer work at the moment.`);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!player.factions.includes(name)) {
|
||||
workerScript.log("workForFaction", () => `You are not a member of '${name}'`);
|
||||
if (!player.factions.includes(facName)) {
|
||||
workerScript.log("workForFaction", () => `You are not a member of '${facName}'`);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1045,7 +1047,7 @@ export function NetscriptSingularity(
|
||||
workerScript.log("workForFaction", () => txt);
|
||||
}
|
||||
|
||||
const fac = Factions[name];
|
||||
const fac = Factions[facName];
|
||||
// Arrays listing factions that allow each time of work
|
||||
|
||||
switch (type.toLowerCase()) {
|
||||
@@ -1105,34 +1107,42 @@ export function NetscriptSingularity(
|
||||
}
|
||||
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.checkSingularityAccess("getFactionRep");
|
||||
const faction = getFaction("getFactionRep", name);
|
||||
const faction = getFaction("getFactionRep", facName);
|
||||
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.checkSingularityAccess("getFactionFavor");
|
||||
const faction = getFaction("getFactionFavor", name);
|
||||
const faction = getFaction("getFactionFavor", facName);
|
||||
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.checkSingularityAccess("getFactionFavorGain");
|
||||
const faction = getFaction("getFactionFavorGain", name);
|
||||
const faction = getFaction("getFactionFavorGain", facName);
|
||||
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.checkSingularityAccess("donateToFaction");
|
||||
const faction = getFaction("donateToFaction", name);
|
||||
const faction = getFaction("donateToFaction", facName);
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
if (typeof amt !== "number" || amt <= 0 || isNaN(amt)) {
|
||||
@@ -1142,7 +1152,7 @@ export function NetscriptSingularity(
|
||||
if (player.money < amt) {
|
||||
workerScript.log(
|
||||
"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;
|
||||
}
|
||||
@@ -1161,13 +1171,15 @@ export function NetscriptSingularity(
|
||||
workerScript.log(
|
||||
"donateToFaction",
|
||||
() =>
|
||||
`${numeralWrapper.formatMoney(amt)} donated to '${name}' for ${numeralWrapper.formatReputation(
|
||||
`${numeralWrapper.formatMoney(amt)} donated to '${facName}' for ${numeralWrapper.formatReputation(
|
||||
repGain,
|
||||
)} reputation`,
|
||||
);
|
||||
return true;
|
||||
},
|
||||
createProgram: function (name: any, focus = true): any {
|
||||
createProgram: function (_programName: unknown, _focus: unknown = true): boolean {
|
||||
const programName = helper.string("createProgram", "programName", _programName).toLowerCase();
|
||||
const focus = helper.boolean(_focus);
|
||||
helper.updateDynamicRam("createProgram", getRamCost(player, "createProgram"));
|
||||
helper.checkSingularityAccess("createProgram");
|
||||
|
||||
@@ -1177,12 +1189,10 @@ export function NetscriptSingularity(
|
||||
workerScript.log("createProgram", () => txt);
|
||||
}
|
||||
|
||||
name = name.toLowerCase();
|
||||
|
||||
const p = Object.values(Programs).find((p) => p.name.toLowerCase() === name);
|
||||
const p = Object.values(Programs).find((p) => p.name.toLowerCase() === programName);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -1213,10 +1223,11 @@ export function NetscriptSingularity(
|
||||
player.stopFocusing();
|
||||
Router.toTerminal();
|
||||
}
|
||||
workerScript.log("createProgram", () => `Began creating program: '${name}'`);
|
||||
workerScript.log("createProgram", () => `Began creating program: '${programName}'`);
|
||||
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.checkSingularityAccess("commitCrime");
|
||||
|
||||
@@ -1236,7 +1247,8 @@ export function NetscriptSingularity(
|
||||
workerScript.log("commitCrime", () => `Attempting to commit ${crime.name}...`);
|
||||
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.checkSingularityAccess("getCrimeChance");
|
||||
|
||||
@@ -1247,7 +1259,8 @@ export function NetscriptSingularity(
|
||||
|
||||
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.checkSingularityAccess("getCrimeStats");
|
||||
|
||||
@@ -1269,7 +1282,8 @@ export function NetscriptSingularity(
|
||||
}
|
||||
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.checkSingularityAccess("getDarkwebProgramCost");
|
||||
|
||||
@@ -1281,7 +1295,6 @@ export function NetscriptSingularity(
|
||||
return -1;
|
||||
}
|
||||
|
||||
programName = programName.toLowerCase();
|
||||
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
|
||||
|
||||
@@ -10,10 +10,16 @@ import { Augmentations } from "../Augmentation/Augmentations";
|
||||
import { CityName } from "../Locations/data/CityNames";
|
||||
import { findCrime } from "../Crime/CrimeHelpers";
|
||||
|
||||
import { Sleeve as ISleeve } from "../ScriptEditor/NetscriptDefinitions";
|
||||
import {
|
||||
AugmentPair,
|
||||
Sleeve as ISleeve,
|
||||
SleeveInformation,
|
||||
SleeveSkills,
|
||||
SleeveTask,
|
||||
} from "../ScriptEditor/NetscriptDefinitions";
|
||||
|
||||
export function NetscriptSleeve(player: IPlayer, workerScript: WorkerScript, helper: INetscriptHelper): ISleeve {
|
||||
const checkSleeveAPIAccess = function (func: any): void {
|
||||
const checkSleeveAPIAccess = function (func: string): void {
|
||||
if (player.bitNodeN !== 10 && !SourceFileFlags[10]) {
|
||||
throw helper.makeRuntimeErrorMsg(
|
||||
`sleeve.${func}`,
|
||||
@@ -22,7 +28,7 @@ export function NetscriptSleeve(player: IPlayer, workerScript: WorkerScript, hel
|
||||
}
|
||||
};
|
||||
|
||||
const checkSleeveNumber = function (func: any, sleeveNumber: any): void {
|
||||
const checkSleeveNumber = function (func: string, sleeveNumber: number): void {
|
||||
if (sleeveNumber >= player.sleeves.length || sleeveNumber < 0) {
|
||||
const msg = `Invalid sleeve number: ${sleeveNumber}`;
|
||||
workerScript.log(func, () => msg);
|
||||
@@ -30,7 +36,7 @@ export function NetscriptSleeve(player: IPlayer, workerScript: WorkerScript, hel
|
||||
}
|
||||
};
|
||||
|
||||
const getSleeveStats = function (sleeveNumber: any): any {
|
||||
const getSleeveStats = function (sleeveNumber: number): SleeveSkills {
|
||||
const sl = player.sleeves[sleeveNumber];
|
||||
return {
|
||||
shock: 100 - sl.shock,
|
||||
@@ -42,7 +48,7 @@ export function NetscriptSleeve(player: IPlayer, workerScript: WorkerScript, hel
|
||||
agility: sl.agility,
|
||||
charisma: sl.charisma,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
getNumSleeves: function (): number {
|
||||
@@ -50,23 +56,23 @@ export function NetscriptSleeve(player: IPlayer, workerScript: WorkerScript, hel
|
||||
checkSleeveAPIAccess("getNumSleeves");
|
||||
return player.sleeves.length;
|
||||
},
|
||||
setToShockRecovery: function (asleeveNumber: any = 0): boolean {
|
||||
const sleeveNumber = helper.number("setToShockRecovery", "sleeveNumber", asleeveNumber);
|
||||
setToShockRecovery: function (_sleeveNumber: unknown): boolean {
|
||||
const sleeveNumber = helper.number("setToShockRecovery", "sleeveNumber", _sleeveNumber);
|
||||
helper.updateDynamicRam("setToShockRecovery", getRamCost(player, "sleeve", "setToShockRecovery"));
|
||||
checkSleeveAPIAccess("setToShockRecovery");
|
||||
checkSleeveNumber("setToShockRecovery", sleeveNumber);
|
||||
return player.sleeves[sleeveNumber].shockRecovery(player);
|
||||
},
|
||||
setToSynchronize: function (asleeveNumber: any = 0): boolean {
|
||||
const sleeveNumber = helper.number("setToSynchronize", "sleeveNumber", asleeveNumber);
|
||||
setToSynchronize: function (_sleeveNumber: unknown): boolean {
|
||||
const sleeveNumber = helper.number("setToSynchronize", "sleeveNumber", _sleeveNumber);
|
||||
helper.updateDynamicRam("setToSynchronize", getRamCost(player, "sleeve", "setToSynchronize"));
|
||||
checkSleeveAPIAccess("setToSynchronize");
|
||||
checkSleeveNumber("setToSynchronize", sleeveNumber);
|
||||
return player.sleeves[sleeveNumber].synchronize(player);
|
||||
},
|
||||
setToCommitCrime: function (asleeveNumber: any = 0, aCrimeRoughName: any = ""): boolean {
|
||||
const sleeveNumber = helper.number("setToCommitCrime", "sleeveNumber", asleeveNumber);
|
||||
const crimeRoughName = helper.string("setToCommitCrime", "crimeName", aCrimeRoughName);
|
||||
setToCommitCrime: function (_sleeveNumber: unknown, _crimeRoughName: unknown): boolean {
|
||||
const sleeveNumber = helper.number("setToCommitCrime", "sleeveNumber", _sleeveNumber);
|
||||
const crimeRoughName = helper.string("setToCommitCrime", "crimeName", _crimeRoughName);
|
||||
helper.updateDynamicRam("setToCommitCrime", getRamCost(player, "sleeve", "setToCommitCrime"));
|
||||
checkSleeveAPIAccess("setToCommitCrime");
|
||||
checkSleeveNumber("setToCommitCrime", sleeveNumber);
|
||||
@@ -76,25 +82,25 @@ export function NetscriptSleeve(player: IPlayer, workerScript: WorkerScript, hel
|
||||
}
|
||||
return player.sleeves[sleeveNumber].commitCrime(player, crime.name);
|
||||
},
|
||||
setToUniversityCourse: function (asleeveNumber: any = 0, auniversityName: any = "", aclassName: any = ""): boolean {
|
||||
const sleeveNumber = helper.number("setToUniversityCourse", "sleeveNumber", asleeveNumber);
|
||||
const universityName = helper.string("setToUniversityCourse", "universityName", auniversityName);
|
||||
const className = helper.string("setToUniversityCourse", "className", aclassName);
|
||||
setToUniversityCourse: function (_sleeveNumber: unknown, _universityName: unknown, _className: unknown): boolean {
|
||||
const sleeveNumber = helper.number("setToUniversityCourse", "sleeveNumber", _sleeveNumber);
|
||||
const universityName = helper.string("setToUniversityCourse", "universityName", _universityName);
|
||||
const className = helper.string("setToUniversityCourse", "className", _className);
|
||||
helper.updateDynamicRam("setToUniversityCourse", getRamCost(player, "sleeve", "setToUniversityCourse"));
|
||||
checkSleeveAPIAccess("setToUniversityCourse");
|
||||
checkSleeveNumber("setToUniversityCourse", sleeveNumber);
|
||||
return player.sleeves[sleeveNumber].takeUniversityCourse(player, universityName, className);
|
||||
},
|
||||
travel: function (asleeveNumber: any = 0, acityName: any = ""): boolean {
|
||||
const sleeveNumber = helper.number("travel", "sleeveNumber", asleeveNumber);
|
||||
const cityName = helper.string("setToUniversityCourse", "cityName", acityName);
|
||||
travel: function (_sleeveNumber: unknown, _cityName: unknown): boolean {
|
||||
const sleeveNumber = helper.number("travel", "sleeveNumber", _sleeveNumber);
|
||||
const cityName = helper.string("setToUniversityCourse", "cityName", _cityName);
|
||||
helper.updateDynamicRam("travel", getRamCost(player, "sleeve", "travel"));
|
||||
checkSleeveAPIAccess("travel");
|
||||
checkSleeveNumber("travel", sleeveNumber);
|
||||
return player.sleeves[sleeveNumber].travel(player, cityName as CityName);
|
||||
},
|
||||
setToCompanyWork: function (asleeveNumber: any = 0, acompanyName: any = ""): boolean {
|
||||
const sleeveNumber = helper.number("setToCompanyWork", "sleeveNumber", asleeveNumber);
|
||||
setToCompanyWork: function (_sleeveNumber: unknown, acompanyName: unknown): boolean {
|
||||
const sleeveNumber = helper.number("setToCompanyWork", "sleeveNumber", _sleeveNumber);
|
||||
const companyName = helper.string("setToUniversityCourse", "companyName", acompanyName);
|
||||
helper.updateDynamicRam("setToCompanyWork", getRamCost(player, "sleeve", "setToCompanyWork"));
|
||||
checkSleeveAPIAccess("setToCompanyWork");
|
||||
@@ -116,10 +122,10 @@ export function NetscriptSleeve(player: IPlayer, workerScript: WorkerScript, hel
|
||||
|
||||
return player.sleeves[sleeveNumber].workForCompany(player, companyName);
|
||||
},
|
||||
setToFactionWork: function (asleeveNumber: any = 0, afactionName: any = "", aworkType: any = ""): boolean {
|
||||
const sleeveNumber = helper.number("setToFactionWork", "sleeveNumber", asleeveNumber);
|
||||
const factionName = helper.string("setToUniversityCourse", "factionName", afactionName);
|
||||
const workType = helper.string("setToUniversityCourse", "workType", aworkType);
|
||||
setToFactionWork: function (_sleeveNumber: unknown, _factionName: unknown, _workType: unknown): boolean {
|
||||
const sleeveNumber = helper.number("setToFactionWork", "sleeveNumber", _sleeveNumber);
|
||||
const factionName = helper.string("setToUniversityCourse", "factionName", _factionName);
|
||||
const workType = helper.string("setToUniversityCourse", "workType", _workType);
|
||||
helper.updateDynamicRam("setToFactionWork", getRamCost(player, "sleeve", "setToFactionWork"));
|
||||
checkSleeveAPIAccess("setToFactionWork");
|
||||
checkSleeveNumber("setToFactionWork", sleeveNumber);
|
||||
@@ -140,40 +146,25 @@ export function NetscriptSleeve(player: IPlayer, workerScript: WorkerScript, hel
|
||||
|
||||
return player.sleeves[sleeveNumber].workForFaction(player, factionName, workType);
|
||||
},
|
||||
setToGymWorkout: function (asleeveNumber: any = 0, agymName: any = "", astat: any = ""): boolean {
|
||||
const sleeveNumber = helper.number("setToGymWorkout", "sleeveNumber", asleeveNumber);
|
||||
const gymName = helper.string("setToUniversityCourse", "gymName", agymName);
|
||||
const stat = helper.string("setToUniversityCourse", "stat", astat);
|
||||
setToGymWorkout: function (_sleeveNumber: unknown, _gymName: unknown, _stat: unknown): boolean {
|
||||
const sleeveNumber = helper.number("setToGymWorkout", "sleeveNumber", _sleeveNumber);
|
||||
const gymName = helper.string("setToUniversityCourse", "gymName", _gymName);
|
||||
const stat = helper.string("setToUniversityCourse", "stat", _stat);
|
||||
helper.updateDynamicRam("setToGymWorkout", getRamCost(player, "sleeve", "setToGymWorkout"));
|
||||
checkSleeveAPIAccess("setToGymWorkout");
|
||||
checkSleeveNumber("setToGymWorkout", sleeveNumber);
|
||||
|
||||
return player.sleeves[sleeveNumber].workoutAtGym(player, gymName, stat);
|
||||
},
|
||||
getSleeveStats: function (asleeveNumber: any = 0): {
|
||||
shock: number;
|
||||
sync: number;
|
||||
hacking: number;
|
||||
strength: number;
|
||||
defense: number;
|
||||
dexterity: number;
|
||||
agility: number;
|
||||
charisma: number;
|
||||
} {
|
||||
const sleeveNumber = helper.number("getSleeveStats", "sleeveNumber", asleeveNumber);
|
||||
getSleeveStats: function (_sleeveNumber: unknown): SleeveSkills {
|
||||
const sleeveNumber = helper.number("getSleeveStats", "sleeveNumber", _sleeveNumber);
|
||||
helper.updateDynamicRam("getSleeveStats", getRamCost(player, "sleeve", "getSleeveStats"));
|
||||
checkSleeveAPIAccess("getSleeveStats");
|
||||
checkSleeveNumber("getSleeveStats", sleeveNumber);
|
||||
return getSleeveStats(sleeveNumber)
|
||||
return getSleeveStats(sleeveNumber);
|
||||
},
|
||||
getTask: function (asleeveNumber: any = 0): {
|
||||
task: string;
|
||||
crime: string;
|
||||
location: string;
|
||||
gymStatType: string;
|
||||
factionWorkType: string;
|
||||
} {
|
||||
const sleeveNumber = helper.number("getTask", "sleeveNumber", asleeveNumber);
|
||||
getTask: function (_sleeveNumber: unknown): SleeveTask {
|
||||
const sleeveNumber = helper.number("getTask", "sleeveNumber", _sleeveNumber);
|
||||
helper.updateDynamicRam("getTask", getRamCost(player, "sleeve", "getTask"));
|
||||
checkSleeveAPIAccess("getTask");
|
||||
checkSleeveNumber("getTask", sleeveNumber);
|
||||
@@ -187,14 +178,15 @@ export function NetscriptSleeve(player: IPlayer, workerScript: WorkerScript, hel
|
||||
factionWorkType: FactionWorkType[sl.factionWorkType],
|
||||
};
|
||||
},
|
||||
getInformation: function (asleeveNumber: any = 0): any {
|
||||
const sleeveNumber = helper.number("getInformation", "sleeveNumber", asleeveNumber);
|
||||
getInformation: function (_sleeveNumber: unknown): SleeveInformation {
|
||||
const sleeveNumber = helper.number("getInformation", "sleeveNumber", _sleeveNumber);
|
||||
helper.updateDynamicRam("getInformation", getRamCost(player, "sleeve", "getInformation"));
|
||||
checkSleeveAPIAccess("getInformation");
|
||||
checkSleeveNumber("getInformation", sleeveNumber);
|
||||
|
||||
const sl = player.sleeves[sleeveNumber];
|
||||
return {
|
||||
tor: false,
|
||||
city: sl.city,
|
||||
hp: sl.hp,
|
||||
jobs: Object.keys(player.jobs), // technically sleeves have the same jobs as the player.
|
||||
@@ -252,8 +244,8 @@ export function NetscriptSleeve(player: IPlayer, workerScript: WorkerScript, hel
|
||||
workRepGain: sl.getRepGain(player),
|
||||
};
|
||||
},
|
||||
getSleeveAugmentations: function (asleeveNumber: any = 0): string[] {
|
||||
const sleeveNumber = helper.number("getSleeveAugmentations", "sleeveNumber", asleeveNumber);
|
||||
getSleeveAugmentations: function (_sleeveNumber: unknown): string[] {
|
||||
const sleeveNumber = helper.number("getSleeveAugmentations", "sleeveNumber", _sleeveNumber);
|
||||
helper.updateDynamicRam("getSleeveAugmentations", getRamCost(player, "sleeve", "getSleeveAugmentations"));
|
||||
checkSleeveAPIAccess("getSleeveAugmentations");
|
||||
checkSleeveNumber("getSleeveAugmentations", sleeveNumber);
|
||||
@@ -264,11 +256,8 @@ export function NetscriptSleeve(player: IPlayer, workerScript: WorkerScript, hel
|
||||
}
|
||||
return augs;
|
||||
},
|
||||
getSleevePurchasableAugs: function (asleeveNumber: any = 0): {
|
||||
name: string;
|
||||
cost: number;
|
||||
}[] {
|
||||
const sleeveNumber = helper.number("getSleevePurchasableAugs", "sleeveNumber", asleeveNumber);
|
||||
getSleevePurchasableAugs: function (_sleeveNumber: unknown): AugmentPair[] {
|
||||
const sleeveNumber = helper.number("getSleevePurchasableAugs", "sleeveNumber", _sleeveNumber);
|
||||
helper.updateDynamicRam("getSleevePurchasableAugs", getRamCost(player, "sleeve", "getSleevePurchasableAugs"));
|
||||
checkSleeveAPIAccess("getSleevePurchasableAugs");
|
||||
checkSleeveNumber("getSleevePurchasableAugs", sleeveNumber);
|
||||
@@ -285,9 +274,9 @@ export function NetscriptSleeve(player: IPlayer, workerScript: WorkerScript, hel
|
||||
|
||||
return augs;
|
||||
},
|
||||
purchaseSleeveAug: function (asleeveNumber: any = 0, aaugName: any = ""): boolean {
|
||||
const sleeveNumber = helper.number("purchaseSleeveAug", "sleeveNumber", asleeveNumber);
|
||||
const augName = helper.string("purchaseSleeveAug", "augName", aaugName);
|
||||
purchaseSleeveAug: function (_sleeveNumber: unknown, _augName: unknown): boolean {
|
||||
const sleeveNumber = helper.number("purchaseSleeveAug", "sleeveNumber", _sleeveNumber);
|
||||
const augName = helper.string("purchaseSleeveAug", "augName", _augName);
|
||||
helper.updateDynamicRam("purchaseSleeveAug", getRamCost(player, "sleeve", "purchaseSleeveAug"));
|
||||
checkSleeveAPIAccess("purchaseSleeveAug");
|
||||
checkSleeveNumber("purchaseSleeveAug", sleeveNumber);
|
||||
|
||||
Reference in New Issue
Block a user