mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-21 00:32:51 +02:00
Merge branch 'dev' of github.com:danielyxie/bitburner into improvement/filter-helper-func
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;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -230,14 +230,14 @@ export function NetscriptCorporation(
|
||||
return corporation;
|
||||
}
|
||||
|
||||
function getDivision(divisionName: any): IIndustry {
|
||||
function getDivision(divisionName: string): IIndustry {
|
||||
const corporation = getCorporation();
|
||||
const division = corporation.divisions.find((div) => div.name === divisionName);
|
||||
if (division === undefined) throw new Error(`No division named '${divisionName}'`);
|
||||
return division;
|
||||
}
|
||||
|
||||
function getOffice(divisionName: any, cityName: any): OfficeSpace {
|
||||
function getOffice(divisionName: string, cityName: string): OfficeSpace {
|
||||
const division = getDivision(divisionName);
|
||||
if (!(cityName in division.offices)) throw new Error(`Invalid city name '${cityName}'`);
|
||||
const office = division.offices[cityName];
|
||||
@@ -245,7 +245,7 @@ export function NetscriptCorporation(
|
||||
return office;
|
||||
}
|
||||
|
||||
function getWarehouse(divisionName: any, cityName: any): Warehouse {
|
||||
function getWarehouse(divisionName: string, cityName: string): Warehouse {
|
||||
const division = getDivision(divisionName);
|
||||
if (!(cityName in division.warehouses)) throw new Error(`Invalid city name '${cityName}'`);
|
||||
const warehouse = division.warehouses[cityName];
|
||||
@@ -253,7 +253,7 @@ export function NetscriptCorporation(
|
||||
return warehouse;
|
||||
}
|
||||
|
||||
function getMaterial(divisionName: any, cityName: any, materialName: any): Material {
|
||||
function getMaterial(divisionName: string, cityName: string, materialName: string): Material {
|
||||
const warehouse = getWarehouse(divisionName, cityName);
|
||||
const matName = (materialName as string).replace(/ /g, "");
|
||||
const material = warehouse.materials[matName];
|
||||
@@ -261,14 +261,14 @@ export function NetscriptCorporation(
|
||||
return material;
|
||||
}
|
||||
|
||||
function getProduct(divisionName: any, productName: any): Product {
|
||||
function getProduct(divisionName: string, productName: string): Product {
|
||||
const division = getDivision(divisionName);
|
||||
const product = division.products[productName];
|
||||
if (product === undefined) throw new Error(`Invalid product name: '${productName}'`);
|
||||
return product;
|
||||
}
|
||||
|
||||
function getEmployee(divisionName: any, cityName: any, employeeName: any): Employee {
|
||||
function getEmployee(divisionName: string, cityName: string, employeeName: string): Employee {
|
||||
const office = getOffice(divisionName, cityName);
|
||||
const employee = office.employees.find((e) => e.name === employeeName);
|
||||
if (employee === undefined) throw new Error(`Invalid employee name: '${employeeName}'`);
|
||||
@@ -314,14 +314,14 @@ export function NetscriptCorporation(
|
||||
getUpgradeWarehouseCost: function (_divisionName: unknown, _cityName: unknown): number {
|
||||
checkAccess("upgradeWarehouse", 7);
|
||||
const divisionName = helper.string("getUpgradeWarehouseCost", "divisionName", _divisionName);
|
||||
const cityName = helper.string("getUpgradeWarehouseCost", "cityName", _cityName);
|
||||
const cityName = helper.city("getUpgradeWarehouseCost", "cityName", _cityName);
|
||||
const warehouse = getWarehouse(divisionName, cityName);
|
||||
return CorporationConstants.WarehouseUpgradeBaseCost * Math.pow(1.07, warehouse.level + 1);
|
||||
},
|
||||
hasWarehouse: function (_divisionName: unknown, _cityName: unknown): boolean {
|
||||
checkAccess("hasWarehouse", 7);
|
||||
const divisionName = helper.string("getWarehouse", "divisionName", _divisionName);
|
||||
const cityName = helper.string("getWarehouse", "cityName", _cityName);
|
||||
const cityName = helper.city("getWarehouse", "cityName", _cityName);
|
||||
const division = getDivision(divisionName);
|
||||
if (!(cityName in division.warehouses)) throw new Error(`Invalid city name '${cityName}'`);
|
||||
const warehouse = division.warehouses[cityName];
|
||||
@@ -330,7 +330,7 @@ export function NetscriptCorporation(
|
||||
getWarehouse: function (_divisionName: unknown, _cityName: unknown): NSWarehouse {
|
||||
checkAccess("getWarehouse", 7);
|
||||
const divisionName = helper.string("getWarehouse", "divisionName", _divisionName);
|
||||
const cityName = helper.string("getWarehouse", "cityName", _cityName);
|
||||
const cityName = helper.city("getWarehouse", "cityName", _cityName);
|
||||
const warehouse = getWarehouse(divisionName, cityName);
|
||||
return {
|
||||
level: warehouse.level,
|
||||
@@ -343,7 +343,7 @@ export function NetscriptCorporation(
|
||||
getMaterial: function (_divisionName: unknown, _cityName: unknown, _materialName: unknown): NSMaterial {
|
||||
checkAccess("getMaterial", 7);
|
||||
const divisionName = helper.string("getMaterial", "divisionName", _divisionName);
|
||||
const cityName = helper.string("getMaterial", "cityName", _cityName);
|
||||
const cityName = helper.city("getMaterial", "cityName", _cityName);
|
||||
const materialName = helper.string("getMaterial", "materialName", _materialName);
|
||||
const material = getMaterial(divisionName, cityName, materialName);
|
||||
return {
|
||||
@@ -372,14 +372,14 @@ export function NetscriptCorporation(
|
||||
purchaseWarehouse: function (_divisionName: unknown, _cityName: unknown): void {
|
||||
checkAccess("purchaseWarehouse", 7);
|
||||
const divisionName = helper.string("purchaseWarehouse", "divisionName", _divisionName);
|
||||
const cityName = helper.string("purchaseWarehouse", "cityName", _cityName);
|
||||
const cityName = helper.city("purchaseWarehouse", "cityName", _cityName);
|
||||
const corporation = getCorporation();
|
||||
PurchaseWarehouse(corporation, getDivision(divisionName), cityName);
|
||||
},
|
||||
upgradeWarehouse: function (_divisionName: unknown, _cityName: unknown): void {
|
||||
checkAccess("upgradeWarehouse", 7);
|
||||
const divisionName = helper.string("upgradeWarehouse", "divisionName", _divisionName);
|
||||
const cityName = helper.string("upgradeWarehouse", "cityName", _cityName);
|
||||
const cityName = helper.city("upgradeWarehouse", "cityName", _cityName);
|
||||
const corporation = getCorporation();
|
||||
UpgradeWarehouse(corporation, getDivision(divisionName), getWarehouse(divisionName, cityName));
|
||||
},
|
||||
@@ -392,7 +392,7 @@ export function NetscriptCorporation(
|
||||
): void {
|
||||
checkAccess("sellMaterial", 7);
|
||||
const divisionName = helper.string("sellMaterial", "divisionName", _divisionName);
|
||||
const cityName = helper.string("sellMaterial", "cityName", _cityName);
|
||||
const cityName = helper.city("sellMaterial", "cityName", _cityName);
|
||||
const materialName = helper.string("sellMaterial", "materialName", _materialName);
|
||||
const amt = helper.string("sellMaterial", "amt", _amt);
|
||||
const price = helper.string("sellMaterial", "price", _price);
|
||||
@@ -409,7 +409,7 @@ export function NetscriptCorporation(
|
||||
): void {
|
||||
checkAccess("sellProduct", 7);
|
||||
const divisionName = helper.string("sellProduct", "divisionName", _divisionName);
|
||||
const cityName = helper.string("sellProduct", "cityName", _cityName);
|
||||
const cityName = helper.city("sellProduct", "cityName", _cityName);
|
||||
const productName = helper.string("sellProduct", "productName", _productName);
|
||||
const amt = helper.string("sellProduct", "amt", _amt);
|
||||
const price = helper.string("sellProduct", "price", _price);
|
||||
@@ -426,7 +426,7 @@ export function NetscriptCorporation(
|
||||
setSmartSupply: function (_divisionName: unknown, _cityName: unknown, _enabled: unknown): void {
|
||||
checkAccess("setSmartSupply", 7);
|
||||
const divisionName = helper.string("setSmartSupply", "divisionName", _divisionName);
|
||||
const cityName = helper.string("sellProduct", "cityName", _cityName);
|
||||
const cityName = helper.city("sellProduct", "cityName", _cityName);
|
||||
const enabled = helper.boolean(_enabled);
|
||||
const warehouse = getWarehouse(divisionName, cityName);
|
||||
if (!hasUnlockUpgrade("Smart Supply"))
|
||||
@@ -444,7 +444,7 @@ export function NetscriptCorporation(
|
||||
): void {
|
||||
checkAccess("setSmartSupplyUseLeftovers", 7);
|
||||
const divisionName = helper.string("setSmartSupply", "divisionName", _divisionName);
|
||||
const cityName = helper.string("sellProduct", "cityName", _cityName);
|
||||
const cityName = helper.city("sellProduct", "cityName", _cityName);
|
||||
const materialName = helper.string("sellProduct", "materialName", _materialName);
|
||||
const enabled = helper.boolean(_enabled);
|
||||
const warehouse = getWarehouse(divisionName, cityName);
|
||||
@@ -459,7 +459,7 @@ export function NetscriptCorporation(
|
||||
buyMaterial: function (_divisionName: unknown, _cityName: unknown, _materialName: unknown, _amt: unknown): void {
|
||||
checkAccess("buyMaterial", 7);
|
||||
const divisionName = helper.string("buyMaterial", "divisionName", _divisionName);
|
||||
const cityName = helper.string("buyMaterial", "cityName", _cityName);
|
||||
const cityName = helper.city("buyMaterial", "cityName", _cityName);
|
||||
const materialName = helper.string("buyMaterial", "materialName", _materialName);
|
||||
const amt = helper.number("buyMaterial", "amt", _amt);
|
||||
if (amt < 0) throw new Error("Invalid value for amount field! Must be numeric and greater than 0");
|
||||
@@ -469,10 +469,10 @@ export function NetscriptCorporation(
|
||||
bulkPurchase: function (_divisionName: unknown, _cityName: unknown, _materialName: unknown, _amt: unknown): void {
|
||||
checkAccess("bulkPurchase", 7);
|
||||
const divisionName = helper.string("bulkPurchase", "divisionName", _divisionName);
|
||||
if (!hasResearched(getDivision(_divisionName), "Bulk Purchasing"))
|
||||
if (!hasResearched(getDivision(divisionName), "Bulk Purchasing"))
|
||||
throw new Error(`You have not researched Bulk Purchasing in ${divisionName}`);
|
||||
const corporation = getCorporation();
|
||||
const cityName = helper.string("bulkPurchase", "cityName", _cityName);
|
||||
const cityName = helper.city("bulkPurchase", "cityName", _cityName);
|
||||
const materialName = helper.string("bulkPurchase", "materialName", _materialName);
|
||||
const amt = helper.number("bulkPurchase", "amt", _amt);
|
||||
const warehouse = getWarehouse(divisionName, cityName);
|
||||
@@ -488,7 +488,7 @@ export function NetscriptCorporation(
|
||||
): void {
|
||||
checkAccess("makeProduct", 7);
|
||||
const divisionName = helper.string("makeProduct", "divisionName", _divisionName);
|
||||
const cityName = helper.string("makeProduct", "cityName", _cityName);
|
||||
const cityName = helper.city("makeProduct", "cityName", _cityName);
|
||||
const productName = helper.string("makeProduct", "productName", _productName);
|
||||
const designInvest = helper.number("makeProduct", "designInvest", _designInvest);
|
||||
const marketingInvest = helper.number("makeProduct", "marketingInvest", _marketingInvest);
|
||||
@@ -543,7 +543,7 @@ export function NetscriptCorporation(
|
||||
): void {
|
||||
checkAccess("setMaterialMarketTA1", 7);
|
||||
const divisionName = helper.string("setMaterialMarketTA1", "divisionName", _divisionName);
|
||||
const cityName = helper.string("setMaterialMarketTA1", "cityName", _cityName);
|
||||
const cityName = helper.city("setMaterialMarketTA1", "cityName", _cityName);
|
||||
const materialName = helper.string("setMaterialMarketTA1", "materialName", _materialName);
|
||||
const on = helper.boolean(_on);
|
||||
if (!getDivision(divisionName).hasResearch("Market-TA.I"))
|
||||
@@ -561,7 +561,7 @@ export function NetscriptCorporation(
|
||||
): void {
|
||||
checkAccess("setMaterialMarketTA2", 7);
|
||||
const divisionName = helper.string("setMaterialMarketTA2", "divisionName", _divisionName);
|
||||
const cityName = helper.string("setMaterialMarketTA2", "cityName", _cityName);
|
||||
const cityName = helper.city("setMaterialMarketTA2", "cityName", _cityName);
|
||||
const materialName = helper.string("setMaterialMarketTA2", "materialName", _materialName);
|
||||
const on = helper.boolean(_on);
|
||||
if (!getDivision(divisionName).hasResearch("Market-TA.II"))
|
||||
@@ -631,7 +631,7 @@ export function NetscriptCorporation(
|
||||
): Promise<boolean> {
|
||||
checkAccess("setAutoJobAssignment", 8);
|
||||
const divisionName = helper.string("setAutoJobAssignment", "divisionName", _divisionName);
|
||||
const cityName = helper.string("setAutoJobAssignment", "cityName", _cityName);
|
||||
const cityName = helper.city("setAutoJobAssignment", "cityName", _cityName);
|
||||
const amount = helper.number("setAutoJobAssignment", "amount", _amount);
|
||||
const job = helper.string("setAutoJobAssignment", "job", _job);
|
||||
const office = getOffice(divisionName, cityName);
|
||||
@@ -646,7 +646,7 @@ export function NetscriptCorporation(
|
||||
getOfficeSizeUpgradeCost: function (_divisionName: unknown, _cityName: unknown, _size: unknown): number {
|
||||
checkAccess("getOfficeSizeUpgradeCost", 8);
|
||||
const divisionName = helper.string("getOfficeSizeUpgradeCost", "divisionName", _divisionName);
|
||||
const cityName = helper.string("getOfficeSizeUpgradeCost", "cityName", _cityName);
|
||||
const cityName = helper.city("getOfficeSizeUpgradeCost", "cityName", _cityName);
|
||||
const size = helper.number("getOfficeSizeUpgradeCost", "size", _size);
|
||||
if (size < 0) throw new Error("Invalid value for size field! Must be numeric and greater than 0");
|
||||
const office = getOffice(divisionName, cityName);
|
||||
@@ -666,7 +666,7 @@ export function NetscriptCorporation(
|
||||
): Promise<void> {
|
||||
checkAccess("assignJob", 8);
|
||||
const divisionName = helper.string("assignJob", "divisionName", _divisionName);
|
||||
const cityName = helper.string("assignJob", "cityName", _cityName);
|
||||
const cityName = helper.city("assignJob", "cityName", _cityName);
|
||||
const employeeName = helper.string("assignJob", "employeeName", _employeeName);
|
||||
const job = helper.string("assignJob", "job", _job);
|
||||
const employee = getEmployee(divisionName, cityName, employeeName);
|
||||
@@ -677,14 +677,14 @@ export function NetscriptCorporation(
|
||||
hireEmployee: function (_divisionName: unknown, _cityName: unknown): any {
|
||||
checkAccess("hireEmployee", 8);
|
||||
const divisionName = helper.string("hireEmployee", "divisionName", _divisionName);
|
||||
const cityName = helper.string("hireEmployee", "cityName", _cityName);
|
||||
const cityName = helper.city("hireEmployee", "cityName", _cityName);
|
||||
const office = getOffice(divisionName, cityName);
|
||||
return office.hireRandomEmployee();
|
||||
},
|
||||
upgradeOfficeSize: function (_divisionName: unknown, _cityName: unknown, _size: unknown): void {
|
||||
checkAccess("upgradeOfficeSize", 8);
|
||||
const divisionName = helper.string("upgradeOfficeSize", "divisionName", _divisionName);
|
||||
const cityName = helper.string("upgradeOfficeSize", "cityName", _cityName);
|
||||
const cityName = helper.city("upgradeOfficeSize", "cityName", _cityName);
|
||||
const size = helper.number("upgradeOfficeSize", "size", _size);
|
||||
if (size < 0) throw new Error("Invalid value for size field! Must be numeric and greater than 0");
|
||||
const office = getOffice(divisionName, cityName);
|
||||
@@ -694,7 +694,7 @@ export function NetscriptCorporation(
|
||||
throwParty: function (_divisionName: unknown, _cityName: unknown, _costPerEmployee: unknown): Promise<number> {
|
||||
checkAccess("throwParty", 8);
|
||||
const divisionName = helper.string("throwParty", "divisionName", _divisionName);
|
||||
const cityName = helper.string("throwParty", "cityName", _cityName);
|
||||
const cityName = helper.city("throwParty", "cityName", _cityName);
|
||||
const costPerEmployee = helper.number("throwParty", "costPerEmployee", _costPerEmployee);
|
||||
if (costPerEmployee < 0)
|
||||
throw new Error("Invalid value for Cost Per Employee field! Must be numeric and greater than 0");
|
||||
@@ -710,7 +710,7 @@ export function NetscriptCorporation(
|
||||
buyCoffee: function (_divisionName: unknown, _cityName: unknown): Promise<void> {
|
||||
checkAccess("buyCoffee", 8);
|
||||
const divisionName = helper.string("buyCoffee", "divisionName", _divisionName);
|
||||
const cityName = helper.string("buyCoffee", "cityName", _cityName);
|
||||
const cityName = helper.city("buyCoffee", "cityName", _cityName);
|
||||
const corporation = getCorporation();
|
||||
return netscriptDelay(
|
||||
(60 * 1000) / (player.hacking_speed_mult * calculateIntelligenceBonus(player.intelligence, 1)),
|
||||
@@ -734,7 +734,7 @@ export function NetscriptCorporation(
|
||||
getOffice: function (_divisionName: unknown, _cityName: unknown): any {
|
||||
checkAccess("getOffice", 8);
|
||||
const divisionName = helper.string("getOffice", "divisionName", _divisionName);
|
||||
const cityName = helper.string("getOffice", "cityName", _cityName);
|
||||
const cityName = helper.city("getOffice", "cityName", _cityName);
|
||||
const office = getOffice(divisionName, cityName);
|
||||
return {
|
||||
loc: office.loc,
|
||||
@@ -758,7 +758,7 @@ export function NetscriptCorporation(
|
||||
getEmployee: function (_divisionName: unknown, _cityName: unknown, _employeeName: unknown): NSEmployee {
|
||||
checkAccess("getEmployee", 8);
|
||||
const divisionName = helper.string("getEmployee", "divisionName", _divisionName);
|
||||
const cityName = helper.string("getEmployee", "cityName", _cityName);
|
||||
const cityName = helper.city("getEmployee", "cityName", _cityName);
|
||||
const employeeName = helper.string("getEmployee", "employeeName", _employeeName);
|
||||
const employee = getEmployee(divisionName, cityName, employeeName);
|
||||
return {
|
||||
@@ -791,7 +791,7 @@ export function NetscriptCorporation(
|
||||
expandCity: function (_divisionName: unknown, _cityName: unknown): void {
|
||||
checkAccess("expandCity");
|
||||
const divisionName = helper.string("expandCity", "divisionName", _divisionName);
|
||||
const cityName = helper.string("expandCity", "cityName", _cityName);
|
||||
const cityName = helper.city("expandCity", "cityName", _cityName);
|
||||
if (!CorporationConstants.Cities.includes(cityName)) throw new Error("Invalid city name");
|
||||
const corporation = getCorporation();
|
||||
const division = getDivision(divisionName);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { CityName } from "src/Locations/data/CityNames";
|
||||
import { BaseServer } from "../Server/BaseServer";
|
||||
|
||||
export interface INetscriptHelper {
|
||||
@@ -5,6 +6,7 @@ export interface INetscriptHelper {
|
||||
makeRuntimeErrorMsg(functionName: string, message: string): void;
|
||||
string(funcName: string, argName: string, v: unknown): string;
|
||||
number(funcName: string, argName: string, v: unknown): number;
|
||||
city(funcName: string, argName: string, v: unknown): CityName;
|
||||
boolean(v: unknown): boolean;
|
||||
getServer(ip: any, fn: any): BaseServer;
|
||||
checkSingularityAccess(func: string): void;
|
||||
|
||||
@@ -466,7 +466,7 @@ export function NetscriptSingularity(
|
||||
},
|
||||
|
||||
travelToCity: function (_cityName: unknown): boolean {
|
||||
const cityName = helper.string("travelToCity", "cityName", _cityName);
|
||||
const cityName = helper.city("travelToCity", "cityName", _cityName);
|
||||
helper.updateDynamicRam("travelToCity", getRamCost(player, "travelToCity"));
|
||||
helper.checkSingularityAccess("travelToCity");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user