mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-22 15:43:49 +01:00
commit
181b7f39e5
163
dist/bitburner.d.ts
vendored
163
dist/bitburner.d.ts
vendored
@ -826,6 +826,30 @@ export declare interface CodingContract {
|
||||
getNumTriesRemaining(filename: string, host?: string): number;
|
||||
}
|
||||
|
||||
export declare interface Corporation extends WarehouseAPI, OfficeAPI {
|
||||
getCorporation(): CorporationInfo;
|
||||
getDivision(divisionName: string): Division;
|
||||
expandIndustry(industryName: string, divisionName: string): void;
|
||||
expandCity(divisionName: string, cityName: string): void;
|
||||
unlockUpgrade(upgradeName: string): void;
|
||||
levelUpgrade(upgradeName: string): void;
|
||||
issueDividends(percent: number): void;
|
||||
}
|
||||
|
||||
export declare interface CorporationInfo {
|
||||
name: string;
|
||||
funds: number;
|
||||
revenue: number;
|
||||
expenses: number;
|
||||
public: boolean;
|
||||
totalShares: number;
|
||||
numShares: number;
|
||||
shareSaleCooldown: number;
|
||||
issuedShares: number;
|
||||
sharePrice: number;
|
||||
state: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Data representing the internal values of a crime.
|
||||
* @public
|
||||
@ -873,6 +897,46 @@ export declare interface CrimeStats {
|
||||
intelligence_exp: number;
|
||||
}
|
||||
|
||||
export declare interface Division {
|
||||
name: string;
|
||||
type: string;
|
||||
awareness: number;
|
||||
popularity: number;
|
||||
prodMult: number;
|
||||
research: number;
|
||||
lastCycleRevenue: number;
|
||||
lastCycleExpenses: number;
|
||||
thisCycleRevenue: number;
|
||||
thisCycleExpenses: number;
|
||||
upgrades: number[];
|
||||
cities: string[];
|
||||
}
|
||||
|
||||
export declare interface Employee {
|
||||
name: string;
|
||||
mor: number;
|
||||
hap: number;
|
||||
ene: number;
|
||||
int: number;
|
||||
cha: number;
|
||||
exp: number;
|
||||
cre: number;
|
||||
eff: number;
|
||||
sal: number;
|
||||
loc: string;
|
||||
pos: string;
|
||||
}
|
||||
|
||||
export declare interface EmployeeJobs {
|
||||
Operations: number;
|
||||
Engineer: number;
|
||||
Business: number;
|
||||
Management: number;
|
||||
"Research & Development": number;
|
||||
Training: number;
|
||||
Unassigned: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Object representing data representing a gang member equipment.
|
||||
* @public
|
||||
@ -1716,6 +1780,12 @@ export declare interface HacknetServersFormulas {
|
||||
constants(): any;
|
||||
}
|
||||
|
||||
export declare interface Material {
|
||||
name: string;
|
||||
qty: number;
|
||||
qlt: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Object representing all the values related to a hacknet node.
|
||||
* @public
|
||||
@ -1784,7 +1854,6 @@ export declare interface NS extends Singularity {
|
||||
* RAM cost: 0 GB
|
||||
*/
|
||||
readonly stock: TIX;
|
||||
|
||||
/**
|
||||
*
|
||||
* Namespace for formulas functions.
|
||||
@ -1797,6 +1866,11 @@ export declare interface NS extends Singularity {
|
||||
* RAM cost: 0 GB
|
||||
*/
|
||||
readonly stanek: Stanek;
|
||||
/**
|
||||
* Namespace for corporation functions.
|
||||
* RAM cost: 0 GB
|
||||
*/
|
||||
readonly corporation: Corporation;
|
||||
|
||||
/**
|
||||
* Arguments passed into the script.
|
||||
@ -3406,6 +3480,31 @@ export declare interface NS extends Singularity {
|
||||
flags(schema: [string, string | number | boolean | string[]][]): any;
|
||||
}
|
||||
|
||||
export declare interface Office {
|
||||
loc: string;
|
||||
size: number;
|
||||
minEne: number;
|
||||
maxEne: number;
|
||||
minHap: number;
|
||||
maxHap: number;
|
||||
maxMor: number;
|
||||
employees: string[];
|
||||
employeeProd: EmployeeJobs;
|
||||
}
|
||||
|
||||
export declare interface OfficeAPI {
|
||||
employees(divisionName: string, cityName: string): string[];
|
||||
assignJob(divisionName: string, cityName: string, employeeName: string, job: string): Promise<void>;
|
||||
hireEmployee(divisionName: string, cityName: string): Employee;
|
||||
upgradeOfficeSize(divisionName: string, cityName: string, size: number): void;
|
||||
throwParty(divisionName: string, cityName: string, costPerEmployee: number): Promise<number>;
|
||||
buyCoffee(divisionName: string, cityName: string): Promise<void>;
|
||||
hireAdVert(divisionName: string): void;
|
||||
research(divisionName: string, researchName: string): void;
|
||||
getOffice(divisionName: string, cityName: string): Office;
|
||||
getEmployee(divisionName: string, cityName: string, employeeName: string): Employee;
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
@ -3532,6 +3631,14 @@ export declare interface ProcessInfo {
|
||||
args: string[];
|
||||
}
|
||||
|
||||
export declare interface Product {
|
||||
name: string;
|
||||
dmd: number;
|
||||
cmp: number;
|
||||
pCost: number;
|
||||
sCost: string | number;
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
@ -5134,4 +5241,58 @@ export declare interface TIX {
|
||||
purchase4SMarketDataTixApi(): boolean;
|
||||
}
|
||||
|
||||
export declare interface Warehouse {
|
||||
level: number;
|
||||
loc: string;
|
||||
size: number;
|
||||
sizeUsed: number;
|
||||
}
|
||||
|
||||
export declare interface WarehouseAPI {
|
||||
sellMaterial(divisionName: string, cityName: string, materialName: string, amt: number, price: number): void;
|
||||
sellProduct(
|
||||
divisionName: string,
|
||||
cityName: string,
|
||||
productName: string,
|
||||
amt: number,
|
||||
price: number,
|
||||
all: boolean,
|
||||
): void;
|
||||
discontinueProduct(divisionName: string, productName: string): void;
|
||||
setSmartSupply(divisionName: string, cityName: string, enabled: boolean): void;
|
||||
buyMaterial(divisionName: string, cityName: string, materialName: string, amt: number): void;
|
||||
getWarehouse(divisionName: string, cityName: string): Warehouse;
|
||||
getProduct(divisionName: string, productName: string): Product;
|
||||
getMaterial(divisionName: string, cityName: string, materialName: string): Material;
|
||||
setMaterialMarketTA1(divisionName: string, cityName: string, materialName: string, on: boolean): void;
|
||||
setMaterialMarketTA2(divisionName: string, cityName: string, materialName: string, on: boolean): void;
|
||||
setProductMarketTA1(divisionName: string, productName: string, on: boolean): void;
|
||||
setProductMarketTA2(divisionName: string, productName: string, on: boolean): void;
|
||||
exportMaterial(
|
||||
sourceDivision: string,
|
||||
sourceCity: string,
|
||||
targetDivision: string,
|
||||
targetCity: string,
|
||||
materialName: string,
|
||||
amt: number,
|
||||
): void;
|
||||
cancelExportMaterial(
|
||||
sourceDivision: string,
|
||||
sourceCity: string,
|
||||
targetDivision: string,
|
||||
targetCity: string,
|
||||
materialName: string,
|
||||
amt: number,
|
||||
): void;
|
||||
purchaseWarehouse(divisionName: string, cityName: string): void;
|
||||
upgradeWarehouse(divisionName: string, cityName: string): void;
|
||||
makeProduct(
|
||||
divisionName: string,
|
||||
cityName: string,
|
||||
productName: string,
|
||||
designInvest: number,
|
||||
marketingInvest: number,
|
||||
): void;
|
||||
}
|
||||
|
||||
export { }
|
||||
|
26
dist/vendor.bundle.js
vendored
26
dist/vendor.bundle.js
vendored
File diff suppressed because one or more lines are too long
@ -16,6 +16,10 @@ v1.1.0 - 2021-12-03 BN13: They're Lunatics (hydroflame & community)
|
||||
* 94 achievements added
|
||||
* Release is 2021-12-10.
|
||||
|
||||
** Corporation API **
|
||||
|
||||
* Added corporation API. (Unstable)
|
||||
|
||||
** Netscript **
|
||||
|
||||
* tprintf crashes when not giving a format as first arg.
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1544
markdown/bitburner.api.md
Normal file
1544
markdown/bitburner.api.md
Normal file
File diff suppressed because it is too large
Load Diff
@ -205,8 +205,8 @@ BitNodes["BitNode5"] = new BitNode(
|
||||
experience is much slower than other stats, and it is also hidden (you won't know when you gain experience and how
|
||||
much). Higher Intelligence levels will boost your production for many actions in the game. <br />
|
||||
<br />
|
||||
In addition, this Source-File will unlock the getBitNodeMultipliers() and getServer() Netscript functions, as well
|
||||
as the formulas API, and will also raise all of your hacking-related multipliers by:
|
||||
In addition, this Source-File will unlock the getBitNodeMultipliers() Netscript function and let you start with
|
||||
Formulas.exe, and will also raise all of your hacking-related multipliers by:
|
||||
<br />
|
||||
<br />
|
||||
Level 1: 8%
|
||||
|
@ -94,7 +94,7 @@ export const BlackOperations: {
|
||||
<>
|
||||
The CIA has just encountered a new security threat. A new criminal group, lead by a shadowy operative who calls
|
||||
himself Juggernaut, has been smuggling drugs and weapons (including suspected bioweapons) into Sector-12. We
|
||||
also have reason to believe the tried to break into one of Universal Energy's facilities in order to cause a
|
||||
also have reason to believe they tried to break into one of Universal Energy's facilities in order to cause a
|
||||
city-wide blackout. The CIA suspects that Juggernaut is a heavily-augmented Synthoid, and have thus enlisted our
|
||||
help.
|
||||
<br />
|
||||
@ -126,9 +126,9 @@ export const BlackOperations: {
|
||||
be catastrophic.
|
||||
<br />
|
||||
<br />
|
||||
We do not have the power or jurisdiction to shutdown this down through legal or political means, so we must
|
||||
resort to a covert operation. Your goal is to destroy this technology and eliminate anyone who was involved in
|
||||
its creation.
|
||||
We do not have the power or jurisdiction to shut this down through legal or political means, so we must resort
|
||||
to a covert operation. Your goal is to destroy this technology and eliminate anyone who was involved in its
|
||||
creation.
|
||||
</>
|
||||
),
|
||||
},
|
||||
@ -149,8 +149,8 @@ export const BlackOperations: {
|
||||
"Operation Tyrell": {
|
||||
desc: (
|
||||
<>
|
||||
A week ago Blade Industries reported a small break-in at one of their Aevum Augmentation storage facitilities.
|
||||
We figured out that The Dark Army was behind the heist, and didn't think any more of it. However, we've just
|
||||
A week ago Blade Industries reported a small break-in at one of their Aevum Augmentation storage facilities. We
|
||||
figured out that The Dark Army was behind the heist, and didn't think any more of it. However, we've just
|
||||
discovered that several known MK-VI Synthoids were part of that break-in group.
|
||||
<br />
|
||||
<br />
|
||||
@ -209,12 +209,12 @@ export const BlackOperations: {
|
||||
desc: (
|
||||
<>
|
||||
DreamSense Technologies is an advertising company that uses special technology to transmit their ads into the
|
||||
peoples dreams and subconcious. They do this using broadcast transmitter towers. Based on information from our
|
||||
people's dreams and subconcious. They do this using broadcast transmitter towers. Based on information from our
|
||||
agents and informants in Chonqging, we have reason to believe that one of the broadcast towers there has been
|
||||
compromised by Synthoids and is being used to spread pro-Synthoid propaganda.
|
||||
<br />
|
||||
<br />
|
||||
The mission is to destroy this broadcast tower. Speed and stealth are of the upmost important for this.
|
||||
The mission is to destroy this broadcast tower. Speed and stealth are of the utmost importance for this.
|
||||
</>
|
||||
),
|
||||
},
|
||||
|
@ -19,7 +19,7 @@ export const GeneralActions: {
|
||||
"Field Analysis": {
|
||||
desc: (
|
||||
<>
|
||||
Mine and analyze Synthoid-related data. This improves the Bladeburner's unit intelligence on Synthoid locations
|
||||
Mine and analyze Synthoid-related data. This improves the Bladeburner unit's intelligence on Synthoid locations
|
||||
and activities. Completing this action will improve the accuracy of your Synthoid population estimated in the
|
||||
current city.
|
||||
<br />
|
||||
|
@ -286,6 +286,10 @@ export const CONSTANTS: {
|
||||
* 94 achievements added
|
||||
* Release is 2021-12-10.
|
||||
|
||||
** Corporation API **
|
||||
|
||||
* Added corporation API. (Unstable)
|
||||
|
||||
** Netscript **
|
||||
|
||||
* tprintf crashes when not giving a format as first arg.
|
||||
|
@ -31,7 +31,6 @@ export class Employee {
|
||||
cre: number;
|
||||
eff: number;
|
||||
sal: number;
|
||||
pro = 0;
|
||||
cyclesUntilRaise = CorporationConstants.CyclesPerEmployeeRaise;
|
||||
loc: string;
|
||||
pos: string;
|
||||
@ -129,25 +128,6 @@ export class Employee {
|
||||
return mult;
|
||||
}
|
||||
|
||||
copy(): Employee {
|
||||
const employee = new Employee();
|
||||
employee.name = this.name;
|
||||
employee.mor = this.mor;
|
||||
employee.hap = this.hap;
|
||||
employee.ene = this.ene;
|
||||
employee.int = this.int;
|
||||
employee.cha = this.cha;
|
||||
employee.exp = this.exp;
|
||||
employee.cre = this.cre;
|
||||
employee.eff = this.eff;
|
||||
employee.sal = this.sal;
|
||||
employee.pro = this.pro;
|
||||
employee.cyclesUntilRaise = this.cyclesUntilRaise;
|
||||
employee.loc = this.loc;
|
||||
employee.pos = this.pos;
|
||||
return employee;
|
||||
}
|
||||
|
||||
toJSON(): any {
|
||||
return Generic_toJSON("Employee", this);
|
||||
}
|
||||
|
@ -1431,59 +1431,6 @@ export class Industry implements IIndustry {
|
||||
return researchTree.getStorageMultiplier();
|
||||
}
|
||||
|
||||
copy(): Industry {
|
||||
// products: { [key: string]: Product | undefined } = {};
|
||||
|
||||
// //Maps locations to warehouses. 0 if no warehouse at that location
|
||||
// warehouses: { [key: string]: Warehouse | 0 };
|
||||
|
||||
// //Maps locations to offices. 0 if no office at that location
|
||||
// offices: { [key: string]: OfficeSpace | 0 } = {
|
||||
// [CityName.Aevum]: 0,
|
||||
// [CityName.Chongqing]: 0,
|
||||
// [CityName.Sector12]: new OfficeSpace({
|
||||
// loc: CityName.Sector12,
|
||||
// size: CorporationConstants.OfficeInitialSize,
|
||||
// }),
|
||||
// [CityName.NewTokyo]: 0,
|
||||
// [CityName.Ishima]: 0,
|
||||
// [CityName.Volhaven]: 0,
|
||||
// };
|
||||
|
||||
const division = new Industry();
|
||||
division.sciResearch = this.sciResearch.copy();
|
||||
division.researched = {};
|
||||
for (const x of Object.keys(this.researched)) {
|
||||
division.researched[x] = this.researched[x];
|
||||
}
|
||||
division.reqMats = {};
|
||||
for (const x of Object.keys(this.reqMats)) {
|
||||
division.reqMats[x] = this.reqMats[x];
|
||||
}
|
||||
division.name = this.name;
|
||||
division.type = this.type;
|
||||
division.makesProducts = this.makesProducts;
|
||||
division.awareness = this.awareness;
|
||||
division.popularity = this.popularity;
|
||||
division.startingCost = this.startingCost;
|
||||
division.reFac = this.reFac;
|
||||
division.sciFac = this.sciFac;
|
||||
division.hwFac = this.hwFac;
|
||||
division.robFac = this.robFac;
|
||||
division.aiFac = this.aiFac;
|
||||
division.advFac = this.advFac;
|
||||
division.prodMult = this.prodMult;
|
||||
division.state = this.state;
|
||||
division.newInd = this.newInd;
|
||||
division.lastCycleRevenue = this.lastCycleRevenue + 0;
|
||||
division.lastCycleExpenses = this.lastCycleExpenses + 0;
|
||||
division.thisCycleRevenue = this.thisCycleRevenue + 0;
|
||||
division.thisCycleExpenses = this.thisCycleExpenses + 0;
|
||||
division.upgrades = this.upgrades.slice();
|
||||
division.prodMats = this.prodMats.slice();
|
||||
return division;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize the current object to a JSON save state.
|
||||
*/
|
||||
|
@ -225,38 +225,6 @@ export class Material {
|
||||
}
|
||||
}
|
||||
|
||||
copy(): Material {
|
||||
const material = new Material();
|
||||
material.name = this.name;
|
||||
material.qty = this.qty;
|
||||
material.qlt = this.qlt;
|
||||
material.dmd = this.dmd;
|
||||
|
||||
material.cmp = this.cmp;
|
||||
|
||||
material.mv = this.mv;
|
||||
material.mku = this.mku;
|
||||
material.buy = this.buy;
|
||||
material.sll = this.sll;
|
||||
material.prd = this.prd;
|
||||
material.imp = this.imp;
|
||||
material.totalExp = this.totalExp;
|
||||
material.bCost = this.bCost;
|
||||
material.marketTa1 = this.marketTa1;
|
||||
material.marketTa2 = this.marketTa2;
|
||||
material.marketTa2Price = this.marketTa2Price;
|
||||
material.sCost = this.sCost;
|
||||
material.prdman = [this.prdman[0], this.prdman[1]];
|
||||
material.sllman = [this.sllman[0], this.sllman[1]];
|
||||
|
||||
material.dmdR = this.dmdR.slice();
|
||||
material.cmpR = this.cmpR.slice();
|
||||
material.exp = this.exp.slice().map((e) => {
|
||||
return { ind: e.ind, city: e.city, amt: e.amt };
|
||||
});
|
||||
return material;
|
||||
}
|
||||
|
||||
// Serialize the current object to a JSON save state.
|
||||
toJSON(): any {
|
||||
return Generic_toJSON("Material", this);
|
||||
|
@ -173,30 +173,6 @@ export class OfficeSpace {
|
||||
return false;
|
||||
}
|
||||
|
||||
copy(): OfficeSpace {
|
||||
const office = new OfficeSpace();
|
||||
office.loc = this.loc;
|
||||
office.size = this.size;
|
||||
office.minEne = this.minEne;
|
||||
office.maxEne = this.maxEne;
|
||||
office.minHap = this.minHap;
|
||||
office.maxHap = this.maxHap;
|
||||
office.maxMor = this.maxMor;
|
||||
office.employeeProd = {
|
||||
[EmployeePositions.Operations]: this.employeeProd[EmployeePositions.Operations],
|
||||
[EmployeePositions.Engineer]: this.employeeProd[EmployeePositions.Engineer],
|
||||
[EmployeePositions.Business]: this.employeeProd[EmployeePositions.Business],
|
||||
[EmployeePositions.Management]: this.employeeProd[EmployeePositions.Management],
|
||||
[EmployeePositions.RandD]: this.employeeProd[EmployeePositions.RandD],
|
||||
total: this.employeeProd["total"],
|
||||
};
|
||||
office.employees = [];
|
||||
for (const employee of this.employees) {
|
||||
office.employees.push(employee.copy());
|
||||
}
|
||||
return office;
|
||||
}
|
||||
|
||||
toJSON(): any {
|
||||
return Generic_toJSON("OfficeSpace", this);
|
||||
}
|
||||
|
@ -65,4 +65,6 @@ export const CorporationUnlockUpgrades: IMap<CorporationUnlockUpgrade> = {
|
||||
"Help national governments further their agendas in exchange for lowered taxes. " +
|
||||
"This reduces the dividend tax rate by 10%",
|
||||
],
|
||||
"7": [7, 50e9, "Warehouse API", "Enables the warehouse API."],
|
||||
"8": [8, 50e9, "Office API", "Enables the office API."],
|
||||
};
|
||||
|
@ -165,7 +165,7 @@ function Upgrades({ rerender }: IUpgradeProps): React.ReactElement {
|
||||
<Typography variant="h4">Unlocks</Typography>
|
||||
<Grid container>
|
||||
{Object.values(CorporationUnlockUpgrades)
|
||||
.filter((upgrade: CorporationUnlockUpgrade) => corp.unlockUpgrades[upgrade[0]] === 0)
|
||||
.filter((upgrade: CorporationUnlockUpgrade) => !corp.unlockUpgrades[upgrade[0]])
|
||||
.map((upgrade: CorporationUnlockUpgrade) => (
|
||||
<UnlockUpgrade rerender={rerender} upgradeData={upgrade} key={upgrade[0]} />
|
||||
))}
|
||||
|
@ -6,6 +6,7 @@ import { IMap } from "../types";
|
||||
export const RamCostConstants: IMap<number> = {
|
||||
ScriptBaseRamCost: 1.6,
|
||||
ScriptDomRamCost: 25,
|
||||
ScriptCorporationRamCost: 1024 - 1.6,
|
||||
ScriptHackRamCost: 0.1,
|
||||
ScriptHackAnalyzeRamCost: 1,
|
||||
ScriptGrowRamCost: 0.15,
|
||||
|
@ -447,7 +447,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
const stanek = NetscriptStanek(Player, workerScript, helper);
|
||||
const bladeburner = NetscriptBladeburner(Player, workerScript, helper);
|
||||
const codingcontract = NetscriptCodingContract(Player, workerScript, helper);
|
||||
const corporation = NetscriptCorporation(Player);
|
||||
const corporation = NetscriptCorporation(Player, workerScript, helper);
|
||||
const formulas = NetscriptFormulas(Player, workerScript, helper);
|
||||
const singularity = NetscriptSingularity(Player, workerScript, helper);
|
||||
const stockmarket = NetscriptStockMarket(Player, workerScript, helper);
|
||||
@ -459,6 +459,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
bladeburner: bladeburner,
|
||||
codingcontract: codingcontract,
|
||||
sleeve: sleeve,
|
||||
corporation: corporation,
|
||||
stanek: stanek,
|
||||
|
||||
formulas: formulas,
|
||||
@ -2282,7 +2283,6 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
||||
// add undocumented functions
|
||||
const ns = {
|
||||
...base,
|
||||
corporation: corporation,
|
||||
...extra,
|
||||
};
|
||||
function getFunctionNames(obj: NS, prefix: string): string[] {
|
||||
|
@ -1,4 +1,7 @@
|
||||
import { INetscriptHelper } from "./INetscriptHelper";
|
||||
import { WorkerScript } from "../Netscript/WorkerScript";
|
||||
import { IPlayer } from "../PersonObjects/IPlayer";
|
||||
import { netscriptDelay } from "../NetscriptEvaluator";
|
||||
|
||||
import { OfficeSpace } from "../Corporation/OfficeSpace";
|
||||
import { Employee } from "../Corporation/Employee";
|
||||
@ -6,6 +9,19 @@ import { Product } from "../Corporation/Product";
|
||||
import { Material } from "../Corporation/Material";
|
||||
import { Warehouse } from "../Corporation/Warehouse";
|
||||
import { IIndustry } from "../Corporation/IIndustry";
|
||||
import { ICorporation } from "../Corporation/ICorporation";
|
||||
|
||||
import {
|
||||
Corporation as NSCorporation,
|
||||
CorporationInfo,
|
||||
Employee as NSEmployee,
|
||||
Product as NSProduct,
|
||||
Material as NSMaterial,
|
||||
Warehouse as NSWarehouse,
|
||||
Division as NSDivision,
|
||||
WarehouseAPI,
|
||||
OfficeAPI,
|
||||
} from "../ScriptEditor/NetscriptDefinitions";
|
||||
|
||||
import {
|
||||
NewIndustry,
|
||||
@ -35,61 +51,22 @@ import {
|
||||
} from "../Corporation/Actions";
|
||||
import { CorporationUnlockUpgrades } from "../Corporation/data/CorporationUnlockUpgrades";
|
||||
import { CorporationUpgrades } from "../Corporation/data/CorporationUpgrades";
|
||||
import { EmployeePositions } from "../Corporation/EmployeePositions";
|
||||
import { calculateIntelligenceBonus } from "../PersonObjects/formulas/intelligence";
|
||||
|
||||
export interface INetscriptCorporation {
|
||||
expandIndustry(industryName: any, divisionName: any): any;
|
||||
expandCity(divisionName: any, cityName: any): any;
|
||||
unlockUpgrade(upgradeName: any): any;
|
||||
levelUpgrade(upgradeName: any): any;
|
||||
issueDividends(percent: any): any;
|
||||
sellMaterial(divisionName: any, cityName: any, materialName: any, amt: any, price: any): any;
|
||||
sellProduct(divisionName: any, cityName: any, productName: any, amt: any, price: any, all: any): any;
|
||||
discontinueProduct(divisionName: any, productName: any): any;
|
||||
setSmartSupply(divisionName: any, cityName: any, enabled: any): any;
|
||||
buyMaterial(divisionName: any, cityName: any, materialName: any, amt: any): any;
|
||||
employees(divisionName: any, cityName: any): any;
|
||||
assignJob(divisionName: any, cityName: any, employeeName: any, job: any): any;
|
||||
hireEmployee(divisionName: any, cityName: any): any;
|
||||
upgradeOfficeSize(divisionName: any, cityName: any, size: any): any;
|
||||
throwParty(divisionName: any, cityName: any, costPerEmployee: any): any;
|
||||
purchaseWarehouse(divisionName: any, cityName: any): any;
|
||||
upgradeWarehouse(divisionName: any, cityName: any): any;
|
||||
buyCoffee(divisionName: any, cityName: any): any;
|
||||
hireAdVert(divisionName: any): any;
|
||||
makeProduct(divisionName: any, cityName: any, productName: any, designInvest: any, marketingInvest: any): any;
|
||||
research(divisionName: any, researchName: any): any;
|
||||
exportMaterial(
|
||||
sourceDivision: any,
|
||||
sourceCity: any,
|
||||
targetDivision: any,
|
||||
targetCity: any,
|
||||
materialName: any,
|
||||
amt: any,
|
||||
): any;
|
||||
cancelExportMaterial(
|
||||
sourceDivision: any,
|
||||
sourceCity: any,
|
||||
targetDivision: any,
|
||||
targetCity: any,
|
||||
materialName: any,
|
||||
amt: any,
|
||||
): any;
|
||||
setMaterialMarketTA1(divisionName: any, cityName: any, materialName: any, on: any): any;
|
||||
setMaterialMarketTA2(divisionName: any, cityName: any, materialName: any, on: any): any;
|
||||
setProductMarketTA1(divisionName: any, productName: any, on: any): any;
|
||||
setProductMarketTA2(divisionName: any, productName: any, on: any): any;
|
||||
getDivision(divisionName: any): any;
|
||||
getOffice(divisionName: any, cityName: any): any;
|
||||
getWarehouse(divisionName: any, cityName: any): any;
|
||||
getMaterial(divisionName: any, cityName: any, materialName: any): any;
|
||||
getProduct(divisionName: any, productName: any): any;
|
||||
getEmployee(divisionName: any, cityName: any, employeeName: any): any;
|
||||
}
|
||||
|
||||
export function NetscriptCorporation(player: IPlayer): INetscriptCorporation {
|
||||
function getDivision(divisionName: any): IIndustry {
|
||||
export function NetscriptCorporation(
|
||||
player: IPlayer,
|
||||
workerScript: WorkerScript,
|
||||
helper: INetscriptHelper,
|
||||
): NSCorporation {
|
||||
function getCorporation(): ICorporation {
|
||||
const corporation = player.corporation;
|
||||
if (corporation === null) throw new Error("cannot be called without a corporation");
|
||||
return corporation;
|
||||
}
|
||||
|
||||
function getDivision(divisionName: any): 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;
|
||||
@ -131,169 +108,403 @@ export function NetscriptCorporation(player: IPlayer): INetscriptCorporation {
|
||||
if (employee === undefined) throw new Error(`Invalid employee name: '${employeeName}'`);
|
||||
return employee;
|
||||
}
|
||||
// Hi, if you're reading this you're a bit nosy.
|
||||
// There's a corporation API but it's very imbalanced right now.
|
||||
// It's here so players can test with if they want.
|
||||
return {
|
||||
expandIndustry: function (industryName: any, divisionName: any): any {
|
||||
const corporation = player.corporation;
|
||||
if (corporation === null) throw new Error("Should not be called without a corporation");
|
||||
NewIndustry(corporation, industryName, divisionName);
|
||||
|
||||
function checkAccess(func: string, api?: number): void {
|
||||
if (player.corporation === null) throw helper.makeRuntimeErrorMsg(`corporation.${func}`, "Must own a corporation.");
|
||||
if (!api) return;
|
||||
|
||||
if (!player.corporation.unlockUpgrades[api])
|
||||
throw helper.makeRuntimeErrorMsg(`corporation.${func}`, "You do not have access to this API.");
|
||||
}
|
||||
|
||||
const warehouseAPI: WarehouseAPI = {
|
||||
getWarehouse: function (adivisionName: any, acityName: any): NSWarehouse {
|
||||
checkAccess("getWarehouse", 7);
|
||||
const divisionName = helper.string("getWarehouse", "divisionName", adivisionName);
|
||||
const cityName = helper.string("getWarehouse", "cityName", acityName);
|
||||
const warehouse = getWarehouse(divisionName, cityName);
|
||||
return {
|
||||
level: warehouse.level,
|
||||
loc: warehouse.loc,
|
||||
size: warehouse.size,
|
||||
sizeUsed: warehouse.sizeUsed,
|
||||
};
|
||||
},
|
||||
expandCity: function (divisionName: any, cityName: any): any {
|
||||
const division = getDivision(divisionName);
|
||||
const corporation = player.corporation;
|
||||
if (corporation === null) throw new Error("Should not be called without a corporation");
|
||||
NewCity(corporation, division, cityName);
|
||||
getMaterial: function (adivisionName: any, acityName: any, amaterialName: any): NSMaterial {
|
||||
checkAccess("getMaterial", 7);
|
||||
const divisionName = helper.string("getMaterial", "divisionName", adivisionName);
|
||||
const cityName = helper.string("getMaterial", "cityName", acityName);
|
||||
const materialName = helper.string("getMaterial", "materialName", amaterialName);
|
||||
const material = getMaterial(divisionName, cityName, materialName);
|
||||
return {
|
||||
name: material.name,
|
||||
qty: material.qty,
|
||||
qlt: material.qlt,
|
||||
};
|
||||
},
|
||||
unlockUpgrade: function (upgradeName: any): any {
|
||||
const upgrade = Object.values(CorporationUnlockUpgrades).find((upgrade) => upgrade[2] === upgradeName);
|
||||
if (upgrade === undefined) throw new Error(`No upgrade named '${upgradeName}'`);
|
||||
const corporation = player.corporation;
|
||||
if (corporation === null) throw new Error("Should not be called without a corporation");
|
||||
UnlockUpgrade(corporation, upgrade);
|
||||
getProduct: function (adivisionName: any, aproductName: any): NSProduct {
|
||||
checkAccess("getProduct", 7);
|
||||
const divisionName = helper.string("getProduct", "divisionName", adivisionName);
|
||||
const productName = helper.string("getProduct", "productName", aproductName);
|
||||
const product = getProduct(divisionName, productName);
|
||||
return {
|
||||
name: product.name,
|
||||
dmd: product.dmd,
|
||||
cmp: product.cmp,
|
||||
pCost: product.pCost,
|
||||
sCost: product.sCost,
|
||||
};
|
||||
},
|
||||
levelUpgrade: function (upgradeName: any): any {
|
||||
const upgrade = Object.values(CorporationUpgrades).find((upgrade) => upgrade[4] === upgradeName);
|
||||
if (upgrade === undefined) throw new Error(`No upgrade named '${upgradeName}'`);
|
||||
const corporation = player.corporation;
|
||||
if (corporation === null) throw new Error("Should not be called without a corporation");
|
||||
LevelUpgrade(corporation, upgrade);
|
||||
purchaseWarehouse: function (adivisionName: any, acityName: any): void {
|
||||
checkAccess("purchaseWarehouse", 7);
|
||||
const divisionName = helper.string("purchaseWarehouse", "divisionName", adivisionName);
|
||||
const cityName = helper.string("purchaseWarehouse", "cityName", acityName);
|
||||
const corporation = getCorporation();
|
||||
PurchaseWarehouse(corporation, getDivision(divisionName), cityName);
|
||||
},
|
||||
issueDividends: function (percent: any): any {
|
||||
const corporation = player.corporation;
|
||||
if (corporation === null) throw new Error("Should not be called without a corporation");
|
||||
IssueDividends(corporation, percent);
|
||||
upgradeWarehouse: function (adivisionName: any, acityName: any): void {
|
||||
checkAccess("upgradeWarehouse", 7);
|
||||
const divisionName = helper.string("upgradeWarehouse", "divisionName", adivisionName);
|
||||
const cityName = helper.string("upgradeWarehouse", "cityName", acityName);
|
||||
const corporation = getCorporation();
|
||||
UpgradeWarehouse(corporation, getDivision(divisionName), getWarehouse(divisionName, cityName));
|
||||
},
|
||||
sellMaterial: function (divisionName: any, cityName: any, materialName: any, amt: any, price: any): any {
|
||||
sellMaterial: function (adivisionName: any, acityName: any, amaterialName: any, aamt: any, aprice: any): void {
|
||||
checkAccess("sellMaterial", 7);
|
||||
const divisionName = helper.string("sellMaterial", "divisionName", adivisionName);
|
||||
const cityName = helper.string("sellMaterial", "cityName", acityName);
|
||||
const materialName = helper.string("sellMaterial", "materialName", amaterialName);
|
||||
const amt = helper.string("sellMaterial", "amt", aamt);
|
||||
const price = helper.string("sellMaterial", "price", aprice);
|
||||
const material = getMaterial(divisionName, cityName, materialName);
|
||||
SellMaterial(material, amt, price);
|
||||
},
|
||||
sellProduct: function (divisionName: any, cityName: any, productName: any, amt: any, price: any, all: any): any {
|
||||
sellProduct: function (
|
||||
adivisionName: any,
|
||||
acityName: any,
|
||||
aproductName: any,
|
||||
aamt: any,
|
||||
aprice: any,
|
||||
aall: any,
|
||||
): void {
|
||||
checkAccess("sellProduct", 7);
|
||||
const divisionName = helper.string("sellProduct", "divisionName", adivisionName);
|
||||
const cityName = helper.string("sellProduct", "cityName", acityName);
|
||||
const productName = helper.string("sellProduct", "productName", aproductName);
|
||||
const amt = helper.string("sellProduct", "amt", aamt);
|
||||
const price = helper.string("sellProduct", "price", aprice);
|
||||
const all = helper.boolean(aall);
|
||||
const product = getProduct(divisionName, productName);
|
||||
SellProduct(product, cityName, amt, price, all);
|
||||
},
|
||||
discontinueProduct: function (divisionName: any, productName: any): any {
|
||||
discontinueProduct: function (adivisionName: any, aproductName: any): void {
|
||||
checkAccess("discontinueProduct", 7);
|
||||
const divisionName = helper.string("discontinueProduct", "divisionName", adivisionName);
|
||||
const productName = helper.string("discontinueProduct", "productName", aproductName);
|
||||
getDivision(divisionName).discontinueProduct(getProduct(divisionName, productName));
|
||||
},
|
||||
setSmartSupply: function (divisionName: any, cityName: any, enabled: any): any {
|
||||
setSmartSupply: function (adivisionName: any, acityName: any, aenabled: any): void {
|
||||
checkAccess("setSmartSupply", 7);
|
||||
const divisionName = helper.string("setSmartSupply", "divisionName", adivisionName);
|
||||
const cityName = helper.string("sellProduct", "cityName", acityName);
|
||||
const enabled = helper.boolean(aenabled);
|
||||
const warehouse = getWarehouse(divisionName, cityName);
|
||||
SetSmartSupply(warehouse, enabled);
|
||||
},
|
||||
// setSmartSupplyUseLeftovers: function (): any {},
|
||||
buyMaterial: function (divisionName: any, cityName: any, materialName: any, amt: any): any {
|
||||
buyMaterial: function (adivisionName: any, acityName: any, amaterialName: any, aamt: any): void {
|
||||
checkAccess("buyMaterial", 7);
|
||||
const divisionName = helper.string("buyMaterial", "divisionName", adivisionName);
|
||||
const cityName = helper.string("buyMaterial", "cityName", acityName);
|
||||
const materialName = helper.string("buyMaterial", "materialName", amaterialName);
|
||||
const amt = helper.number("buyMaterial", "amt", aamt);
|
||||
const material = getMaterial(divisionName, cityName, materialName);
|
||||
BuyMaterial(material, amt);
|
||||
},
|
||||
employees: function (divisionName: any, cityName: any): any {
|
||||
const office = getOffice(divisionName, cityName);
|
||||
return office.employees.map((e) => Object.assign({}, e));
|
||||
},
|
||||
assignJob: function (divisionName: any, cityName: any, employeeName: any, job: any): any {
|
||||
const employee = getEmployee(divisionName, cityName, employeeName);
|
||||
AssignJob(employee, job);
|
||||
},
|
||||
hireEmployee: function (divisionName: any, cityName: any): any {
|
||||
const office = getOffice(divisionName, cityName);
|
||||
office.hireRandomEmployee();
|
||||
},
|
||||
upgradeOfficeSize: function (divisionName: any, cityName: any, size: any): any {
|
||||
const office = getOffice(divisionName, cityName);
|
||||
const corporation = player.corporation;
|
||||
if (corporation === null) throw new Error("Should not be called without a corporation");
|
||||
UpgradeOfficeSize(corporation, office, size);
|
||||
},
|
||||
throwParty: function (divisionName: any, cityName: any, costPerEmployee: any): any {
|
||||
const office = getOffice(divisionName, cityName);
|
||||
const corporation = player.corporation;
|
||||
if (corporation === null) throw new Error("Should not be called without a corporation");
|
||||
ThrowParty(corporation, office, costPerEmployee);
|
||||
},
|
||||
purchaseWarehouse: function (divisionName: any, cityName: any): any {
|
||||
const corporation = player.corporation;
|
||||
if (corporation === null) throw new Error("Should not be called without a corporation");
|
||||
PurchaseWarehouse(corporation, getDivision(divisionName), cityName);
|
||||
},
|
||||
upgradeWarehouse: function (divisionName: any, cityName: any): any {
|
||||
const corporation = player.corporation;
|
||||
if (corporation === null) throw new Error("Should not be called without a corporation");
|
||||
UpgradeWarehouse(corporation, getDivision(divisionName), getWarehouse(divisionName, cityName));
|
||||
},
|
||||
buyCoffee: function (divisionName: any, cityName: any): any {
|
||||
const corporation = player.corporation;
|
||||
if (corporation === null) throw new Error("Should not be called without a corporation");
|
||||
BuyCoffee(corporation, getDivision(divisionName), getOffice(divisionName, cityName));
|
||||
},
|
||||
hireAdVert: function (divisionName: any): any {
|
||||
const corporation = player.corporation;
|
||||
if (corporation === null) throw new Error("Should not be called without a corporation");
|
||||
HireAdVert(corporation, getDivision(divisionName), getOffice(divisionName, "Sector-12"));
|
||||
},
|
||||
makeProduct: function (
|
||||
divisionName: any,
|
||||
cityName: any,
|
||||
productName: any,
|
||||
designInvest: any,
|
||||
marketingInvest: any,
|
||||
): any {
|
||||
const corporation = player.corporation;
|
||||
if (corporation === null) throw new Error("Should not be called without a corporation");
|
||||
adivisionName: any,
|
||||
acityName: any,
|
||||
aproductName: any,
|
||||
adesignInvest: any,
|
||||
amarketingInvest: any,
|
||||
): void {
|
||||
checkAccess("makeProduct", 7);
|
||||
const divisionName = helper.string("makeProduct", "divisionName", adivisionName);
|
||||
const cityName = helper.string("makeProduct", "cityName", acityName);
|
||||
const productName = helper.string("makeProduct", "productName", aproductName);
|
||||
const designInvest = helper.number("makeProduct", "designInvest", adesignInvest);
|
||||
const marketingInvest = helper.number("makeProduct", "marketingInvest", amarketingInvest);
|
||||
const corporation = getCorporation();
|
||||
MakeProduct(corporation, getDivision(divisionName), cityName, productName, designInvest, marketingInvest);
|
||||
},
|
||||
research: function (divisionName: any, researchName: any): any {
|
||||
Research(getDivision(divisionName), researchName);
|
||||
},
|
||||
exportMaterial: function (
|
||||
sourceDivision: any,
|
||||
sourceCity: any,
|
||||
targetDivision: any,
|
||||
targetCity: any,
|
||||
materialName: any,
|
||||
amt: any,
|
||||
): any {
|
||||
asourceDivision: any,
|
||||
asourceCity: any,
|
||||
atargetDivision: any,
|
||||
atargetCity: any,
|
||||
amaterialName: any,
|
||||
aamt: any,
|
||||
): void {
|
||||
checkAccess("exportMaterial", 7);
|
||||
const sourceDivision = helper.string("exportMaterial", "sourceDivision", asourceDivision);
|
||||
const sourceCity = helper.string("exportMaterial", "sourceCity", asourceCity);
|
||||
const targetDivision = helper.string("exportMaterial", "targetDivision", atargetDivision);
|
||||
const targetCity = helper.string("exportMaterial", "targetCity", atargetCity);
|
||||
const materialName = helper.string("exportMaterial", "materialName", amaterialName);
|
||||
const amt = helper.string("exportMaterial", "amt", aamt);
|
||||
ExportMaterial(targetDivision, targetCity, getMaterial(sourceDivision, sourceCity, materialName), amt + "");
|
||||
},
|
||||
cancelExportMaterial: function (
|
||||
sourceDivision: any,
|
||||
sourceCity: any,
|
||||
targetDivision: any,
|
||||
targetCity: any,
|
||||
materialName: any,
|
||||
amt: any,
|
||||
): any {
|
||||
asourceDivision: any,
|
||||
asourceCity: any,
|
||||
atargetDivision: any,
|
||||
atargetCity: any,
|
||||
amaterialName: any,
|
||||
aamt: any,
|
||||
): void {
|
||||
checkAccess("cancelExportMaterial", 7);
|
||||
const sourceDivision = helper.string("cancelExportMaterial", "sourceDivision", asourceDivision);
|
||||
const sourceCity = helper.string("cancelExportMaterial", "sourceCity", asourceCity);
|
||||
const targetDivision = helper.string("cancelExportMaterial", "targetDivision", atargetDivision);
|
||||
const targetCity = helper.string("cancelExportMaterial", "targetCity", atargetCity);
|
||||
const materialName = helper.string("cancelExportMaterial", "materialName", amaterialName);
|
||||
const amt = helper.string("cancelExportMaterial", "amt", aamt);
|
||||
CancelExportMaterial(targetDivision, targetCity, getMaterial(sourceDivision, sourceCity, materialName), amt + "");
|
||||
},
|
||||
setMaterialMarketTA1: function (divisionName: any, cityName: any, materialName: any, on: any): any {
|
||||
setMaterialMarketTA1: function (adivisionName: any, acityName: any, amaterialName: any, aon: any): void {
|
||||
checkAccess("setMaterialMarketTA1", 7);
|
||||
const divisionName = helper.string("setMaterialMarketTA1", "divisionName", adivisionName);
|
||||
const cityName = helper.string("setMaterialMarketTA1", "cityName", acityName);
|
||||
const materialName = helper.string("setMaterialMarketTA1", "materialName", amaterialName);
|
||||
const on = helper.boolean(aon);
|
||||
SetMaterialMarketTA1(getMaterial(divisionName, cityName, materialName), on);
|
||||
},
|
||||
setMaterialMarketTA2: function (divisionName: any, cityName: any, materialName: any, on: any) {
|
||||
setMaterialMarketTA2: function (adivisionName: any, acityName: any, amaterialName: any, aon: any): void {
|
||||
checkAccess("setMaterialMarketTA2", 7);
|
||||
const divisionName = helper.string("setMaterialMarketTA2", "divisionName", adivisionName);
|
||||
const cityName = helper.string("setMaterialMarketTA2", "cityName", acityName);
|
||||
const materialName = helper.string("setMaterialMarketTA2", "materialName", amaterialName);
|
||||
const on = helper.boolean(aon);
|
||||
SetMaterialMarketTA2(getMaterial(divisionName, cityName, materialName), on);
|
||||
},
|
||||
setProductMarketTA1: function (divisionName: any, productName: any, on: any): any {
|
||||
setProductMarketTA1: function (adivisionName: any, aproductName: any, aon: any): void {
|
||||
checkAccess("setProductMarketTA1", 7);
|
||||
const divisionName = helper.string("setProductMarketTA1", "divisionName", adivisionName);
|
||||
const productName = helper.string("setProductMarketTA1", "productName", aproductName);
|
||||
const on = helper.boolean(aon);
|
||||
SetProductMarketTA1(getProduct(divisionName, productName), on);
|
||||
},
|
||||
setProductMarketTA2: function (divisionName: any, productName: any, on: any) {
|
||||
setProductMarketTA2: function (adivisionName: any, aproductName: any, aon: any): void {
|
||||
checkAccess("setProductMarketTA2", 7);
|
||||
const divisionName = helper.string("setProductMarketTA2", "divisionName", adivisionName);
|
||||
const productName = helper.string("setProductMarketTA2", "productName", aproductName);
|
||||
const on = helper.boolean(aon);
|
||||
SetProductMarketTA2(getProduct(divisionName, productName), on);
|
||||
},
|
||||
};
|
||||
|
||||
const officeAPI: OfficeAPI = {
|
||||
employees: function (adivisionName: any, acityName: any): any {
|
||||
checkAccess("employees", 8);
|
||||
const divisionName = helper.string("employees", "divisionName", adivisionName);
|
||||
const cityName = helper.string("employees", "cityName", acityName);
|
||||
const office = getOffice(divisionName, cityName);
|
||||
return office.employees.map((e) => Object.assign({}, e));
|
||||
},
|
||||
assignJob: function (adivisionName: any, acityName: any, aemployeeName: any, ajob: any): Promise<void> {
|
||||
checkAccess("assignJob", 8);
|
||||
const divisionName = helper.string("assignJob", "divisionName", adivisionName);
|
||||
const cityName = helper.string("assignJob", "cityName", acityName);
|
||||
const employeeName = helper.string("assignJob", "employeeName", aemployeeName);
|
||||
const job = helper.string("assignJob", "job", ajob);
|
||||
const employee = getEmployee(divisionName, cityName, employeeName);
|
||||
return netscriptDelay(1000, workerScript).then(function () {
|
||||
return Promise.resolve(AssignJob(employee, job));
|
||||
});
|
||||
},
|
||||
hireEmployee: function (adivisionName: any, acityName: any): any {
|
||||
checkAccess("hireEmployee", 8);
|
||||
const divisionName = helper.string("hireEmployee", "divisionName", adivisionName);
|
||||
const cityName = helper.string("hireEmployee", "cityName", acityName);
|
||||
const office = getOffice(divisionName, cityName);
|
||||
office.hireRandomEmployee();
|
||||
},
|
||||
upgradeOfficeSize: function (adivisionName: any, acityName: any, asize: any): void {
|
||||
checkAccess("upgradeOfficeSize", 8);
|
||||
const divisionName = helper.string("upgradeOfficeSize", "divisionName", adivisionName);
|
||||
const cityName = helper.string("upgradeOfficeSize", "cityName", acityName);
|
||||
const size = helper.number("upgradeOfficeSize", "size", asize);
|
||||
const office = getOffice(divisionName, cityName);
|
||||
const corporation = getCorporation();
|
||||
UpgradeOfficeSize(corporation, office, size);
|
||||
},
|
||||
throwParty: function (adivisionName: any, acityName: any, acostPerEmployee: any): Promise<number> {
|
||||
checkAccess("throwParty", 8);
|
||||
const divisionName = helper.string("throwParty", "divisionName", adivisionName);
|
||||
const cityName = helper.string("throwParty", "cityName", acityName);
|
||||
const costPerEmployee = helper.number("throwParty", "costPerEmployee", acostPerEmployee);
|
||||
const office = getOffice(divisionName, cityName);
|
||||
const corporation = getCorporation();
|
||||
return netscriptDelay(
|
||||
(60 * 1000) / (player.hacking_speed_mult * calculateIntelligenceBonus(player.intelligence, 1)),
|
||||
workerScript,
|
||||
).then(function () {
|
||||
return Promise.resolve(ThrowParty(corporation, office, costPerEmployee));
|
||||
});
|
||||
},
|
||||
buyCoffee: function (adivisionName: any, acityName: any): Promise<void> {
|
||||
checkAccess("buyCoffee", 8);
|
||||
const divisionName = helper.string("buyCoffee", "divisionName", adivisionName);
|
||||
const cityName = helper.string("buyCoffee", "cityName", acityName);
|
||||
const corporation = getCorporation();
|
||||
return netscriptDelay(
|
||||
(60 * 1000) / (player.hacking_speed_mult * calculateIntelligenceBonus(player.intelligence, 1)),
|
||||
workerScript,
|
||||
).then(function () {
|
||||
return Promise.resolve(BuyCoffee(corporation, getDivision(divisionName), getOffice(divisionName, cityName)));
|
||||
});
|
||||
},
|
||||
hireAdVert: function (adivisionName: any): void {
|
||||
checkAccess("hireAdVert", 8);
|
||||
const divisionName = helper.string("hireAdVert", "divisionName", adivisionName);
|
||||
const corporation = getCorporation();
|
||||
HireAdVert(corporation, getDivision(divisionName), getOffice(divisionName, "Sector-12"));
|
||||
},
|
||||
research: function (adivisionName: any, aresearchName: any): void {
|
||||
checkAccess("research", 8);
|
||||
const divisionName = helper.string("research", "divisionName", adivisionName);
|
||||
const researchName = helper.string("research", "researchName", aresearchName);
|
||||
Research(getDivision(divisionName), researchName);
|
||||
},
|
||||
getOffice: function (adivisionName: any, acityName: any): any {
|
||||
checkAccess("getOffice", 8);
|
||||
const divisionName = helper.string("getOffice", "divisionName", adivisionName);
|
||||
const cityName = helper.string("getOffice", "cityName", acityName);
|
||||
const office = getOffice(divisionName, cityName);
|
||||
return {
|
||||
loc: office.loc,
|
||||
size: office.size,
|
||||
minEne: office.minEne,
|
||||
maxEne: office.maxEne,
|
||||
minHap: office.minHap,
|
||||
maxHap: office.maxHap,
|
||||
maxMor: office.maxMor,
|
||||
employees: office.employees.map((e) => e.name),
|
||||
employeeProd: {
|
||||
Operations: office.employeeProd[EmployeePositions.Operations],
|
||||
Engineer: office.employeeProd[EmployeePositions.Engineer],
|
||||
Business: office.employeeProd[EmployeePositions.Business],
|
||||
Management: office.employeeProd[EmployeePositions.Management],
|
||||
"Research & Development": office.employeeProd[EmployeePositions.RandD],
|
||||
Training: office.employeeProd[EmployeePositions.Training],
|
||||
},
|
||||
};
|
||||
},
|
||||
getEmployee: function (adivisionName: any, acityName: any, aemployeeName: any): NSEmployee {
|
||||
checkAccess("getEmployee", 8);
|
||||
const divisionName = helper.string("getEmployee", "divisionName", adivisionName);
|
||||
const cityName = helper.string("getEmployee", "cityName", acityName);
|
||||
const employeeName = helper.string("getEmployee", "employeeName", aemployeeName);
|
||||
const employee = getEmployee(divisionName, cityName, employeeName);
|
||||
return {
|
||||
name: employee.name,
|
||||
mor: employee.mor,
|
||||
hap: employee.hap,
|
||||
ene: employee.ene,
|
||||
int: employee.int,
|
||||
cha: employee.cha,
|
||||
exp: employee.exp,
|
||||
cre: employee.cre,
|
||||
eff: employee.eff,
|
||||
sal: employee.sal,
|
||||
loc: employee.loc,
|
||||
pos: employee.pos,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
return {
|
||||
...warehouseAPI,
|
||||
...officeAPI,
|
||||
expandIndustry: function (aindustryName: any, adivisionName: any): void {
|
||||
checkAccess("expandIndustry");
|
||||
const industryName = helper.string("expandIndustry", "industryName", aindustryName);
|
||||
const divisionName = helper.string("expandIndustry", "divisionName", adivisionName);
|
||||
const corporation = getCorporation();
|
||||
NewIndustry(corporation, industryName, divisionName);
|
||||
},
|
||||
expandCity: function (adivisionName: any, acityName: any): void {
|
||||
checkAccess("expandCity");
|
||||
const divisionName = helper.string("expandCity", "divisionName", adivisionName);
|
||||
const cityName = helper.string("expandCity", "cityName", acityName);
|
||||
const corporation = getCorporation();
|
||||
const division = getDivision(divisionName);
|
||||
NewCity(corporation, division, cityName);
|
||||
},
|
||||
unlockUpgrade: function (aupgradeName: any): void {
|
||||
checkAccess("unlockUpgrade");
|
||||
const upgradeName = helper.string("unlockUpgrade", "upgradeName", aupgradeName);
|
||||
const corporation = getCorporation();
|
||||
const upgrade = Object.values(CorporationUnlockUpgrades).find((upgrade) => upgrade[2] === upgradeName);
|
||||
if (upgrade === undefined) throw new Error(`No upgrade named '${upgradeName}'`);
|
||||
UnlockUpgrade(corporation, upgrade);
|
||||
},
|
||||
levelUpgrade: function (aupgradeName: any): void {
|
||||
checkAccess("levelUpgrade");
|
||||
const upgradeName = helper.string("levelUpgrade", "upgradeName", aupgradeName);
|
||||
const corporation = getCorporation();
|
||||
const upgrade = Object.values(CorporationUpgrades).find((upgrade) => upgrade[4] === upgradeName);
|
||||
if (upgrade === undefined) throw new Error(`No upgrade named '${upgradeName}'`);
|
||||
LevelUpgrade(corporation, upgrade);
|
||||
},
|
||||
issueDividends: function (apercent: any): void {
|
||||
checkAccess("issueDividends");
|
||||
const percent = helper.number("issueDividends", "percent", apercent);
|
||||
const corporation = getCorporation();
|
||||
IssueDividends(corporation, percent);
|
||||
},
|
||||
|
||||
// If you modify these objects you will affect them for real, it's not
|
||||
// copies.
|
||||
getDivision: function (divisionName: any): any {
|
||||
return getDivision(divisionName);
|
||||
getDivision: function (adivisionName: any): NSDivision {
|
||||
checkAccess("getDivision");
|
||||
const divisionName = helper.string("getDivision", "divisionName", adivisionName);
|
||||
const division = getDivision(divisionName);
|
||||
const cities: string[] = [];
|
||||
for (const office of Object.values(division.offices)) {
|
||||
if (office === 0) continue;
|
||||
cities.push(office.loc);
|
||||
}
|
||||
return {
|
||||
name: division.name,
|
||||
type: division.type,
|
||||
awareness: division.awareness,
|
||||
popularity: division.popularity,
|
||||
prodMult: division.prodMult,
|
||||
research: division.sciResearch.qty,
|
||||
lastCycleRevenue: division.lastCycleRevenue,
|
||||
lastCycleExpenses: division.lastCycleExpenses,
|
||||
thisCycleRevenue: division.thisCycleRevenue,
|
||||
thisCycleExpenses: division.thisCycleExpenses,
|
||||
upgrades: division.upgrades,
|
||||
cities: cities,
|
||||
};
|
||||
},
|
||||
getOffice: function (divisionName: any, cityName: any): any {
|
||||
return getOffice(divisionName, cityName);
|
||||
},
|
||||
getWarehouse: function (divisionName: any, cityName: any): any {
|
||||
return getWarehouse(divisionName, cityName);
|
||||
},
|
||||
getMaterial: function (divisionName: any, cityName: any, materialName: any): any {
|
||||
return getMaterial(divisionName, cityName, materialName);
|
||||
},
|
||||
getProduct: function (divisionName: any, productName: any): any {
|
||||
return getProduct(divisionName, productName);
|
||||
},
|
||||
getEmployee: function (divisionName: any, cityName: any, employeeName: any): any {
|
||||
return getEmployee(divisionName, cityName, employeeName);
|
||||
getCorporation: function (): CorporationInfo {
|
||||
checkAccess("getCorporation");
|
||||
const corporation = getCorporation();
|
||||
return {
|
||||
name: corporation.name,
|
||||
funds: corporation.funds,
|
||||
revenue: corporation.revenue,
|
||||
expenses: corporation.expenses,
|
||||
public: corporation.public,
|
||||
totalShares: corporation.totalShares,
|
||||
numShares: corporation.numShares,
|
||||
shareSaleCooldown: corporation.shareSaleCooldown,
|
||||
issuedShares: corporation.issuedShares,
|
||||
sharePrice: corporation.sharePrice,
|
||||
state: corporation.state + "",
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -141,6 +141,9 @@ async function parseOnlyRamCalculate(
|
||||
if (ref === "window" && !resolvedRefs.has("window")) {
|
||||
ram += RamCostConstants.ScriptDomRamCost;
|
||||
}
|
||||
if (ref === "corporation" && !resolvedRefs.has("corporation")) {
|
||||
ram += RamCostConstants.ScriptCorporationRamCost;
|
||||
}
|
||||
|
||||
resolvedRefs.add(ref);
|
||||
|
||||
|
163
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
163
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
@ -3512,7 +3512,6 @@ export interface NS extends Singularity {
|
||||
* RAM cost: 0 GB
|
||||
*/
|
||||
readonly stock: TIX;
|
||||
|
||||
/**
|
||||
*
|
||||
* Namespace for formulas functions.
|
||||
@ -3525,6 +3524,11 @@ export interface NS extends Singularity {
|
||||
* RAM cost: 0 GB
|
||||
*/
|
||||
readonly stanek: Stanek;
|
||||
/**
|
||||
* Namespace for corporation functions.
|
||||
* RAM cost: 0 GB
|
||||
*/
|
||||
readonly corporation: Corporation;
|
||||
|
||||
/**
|
||||
* Arguments passed into the script.
|
||||
@ -5133,3 +5137,160 @@ export interface NS extends Singularity {
|
||||
*/
|
||||
flags(schema: [string, string | number | boolean | string[]][]): any;
|
||||
}
|
||||
|
||||
export interface OfficeAPI {
|
||||
employees(divisionName: string, cityName: string): string[];
|
||||
assignJob(divisionName: string, cityName: string, employeeName: string, job: string): Promise<void>;
|
||||
hireEmployee(divisionName: string, cityName: string): Employee;
|
||||
upgradeOfficeSize(divisionName: string, cityName: string, size: number): void;
|
||||
throwParty(divisionName: string, cityName: string, costPerEmployee: number): Promise<number>;
|
||||
buyCoffee(divisionName: string, cityName: string): Promise<void>;
|
||||
hireAdVert(divisionName: string): void;
|
||||
research(divisionName: string, researchName: string): void;
|
||||
getOffice(divisionName: string, cityName: string): Office;
|
||||
getEmployee(divisionName: string, cityName: string, employeeName: string): Employee;
|
||||
}
|
||||
|
||||
export interface WarehouseAPI {
|
||||
sellMaterial(divisionName: string, cityName: string, materialName: string, amt: number, price: number): void;
|
||||
sellProduct(
|
||||
divisionName: string,
|
||||
cityName: string,
|
||||
productName: string,
|
||||
amt: number,
|
||||
price: number,
|
||||
all: boolean,
|
||||
): void;
|
||||
discontinueProduct(divisionName: string, productName: string): void;
|
||||
setSmartSupply(divisionName: string, cityName: string, enabled: boolean): void;
|
||||
buyMaterial(divisionName: string, cityName: string, materialName: string, amt: number): void;
|
||||
getWarehouse(divisionName: string, cityName: string): Warehouse;
|
||||
getProduct(divisionName: string, productName: string): Product;
|
||||
getMaterial(divisionName: string, cityName: string, materialName: string): Material;
|
||||
setMaterialMarketTA1(divisionName: string, cityName: string, materialName: string, on: boolean): void;
|
||||
setMaterialMarketTA2(divisionName: string, cityName: string, materialName: string, on: boolean): void;
|
||||
setProductMarketTA1(divisionName: string, productName: string, on: boolean): void;
|
||||
setProductMarketTA2(divisionName: string, productName: string, on: boolean): void;
|
||||
exportMaterial(
|
||||
sourceDivision: string,
|
||||
sourceCity: string,
|
||||
targetDivision: string,
|
||||
targetCity: string,
|
||||
materialName: string,
|
||||
amt: number,
|
||||
): void;
|
||||
cancelExportMaterial(
|
||||
sourceDivision: string,
|
||||
sourceCity: string,
|
||||
targetDivision: string,
|
||||
targetCity: string,
|
||||
materialName: string,
|
||||
amt: number,
|
||||
): void;
|
||||
purchaseWarehouse(divisionName: string, cityName: string): void;
|
||||
upgradeWarehouse(divisionName: string, cityName: string): void;
|
||||
makeProduct(
|
||||
divisionName: string,
|
||||
cityName: string,
|
||||
productName: string,
|
||||
designInvest: number,
|
||||
marketingInvest: number,
|
||||
): void;
|
||||
}
|
||||
|
||||
export interface Corporation extends WarehouseAPI, OfficeAPI {
|
||||
getCorporation(): CorporationInfo;
|
||||
getDivision(divisionName: string): Division;
|
||||
expandIndustry(industryName: string, divisionName: string): void;
|
||||
expandCity(divisionName: string, cityName: string): void;
|
||||
unlockUpgrade(upgradeName: string): void;
|
||||
levelUpgrade(upgradeName: string): void;
|
||||
issueDividends(percent: number): void;
|
||||
}
|
||||
|
||||
interface CorporationInfo {
|
||||
name: string;
|
||||
funds: number;
|
||||
revenue: number;
|
||||
expenses: number;
|
||||
public: boolean;
|
||||
totalShares: number;
|
||||
numShares: number;
|
||||
shareSaleCooldown: number;
|
||||
issuedShares: number;
|
||||
sharePrice: number;
|
||||
state: string;
|
||||
}
|
||||
|
||||
interface Employee {
|
||||
name: string;
|
||||
mor: number;
|
||||
hap: number;
|
||||
ene: number;
|
||||
int: number;
|
||||
cha: number;
|
||||
exp: number;
|
||||
cre: number;
|
||||
eff: number;
|
||||
sal: number;
|
||||
loc: string;
|
||||
pos: string;
|
||||
}
|
||||
|
||||
interface Product {
|
||||
name: string;
|
||||
dmd: number;
|
||||
cmp: number;
|
||||
pCost: number;
|
||||
sCost: string | number;
|
||||
}
|
||||
|
||||
interface Material {
|
||||
name: string;
|
||||
qty: number;
|
||||
qlt: number;
|
||||
}
|
||||
|
||||
interface Warehouse {
|
||||
level: number;
|
||||
loc: string;
|
||||
size: number;
|
||||
sizeUsed: number;
|
||||
}
|
||||
|
||||
interface Office {
|
||||
loc: string;
|
||||
size: number;
|
||||
minEne: number;
|
||||
maxEne: number;
|
||||
minHap: number;
|
||||
maxHap: number;
|
||||
maxMor: number;
|
||||
employees: string[];
|
||||
employeeProd: EmployeeJobs;
|
||||
}
|
||||
|
||||
interface EmployeeJobs {
|
||||
Operations: number;
|
||||
Engineer: number;
|
||||
Business: number;
|
||||
Management: number;
|
||||
"Research & Development": number;
|
||||
Training: number;
|
||||
Unassigned: number;
|
||||
}
|
||||
|
||||
interface Division {
|
||||
name: string;
|
||||
type: string;
|
||||
awareness: number;
|
||||
popularity: number;
|
||||
prodMult: number;
|
||||
research: number;
|
||||
lastCycleRevenue: number;
|
||||
lastCycleExpenses: number;
|
||||
thisCycleRevenue: number;
|
||||
thisCycleExpenses: number;
|
||||
upgrades: number[];
|
||||
cities: string[];
|
||||
}
|
||||
|
@ -68,8 +68,8 @@ SourceFiles["SourceFile5"] = new SourceFile(
|
||||
persistent (it never gets reset back to 1). However, gaining Intelligence experience is much slower than other
|
||||
stats, and it is also hidden (you won't know when you gain experience and how much). Higher Intelligence levels
|
||||
will boost your production for many actions in the game. In addition, this Source-File will unlock the
|
||||
getBitNodeMultipliers() and let you start with Formulas.exe, and will raise all of your hacking-related
|
||||
multipliers by:
|
||||
getBitNodeMultipliers() Netscript function and let you start with Formulas.exe, and will raise all of your
|
||||
hacking-related multipliers by:
|
||||
<br />
|
||||
<br />
|
||||
Level 1: 8%
|
||||
|
Loading…
Reference in New Issue
Block a user