mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-29 19:13:49 +01:00
Make list of divisions accessable on the corp
This commit is contained in:
parent
360b8d8d16
commit
74019bc2be
@ -53,6 +53,7 @@ import { CorporationUnlockUpgrades } from "../Corporation/data/CorporationUnlock
|
||||
import { CorporationUpgrades } from "../Corporation/data/CorporationUpgrades";
|
||||
import { EmployeePositions } from "../Corporation/EmployeePositions";
|
||||
import { calculateIntelligenceBonus } from "../PersonObjects/formulas/intelligence";
|
||||
import { Industry } from "../Corporation/Industry";
|
||||
|
||||
export function NetscriptCorporation(
|
||||
player: IPlayer,
|
||||
@ -133,6 +134,28 @@ export function NetscriptCorporation(
|
||||
throw helper.makeRuntimeErrorMsg(`corporation.${func}`, "You do not have access to this API.");
|
||||
}
|
||||
|
||||
function getSafeDivision(division: Industry): NSDivision {
|
||||
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,
|
||||
};
|
||||
}
|
||||
|
||||
const warehouseAPI: WarehouseAPI = {
|
||||
getWarehouse: function (adivisionName: any, acityName: any): NSWarehouse {
|
||||
checkAccess("getWarehouse", 7);
|
||||
@ -478,25 +501,7 @@ export function NetscriptCorporation(
|
||||
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,
|
||||
};
|
||||
return getSafeDivision(division);
|
||||
},
|
||||
createCorporation: function (corporationName: string, selfFund = true): boolean {
|
||||
return createCorporation(corporationName, selfFund);
|
||||
@ -516,6 +521,7 @@ export function NetscriptCorporation(
|
||||
issuedShares: corporation.issuedShares,
|
||||
sharePrice: corporation.sharePrice,
|
||||
state: corporation.state.getState(),
|
||||
divisions: corporation.divisions.map((division): NSDivision => getSafeDivision(division)),
|
||||
};
|
||||
},
|
||||
};
|
||||
|
2
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
2
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
@ -6388,6 +6388,8 @@ interface CorporationInfo {
|
||||
sharePrice: number;
|
||||
/** State of the corporation. Possible states are START, PURCHASE, PRODUCTION, SALE, EXPORT. */
|
||||
state: string;
|
||||
/** Array of all divisions */
|
||||
divisions: Division[];
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user