Merge pull request #1822 from danielyxie/dev

corp api
This commit is contained in:
hydroflame 2021-12-03 23:08:30 -05:00 committed by GitHub
commit 181b7f39e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 6588 additions and 339 deletions

163
dist/bitburner.d.ts vendored

@ -826,6 +826,30 @@ export declare interface CodingContract {
getNumTriesRemaining(filename: string, host?: string): number; 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. * Data representing the internal values of a crime.
* @public * @public
@ -873,6 +897,46 @@ export declare interface CrimeStats {
intelligence_exp: number; 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. * Object representing data representing a gang member equipment.
* @public * @public
@ -1716,6 +1780,12 @@ export declare interface HacknetServersFormulas {
constants(): any; constants(): any;
} }
export declare interface Material {
name: string;
qty: number;
qlt: number;
}
/** /**
* Object representing all the values related to a hacknet node. * Object representing all the values related to a hacknet node.
* @public * @public
@ -1784,7 +1854,6 @@ export declare interface NS extends Singularity {
* RAM cost: 0 GB * RAM cost: 0 GB
*/ */
readonly stock: TIX; readonly stock: TIX;
/** /**
* *
* Namespace for formulas functions. * Namespace for formulas functions.
@ -1797,6 +1866,11 @@ export declare interface NS extends Singularity {
* RAM cost: 0 GB * RAM cost: 0 GB
*/ */
readonly stanek: Stanek; readonly stanek: Stanek;
/**
* Namespace for corporation functions.
* RAM cost: 0 GB
*/
readonly corporation: Corporation;
/** /**
* Arguments passed into the script. * Arguments passed into the script.
@ -3406,6 +3480,31 @@ export declare interface NS extends Singularity {
flags(schema: [string, string | number | boolean | string[]][]): any; 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 * @public
*/ */
@ -3532,6 +3631,14 @@ export declare interface ProcessInfo {
args: string[]; args: string[];
} }
export declare interface Product {
name: string;
dmd: number;
cmp: number;
pCost: number;
sCost: string | number;
}
/** /**
* @public * @public
*/ */
@ -5134,4 +5241,58 @@ export declare interface TIX {
purchase4SMarketDataTixApi(): boolean; 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 { } export { }

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 * 94 achievements added
* Release is 2021-12-10. * Release is 2021-12-10.
** Corporation API **
* Added corporation API. (Unstable)
** Netscript ** ** Netscript **
* tprintf crashes when not giving a format as first arg. * 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

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 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 /> much). Higher Intelligence levels will boost your production for many actions in the game. <br />
<br /> <br />
In addition, this Source-File will unlock the getBitNodeMultipliers() and getServer() Netscript functions, as well In addition, this Source-File will unlock the getBitNodeMultipliers() Netscript function and let you start with
as the formulas API, and will also raise all of your hacking-related multipliers by: Formulas.exe, and will also raise all of your hacking-related multipliers by:
<br /> <br />
<br /> <br />
Level 1: 8% 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 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 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 city-wide blackout. The CIA suspects that Juggernaut is a heavily-augmented Synthoid, and have thus enlisted our
help. help.
<br /> <br />
@ -126,9 +126,9 @@ export const BlackOperations: {
be catastrophic. be catastrophic.
<br /> <br />
<br /> <br />
We do not have the power or jurisdiction to shutdown this down through legal or political means, so we must We do not have the power or jurisdiction to shut this down through legal or political means, so we must resort
resort to a covert operation. Your goal is to destroy this technology and eliminate anyone who was involved in to a covert operation. Your goal is to destroy this technology and eliminate anyone who was involved in its
its creation. creation.
</> </>
), ),
}, },
@ -149,8 +149,8 @@ export const BlackOperations: {
"Operation Tyrell": { "Operation Tyrell": {
desc: ( desc: (
<> <>
A week ago Blade Industries reported a small break-in at one of their Aevum Augmentation storage facitilities. A week ago Blade Industries reported a small break-in at one of their Aevum Augmentation storage facilities. We
We figured out that The Dark Army was behind the heist, and didn't think any more of it. However, we've just 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. discovered that several known MK-VI Synthoids were part of that break-in group.
<br /> <br />
<br /> <br />
@ -209,12 +209,12 @@ export const BlackOperations: {
desc: ( desc: (
<> <>
DreamSense Technologies is an advertising company that uses special technology to transmit their ads into the 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 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. compromised by Synthoids and is being used to spread pro-Synthoid propaganda.
<br /> <br />
<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": { "Field Analysis": {
desc: ( 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 and activities. Completing this action will improve the accuracy of your Synthoid population estimated in the
current city. current city.
<br /> <br />

@ -286,6 +286,10 @@ export const CONSTANTS: {
* 94 achievements added * 94 achievements added
* Release is 2021-12-10. * Release is 2021-12-10.
** Corporation API **
* Added corporation API. (Unstable)
** Netscript ** ** Netscript **
* tprintf crashes when not giving a format as first arg. * tprintf crashes when not giving a format as first arg.

@ -31,7 +31,6 @@ export class Employee {
cre: number; cre: number;
eff: number; eff: number;
sal: number; sal: number;
pro = 0;
cyclesUntilRaise = CorporationConstants.CyclesPerEmployeeRaise; cyclesUntilRaise = CorporationConstants.CyclesPerEmployeeRaise;
loc: string; loc: string;
pos: string; pos: string;
@ -129,25 +128,6 @@ export class Employee {
return mult; 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 { toJSON(): any {
return Generic_toJSON("Employee", this); return Generic_toJSON("Employee", this);
} }

@ -1431,59 +1431,6 @@ export class Industry implements IIndustry {
return researchTree.getStorageMultiplier(); 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. * 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. // Serialize the current object to a JSON save state.
toJSON(): any { toJSON(): any {
return Generic_toJSON("Material", this); return Generic_toJSON("Material", this);

@ -173,30 +173,6 @@ export class OfficeSpace {
return false; 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 { toJSON(): any {
return Generic_toJSON("OfficeSpace", this); 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. " + "Help national governments further their agendas in exchange for lowered taxes. " +
"This reduces the dividend tax rate by 10%", "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> <Typography variant="h4">Unlocks</Typography>
<Grid container> <Grid container>
{Object.values(CorporationUnlockUpgrades) {Object.values(CorporationUnlockUpgrades)
.filter((upgrade: CorporationUnlockUpgrade) => corp.unlockUpgrades[upgrade[0]] === 0) .filter((upgrade: CorporationUnlockUpgrade) => !corp.unlockUpgrades[upgrade[0]])
.map((upgrade: CorporationUnlockUpgrade) => ( .map((upgrade: CorporationUnlockUpgrade) => (
<UnlockUpgrade rerender={rerender} upgradeData={upgrade} key={upgrade[0]} /> <UnlockUpgrade rerender={rerender} upgradeData={upgrade} key={upgrade[0]} />
))} ))}

@ -6,6 +6,7 @@ import { IMap } from "../types";
export const RamCostConstants: IMap<number> = { export const RamCostConstants: IMap<number> = {
ScriptBaseRamCost: 1.6, ScriptBaseRamCost: 1.6,
ScriptDomRamCost: 25, ScriptDomRamCost: 25,
ScriptCorporationRamCost: 1024 - 1.6,
ScriptHackRamCost: 0.1, ScriptHackRamCost: 0.1,
ScriptHackAnalyzeRamCost: 1, ScriptHackAnalyzeRamCost: 1,
ScriptGrowRamCost: 0.15, ScriptGrowRamCost: 0.15,

@ -447,7 +447,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
const stanek = NetscriptStanek(Player, workerScript, helper); const stanek = NetscriptStanek(Player, workerScript, helper);
const bladeburner = NetscriptBladeburner(Player, workerScript, helper); const bladeburner = NetscriptBladeburner(Player, workerScript, helper);
const codingcontract = NetscriptCodingContract(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 formulas = NetscriptFormulas(Player, workerScript, helper);
const singularity = NetscriptSingularity(Player, workerScript, helper); const singularity = NetscriptSingularity(Player, workerScript, helper);
const stockmarket = NetscriptStockMarket(Player, workerScript, helper); const stockmarket = NetscriptStockMarket(Player, workerScript, helper);
@ -459,6 +459,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
bladeburner: bladeburner, bladeburner: bladeburner,
codingcontract: codingcontract, codingcontract: codingcontract,
sleeve: sleeve, sleeve: sleeve,
corporation: corporation,
stanek: stanek, stanek: stanek,
formulas: formulas, formulas: formulas,
@ -2282,7 +2283,6 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
// add undocumented functions // add undocumented functions
const ns = { const ns = {
...base, ...base,
corporation: corporation,
...extra, ...extra,
}; };
function getFunctionNames(obj: NS, prefix: string): string[] { 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 { IPlayer } from "../PersonObjects/IPlayer";
import { netscriptDelay } from "../NetscriptEvaluator";
import { OfficeSpace } from "../Corporation/OfficeSpace"; import { OfficeSpace } from "../Corporation/OfficeSpace";
import { Employee } from "../Corporation/Employee"; import { Employee } from "../Corporation/Employee";
@ -6,6 +9,19 @@ import { Product } from "../Corporation/Product";
import { Material } from "../Corporation/Material"; import { Material } from "../Corporation/Material";
import { Warehouse } from "../Corporation/Warehouse"; import { Warehouse } from "../Corporation/Warehouse";
import { IIndustry } from "../Corporation/IIndustry"; 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 { import {
NewIndustry, NewIndustry,
@ -35,61 +51,22 @@ import {
} from "../Corporation/Actions"; } from "../Corporation/Actions";
import { CorporationUnlockUpgrades } from "../Corporation/data/CorporationUnlockUpgrades"; import { CorporationUnlockUpgrades } from "../Corporation/data/CorporationUnlockUpgrades";
import { CorporationUpgrades } from "../Corporation/data/CorporationUpgrades"; import { CorporationUpgrades } from "../Corporation/data/CorporationUpgrades";
import { EmployeePositions } from "../Corporation/EmployeePositions";
import { calculateIntelligenceBonus } from "../PersonObjects/formulas/intelligence";
export interface INetscriptCorporation { export function NetscriptCorporation(
expandIndustry(industryName: any, divisionName: any): any; player: IPlayer,
expandCity(divisionName: any, cityName: any): any; workerScript: WorkerScript,
unlockUpgrade(upgradeName: any): any; helper: INetscriptHelper,
levelUpgrade(upgradeName: any): any; ): NSCorporation {
issueDividends(percent: any): any; function getCorporation(): ICorporation {
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 {
const corporation = player.corporation; const corporation = player.corporation;
if (corporation === null) throw new Error("cannot be called without a 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); 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;
@ -131,169 +108,403 @@ export function NetscriptCorporation(player: IPlayer): INetscriptCorporation {
if (employee === undefined) throw new Error(`Invalid employee name: '${employeeName}'`); if (employee === undefined) throw new Error(`Invalid employee name: '${employeeName}'`);
return employee; 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. function checkAccess(func: string, api?: number): void {
// It's here so players can test with if they want. if (player.corporation === null) throw helper.makeRuntimeErrorMsg(`corporation.${func}`, "Must own a corporation.");
return { if (!api) return;
expandIndustry: function (industryName: any, divisionName: any): any {
const corporation = player.corporation; if (!player.corporation.unlockUpgrades[api])
if (corporation === null) throw new Error("Should not be called without a corporation"); throw helper.makeRuntimeErrorMsg(`corporation.${func}`, "You do not have access to this API.");
NewIndustry(corporation, industryName, divisionName); }
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 { getMaterial: function (adivisionName: any, acityName: any, amaterialName: any): NSMaterial {
const division = getDivision(divisionName); checkAccess("getMaterial", 7);
const corporation = player.corporation; const divisionName = helper.string("getMaterial", "divisionName", adivisionName);
if (corporation === null) throw new Error("Should not be called without a corporation"); const cityName = helper.string("getMaterial", "cityName", acityName);
NewCity(corporation, division, cityName); 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 { getProduct: function (adivisionName: any, aproductName: any): NSProduct {
const upgrade = Object.values(CorporationUnlockUpgrades).find((upgrade) => upgrade[2] === upgradeName); checkAccess("getProduct", 7);
if (upgrade === undefined) throw new Error(`No upgrade named '${upgradeName}'`); const divisionName = helper.string("getProduct", "divisionName", adivisionName);
const corporation = player.corporation; const productName = helper.string("getProduct", "productName", aproductName);
if (corporation === null) throw new Error("Should not be called without a corporation"); const product = getProduct(divisionName, productName);
UnlockUpgrade(corporation, upgrade); return {
name: product.name,
dmd: product.dmd,
cmp: product.cmp,
pCost: product.pCost,
sCost: product.sCost,
};
}, },
levelUpgrade: function (upgradeName: any): any { purchaseWarehouse: function (adivisionName: any, acityName: any): void {
const upgrade = Object.values(CorporationUpgrades).find((upgrade) => upgrade[4] === upgradeName); checkAccess("purchaseWarehouse", 7);
if (upgrade === undefined) throw new Error(`No upgrade named '${upgradeName}'`); const divisionName = helper.string("purchaseWarehouse", "divisionName", adivisionName);
const corporation = player.corporation; const cityName = helper.string("purchaseWarehouse", "cityName", acityName);
if (corporation === null) throw new Error("Should not be called without a corporation"); const corporation = getCorporation();
LevelUpgrade(corporation, upgrade); PurchaseWarehouse(corporation, getDivision(divisionName), cityName);
}, },
issueDividends: function (percent: any): any { upgradeWarehouse: function (adivisionName: any, acityName: any): void {
const corporation = player.corporation; checkAccess("upgradeWarehouse", 7);
if (corporation === null) throw new Error("Should not be called without a corporation"); const divisionName = helper.string("upgradeWarehouse", "divisionName", adivisionName);
IssueDividends(corporation, percent); 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); const material = getMaterial(divisionName, cityName, materialName);
SellMaterial(material, amt, price); 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); const product = getProduct(divisionName, productName);
SellProduct(product, cityName, amt, price, all); 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)); 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); const warehouse = getWarehouse(divisionName, cityName);
SetSmartSupply(warehouse, enabled); SetSmartSupply(warehouse, enabled);
}, },
// setSmartSupplyUseLeftovers: function (): any {}, buyMaterial: function (adivisionName: any, acityName: any, amaterialName: any, aamt: any): void {
buyMaterial: function (divisionName: any, cityName: any, materialName: any, amt: any): any { 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); const material = getMaterial(divisionName, cityName, materialName);
BuyMaterial(material, amt); 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 ( makeProduct: function (
divisionName: any, adivisionName: any,
cityName: any, acityName: any,
productName: any, aproductName: any,
designInvest: any, adesignInvest: any,
marketingInvest: any, amarketingInvest: any,
): any { ): void {
const corporation = player.corporation; checkAccess("makeProduct", 7);
if (corporation === null) throw new Error("Should not be called without a corporation"); 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); MakeProduct(corporation, getDivision(divisionName), cityName, productName, designInvest, marketingInvest);
}, },
research: function (divisionName: any, researchName: any): any {
Research(getDivision(divisionName), researchName);
},
exportMaterial: function ( exportMaterial: function (
sourceDivision: any, asourceDivision: any,
sourceCity: any, asourceCity: any,
targetDivision: any, atargetDivision: any,
targetCity: any, atargetCity: any,
materialName: any, amaterialName: any,
amt: any, aamt: any,
): 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 + ""); ExportMaterial(targetDivision, targetCity, getMaterial(sourceDivision, sourceCity, materialName), amt + "");
}, },
cancelExportMaterial: function ( cancelExportMaterial: function (
sourceDivision: any, asourceDivision: any,
sourceCity: any, asourceCity: any,
targetDivision: any, atargetDivision: any,
targetCity: any, atargetCity: any,
materialName: any, amaterialName: any,
amt: any, aamt: any,
): 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 + ""); 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); 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); 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); 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); 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 // If you modify these objects you will affect them for real, it's not
// copies. // copies.
getDivision: function (divisionName: any): any { getDivision: function (adivisionName: any): NSDivision {
return getDivision(divisionName); 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 { getCorporation: function (): CorporationInfo {
return getOffice(divisionName, cityName); checkAccess("getCorporation");
}, const corporation = getCorporation();
getWarehouse: function (divisionName: any, cityName: any): any { return {
return getWarehouse(divisionName, cityName); name: corporation.name,
}, funds: corporation.funds,
getMaterial: function (divisionName: any, cityName: any, materialName: any): any { revenue: corporation.revenue,
return getMaterial(divisionName, cityName, materialName); expenses: corporation.expenses,
}, public: corporation.public,
getProduct: function (divisionName: any, productName: any): any { totalShares: corporation.totalShares,
return getProduct(divisionName, productName); numShares: corporation.numShares,
}, shareSaleCooldown: corporation.shareSaleCooldown,
getEmployee: function (divisionName: any, cityName: any, employeeName: any): any { issuedShares: corporation.issuedShares,
return getEmployee(divisionName, cityName, employeeName); sharePrice: corporation.sharePrice,
state: corporation.state + "",
};
}, },
}; };
} }

@ -141,6 +141,9 @@ async function parseOnlyRamCalculate(
if (ref === "window" && !resolvedRefs.has("window")) { if (ref === "window" && !resolvedRefs.has("window")) {
ram += RamCostConstants.ScriptDomRamCost; ram += RamCostConstants.ScriptDomRamCost;
} }
if (ref === "corporation" && !resolvedRefs.has("corporation")) {
ram += RamCostConstants.ScriptCorporationRamCost;
}
resolvedRefs.add(ref); resolvedRefs.add(ref);

@ -3512,7 +3512,6 @@ export interface NS extends Singularity {
* RAM cost: 0 GB * RAM cost: 0 GB
*/ */
readonly stock: TIX; readonly stock: TIX;
/** /**
* *
* Namespace for formulas functions. * Namespace for formulas functions.
@ -3525,6 +3524,11 @@ export interface NS extends Singularity {
* RAM cost: 0 GB * RAM cost: 0 GB
*/ */
readonly stanek: Stanek; readonly stanek: Stanek;
/**
* Namespace for corporation functions.
* RAM cost: 0 GB
*/
readonly corporation: Corporation;
/** /**
* Arguments passed into the script. * Arguments passed into the script.
@ -5133,3 +5137,160 @@ export interface NS extends Singularity {
*/ */
flags(schema: [string, string | number | boolean | string[]][]): any; 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 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 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 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 getBitNodeMultipliers() Netscript function and let you start with Formulas.exe, and will raise all of your
multipliers by: hacking-related multipliers by:
<br /> <br />
<br /> <br />
Level 1: 8% Level 1: 8%