diff --git a/markdown/bitburner.officeapi.getofficesizeupgradecost.md b/markdown/bitburner.officeapi.getofficesizeupgradecost.md new file mode 100644 index 000000000..1488a0d85 --- /dev/null +++ b/markdown/bitburner.officeapi.getofficesizeupgradecost.md @@ -0,0 +1,28 @@ + + +[Home](./index.md) > [bitburner](./bitburner.md) > [OfficeAPI](./bitburner.officeapi.md) > [getOfficeSizeUpgradeCost](./bitburner.officeapi.getofficesizeupgradecost.md) + +## OfficeAPI.getOfficeSizeUpgradeCost() method + +Cost to Upgrade office size. + +Signature: + +```typescript +getOfficeSizeUpgradeCost(divisionName: string, cityName: string, asize: number): number; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| divisionName | string | Name of the division | +| cityName | string | Name of the city | +| asize | number | | + +Returns: + +number + +Cost of upgrading the office + diff --git a/markdown/bitburner.officeapi.md b/markdown/bitburner.officeapi.md index ad66b2683..a3fcca6d9 100644 --- a/markdown/bitburner.officeapi.md +++ b/markdown/bitburner.officeapi.md @@ -26,6 +26,7 @@ Requires the Office API upgrade from your corporation. | [getHireAdVertCost(divisionName)](./bitburner.officeapi.gethireadvertcost.md) | Get the cost to Hire AdVert | | [getHireAdVertCount(adivisionName)](./bitburner.officeapi.gethireadvertcount.md) | Get the number of times you have Hired AdVert | | [getOffice(divisionName, cityName)](./bitburner.officeapi.getoffice.md) | Get data about an office | +| [getOfficeSizeUpgradeCost(divisionName, cityName, asize)](./bitburner.officeapi.getofficesizeupgradecost.md) | Cost to Upgrade office size. | | [getResearchCost(divisionName, researchName)](./bitburner.officeapi.getresearchcost.md) | Get the cost to unlock research | | [hasResearched(divisionName, researchName)](./bitburner.officeapi.hasresearched.md) | Gets if you have unlocked a research | | [hireAdVert(divisionName)](./bitburner.officeapi.hireadvert.md) | Hire AdVert. | diff --git a/src/NetscriptFunctions/Corporation.ts b/src/NetscriptFunctions/Corporation.ts index 52fe44a43..05845801c 100644 --- a/src/NetscriptFunctions/Corporation.ts +++ b/src/NetscriptFunctions/Corporation.ts @@ -543,6 +543,21 @@ export function NetscriptCorporation( return Promise.resolve(office.setEmployeeToJob(job, amount)); }); }, + getOfficeSizeUpgradeCost: function (adivisionName: any, acityName: any, asize: any): number { + checkAccess("getOfficeSizeUpgradeCost", 8); + const divisionName = helper.string("getOfficeSizeUpgradeCost", "divisionName", adivisionName); + const cityName = helper.string("getOfficeSizeUpgradeCost", "cityName", acityName); + const size = helper.number("getOfficeSizeUpgradeCost", "size", asize); + if (size < 0) throw new Error("Invalid value for size field! Must be numeric and grater than 0"); + const office = getOffice(divisionName, cityName); + const initialPriceMult = Math.round(office.size / CorporationConstants.OfficeInitialSize); + const costMultiplier = 1.09; + let mult = 0; + for (let i = 0; i < size / CorporationConstants.OfficeInitialSize; ++i) { + mult += Math.pow(costMultiplier, initialPriceMult + i); + } + return CorporationConstants.OfficeInitialCost * mult; + }, assignJob: function (adivisionName: any, acityName: any, aemployeeName: any, ajob: any): Promise { checkAccess("assignJob", 8); const divisionName = helper.string("assignJob", "divisionName", adivisionName); diff --git a/src/ScriptEditor/NetscriptDefinitions.d.ts b/src/ScriptEditor/NetscriptDefinitions.d.ts index 040e6d82f..d99fa5558 100644 --- a/src/ScriptEditor/NetscriptDefinitions.d.ts +++ b/src/ScriptEditor/NetscriptDefinitions.d.ts @@ -6175,6 +6175,14 @@ export interface OfficeAPI { * @returns A promise that is fulfilled when the assignment is complete. */ setAutoJobAssignment(divisionName: string, cityName: string, job: string, amount: number): Promise; + /** + * Cost to Upgrade office size. + * @param divisionName - Name of the division + * @param cityName - Name of the city + * @param size - Amount of positions to open + * @returns Cost of upgrading the office + */ + getOfficeSizeUpgradeCost(divisionName: string, cityName: string, asize: number): number; } /**