DOCUMENTATION: Update documentation of Corporation API (#1587)

This commit is contained in:
catloversg
2024-08-16 16:02:23 +07:00
committed by GitHub
parent d82247a404
commit a9cb46606c
69 changed files with 841 additions and 256 deletions

View File

@@ -7579,7 +7579,7 @@ export interface NS {
* ns.tprint(`The last augmentation reset was: ${new Date(lastAugReset)}`);
* ns.tprint(`It has been ${Date.now() - lastAugReset} ms since the last augmentation reset.`);
* ```
* */
*/
getResetInfo(): ResetInfo;
/**
@@ -7934,88 +7934,148 @@ export type NSEnums = {
/**
* Corporation Office API
*
* @remarks
* requires the Office API upgrade from your corporation.
* Requires the Office API upgrade from your corporation.
*
* @public
*/
export interface OfficeAPI {
/**
* Hire an employee.
*
* @remarks
* RAM cost: 20 GB
*
* @param divisionName - Name of the division
* @param city - Name of the city
* @param employeePosition - Position to place into. Defaults to "Unassigned".
* @returns True if an employee was hired, false otherwise
*/
hireEmployee(divisionName: string, city: CityName | `${CityName}`, employeePosition?: CorpEmployeePosition): boolean;
/**
* Upgrade office size.
*
* @remarks
* RAM cost: 20 GB
*
* @param divisionName - Name of the division
* @param city - Name of the city
* @param size - Amount of positions to open
*/
upgradeOfficeSize(divisionName: string, city: CityName | `${CityName}`, size: number): void;
/**
* Throw a party for your employees
* Throw a party for your employees.
*
* @remarks
* RAM cost: 20 GB
*
* @param divisionName - Name of the division
* @param city - Name of the city
* @param costPerEmployee - Amount to spend per employee.
* @returns Multiplier for morale, or zero on failure
*/
throwParty(divisionName: string, city: CityName | `${CityName}`, costPerEmployee: number): number;
/**
* Buy tea for your employees
* Buy tea for your employees.
*
* @remarks
* RAM cost: 20 GB
*
* @param divisionName - Name of the division
* @param city - Name of the city
* @returns true if buying tea was successful, false otherwise
*/
buyTea(divisionName: string, city: CityName | `${CityName}`): boolean;
/**
* Hire AdVert.
*
* @remarks
* RAM cost: 20 GB
*
* @param divisionName - Name of the division
*/
hireAdVert(divisionName: string): void;
/**
* Purchase a research
* Purchase a research.
*
* @remarks
* RAM cost: 20 GB
*
* @param divisionName - Name of the division
* @param researchName - Name of the research
*/
research(divisionName: string, researchName: string): void;
/**
* Get data about an office
* Get data about an office.
*
* @remarks
* RAM cost: 10 GB
*
* @param divisionName - Name of the division
* @param city - Name of the city
* @returns Office data
*/
getOffice(divisionName: string, city: CityName | `${CityName}`): Office;
/**
* Get the cost to hire AdVert.
*
* @remarks
* RAM cost: 10 GB
*
* @param divisionName - Name of the division.
* @returns The cost to hire AdVert.
*/
getHireAdVertCost(divisionName: string): number;
/**
* Get the number of times you have hired AdVert.
*
* @remarks
* RAM cost: 10 GB
*
* @param divisionName - Name of the division.
* @returns Number of times you have hired AdVert.
*/
getHireAdVertCount(divisionName: string): number;
/**
* Get the cost to unlock research
* Get the cost to unlock a research.
*
* @remarks
* RAM cost: 10 GB
*
* @param divisionName - Name of the division
* @param researchName - Name of the research
* @returns cost
* @returns Cost
*/
getResearchCost(divisionName: string, researchName: string): number;
/**
* Gets if you have unlocked a research
* Check if you unlocked a research.
*
* @remarks
* RAM cost: 10 GB
*
* @param divisionName - Name of the division
* @param researchName - Name of the research
* @returns true is unlocked, false if not
*/
hasResearched(divisionName: string, researchName: string): boolean;
/**
* Set the auto job assignment for a job
* Set the job assignment for a job.
*
* @remarks
* RAM cost: 20 GB
*
* @param divisionName - Name of the division
* @param city - Name of the city
* @param job - Name of the job
@@ -8023,8 +8083,13 @@ export interface OfficeAPI {
* @returns true if the employee count reached the target amount, false if not
*/
setAutoJobAssignment(divisionName: string, city: CityName | `${CityName}`, job: string, amount: number): boolean;
/**
* Cost to Upgrade office size.
* Get the cost to upgrade an office.
*
* @remarks
* RAM cost: 10 GB
*
* @param divisionName - Name of the division
* @param city - Name of the city
* @param size - Amount of positions to open
@@ -8035,13 +8100,19 @@ export interface OfficeAPI {
/**
* Corporation Warehouse API
*
* @remarks
* Requires the Warehouse API upgrade from your corporation.
*
* @public
*/
export interface WarehouseAPI {
/**
* Set material sell data.
*
* @remarks
* RAM cost: 20 GB
*
* @param divisionName - Name of the division
* @param city - Name of the city
* @param materialName - Name of the material
@@ -8055,8 +8126,13 @@ export interface WarehouseAPI {
amt: string,
price: string,
): void;
/**
* Set product sell data.
*
* @remarks
* RAM cost: 20 GB
*
* @param divisionName - Name of the division
* @param city - Name of the city
* @param productName - Name of the product
@@ -8072,25 +8148,40 @@ export interface WarehouseAPI {
price: string,
all: boolean,
): void;
/**
* Discontinue a product.
*
* @remarks
* RAM cost: 20 GB
*
* @param divisionName - Name of the division
* @param productName - Name of the product
*/
discontinueProduct(divisionName: string, productName: string): void;
/**
* Set smart supply
* Set smart supply.
*
* @remarks
* RAM cost: 20 GB
*
* @param divisionName - Name of the division
* @param city - Name of the city
* @param enabled - smart supply enabled
* @param enabled - Use true to enable, false otherwise.
*/
setSmartSupply(divisionName: string, city: CityName | `${CityName}`, enabled: boolean): void;
/**
* Set whether smart supply uses leftovers before buying
* Set whether smart supply uses leftovers before buying.
*
* @remarks
* RAM cost: 20 GB
*
* @param divisionName - Name of the division
* @param city - Name of the city
* @param materialName - Name of the material
* @param option - smart supply option, "leftovers" to use leftovers, "imports" to use only imported materials, "none" to not use materials from store
* @param option - Smart supply option. Set "leftovers" to use leftovers, "imports" to use only imported materials, and "none" to not use stored materials.
*/
setSmartSupplyOption(
divisionName: string,
@@ -8098,16 +8189,26 @@ export interface WarehouseAPI {
materialName: string,
option: CorpSmartSupplyOption,
): void;
/**
* Set material buy data
* Set material buy data.
*
* @remarks
* RAM cost: 20 GB
*
* @param divisionName - Name of the division
* @param city - Name of the city
* @param materialName - Name of the material
* @param amt - Amount of material to buy
*/
buyMaterial(divisionName: string, city: CityName | `${CityName}`, materialName: string, amt: number): void;
/**
* Set material to bulk buy
* Set material to bulk-buy.
*
* @remarks
* RAM cost: 20 GB
*
* @param divisionName - Name of the division
* @param city - Name of the city
* @param materialName - Name of the material
@@ -8115,56 +8216,100 @@ export interface WarehouseAPI {
*/
bulkPurchase(divisionName: string, city: CityName | `${CityName}`, materialName: string, amt: number): void;
/** Get warehouse data
/**
* Get warehouse data.
*
* @remarks
* RAM cost: 10 GB
*
* @param divisionName - Name of the division
* @param city - Name of the city
* @returns warehouse data */
* @returns Warehouse data
*/
getWarehouse(divisionName: string, city: CityName | `${CityName}`): Warehouse;
/** Get product data
/**
* Get product data.
*
* @remarks
* RAM cost: 10 GB
*
* @param divisionName - Name of the division
* @param cityName - Name of the city
* @param productName - Name of the product
* @returns product data */
* @returns Product data
*/
getProduct(divisionName: string, cityName: CityName | `${CityName}`, productName: string): Product;
/**
* Get material data
* Get material data.
*
* @remarks
* RAM cost: 10 GB
*
* @param divisionName - Name of the division
* @param city - Name of the city
* @param materialName - Name of the material
* @returns material data
* @returns Material data
*/
getMaterial(divisionName: string, city: CityName | `${CityName}`, materialName: string): Material;
/**
* Set market TA 1 for a material.
* Set Market-TA1 for a material.
*
* @remarks
* RAM cost: 20 GB
*
* @param divisionName - Name of the division
* @param city - Name of the city
* @param materialName - Name of the material
* @param on - market ta enabled
* @param on - Use true to enable, false otherwise.
*/
setMaterialMarketTA1(divisionName: string, city: CityName | `${CityName}`, materialName: string, on: boolean): void;
/**
* Set market TA 2 for a material.
* Set Market-TA2 for a material.
*
* @remarks
* RAM cost: 20 GB
*
* @param divisionName - Name of the division
* @param city - Name of the city
* @param materialName - Name of the material
* @param on - market ta enabled
* @param on - Use true to enable, false otherwise.
*/
setMaterialMarketTA2(divisionName: string, city: CityName | `${CityName}`, materialName: string, on: boolean): void;
/** * Set market TA 1 for a product.
/**
* Set Market-TA1 for a product.
*
* @remarks
* RAM cost: 20 GB
*
* @param divisionName - Name of the division
* @param productName - Name of the product
* @param on - market ta enabled */
* @param on - Use true to enable, false otherwise.
*/
setProductMarketTA1(divisionName: string, productName: string, on: boolean): void;
/** Set market TA 2 for a product.
/**
* Set Market-TA2 for a product.
*
* @remarks
* RAM cost: 20 GB
*
* @param divisionName - Name of the division
* @param productName - Name of the product
* @param on - market ta enabled */
* @param on - Use true to enable, false otherwise.
*/
setProductMarketTA2(divisionName: string, productName: string, on: boolean): void;
/**
* Set material export data
* Set material export data.
*
* @remarks
* RAM cost: 20 GB
*
* @param sourceDivision - Source division
* @param sourceCity - Source city
* @param targetDivision - Target division
@@ -8180,8 +8325,13 @@ export interface WarehouseAPI {
materialName: string,
amt: number | string,
): void;
/**
* Cancel material export
* Cancel material export.
*
* @remarks
* RAM cost: 20 GB
*
* @param sourceDivision - Source division
* @param sourceCity - Source city
* @param targetDivision - Target division
@@ -8195,21 +8345,36 @@ export interface WarehouseAPI {
targetCity: CityName | `${CityName}`,
materialName: string,
): void;
/**
* Purchase warehouse for a new city
* Purchase warehouse for a new city.
*
* @remarks
* RAM cost: 20 GB
*
* @param divisionName - Name of the division
* @param city - Name of the city
*/
purchaseWarehouse(divisionName: string, city: CityName | `${CityName}`): void;
/**
* Upgrade warehouse
* Upgrade warehouse.
*
* @remarks
* RAM cost: 20 GB
*
* @param divisionName - Name of the division
* @param city - Name of the city
* @param amt - amount of upgrades defaults to 1
* @param amt - Amount of upgrades. Defaults to 1.
*/
upgradeWarehouse(divisionName: string, city: CityName | `${CityName}`, amt?: number): void;
/**
* Create a new product
* Create a new product.
*
* @remarks
* RAM cost: 20 GB
*
* @param divisionName - Name of the division
* @param city - Name of the city
* @param productName - Name of the product
@@ -8223,8 +8388,13 @@ export interface WarehouseAPI {
designInvest: number,
marketingInvest: number,
): void;
/**
* Limit Material Production.
* Limit material production.
*
* @remarks
* RAM cost: 20 GB
*
* @param divisionName - Name of the division.
* @param city - Name of the city.
* @param materialName - Name of the material.
@@ -8236,25 +8406,40 @@ export interface WarehouseAPI {
materialName: string,
qty: number,
): void;
/**
* Limit Product Production.
* Limit product production.
*
* @remarks
* RAM cost: 20 GB
*
* @param divisionName - Name of the division.
* @param city - Name of the city.
* @param productName - Name of the product.
* @param qty - Amount to limit to. Pass a negative value to remove the limit instead.
*/
limitProductProduction(divisionName: string, city: CityName | `${CityName}`, productName: string, qty: number): void;
/**
* Gets the cost to upgrade a warehouse to the next level
* Get the cost to upgrade a warehouse to the next level.
*
* @remarks
* RAM cost: 10 GB
*
* @param divisionName - Name of the division
* @param city - Name of the city
* @param amt - amount of upgrades. Optional, defaults to 1
* @returns cost to upgrade
* @param amt - Amount of upgrades. Optional. Defaults to 1.
* @returns Cost to upgrade
*/
getUpgradeWarehouseCost(divisionName: string, city: CityName | `${CityName}`, amt?: number): number;
/**
* Check if you have a warehouse in city
* @returns true if warehouse is present, false if not
* Check if you have a warehouse in city.
*
* @remarks
* RAM cost: 10 GB
*
* @returns true if warehouse is present, false if not.
*/
hasWarehouse(divisionName: string, city: CityName | `${CityName}`): boolean;
}
@@ -8264,133 +8449,281 @@ export interface WarehouseAPI {
* @public
*/
export interface Corporation extends WarehouseAPI, OfficeAPI {
/** Returns whether the player has a corporation. Does not require API access.
* @returns whether the player has a corporation */
/**
* Returns whether the player has a corporation. Does not require API access.
*
* @remarks
* RAM cost: 0 GB
*
* @returns Whether the player has a corporation
*/
hasCorporation(): boolean;
/** Create a Corporation
/**
* Create a Corporation.
*
* @remarks
* RAM cost: 20 GB
*
* This function throws an error if:
*
* - Try to self-fund outside BitNode 3.
*
* - Be in a BitNode that has CorporationSoftcap (a BN modifier) less than 0.15. Use
* {@link NS.getBitNodeMultipliers | getBitNodeMultipliers} to get the value of this modifier.
*
* @param corporationName - Name of the corporation
* @param selfFund - If you should self fund, defaults to true, false will only work on BitNode 3
* @returns true if created and false if not */
* @param selfFund - If you want to self-fund. Defaults to true, false will only work in BitNode 3.
* @returns true if created and false if not
*/
createCorporation(corporationName: string, selfFund: boolean): boolean;
/** Check if you have a one time unlockable upgrade
/**
* Check if you have a one-time unlockable upgrade.
*
* @remarks
* RAM cost: 10 GB
*
* @param upgradeName - Name of the upgrade
* @returns true if unlocked and false if not */
* @returns true if unlocked and false if not
*/
hasUnlock(upgradeName: string): boolean;
/** Gets the cost to unlock a one time unlockable upgrade
/**
* Get the cost to unlock a one-time unlockable upgrade.
*
* @remarks
* RAM cost: 10 GB
*
* @param upgradeName - Name of the upgrade
* @returns cost of the upgrade */
* @returns Cost of the upgrade
*/
getUnlockCost(upgradeName: string): number;
/** Get the level of a levelable upgrade
/**
* Get the level of a levelable upgrade.
*
* @remarks
* RAM cost: 10 GB
*
* @param upgradeName - Name of the upgrade
* @returns the level of the upgrade */
* @returns The level of the upgrade
*/
getUpgradeLevel(upgradeName: string): number;
/** Gets the cost to unlock the next level of a levelable upgrade
/**
* Get the cost to unlock the next level of a levelable upgrade.
*
* @remarks
* RAM cost: 10 GB
*
* @param upgradeName - Name of the upgrade
* @returns cost of the upgrade */
* @returns Cost of the upgrade
*/
getUpgradeLevelCost(upgradeName: string): number;
/** Get an offer for investment based on you companies current valuation
* @returns An offer of investment */
/**
* Get an offer for investment based on current corporation valuation.
*
* @remarks
* RAM cost: 10 GB
*
* @returns An offer of investment
*/
getInvestmentOffer(): InvestmentOffer;
/** Get corporation related constants
* @returns corporation related constants */
/**
* Get corporation-related constants.
*
* @remarks
* RAM cost: 0 GB
*
* @returns Corporation-related constants
*/
getConstants(): CorpConstants;
/** Get constant industry definition data for a specific industry */
/**
* Get constant data of an industry.
*
* @remarks
* RAM cost: 10 GB
*
* @param industryName - Name of the industry
* @returns Industry data
*/
getIndustryData(industryName: CorpIndustryName): CorpIndustryData;
/** Get constant data for a specific material */
/**
* Get constant data of a material.
*
* @remarks
* RAM cost: 10 GB
*
* @param materialName - Name of the material
* @returns Material data
*/
getMaterialData(materialName: CorpMaterialName): CorpMaterialConstantData;
/** Accept investment based on you companies current valuation
/**
* Accept the investment offer. The value of offer is based on current corporation valuation.
*
* @remarks
* Is based on current valuation and will not honer a specific Offer
* @returns An offer of investment */
* RAM cost: 20 GB
*
* @returns true if you successfully accept the offer, false if not
*/
acceptInvestmentOffer(): boolean;
/** Go public
* @param numShares - number of shares you would like to issue for your IPO
* @returns true if you successfully go public, false if not */
/**
* Go public.
*
* @remarks
* RAM cost: 20 GB
*
* @param numShares - Number of shares you would like to issue for your IPO
* @returns true if you successfully go public, false if not
*/
goPublic(numShares: number): boolean;
/** Bribe a faction
/**
* Bribe a faction.
*
* @remarks
* RAM cost: 20 GB
*
* @param factionName - Faction name
* @param amountCash - Amount of money to bribe
* @returns True if successful, false if not */
* @returns true if successful, false if not
*/
bribe(factionName: string, amountCash: number): boolean;
/** Get corporation data
* @returns Corporation data */
/**
* Get corporation data.
*
* @remarks
* RAM cost: 10 GB
*
* @returns Corporation data
*/
getCorporation(): CorporationInfo;
/** Get division data
/**
* Get division data.
*
* @remarks
* RAM cost: 10 GB
*
* @param divisionName - Name of the division
* @returns Division data */
* @returns Division data
*/
getDivision(divisionName: string): Division;
/** Expand to a new industry
/**
* Expand to a new industry.
*
* @remarks
* RAM cost: 20 GB
*
* @param industryType - Name of the industry
* @param divisionName - Name of the division */
* @param divisionName - Name of the division
*/
expandIndustry(industryType: CorpIndustryName, divisionName: string): void;
/** Expand to a new city
/**
* Expand to a new city.
*
* @remarks
* RAM cost: 20 GB
*
* @param divisionName - Name of the division
* @param city - Name of the city */
* @param city - Name of the city
*/
expandCity(divisionName: string, city: CityName | `${CityName}`): void;
/** Unlock an upgrade
* @param upgradeName - Name of the upgrade */
/**
* Unlock an upgrade.
*
* @remarks
* RAM cost: 20 GB
*
* @param upgradeName - Name of the upgrade
*/
purchaseUnlock(upgradeName: string): void;
/** Level an upgrade.
* @param upgradeName - Name of the upgrade */
/**
* Level up an upgrade.
*
* @remarks
* RAM cost: 20 GB
*
* @param upgradeName - Name of the upgrade
*/
levelUpgrade(upgradeName: string): void;
/** Issue dividends
* @param rate - Fraction of profit to issue as dividends. */
/**
* Issue dividends.
*
* @remarks
* RAM cost: 20 GB
*
* @param rate - Fraction of profit to issue as dividends.
*/
issueDividends(rate: number): void;
/** Issue new shares
* @param amount - Number of new shares to issue, will be rounded to nearest 10m. Defaults to max amount.
* @returns Amount of funds generated for the corporation. */
/**
* Issue new shares.
*
* @remarks
* RAM cost: 20 GB
*
* @param amount - Number of new shares to issue. It will be rounded to nearest 10 million. Defaults to max amount.
* @returns Amount of funds generated for the corporation.
*/
issueNewShares(amount?: number): number;
/** Buyback Shares.
* Spend money from the player's wallet to transfer shares from public traders to the CEO.
* @param amount - Amount of shares to buy back, must be integer and larger than 0 */
/**
* Buyback shares. Spend money from the player's wallet to transfer shares from public traders to the CEO.
*
* @remarks
* RAM cost: 20 GB
*
* @param amount - Amount of shares to buy back, must be integer and larger than 0
*/
buyBackShares(amount: number): void;
/** Sell Shares.
* Transfer shares from the CEO to public traders to receive money in the player's wallet.
* @param amount - Amount of shares to sell, must be integer between 1 and 100t */
/**
* Sell shares. Transfer shares from the CEO to public traders to receive money in the player's wallet.
*
* @remarks
* RAM cost: 20 GB
*
* @param amount - Amount of shares to sell, must be integer between 1 and 100t
*/
sellShares(amount: number): void;
/** Get bonus time.
* Bonus time is accumulated when the game is offline or if the game is inactive in the browser.
* “Bonus time makes the game progress faster.
* @returns Bonus time for the Corporation mechanic in milliseconds. */
/**
* Get bonus time. Bonus time is accumulated when the game is offline or if the game is inactive in the browser. Bonus
* time makes the corporation progress faster.
*
* @remarks
* RAM cost: 0 GB
*
* @returns Bonus time for the Corporation mechanic in milliseconds.
*/
getBonusTime(): number;
/**
* Sleep until the next Corporation update has happened.
* Sleep until the next Corporation update happens.
*
* @remarks
* RAM cost: 1 GB
*
* The amount of real time spent asleep between updates can vary due to "bonus time"
* (usually 200 milliseconds - 2 seconds).
*
* @returns Promise that resolves to the name of the state that was just processed.
* If the returned state is X, it means X just happened.
*
* I.e. when the state is PURCHASE, it means purchasing has just happened.
* Note that this is the state just before `getCorporation().state`.
*
* Possible states are START, PURCHASE, PRODUCTION, EXPORT, SALE.
* Possible states are START, PURCHASE, PRODUCTION, EXPORT, SALE.
*
* @example
* ```js
@@ -8401,15 +8734,19 @@ export interface Corporation extends WarehouseAPI, OfficeAPI {
* // Manage the Corporation
* }
* ```
*
* @returns Promise that resolves to the name of the state that was just processed.
*/
nextUpdate(): Promise<CorpStateName>;
/**
* Sell a division
* Sell a division.
*
* @remarks
* RAM cost: 20 GB
*
* @param divisionName - Name of the division */
* @param divisionName - Name of the division
*/
sellDivision(divisionName: string): void;
}