|
1 | 1 | import { installAugmentations } from "../../../src/Augmentation/AugmentationHelpers";
|
2 | 2 | import { blackOpsArray } from "../../../src/Bladeburner/data/BlackOperations";
|
3 |
| -import { AugmentationName } from "../../../src/Enums"; |
4 |
| -import { Player } from "../../../src/Player"; |
| 3 | +import { AugmentationName, FactionName } from "@enums"; |
| 4 | +import { Player } from "@player"; |
| 5 | +import { prestigeSourceFile } from "../../../src/Prestige"; |
5 | 6 | import { GetServerOrThrow } from "../../../src/Server/AllServers";
|
6 | 7 | import { SpecialServers } from "../../../src/Server/data/SpecialServers";
|
| 8 | +import { Factions } from "../../../src/Faction/Factions"; |
| 9 | +import { PlayerOwnedAugmentation } from "../../../src/Augmentation/PlayerOwnedAugmentation"; |
7 | 10 | import { getNS, initGameEnvironment, setupBasicTestingEnvironment } from "./Utilities";
|
8 | 11 |
|
9 | 12 | function setNumBlackOpsComplete(value: number): void {
|
@@ -179,3 +182,118 @@ describe("destroyW0r1dD43m0n", () => {
|
179 | 182 | });
|
180 | 183 | });
|
181 | 184 | });
|
| 185 | + |
| 186 | +describe("purchaseAugmentation", () => { |
| 187 | + beforeEach(() => { |
| 188 | + setupBasicTestingEnvironment(); |
| 189 | + prestigeSourceFile(true); |
| 190 | + Player.money = 1e100; |
| 191 | + Player.factions.push(FactionName.CyberSec); |
| 192 | + Factions[FactionName.CyberSec].playerReputation = 1e10; |
| 193 | + Player.factions.push(FactionName.Illuminati); |
| 194 | + }); |
| 195 | + |
| 196 | + describe("Success", () => { |
| 197 | + const expectQueuedAugmentation = (augmentationName: AugmentationName, level: number) => { |
| 198 | + expect( |
| 199 | + Player.queuedAugmentations.find((augmentation) => augmentation.name === augmentationName)?.level, |
| 200 | + ).toStrictEqual(level); |
| 201 | + }; |
| 202 | + test("NFG", () => { |
| 203 | + const ns = getNS(); |
| 204 | + expect( |
| 205 | + ns.singularity.purchaseAugmentation(FactionName.CyberSec, AugmentationName.NeuroFluxGovernor), |
| 206 | + ).toStrictEqual(true); |
| 207 | + expectQueuedAugmentation(AugmentationName.NeuroFluxGovernor, 1); |
| 208 | + }); |
| 209 | + // Check if the level of NFG is increased properly. |
| 210 | + test("Upgrade NFG", () => { |
| 211 | + Player.augmentations.push(new PlayerOwnedAugmentation(AugmentationName.NeuroFluxGovernor)); |
| 212 | + const ns = getNS(); |
| 213 | + expect( |
| 214 | + ns.singularity.purchaseAugmentation(FactionName.CyberSec, AugmentationName.NeuroFluxGovernor), |
| 215 | + ).toStrictEqual(true); |
| 216 | + expectQueuedAugmentation(AugmentationName.NeuroFluxGovernor, 2); |
| 217 | + }); |
| 218 | + test("Normal augmentation", () => { |
| 219 | + const ns = getNS(); |
| 220 | + expect( |
| 221 | + ns.singularity.purchaseAugmentation(FactionName.CyberSec, AugmentationName.CranialSignalProcessorsG1), |
| 222 | + ).toStrictEqual(true); |
| 223 | + expectQueuedAugmentation(AugmentationName.CranialSignalProcessorsG1, 1); |
| 224 | + }); |
| 225 | + test("Normal augmentation with prerequisite", () => { |
| 226 | + Player.augmentations.push(new PlayerOwnedAugmentation(AugmentationName.CranialSignalProcessorsG1)); |
| 227 | + const ns = getNS(); |
| 228 | + expect( |
| 229 | + ns.singularity.purchaseAugmentation(FactionName.CyberSec, AugmentationName.CranialSignalProcessorsG2), |
| 230 | + ).toStrictEqual(true); |
| 231 | + expectQueuedAugmentation(AugmentationName.CranialSignalProcessorsG2, 1); |
| 232 | + }); |
| 233 | + test("Buy 0-money-cost augmentation with negative money", () => { |
| 234 | + Player.money = -1000; |
| 235 | + Player.factions.push(FactionName.Daedalus); |
| 236 | + Factions[FactionName.Daedalus].playerReputation = 1e10; |
| 237 | + const ns = getNS(); |
| 238 | + expect(ns.singularity.purchaseAugmentation(FactionName.Daedalus, AugmentationName.TheRedPill)).toStrictEqual( |
| 239 | + true, |
| 240 | + ); |
| 241 | + expectQueuedAugmentation(AugmentationName.TheRedPill, 1); |
| 242 | + }); |
| 243 | + }); |
| 244 | + |
| 245 | + describe("Failure", () => { |
| 246 | + const expectNoQueuedAugmentation = (augmentationName: AugmentationName) => { |
| 247 | + expect(Player.queuedAugmentations.find((augmentation) => augmentation.name === augmentationName)).toStrictEqual( |
| 248 | + undefined, |
| 249 | + ); |
| 250 | + }; |
| 251 | + test("Not a member of specified faction", () => { |
| 252 | + const ns = getNS(); |
| 253 | + expect( |
| 254 | + ns.singularity.purchaseAugmentation(FactionName.Daedalus, AugmentationName.NeuroFluxGovernor), |
| 255 | + ).toStrictEqual(false); |
| 256 | + expectNoQueuedAugmentation(AugmentationName.NeuroFluxGovernor); |
| 257 | + }); |
| 258 | + test("Faction does not have specified augmentation", () => { |
| 259 | + const ns = getNS(); |
| 260 | + expect(ns.singularity.purchaseAugmentation(FactionName.CyberSec, AugmentationName.QLink)).toStrictEqual(false); |
| 261 | + expectNoQueuedAugmentation(AugmentationName.QLink); |
| 262 | + }); |
| 263 | + test("Purchase installed augmentation", () => { |
| 264 | + Player.augmentations.push(new PlayerOwnedAugmentation(AugmentationName.CranialSignalProcessorsG1)); |
| 265 | + const ns = getNS(); |
| 266 | + expect( |
| 267 | + ns.singularity.purchaseAugmentation(FactionName.CyberSec, AugmentationName.CranialSignalProcessorsG1), |
| 268 | + ).toStrictEqual(false); |
| 269 | + expectNoQueuedAugmentation(AugmentationName.CranialSignalProcessorsG1); |
| 270 | + }); |
| 271 | + test("Purchase queued augmentation", () => { |
| 272 | + Player.queuedAugmentations.push(new PlayerOwnedAugmentation(AugmentationName.CranialSignalProcessorsG1)); |
| 273 | + const ns = getNS(); |
| 274 | + expect( |
| 275 | + ns.singularity.purchaseAugmentation(FactionName.CyberSec, AugmentationName.CranialSignalProcessorsG1), |
| 276 | + ).toStrictEqual(false); |
| 277 | + }); |
| 278 | + test("Not have prerequisite augmentation", () => { |
| 279 | + const ns = getNS(); |
| 280 | + expect( |
| 281 | + ns.singularity.purchaseAugmentation(FactionName.CyberSec, AugmentationName.CranialSignalProcessorsG2), |
| 282 | + ).toStrictEqual(false); |
| 283 | + expectNoQueuedAugmentation(AugmentationName.CranialSignalProcessorsG2); |
| 284 | + }); |
| 285 | + test("Not enough money", () => { |
| 286 | + Player.money = 1000; |
| 287 | + const ns = getNS(); |
| 288 | + expect( |
| 289 | + ns.singularity.purchaseAugmentation(FactionName.CyberSec, AugmentationName.CranialSignalProcessorsG1), |
| 290 | + ).toStrictEqual(false); |
| 291 | + expectNoQueuedAugmentation(AugmentationName.CranialSignalProcessorsG1); |
| 292 | + }); |
| 293 | + test("Not enough reputation", () => { |
| 294 | + const ns = getNS(); |
| 295 | + expect(ns.singularity.purchaseAugmentation(FactionName.Illuminati, AugmentationName.QLink)).toStrictEqual(false); |
| 296 | + expectNoQueuedAugmentation(AugmentationName.QLink); |
| 297 | + }); |
| 298 | + }); |
| 299 | +}); |
0 commit comments