mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-17 14:59:16 +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:
@@ -1,7 +1,11 @@
|
||||
import { PositiveInteger } from "../../src/types";
|
||||
import { Corporation } from "../../src/Corporation/Corporation";
|
||||
import { CorpUpgrades } from "../../src/Corporation/data/CorporationUpgrades";
|
||||
import { calculateMaxAffordableUpgrade, calculateUpgradeCost } from "../../src/Corporation/helpers";
|
||||
import {
|
||||
calculateMaxAffordableUpgrade,
|
||||
calculateUpgradeCost,
|
||||
calculateOfficeSizeUpgradeCost,
|
||||
} from "../../src/Corporation/helpers";
|
||||
import { Player, setPlayer } from "../../src/Player";
|
||||
import { PlayerObject } from "../../src/PersonObjects/Player/PlayerObject";
|
||||
import {
|
||||
@@ -112,4 +116,25 @@ describe("Corporation", () => {
|
||||
expectSharesToAddUp(corporation);
|
||||
});
|
||||
});
|
||||
|
||||
describe("helpers.calculateOfficeSizeUpgradeCost matches documented formula", () => {
|
||||
// for discussion and computation of these test values, see:
|
||||
// https://github.com/bitburner-official/bitburner-src/pull/1179#discussion_r1534948725
|
||||
it.each([
|
||||
{ fromSize: 3, increaseBy: 3, expectedCost: 4360000000.0 },
|
||||
{ fromSize: 3, increaseBy: 15, expectedCost: 26093338259.6 },
|
||||
{ fromSize: 3, increaseBy: 150, expectedCost: 3553764305895.24902 },
|
||||
{ fromSize: 6, increaseBy: 3, expectedCost: 4752400000.0 },
|
||||
{ fromSize: 6, increaseBy: 15, expectedCost: 28441738702.964 },
|
||||
{ fromSize: 6, increaseBy: 150, expectedCost: 3873603093425.821 },
|
||||
{ fromSize: 9, increaseBy: 3, expectedCost: 5180116000.0 },
|
||||
{ fromSize: 9, increaseBy: 15, expectedCost: 31001495186.23076 },
|
||||
{ fromSize: 9, increaseBy: 150, expectedCost: 4222227371834.145 },
|
||||
])(
|
||||
"should cost $expectedCost to upgrade office by $increaseBy from size $fromSize",
|
||||
({ fromSize, increaseBy, expectedCost }) => {
|
||||
expect(calculateOfficeSizeUpgradeCost(fromSize, increaseBy as PositiveInteger)).toBeCloseTo(expectedCost, 1);
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user