mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-05-02 05:47:14 +02:00
CORPORATION: more granular office size upgrades (#1179)
Allows corporation.upgradeOfficeSize to increase the size of a Corporation office by a non-multiple of 3 and also be charged a corresponding amount of corporate funds. See #1166 for details of current behavior.
This commit is contained in:
@@ -63,7 +63,7 @@ import { InternalAPI, NetscriptContext, setRemovedFunctions } from "../Netscript
|
||||
import { helpers } from "../Netscript/NetscriptHelpers";
|
||||
import { getEnumHelper } from "../utils/EnumHelper";
|
||||
import { MaterialInfo } from "../Corporation/MaterialInfo";
|
||||
import { calculateUpgradeCost } from "../Corporation/helpers";
|
||||
import { calculateOfficeSizeUpgradeCost, calculateUpgradeCost } from "../Corporation/helpers";
|
||||
import { PositiveInteger } from "../types";
|
||||
import { getRecordKeys } from "../Types/Record";
|
||||
|
||||
@@ -504,20 +504,13 @@ export function NetscriptCorporation(): InternalAPI<NSCorporation> {
|
||||
const researchName = getEnumHelper("CorpResearchName").nsGetMember(ctx, _researchName, "researchName");
|
||||
return hasResearched(getDivision(divisionName), researchName);
|
||||
},
|
||||
getOfficeSizeUpgradeCost: (ctx) => (_divisionName, _cityName, _size) => {
|
||||
getOfficeSizeUpgradeCost: (ctx) => (_divisionName, _cityName, _increase) => {
|
||||
checkAccess(ctx, CorpUnlockName.OfficeAPI);
|
||||
const divisionName = helpers.string(ctx, "divisionName", _divisionName);
|
||||
const cityName = getEnumHelper("CityName").nsGetMember(ctx, _cityName);
|
||||
const size = helpers.number(ctx, "size", _size);
|
||||
if (size < 0) throw new Error("Invalid value for size field! Must be numeric and greater than 0");
|
||||
const increase = helpers.positiveInteger(ctx, "increase", _increase);
|
||||
const office = getOffice(divisionName, cityName);
|
||||
const initialPriceMult = Math.round(office.size / corpConstants.officeInitialSize);
|
||||
const costMultiplier = 1.09;
|
||||
let mult = 0;
|
||||
for (let i = 0; i < size / corpConstants.officeInitialSize; ++i) {
|
||||
mult += Math.pow(costMultiplier, initialPriceMult + i);
|
||||
}
|
||||
return corpConstants.officeInitialCost * mult;
|
||||
return calculateOfficeSizeUpgradeCost(office.size, increase);
|
||||
},
|
||||
setAutoJobAssignment: (ctx) => (_divisionName, _cityName, _job, _amount) => {
|
||||
checkAccess(ctx, CorpUnlockName.OfficeAPI);
|
||||
@@ -558,8 +551,8 @@ export function NetscriptCorporation(): InternalAPI<NSCorporation> {
|
||||
checkAccess(ctx, CorpUnlockName.OfficeAPI);
|
||||
const divisionName = helpers.string(ctx, "divisionName", _divisionName);
|
||||
const cityName = getEnumHelper("CityName").nsGetMember(ctx, _cityName);
|
||||
const size = helpers.number(ctx, "size", _size);
|
||||
if (size < 0) throw new Error("Invalid value for size field! Must be numeric and greater than 0");
|
||||
const size = helpers.positiveInteger(ctx, "size", _size);
|
||||
|
||||
const office = getOffice(divisionName, cityName);
|
||||
const corporation = getCorporation();
|
||||
UpgradeOfficeSize(corporation, office, size);
|
||||
|
||||
Reference in New Issue
Block a user