mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-11 02:03:58 +01:00
Merge branch 'feature/add-infiltration-faction' of github.com:phyzical/bitburner into feature/add-infiltration-faction
This commit is contained in:
commit
d56702b742
42
dist/vendor.bundle.js
vendored
42
dist/vendor.bundle.js
vendored
File diff suppressed because one or more lines are too long
2
dist/vendor.bundle.js.map
vendored
2
dist/vendor.bundle.js.map
vendored
File diff suppressed because one or more lines are too long
1
letter_to_fandom.com
Normal file
1
letter_to_fandom.com
Normal file
@ -0,0 +1 @@
|
|||||||
|
I want the wiki here https://bitburner.fandom.com/wiki/Bitburner_Wiki taken down please.
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -110,6 +110,7 @@ function updateGeneralAugmentationPrice(augmentation: Augmentation): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function updateAugmentationCosts(): void {
|
export function updateAugmentationCosts(): void {
|
||||||
|
console.log(Player.queuedAugmentations);
|
||||||
for (const name of Object.keys(Augmentations)) {
|
for (const name of Object.keys(Augmentations)) {
|
||||||
if (Augmentations.hasOwnProperty(name)) {
|
if (Augmentations.hasOwnProperty(name)) {
|
||||||
const augmentationToUpdate = Augmentations[name];
|
const augmentationToUpdate = Augmentations[name];
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { IPlayer } from 'src/PersonObjects/IPlayer';
|
import { IPlayer } from "src/PersonObjects/IPlayer";
|
||||||
import { MaterialSizes } from './MaterialSizes';
|
import { MaterialSizes } from "./MaterialSizes";
|
||||||
import { ICorporation } from "./ICorporation";
|
import { ICorporation } from "./ICorporation";
|
||||||
import { IIndustry } from "./IIndustry";
|
import { IIndustry } from "./IIndustry";
|
||||||
import { IndustryStartingCosts, IndustryResearchTrees } from "./IndustryData";
|
import { IndustryStartingCosts, IndustryResearchTrees } from "./IndustryData";
|
||||||
@ -17,6 +17,7 @@ import { Employee } from "./Employee";
|
|||||||
import { IndustryUpgrades } from "./IndustryUpgrades";
|
import { IndustryUpgrades } from "./IndustryUpgrades";
|
||||||
import { ResearchMap } from "./ResearchMap";
|
import { ResearchMap } from "./ResearchMap";
|
||||||
import { isRelevantMaterial } from "./ui/Helpers";
|
import { isRelevantMaterial } from "./ui/Helpers";
|
||||||
|
import { CityName } from "src/Locations/data/CityNames";
|
||||||
|
|
||||||
export function NewIndustry(corporation: ICorporation, industry: string, name: string): void {
|
export function NewIndustry(corporation: ICorporation, industry: string, name: string): void {
|
||||||
if (corporation.divisions.find(({ type }) => industry == type))
|
if (corporation.divisions.find(({ type }) => industry == type))
|
||||||
@ -64,7 +65,7 @@ export function UnlockUpgrade(corporation: ICorporation, upgrade: CorporationUnl
|
|||||||
if (corporation.funds < upgrade[1]) {
|
if (corporation.funds < upgrade[1]) {
|
||||||
throw new Error("Insufficient funds");
|
throw new Error("Insufficient funds");
|
||||||
}
|
}
|
||||||
if(corporation.unlockUpgrades[upgrade[0]] === 1){
|
if (corporation.unlockUpgrades[upgrade[0]] === 1) {
|
||||||
throw new Error(`You have already unlocked the ${upgrade[2]} upgrade!`);
|
throw new Error(`You have already unlocked the ${upgrade[2]} upgrade!`);
|
||||||
}
|
}
|
||||||
corporation.unlock(upgrade);
|
corporation.unlock(upgrade);
|
||||||
@ -222,15 +223,15 @@ export function SellProduct(product: Product, city: string, amt: string, price:
|
|||||||
product.sllman[city][1] = "";
|
product.sllman[city][1] = "";
|
||||||
}
|
}
|
||||||
} else if (all) {
|
} else if (all) {
|
||||||
for (let i = 0; i < cities.length; ++i) {
|
for (let i = 0; i < cities.length; ++i) {
|
||||||
const tempCity = cities[i];
|
const tempCity = cities[i];
|
||||||
product.sllman[tempCity][0] = true;
|
product.sllman[tempCity][0] = true;
|
||||||
product.sllman[tempCity][1] = qty;
|
product.sllman[tempCity][1] = qty;
|
||||||
}
|
|
||||||
} else {
|
|
||||||
product.sllman[city][0] = true;
|
|
||||||
product.sllman[city][1] = qty;
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
product.sllman[city][0] = true;
|
||||||
|
product.sllman[city][1] = qty;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,7 +258,7 @@ export function BulkPurchase(corp: ICorporation, warehouse: Warehouse, material:
|
|||||||
if (isNaN(amt) || amt < 0) {
|
if (isNaN(amt) || amt < 0) {
|
||||||
throw new Error(`Invalid input amount`);
|
throw new Error(`Invalid input amount`);
|
||||||
}
|
}
|
||||||
if (amt * matSize > maxAmount) {
|
if (amt * matSize <= maxAmount) {
|
||||||
throw new Error(`You do not have enough warehouse size to fit this purchase`);
|
throw new Error(`You do not have enough warehouse size to fit this purchase`);
|
||||||
}
|
}
|
||||||
const cost = amt * material.bCost;
|
const cost = amt * material.bCost;
|
||||||
@ -295,7 +296,7 @@ export function BuyBackShares(corporation: ICorporation, player: IPlayer, numSha
|
|||||||
if (numShares > corporation.issuedShares) throw new Error("You don't have that many shares to buy!");
|
if (numShares > corporation.issuedShares) throw new Error("You don't have that many shares to buy!");
|
||||||
if (!corporation.public) throw new Error("You haven't gone public!");
|
if (!corporation.public) throw new Error("You haven't gone public!");
|
||||||
const buybackPrice = corporation.sharePrice * 1.1;
|
const buybackPrice = corporation.sharePrice * 1.1;
|
||||||
if (player.money < (numShares * buybackPrice)) throw new Error("You cant afford that many shares!");
|
if (player.money < numShares * buybackPrice) throw new Error("You cant afford that many shares!");
|
||||||
corporation.numShares += numShares;
|
corporation.numShares += numShares;
|
||||||
corporation.issuedShares -= numShares;
|
corporation.issuedShares -= numShares;
|
||||||
player.loseMoney(numShares * buybackPrice, "corporation");
|
player.loseMoney(numShares * buybackPrice, "corporation");
|
||||||
@ -404,13 +405,13 @@ export function MakeProduct(
|
|||||||
if (corp.funds < designInvest + marketingInvest) {
|
if (corp.funds < designInvest + marketingInvest) {
|
||||||
throw new Error("You don't have enough company funds to make this large of an investment");
|
throw new Error("You don't have enough company funds to make this large of an investment");
|
||||||
}
|
}
|
||||||
let maxProducts = 3
|
let maxProducts = 3;
|
||||||
if (division.hasResearch("uPgrade: Capacity.II")) {
|
if (division.hasResearch("uPgrade: Capacity.II")) {
|
||||||
maxProducts = 5
|
maxProducts = 5;
|
||||||
} else if (division.hasResearch("uPgrade: Capacity.I")) {
|
} else if (division.hasResearch("uPgrade: Capacity.I")) {
|
||||||
maxProducts = 4
|
maxProducts = 4;
|
||||||
}
|
}
|
||||||
const products = division.products
|
const products = division.products;
|
||||||
if (Object.keys(products).length >= maxProducts) {
|
if (Object.keys(products).length >= maxProducts) {
|
||||||
throw new Error(`You are already at the max products (${maxProducts}) for division: ${division.name}!`);
|
throw new Error(`You are already at the max products (${maxProducts}) for division: ${division.name}!`);
|
||||||
}
|
}
|
||||||
@ -445,7 +446,13 @@ export function Research(division: IIndustry, researchName: string): void {
|
|||||||
division.researched[researchName] = true;
|
division.researched[researchName] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ExportMaterial(divisionName: string, cityName: string, material: Material, amt: string, division?: Industry): void {
|
export function ExportMaterial(
|
||||||
|
divisionName: string,
|
||||||
|
cityName: string,
|
||||||
|
material: Material,
|
||||||
|
amt: string,
|
||||||
|
division?: Industry,
|
||||||
|
): void {
|
||||||
// Sanitize amt
|
// Sanitize amt
|
||||||
let sanitizedAmt = amt.replace(/\s+/g, "").toUpperCase();
|
let sanitizedAmt = amt.replace(/\s+/g, "").toUpperCase();
|
||||||
sanitizedAmt = sanitizedAmt.replace(/[^-()\d/*+.MAX]/g, "");
|
sanitizedAmt = sanitizedAmt.replace(/[^-()\d/*+.MAX]/g, "");
|
||||||
|
@ -67,7 +67,7 @@ export function WireCuttingGame(props: IMinigameProps): React.ReactElement {
|
|||||||
const hasAugment = Player.hasAugmentation(AugmentationNames.SecurityWireContacts, true);
|
const hasAugment = Player.hasAugmentation(AugmentationNames.SecurityWireContacts, true);
|
||||||
|
|
||||||
function checkWire(wireNum: number): boolean {
|
function checkWire(wireNum: number): boolean {
|
||||||
return questions.some((q) => q.shouldCut(wires[wireNum - 1], wireNum - 1));
|
return !questions.some((q) => q.shouldCut(wires[wireNum - 1], wireNum - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -100,6 +100,7 @@ import { SnackbarEvents } from "./ui/React/Snackbar";
|
|||||||
import { Flags } from "./NetscriptFunctions/Flags";
|
import { Flags } from "./NetscriptFunctions/Flags";
|
||||||
import { calculateIntelligenceBonus } from "./PersonObjects/formulas/intelligence";
|
import { calculateIntelligenceBonus } from "./PersonObjects/formulas/intelligence";
|
||||||
import { CalculateShareMult, StartSharing } from "./NetworkShare/Share";
|
import { CalculateShareMult, StartSharing } from "./NetworkShare/Share";
|
||||||
|
import { CityName } from "./Locations/data/CityNames";
|
||||||
|
|
||||||
interface NS extends INS {
|
interface NS extends INS {
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
@ -443,21 +444,28 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
string: (funcName: string, argName: string, v: unknown): string => {
|
string: (funcName: string, argName: string, v: unknown): string => {
|
||||||
if (typeof v === "string") return v;
|
if (typeof v === "string") return v;
|
||||||
if (typeof v === "number") return v + ""; // cast to string;
|
if (typeof v === "number") return v + ""; // cast to string;
|
||||||
throw makeRuntimeErrorMsg(funcName, `${argName} should be a string`);
|
throw makeRuntimeErrorMsg(funcName, `${argName} should be a string.`);
|
||||||
},
|
},
|
||||||
number: (funcName: string, argName: string, v: unknown): number => {
|
number: (funcName: string, argName: string, v: unknown): number => {
|
||||||
if (typeof v === "string") {
|
if (typeof v === "string") {
|
||||||
const x = parseFloat(v);
|
const x = parseFloat(v);
|
||||||
if (!isNaN(x)) return x; // otherwise it wasn't even a string representing a number.
|
if (!isNaN(x)) return x; // otherwise it wasn't even a string representing a number.
|
||||||
} else if (typeof v === "number") {
|
} else if (typeof v === "number") {
|
||||||
if (isNaN(v)) throw makeRuntimeErrorMsg(funcName, `${argName} is NaN`);
|
if (isNaN(v)) throw makeRuntimeErrorMsg(funcName, `${argName} is NaN.`);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
throw makeRuntimeErrorMsg(funcName, `${argName} should be a number`);
|
throw makeRuntimeErrorMsg(funcName, `${argName} should be a number.`);
|
||||||
},
|
},
|
||||||
boolean: (v: unknown): boolean => {
|
boolean: (v: unknown): boolean => {
|
||||||
return !!v; // Just convert it to boolean.
|
return !!v; // Just convert it to boolean.
|
||||||
},
|
},
|
||||||
|
city: (funcName: string, argName: string, v: unknown): CityName => {
|
||||||
|
if (typeof v !== "string") throw makeRuntimeErrorMsg(funcName, `${argName} should be a city name.`);
|
||||||
|
const s = v as CityName;
|
||||||
|
if (!Object.values(CityName).includes(s))
|
||||||
|
throw makeRuntimeErrorMsg(funcName, `${argName} should be a city name.`);
|
||||||
|
return s;
|
||||||
|
},
|
||||||
getServer: safeGetServer,
|
getServer: safeGetServer,
|
||||||
checkSingularityAccess: checkSingularityAccess,
|
checkSingularityAccess: checkSingularityAccess,
|
||||||
hack: hack,
|
hack: hack,
|
||||||
@ -884,9 +892,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
}
|
}
|
||||||
return !workerScript.disableLogs[fn];
|
return !workerScript.disableLogs[fn];
|
||||||
},
|
},
|
||||||
getScriptLogs: function (_fn: unknown, _hostname: unknown, ...scriptArgs: any[]): string[] {
|
getScriptLogs: function (fn: any, hostname: any, ...scriptArgs: any[]): string[] {
|
||||||
const fn = helper.string("getScriptLogs", "fn", _fn);
|
|
||||||
const hostname = helper.string("getScriptLogs", "hostname", _hostname);
|
|
||||||
updateDynamicRam("getScriptLogs", getRamCost(Player, "getScriptLogs"));
|
updateDynamicRam("getScriptLogs", getRamCost(Player, "getScriptLogs"));
|
||||||
const runningScriptObj = getRunningScript(fn, hostname, "getScriptLogs", scriptArgs);
|
const runningScriptObj = getRunningScript(fn, hostname, "getScriptLogs", scriptArgs);
|
||||||
if (runningScriptObj == null) {
|
if (runningScriptObj == null) {
|
||||||
@ -896,9 +902,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
|
|
||||||
return runningScriptObj.logs.slice();
|
return runningScriptObj.logs.slice();
|
||||||
},
|
},
|
||||||
tail: function (_fn: unknown, _hostname: unknown = workerScript.hostname, ...scriptArgs: any[]): void {
|
tail: function (fn: any, hostname: any = workerScript.hostname, ...scriptArgs: any[]): void {
|
||||||
const fn = helper.string("tail", "fn", _fn);
|
|
||||||
const hostname = helper.string("tail", "hostname", _hostname);
|
|
||||||
updateDynamicRam("tail", getRamCost(Player, "tail"));
|
updateDynamicRam("tail", getRamCost(Player, "tail"));
|
||||||
let runningScriptObj;
|
let runningScriptObj;
|
||||||
if (arguments.length === 0) {
|
if (arguments.length === 0) {
|
||||||
@ -1114,9 +1118,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
workerScript.log("spawn", () => "Exiting...");
|
workerScript.log("spawn", () => "Exiting...");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
kill: function (_filename: unknown, _hostname?: unknown, ...scriptArgs: any[]): boolean {
|
kill: function (filename: any, hostname?: any, ...scriptArgs: any[]): boolean {
|
||||||
const filename = helper.string("kill", "filename", _filename);
|
|
||||||
const hostname = helper.string("kill", "hostname", _hostname);
|
|
||||||
updateDynamicRam("kill", getRamCost(Player, "kill"));
|
updateDynamicRam("kill", getRamCost(Player, "kill"));
|
||||||
|
|
||||||
let res;
|
let res;
|
||||||
@ -1710,9 +1712,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
const txtFile = getTextFile(filename, server);
|
const txtFile = getTextFile(filename, server);
|
||||||
return txtFile != null;
|
return txtFile != null;
|
||||||
},
|
},
|
||||||
isRunning: function (_fn: unknown, _hostname: unknown = workerScript.hostname, ...scriptArgs: any[]): boolean {
|
isRunning: function (fn: any, hostname: any = workerScript.hostname, ...scriptArgs: any[]): boolean {
|
||||||
const fn = helper.string("isRunning", "fn", _fn);
|
|
||||||
const hostname = helper.string("isRunning", "hostname", _hostname);
|
|
||||||
updateDynamicRam("isRunning", getRamCost(Player, "isRunning"));
|
updateDynamicRam("isRunning", getRamCost(Player, "isRunning"));
|
||||||
if (fn === undefined || hostname === undefined) {
|
if (fn === undefined || hostname === undefined) {
|
||||||
throw makeRuntimeErrorMsg("isRunning", "Usage: isRunning(scriptname, server, [arg1], [arg2]...)");
|
throw makeRuntimeErrorMsg("isRunning", "Usage: isRunning(scriptname, server, [arg1], [arg2]...)");
|
||||||
@ -2063,9 +2063,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
const iport = helper.getValidPort("getPortHandle", port);
|
const iport = helper.getValidPort("getPortHandle", port);
|
||||||
return iport;
|
return iport;
|
||||||
},
|
},
|
||||||
rm: function (_fn: unknown, _hostname: unknown): boolean {
|
rm: function (_fn: unknown, hostname: any): boolean {
|
||||||
const fn = helper.string("rm", "fn", _fn);
|
const fn = helper.string("rm", "fn", _fn);
|
||||||
let hostname = helper.string("rm", "hostname", _hostname);
|
|
||||||
updateDynamicRam("rm", getRamCost(Player, "rm"));
|
updateDynamicRam("rm", getRamCost(Player, "rm"));
|
||||||
|
|
||||||
if (hostname == null || hostname === "") {
|
if (hostname == null || hostname === "") {
|
||||||
@ -2123,9 +2122,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
},
|
},
|
||||||
getRunningScript: function (_fn: unknown, _hostname: unknown, ...args: any[]): IRunningScriptDef | null {
|
getRunningScript: function (fn: any, hostname: any, ...args: any[]): IRunningScriptDef | null {
|
||||||
const fn = helper.string("getRunningScript", "fn", _fn);
|
|
||||||
const hostname = helper.string("getRunningScript", "hostname", _hostname);
|
|
||||||
updateDynamicRam("getRunningScript", getRamCost(Player, "getRunningScript"));
|
updateDynamicRam("getRunningScript", getRamCost(Player, "getRunningScript"));
|
||||||
|
|
||||||
let runningScript;
|
let runningScript;
|
||||||
@ -2271,10 +2268,9 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
updateDynamicRam("alert", getRamCost(Player, "alert"));
|
updateDynamicRam("alert", getRamCost(Player, "alert"));
|
||||||
dialogBoxCreate(message);
|
dialogBoxCreate(message);
|
||||||
},
|
},
|
||||||
toast: function (_message: unknown, _variant: unknown = "success", _duration: unknown = 2000): void {
|
toast: function (_message: unknown, _variant: unknown = "success", duration: any = 2000): void {
|
||||||
const message = helper.string("toast", "message", _message);
|
const message = helper.string("toast", "message", _message);
|
||||||
const variant = helper.string("toast", "variant", _variant);
|
const variant = helper.string("toast", "variant", _variant);
|
||||||
const duration = helper.number("toast", "duration", _duration);
|
|
||||||
updateDynamicRam("toast", getRamCost(Player, "toast"));
|
updateDynamicRam("toast", getRamCost(Player, "toast"));
|
||||||
if (!["success", "info", "warning", "error"].includes(variant))
|
if (!["success", "info", "warning", "error"].includes(variant))
|
||||||
throw new Error(`variant must be one of "success", "info", "warning", or "error"`);
|
throw new Error(`variant must be one of "success", "info", "warning", or "error"`);
|
||||||
|
@ -230,14 +230,14 @@ export function NetscriptCorporation(
|
|||||||
return corporation;
|
return corporation;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDivision(divisionName: any): IIndustry {
|
function getDivision(divisionName: string): IIndustry {
|
||||||
const corporation = getCorporation();
|
const corporation = getCorporation();
|
||||||
const division = corporation.divisions.find((div) => div.name === divisionName);
|
const division = corporation.divisions.find((div) => div.name === divisionName);
|
||||||
if (division === undefined) throw new Error(`No division named '${divisionName}'`);
|
if (division === undefined) throw new Error(`No division named '${divisionName}'`);
|
||||||
return division;
|
return division;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getOffice(divisionName: any, cityName: any): OfficeSpace {
|
function getOffice(divisionName: string, cityName: string): OfficeSpace {
|
||||||
const division = getDivision(divisionName);
|
const division = getDivision(divisionName);
|
||||||
if (!(cityName in division.offices)) throw new Error(`Invalid city name '${cityName}'`);
|
if (!(cityName in division.offices)) throw new Error(`Invalid city name '${cityName}'`);
|
||||||
const office = division.offices[cityName];
|
const office = division.offices[cityName];
|
||||||
@ -245,7 +245,7 @@ export function NetscriptCorporation(
|
|||||||
return office;
|
return office;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getWarehouse(divisionName: any, cityName: any): Warehouse {
|
function getWarehouse(divisionName: string, cityName: string): Warehouse {
|
||||||
const division = getDivision(divisionName);
|
const division = getDivision(divisionName);
|
||||||
if (!(cityName in division.warehouses)) throw new Error(`Invalid city name '${cityName}'`);
|
if (!(cityName in division.warehouses)) throw new Error(`Invalid city name '${cityName}'`);
|
||||||
const warehouse = division.warehouses[cityName];
|
const warehouse = division.warehouses[cityName];
|
||||||
@ -253,7 +253,7 @@ export function NetscriptCorporation(
|
|||||||
return warehouse;
|
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 warehouse = getWarehouse(divisionName, cityName);
|
||||||
const matName = (materialName as string).replace(/ /g, "");
|
const matName = (materialName as string).replace(/ /g, "");
|
||||||
const material = warehouse.materials[matName];
|
const material = warehouse.materials[matName];
|
||||||
@ -261,14 +261,14 @@ export function NetscriptCorporation(
|
|||||||
return material;
|
return material;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getProduct(divisionName: any, productName: any): Product {
|
function getProduct(divisionName: string, productName: string): Product {
|
||||||
const division = getDivision(divisionName);
|
const division = getDivision(divisionName);
|
||||||
const product = division.products[productName];
|
const product = division.products[productName];
|
||||||
if (product === undefined) throw new Error(`Invalid product name: '${productName}'`);
|
if (product === undefined) throw new Error(`Invalid product name: '${productName}'`);
|
||||||
return product;
|
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 office = getOffice(divisionName, cityName);
|
||||||
const employee = office.employees.find((e) => e.name === employeeName);
|
const employee = office.employees.find((e) => e.name === employeeName);
|
||||||
if (employee === undefined) throw new Error(`Invalid employee 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 {
|
getUpgradeWarehouseCost: function (_divisionName: unknown, _cityName: unknown): number {
|
||||||
checkAccess("upgradeWarehouse", 7);
|
checkAccess("upgradeWarehouse", 7);
|
||||||
const divisionName = helper.string("getUpgradeWarehouseCost", "divisionName", _divisionName);
|
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);
|
const warehouse = getWarehouse(divisionName, cityName);
|
||||||
return CorporationConstants.WarehouseUpgradeBaseCost * Math.pow(1.07, warehouse.level + 1);
|
return CorporationConstants.WarehouseUpgradeBaseCost * Math.pow(1.07, warehouse.level + 1);
|
||||||
},
|
},
|
||||||
hasWarehouse: function (_divisionName: unknown, _cityName: unknown): boolean {
|
hasWarehouse: function (_divisionName: unknown, _cityName: unknown): boolean {
|
||||||
checkAccess("hasWarehouse", 7);
|
checkAccess("hasWarehouse", 7);
|
||||||
const divisionName = helper.string("getWarehouse", "divisionName", _divisionName);
|
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);
|
const division = getDivision(divisionName);
|
||||||
if (!(cityName in division.warehouses)) throw new Error(`Invalid city name '${cityName}'`);
|
if (!(cityName in division.warehouses)) throw new Error(`Invalid city name '${cityName}'`);
|
||||||
const warehouse = division.warehouses[cityName];
|
const warehouse = division.warehouses[cityName];
|
||||||
@ -330,7 +330,7 @@ export function NetscriptCorporation(
|
|||||||
getWarehouse: function (_divisionName: unknown, _cityName: unknown): NSWarehouse {
|
getWarehouse: function (_divisionName: unknown, _cityName: unknown): NSWarehouse {
|
||||||
checkAccess("getWarehouse", 7);
|
checkAccess("getWarehouse", 7);
|
||||||
const divisionName = helper.string("getWarehouse", "divisionName", _divisionName);
|
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);
|
const warehouse = getWarehouse(divisionName, cityName);
|
||||||
return {
|
return {
|
||||||
level: warehouse.level,
|
level: warehouse.level,
|
||||||
@ -343,7 +343,7 @@ export function NetscriptCorporation(
|
|||||||
getMaterial: function (_divisionName: unknown, _cityName: unknown, _materialName: unknown): NSMaterial {
|
getMaterial: function (_divisionName: unknown, _cityName: unknown, _materialName: unknown): NSMaterial {
|
||||||
checkAccess("getMaterial", 7);
|
checkAccess("getMaterial", 7);
|
||||||
const divisionName = helper.string("getMaterial", "divisionName", _divisionName);
|
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 materialName = helper.string("getMaterial", "materialName", _materialName);
|
||||||
const material = getMaterial(divisionName, cityName, materialName);
|
const material = getMaterial(divisionName, cityName, materialName);
|
||||||
return {
|
return {
|
||||||
@ -372,14 +372,14 @@ export function NetscriptCorporation(
|
|||||||
purchaseWarehouse: function (_divisionName: unknown, _cityName: unknown): void {
|
purchaseWarehouse: function (_divisionName: unknown, _cityName: unknown): void {
|
||||||
checkAccess("purchaseWarehouse", 7);
|
checkAccess("purchaseWarehouse", 7);
|
||||||
const divisionName = helper.string("purchaseWarehouse", "divisionName", _divisionName);
|
const divisionName = helper.string("purchaseWarehouse", "divisionName", _divisionName);
|
||||||
const cityName = helper.string("purchaseWarehouse", "cityName", _cityName);
|
const cityName = helper.city("purchaseWarehouse", "cityName", _cityName);
|
||||||
const corporation = getCorporation();
|
const corporation = getCorporation();
|
||||||
PurchaseWarehouse(corporation, getDivision(divisionName), cityName);
|
PurchaseWarehouse(corporation, getDivision(divisionName), cityName);
|
||||||
},
|
},
|
||||||
upgradeWarehouse: function (_divisionName: unknown, _cityName: unknown): void {
|
upgradeWarehouse: function (_divisionName: unknown, _cityName: unknown): void {
|
||||||
checkAccess("upgradeWarehouse", 7);
|
checkAccess("upgradeWarehouse", 7);
|
||||||
const divisionName = helper.string("upgradeWarehouse", "divisionName", _divisionName);
|
const divisionName = helper.string("upgradeWarehouse", "divisionName", _divisionName);
|
||||||
const cityName = helper.string("upgradeWarehouse", "cityName", _cityName);
|
const cityName = helper.city("upgradeWarehouse", "cityName", _cityName);
|
||||||
const corporation = getCorporation();
|
const corporation = getCorporation();
|
||||||
UpgradeWarehouse(corporation, getDivision(divisionName), getWarehouse(divisionName, cityName));
|
UpgradeWarehouse(corporation, getDivision(divisionName), getWarehouse(divisionName, cityName));
|
||||||
},
|
},
|
||||||
@ -392,7 +392,7 @@ export function NetscriptCorporation(
|
|||||||
): void {
|
): void {
|
||||||
checkAccess("sellMaterial", 7);
|
checkAccess("sellMaterial", 7);
|
||||||
const divisionName = helper.string("sellMaterial", "divisionName", _divisionName);
|
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 materialName = helper.string("sellMaterial", "materialName", _materialName);
|
||||||
const amt = helper.string("sellMaterial", "amt", _amt);
|
const amt = helper.string("sellMaterial", "amt", _amt);
|
||||||
const price = helper.string("sellMaterial", "price", _price);
|
const price = helper.string("sellMaterial", "price", _price);
|
||||||
@ -409,7 +409,7 @@ export function NetscriptCorporation(
|
|||||||
): void {
|
): void {
|
||||||
checkAccess("sellProduct", 7);
|
checkAccess("sellProduct", 7);
|
||||||
const divisionName = helper.string("sellProduct", "divisionName", _divisionName);
|
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 productName = helper.string("sellProduct", "productName", _productName);
|
||||||
const amt = helper.string("sellProduct", "amt", _amt);
|
const amt = helper.string("sellProduct", "amt", _amt);
|
||||||
const price = helper.string("sellProduct", "price", _price);
|
const price = helper.string("sellProduct", "price", _price);
|
||||||
@ -426,7 +426,7 @@ export function NetscriptCorporation(
|
|||||||
setSmartSupply: function (_divisionName: unknown, _cityName: unknown, _enabled: unknown): void {
|
setSmartSupply: function (_divisionName: unknown, _cityName: unknown, _enabled: unknown): void {
|
||||||
checkAccess("setSmartSupply", 7);
|
checkAccess("setSmartSupply", 7);
|
||||||
const divisionName = helper.string("setSmartSupply", "divisionName", _divisionName);
|
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 enabled = helper.boolean(_enabled);
|
||||||
const warehouse = getWarehouse(divisionName, cityName);
|
const warehouse = getWarehouse(divisionName, cityName);
|
||||||
if (!hasUnlockUpgrade("Smart Supply"))
|
if (!hasUnlockUpgrade("Smart Supply"))
|
||||||
@ -444,7 +444,7 @@ export function NetscriptCorporation(
|
|||||||
): void {
|
): void {
|
||||||
checkAccess("setSmartSupplyUseLeftovers", 7);
|
checkAccess("setSmartSupplyUseLeftovers", 7);
|
||||||
const divisionName = helper.string("setSmartSupply", "divisionName", _divisionName);
|
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 materialName = helper.string("sellProduct", "materialName", _materialName);
|
||||||
const enabled = helper.boolean(_enabled);
|
const enabled = helper.boolean(_enabled);
|
||||||
const warehouse = getWarehouse(divisionName, cityName);
|
const warehouse = getWarehouse(divisionName, cityName);
|
||||||
@ -459,7 +459,7 @@ export function NetscriptCorporation(
|
|||||||
buyMaterial: function (_divisionName: unknown, _cityName: unknown, _materialName: unknown, _amt: unknown): void {
|
buyMaterial: function (_divisionName: unknown, _cityName: unknown, _materialName: unknown, _amt: unknown): void {
|
||||||
checkAccess("buyMaterial", 7);
|
checkAccess("buyMaterial", 7);
|
||||||
const divisionName = helper.string("buyMaterial", "divisionName", _divisionName);
|
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 materialName = helper.string("buyMaterial", "materialName", _materialName);
|
||||||
const amt = helper.number("buyMaterial", "amt", _amt);
|
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");
|
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 {
|
bulkPurchase: function (_divisionName: unknown, _cityName: unknown, _materialName: unknown, _amt: unknown): void {
|
||||||
checkAccess("bulkPurchase", 7);
|
checkAccess("bulkPurchase", 7);
|
||||||
const divisionName = helper.string("bulkPurchase", "divisionName", _divisionName);
|
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}`);
|
throw new Error(`You have not researched Bulk Purchasing in ${divisionName}`);
|
||||||
const corporation = getCorporation();
|
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 materialName = helper.string("bulkPurchase", "materialName", _materialName);
|
||||||
const amt = helper.number("bulkPurchase", "amt", _amt);
|
const amt = helper.number("bulkPurchase", "amt", _amt);
|
||||||
const warehouse = getWarehouse(divisionName, cityName);
|
const warehouse = getWarehouse(divisionName, cityName);
|
||||||
@ -488,7 +488,7 @@ export function NetscriptCorporation(
|
|||||||
): void {
|
): void {
|
||||||
checkAccess("makeProduct", 7);
|
checkAccess("makeProduct", 7);
|
||||||
const divisionName = helper.string("makeProduct", "divisionName", _divisionName);
|
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 productName = helper.string("makeProduct", "productName", _productName);
|
||||||
const designInvest = helper.number("makeProduct", "designInvest", _designInvest);
|
const designInvest = helper.number("makeProduct", "designInvest", _designInvest);
|
||||||
const marketingInvest = helper.number("makeProduct", "marketingInvest", _marketingInvest);
|
const marketingInvest = helper.number("makeProduct", "marketingInvest", _marketingInvest);
|
||||||
@ -543,7 +543,7 @@ export function NetscriptCorporation(
|
|||||||
): void {
|
): void {
|
||||||
checkAccess("setMaterialMarketTA1", 7);
|
checkAccess("setMaterialMarketTA1", 7);
|
||||||
const divisionName = helper.string("setMaterialMarketTA1", "divisionName", _divisionName);
|
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 materialName = helper.string("setMaterialMarketTA1", "materialName", _materialName);
|
||||||
const on = helper.boolean(_on);
|
const on = helper.boolean(_on);
|
||||||
if (!getDivision(divisionName).hasResearch("Market-TA.I"))
|
if (!getDivision(divisionName).hasResearch("Market-TA.I"))
|
||||||
@ -561,7 +561,7 @@ export function NetscriptCorporation(
|
|||||||
): void {
|
): void {
|
||||||
checkAccess("setMaterialMarketTA2", 7);
|
checkAccess("setMaterialMarketTA2", 7);
|
||||||
const divisionName = helper.string("setMaterialMarketTA2", "divisionName", _divisionName);
|
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 materialName = helper.string("setMaterialMarketTA2", "materialName", _materialName);
|
||||||
const on = helper.boolean(_on);
|
const on = helper.boolean(_on);
|
||||||
if (!getDivision(divisionName).hasResearch("Market-TA.II"))
|
if (!getDivision(divisionName).hasResearch("Market-TA.II"))
|
||||||
@ -631,7 +631,7 @@ export function NetscriptCorporation(
|
|||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
checkAccess("setAutoJobAssignment", 8);
|
checkAccess("setAutoJobAssignment", 8);
|
||||||
const divisionName = helper.string("setAutoJobAssignment", "divisionName", _divisionName);
|
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 amount = helper.number("setAutoJobAssignment", "amount", _amount);
|
||||||
const job = helper.string("setAutoJobAssignment", "job", _job);
|
const job = helper.string("setAutoJobAssignment", "job", _job);
|
||||||
const office = getOffice(divisionName, cityName);
|
const office = getOffice(divisionName, cityName);
|
||||||
@ -646,7 +646,7 @@ export function NetscriptCorporation(
|
|||||||
getOfficeSizeUpgradeCost: function (_divisionName: unknown, _cityName: unknown, _size: unknown): number {
|
getOfficeSizeUpgradeCost: function (_divisionName: unknown, _cityName: unknown, _size: unknown): number {
|
||||||
checkAccess("getOfficeSizeUpgradeCost", 8);
|
checkAccess("getOfficeSizeUpgradeCost", 8);
|
||||||
const divisionName = helper.string("getOfficeSizeUpgradeCost", "divisionName", _divisionName);
|
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);
|
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");
|
if (size < 0) throw new Error("Invalid value for size field! Must be numeric and greater than 0");
|
||||||
const office = getOffice(divisionName, cityName);
|
const office = getOffice(divisionName, cityName);
|
||||||
@ -666,7 +666,7 @@ export function NetscriptCorporation(
|
|||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
checkAccess("assignJob", 8);
|
checkAccess("assignJob", 8);
|
||||||
const divisionName = helper.string("assignJob", "divisionName", _divisionName);
|
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 employeeName = helper.string("assignJob", "employeeName", _employeeName);
|
||||||
const job = helper.string("assignJob", "job", _job);
|
const job = helper.string("assignJob", "job", _job);
|
||||||
const employee = getEmployee(divisionName, cityName, employeeName);
|
const employee = getEmployee(divisionName, cityName, employeeName);
|
||||||
@ -677,14 +677,14 @@ export function NetscriptCorporation(
|
|||||||
hireEmployee: function (_divisionName: unknown, _cityName: unknown): any {
|
hireEmployee: function (_divisionName: unknown, _cityName: unknown): any {
|
||||||
checkAccess("hireEmployee", 8);
|
checkAccess("hireEmployee", 8);
|
||||||
const divisionName = helper.string("hireEmployee", "divisionName", _divisionName);
|
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);
|
const office = getOffice(divisionName, cityName);
|
||||||
return office.hireRandomEmployee();
|
return office.hireRandomEmployee();
|
||||||
},
|
},
|
||||||
upgradeOfficeSize: function (_divisionName: unknown, _cityName: unknown, _size: unknown): void {
|
upgradeOfficeSize: function (_divisionName: unknown, _cityName: unknown, _size: unknown): void {
|
||||||
checkAccess("upgradeOfficeSize", 8);
|
checkAccess("upgradeOfficeSize", 8);
|
||||||
const divisionName = helper.string("upgradeOfficeSize", "divisionName", _divisionName);
|
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);
|
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");
|
if (size < 0) throw new Error("Invalid value for size field! Must be numeric and greater than 0");
|
||||||
const office = getOffice(divisionName, cityName);
|
const office = getOffice(divisionName, cityName);
|
||||||
@ -694,7 +694,7 @@ export function NetscriptCorporation(
|
|||||||
throwParty: function (_divisionName: unknown, _cityName: unknown, _costPerEmployee: unknown): Promise<number> {
|
throwParty: function (_divisionName: unknown, _cityName: unknown, _costPerEmployee: unknown): Promise<number> {
|
||||||
checkAccess("throwParty", 8);
|
checkAccess("throwParty", 8);
|
||||||
const divisionName = helper.string("throwParty", "divisionName", _divisionName);
|
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);
|
const costPerEmployee = helper.number("throwParty", "costPerEmployee", _costPerEmployee);
|
||||||
if (costPerEmployee < 0)
|
if (costPerEmployee < 0)
|
||||||
throw new Error("Invalid value for Cost Per Employee field! Must be numeric and greater than 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> {
|
buyCoffee: function (_divisionName: unknown, _cityName: unknown): Promise<void> {
|
||||||
checkAccess("buyCoffee", 8);
|
checkAccess("buyCoffee", 8);
|
||||||
const divisionName = helper.string("buyCoffee", "divisionName", _divisionName);
|
const divisionName = helper.string("buyCoffee", "divisionName", _divisionName);
|
||||||
const cityName = helper.string("buyCoffee", "cityName", _cityName);
|
const cityName = helper.city("buyCoffee", "cityName", _cityName);
|
||||||
const corporation = getCorporation();
|
const corporation = getCorporation();
|
||||||
return netscriptDelay(
|
return netscriptDelay(
|
||||||
(60 * 1000) / (player.hacking_speed_mult * calculateIntelligenceBonus(player.intelligence, 1)),
|
(60 * 1000) / (player.hacking_speed_mult * calculateIntelligenceBonus(player.intelligence, 1)),
|
||||||
@ -734,7 +734,7 @@ export function NetscriptCorporation(
|
|||||||
getOffice: function (_divisionName: unknown, _cityName: unknown): any {
|
getOffice: function (_divisionName: unknown, _cityName: unknown): any {
|
||||||
checkAccess("getOffice", 8);
|
checkAccess("getOffice", 8);
|
||||||
const divisionName = helper.string("getOffice", "divisionName", _divisionName);
|
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);
|
const office = getOffice(divisionName, cityName);
|
||||||
return {
|
return {
|
||||||
loc: office.loc,
|
loc: office.loc,
|
||||||
@ -758,7 +758,7 @@ export function NetscriptCorporation(
|
|||||||
getEmployee: function (_divisionName: unknown, _cityName: unknown, _employeeName: unknown): NSEmployee {
|
getEmployee: function (_divisionName: unknown, _cityName: unknown, _employeeName: unknown): NSEmployee {
|
||||||
checkAccess("getEmployee", 8);
|
checkAccess("getEmployee", 8);
|
||||||
const divisionName = helper.string("getEmployee", "divisionName", _divisionName);
|
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 employeeName = helper.string("getEmployee", "employeeName", _employeeName);
|
||||||
const employee = getEmployee(divisionName, cityName, employeeName);
|
const employee = getEmployee(divisionName, cityName, employeeName);
|
||||||
return {
|
return {
|
||||||
@ -791,7 +791,7 @@ export function NetscriptCorporation(
|
|||||||
expandCity: function (_divisionName: unknown, _cityName: unknown): void {
|
expandCity: function (_divisionName: unknown, _cityName: unknown): void {
|
||||||
checkAccess("expandCity");
|
checkAccess("expandCity");
|
||||||
const divisionName = helper.string("expandCity", "divisionName", _divisionName);
|
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");
|
if (!CorporationConstants.Cities.includes(cityName)) throw new Error("Invalid city name");
|
||||||
const corporation = getCorporation();
|
const corporation = getCorporation();
|
||||||
const division = getDivision(divisionName);
|
const division = getDivision(divisionName);
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { CityName } from "src/Locations/data/CityNames";
|
||||||
import { BaseServer } from "../Server/BaseServer";
|
import { BaseServer } from "../Server/BaseServer";
|
||||||
|
|
||||||
export interface INetscriptHelper {
|
export interface INetscriptHelper {
|
||||||
@ -5,6 +6,7 @@ export interface INetscriptHelper {
|
|||||||
makeRuntimeErrorMsg(functionName: string, message: string): void;
|
makeRuntimeErrorMsg(functionName: string, message: string): void;
|
||||||
string(funcName: string, argName: string, v: unknown): string;
|
string(funcName: string, argName: string, v: unknown): string;
|
||||||
number(funcName: string, argName: string, v: unknown): number;
|
number(funcName: string, argName: string, v: unknown): number;
|
||||||
|
city(funcName: string, argName: string, v: unknown): CityName;
|
||||||
boolean(v: unknown): boolean;
|
boolean(v: unknown): boolean;
|
||||||
getServer(ip: any, fn: any): BaseServer;
|
getServer(ip: any, fn: any): BaseServer;
|
||||||
checkSingularityAccess(func: string): void;
|
checkSingularityAccess(func: string): void;
|
||||||
|
@ -504,7 +504,7 @@ export function NetscriptSingularity(
|
|||||||
},
|
},
|
||||||
|
|
||||||
travelToCity: function (_cityName: unknown): boolean {
|
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.updateDynamicRam("travelToCity", getRamCost(player, "travelToCity"));
|
||||||
helper.checkSingularityAccess("travelToCity");
|
helper.checkSingularityAccess("travelToCity");
|
||||||
|
|
||||||
|
@ -26,6 +26,6 @@ export class GraftableAugmentation {
|
|||||||
const antiLog = Math.max(sum(Object.values(this.augmentation.mults)), 1);
|
const antiLog = Math.max(sum(Object.values(this.augmentation.mults)), 1);
|
||||||
|
|
||||||
const mult = Math.log2(antiLog);
|
const mult = Math.log2(antiLog);
|
||||||
return CONSTANTS.AugmentationGraftingTimeBase * mult + CONSTANTS.MillisecondsPerHalfHour;
|
return (CONSTANTS.AugmentationGraftingTimeBase * mult + CONSTANTS.MillisecondsPerHalfHour) / 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,74 +64,78 @@ export const GraftingRoot = (): React.ReactElement => {
|
|||||||
|
|
||||||
<Box sx={{ my: 3 }}>
|
<Box sx={{ my: 3 }}>
|
||||||
<Typography variant="h5">Graft Augmentations</Typography>
|
<Typography variant="h5">Graft Augmentations</Typography>
|
||||||
<Paper sx={{ my: 1, width: "fit-content", display: "grid", gridTemplateColumns: "1fr 3fr" }}>
|
{getAvailableAugs(player).length > 0 ? (
|
||||||
<List sx={{ maxHeight: 400, overflowY: "scroll", borderRight: `1px solid ${Settings.theme.welllight}` }}>
|
<Paper sx={{ my: 1, width: "fit-content", display: "grid", gridTemplateColumns: "1fr 3fr" }}>
|
||||||
{getAvailableAugs(player).map((k, i) => (
|
<List sx={{ maxHeight: 400, overflowY: "scroll", borderRight: `1px solid ${Settings.theme.welllight}` }}>
|
||||||
<ListItemButton key={i + 1} onClick={() => setSelectedAug(k)} selected={selectedAug === k}>
|
{getAvailableAugs(player).map((k, i) => (
|
||||||
<Typography>{k}</Typography>
|
<ListItemButton key={i + 1} onClick={() => setSelectedAug(k)} selected={selectedAug === k}>
|
||||||
</ListItemButton>
|
<Typography>{k}</Typography>
|
||||||
))}
|
</ListItemButton>
|
||||||
</List>
|
))}
|
||||||
<Box sx={{ m: 1 }}>
|
</List>
|
||||||
<Typography variant="h6" sx={{ display: "flex", alignItems: "center", flexWrap: "wrap" }}>
|
<Box sx={{ m: 1 }}>
|
||||||
<Construction sx={{ mr: 1 }} /> {selectedAug}
|
<Typography variant="h6" sx={{ display: "flex", alignItems: "center", flexWrap: "wrap" }}>
|
||||||
</Typography>
|
<Construction sx={{ mr: 1 }} /> {selectedAug}
|
||||||
<Button
|
|
||||||
onClick={() => setGraftOpen(true)}
|
|
||||||
sx={{ width: "100%" }}
|
|
||||||
disabled={player.money < GraftableAugmentations[selectedAug].cost}
|
|
||||||
>
|
|
||||||
Graft Augmentation (
|
|
||||||
<Typography>
|
|
||||||
<Money money={GraftableAugmentations[selectedAug].cost} player={player} />
|
|
||||||
</Typography>
|
</Typography>
|
||||||
)
|
<Button
|
||||||
</Button>
|
onClick={() => setGraftOpen(true)}
|
||||||
<ConfirmationModal
|
sx={{ width: "100%" }}
|
||||||
open={graftOpen}
|
disabled={player.money < GraftableAugmentations[selectedAug].cost}
|
||||||
onClose={() => setGraftOpen(false)}
|
>
|
||||||
onConfirm={() => {
|
Graft Augmentation (
|
||||||
const graftableAug = GraftableAugmentations[selectedAug];
|
<Typography>
|
||||||
player.loseMoney(graftableAug.cost, "augmentations");
|
<Money money={GraftableAugmentations[selectedAug].cost} player={player} />
|
||||||
player.startGraftAugmentationWork(selectedAug, graftableAug.time);
|
</Typography>
|
||||||
player.startFocusing();
|
)
|
||||||
router.toWork();
|
</Button>
|
||||||
}}
|
<ConfirmationModal
|
||||||
confirmationText={
|
open={graftOpen}
|
||||||
<>
|
onClose={() => setGraftOpen(false)}
|
||||||
Cancelling grafting will <b>not</b> save grafting progress, and the money you spend will <b>not</b> be
|
onConfirm={() => {
|
||||||
returned.
|
const graftableAug = GraftableAugmentations[selectedAug];
|
||||||
<br />
|
player.loseMoney(graftableAug.cost, "augmentations");
|
||||||
<br />
|
player.startGraftAugmentationWork(selectedAug, graftableAug.time);
|
||||||
Additionally, grafting an Augmentation will increase the potency of the Entropy virus.
|
player.startFocusing();
|
||||||
</>
|
router.toWork();
|
||||||
}
|
}}
|
||||||
/>
|
confirmationText={
|
||||||
<Typography color={Settings.theme.info}>
|
|
||||||
<b>Time to Graft:</b>{" "}
|
|
||||||
{convertTimeMsToTimeElapsedString(
|
|
||||||
GraftableAugmentations[selectedAug].time / (1 + (player.getIntelligenceBonus(3) - 1) / 3),
|
|
||||||
)}
|
|
||||||
{/* Use formula so the displayed creation time is accurate to player bonus */}
|
|
||||||
</Typography>
|
|
||||||
<Typography sx={{ maxHeight: 305, overflowY: "scroll" }}>
|
|
||||||
{(() => {
|
|
||||||
const aug = Augmentations[selectedAug];
|
|
||||||
|
|
||||||
const info = typeof aug.info === "string" ? <span>{aug.info}</span> : aug.info;
|
|
||||||
const tooltip = (
|
|
||||||
<>
|
<>
|
||||||
{info}
|
Cancelling grafting will <b>not</b> save grafting progress, and the money you spend will <b>not</b>{" "}
|
||||||
|
be returned.
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
{aug.stats}
|
Additionally, grafting an Augmentation will increase the potency of the Entropy virus.
|
||||||
</>
|
</>
|
||||||
);
|
}
|
||||||
return tooltip;
|
/>
|
||||||
})()}
|
<Typography color={Settings.theme.info}>
|
||||||
</Typography>
|
<b>Time to Graft:</b>{" "}
|
||||||
</Box>
|
{convertTimeMsToTimeElapsedString(
|
||||||
</Paper>
|
GraftableAugmentations[selectedAug].time / (1 + (player.getIntelligenceBonus(3) - 1) / 3),
|
||||||
|
)}
|
||||||
|
{/* Use formula so the displayed creation time is accurate to player bonus */}
|
||||||
|
</Typography>
|
||||||
|
<Typography sx={{ maxHeight: 305, overflowY: "scroll" }}>
|
||||||
|
{(() => {
|
||||||
|
const aug = Augmentations[selectedAug];
|
||||||
|
|
||||||
|
const info = typeof aug.info === "string" ? <span>{aug.info}</span> : aug.info;
|
||||||
|
const tooltip = (
|
||||||
|
<>
|
||||||
|
{info}
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
{aug.stats}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
return tooltip;
|
||||||
|
})()}
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
</Paper>
|
||||||
|
) : (
|
||||||
|
<Typography>All Augmentations owned</Typography>
|
||||||
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
<Box sx={{ my: 3 }}>
|
<Box sx={{ my: 3 }}>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { FactionNames } from './Faction/data/FactionNames';
|
import { FactionNames } from "./Faction/data/FactionNames";
|
||||||
import { CityName } from './Locations/data/CityNames';
|
import { CityName } from "./Locations/data/CityNames";
|
||||||
import { Augmentations } from "./Augmentation/Augmentations";
|
import { Augmentations } from "./Augmentation/Augmentations";
|
||||||
import { augmentationExists, initAugmentations } from "./Augmentation/AugmentationHelpers";
|
import { augmentationExists, initAugmentations } from "./Augmentation/AugmentationHelpers";
|
||||||
import { AugmentationNames } from "./Augmentation/data/AugmentationNames";
|
import { AugmentationNames } from "./Augmentation/data/AugmentationNames";
|
||||||
@ -263,7 +263,7 @@ export function prestigeSourceFile(flume: boolean): void {
|
|||||||
homeComp.messages.push(LiteratureNames.CorporationManagementHandbook);
|
homeComp.messages.push(LiteratureNames.CorporationManagementHandbook);
|
||||||
dialogBoxCreate(
|
dialogBoxCreate(
|
||||||
"You received a copy of the Corporation Management Handbook on your home computer. " +
|
"You received a copy of the Corporation Management Handbook on your home computer. " +
|
||||||
"Read it if you need help getting started with Corporations!",
|
"Read it if you need help getting started with Corporations!",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ function isNs2(filename: string): boolean {
|
|||||||
return filename.endsWith(".ns") || filename.endsWith(".js");
|
return filename.endsWith(".ns") || filename.endsWith(".js");
|
||||||
}
|
}
|
||||||
|
|
||||||
const newNs2Template = `/** @param {NS} ns **/
|
const newNs2Template = `/** @param {NS} ns */
|
||||||
export async function main(ns) {
|
export async function main(ns) {
|
||||||
|
|
||||||
}`;
|
}`;
|
||||||
|
@ -217,11 +217,19 @@ export function WorkInProgressRoot(): React.ReactElement {
|
|||||||
|
|
||||||
if (player.workType == CONSTANTS.WorkTypeCompany) {
|
if (player.workType == CONSTANTS.WorkTypeCompany) {
|
||||||
const comp = Companies[player.companyName];
|
const comp = Companies[player.companyName];
|
||||||
let companyRep = 0;
|
|
||||||
if (comp == null || !(comp instanceof Company)) {
|
if (comp == null || !(comp instanceof Company)) {
|
||||||
throw new Error(`Could not find Company: ${player.companyName}`);
|
return (
|
||||||
|
<>
|
||||||
|
<Typography variant="h4" color="primary">
|
||||||
|
You cannot work for {player.companyName || "(Company not found)"} at this time, please try again if you
|
||||||
|
think this should have worked
|
||||||
|
</Typography>
|
||||||
|
<Button onClick={() => router.toTerminal()}>Back to Terminal</Button>
|
||||||
|
</>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
companyRep = comp.playerReputation;
|
|
||||||
|
const companyRep = comp.playerReputation;
|
||||||
|
|
||||||
function cancel(): void {
|
function cancel(): void {
|
||||||
player.finishWork(true);
|
player.finishWork(true);
|
||||||
|
@ -8,7 +8,7 @@ jest.mock(`!!raw-loader!../NetscriptDefinitions.d.ts`, () => "", {
|
|||||||
virtual: true,
|
virtual: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
const code = `/** @param {NS} ns **/
|
const code = `/** @param {NS} ns */
|
||||||
export async function main(ns) {
|
export async function main(ns) {
|
||||||
ns.print(ns.getWeakenTime('n00dles'));
|
ns.print(ns.getWeakenTime('n00dles'));
|
||||||
}`;
|
}`;
|
||||||
|
Loading…
Reference in New Issue
Block a user