From b364cdf7343c365f4edd3e39e2cca8fe41011cb8 Mon Sep 17 00:00:00 2001 From: Snarling <84951833+Snarling@users.noreply.github.com> Date: Tue, 27 Sep 2022 13:20:42 -0400 Subject: [PATCH] Rebase fix, move hasAugmentation to Person --- src/Crime/CrimeHelpers.ts | 1 + src/PersonObjects/PersonMethods.ts | 4 ++++ src/PersonObjects/Player/PlayerObject.ts | 5 +--- .../Player/PlayerObjectAugmentationMethods.ts | 23 ------------------- 4 files changed, 6 insertions(+), 27 deletions(-) diff --git a/src/Crime/CrimeHelpers.ts b/src/Crime/CrimeHelpers.ts index 56cbe7bc6..c11b6ee47 100644 --- a/src/Crime/CrimeHelpers.ts +++ b/src/Crime/CrimeHelpers.ts @@ -4,6 +4,7 @@ import { Player } from "../Player"; import { dialogBoxCreate } from "../ui/React/DialogBox"; +//This is only used for the player export function determineCrimeSuccess(type: string): boolean { let chance = 0; let found = false; diff --git a/src/PersonObjects/PersonMethods.ts b/src/PersonObjects/PersonMethods.ts index b3657c438..9c4d4bbb8 100644 --- a/src/PersonObjects/PersonMethods.ts +++ b/src/PersonObjects/PersonMethods.ts @@ -197,3 +197,7 @@ export function updateSkillLevels(this: Person): void { this.hp.max = Math.floor(10 + this.skills.defense / 10); this.hp.current = Math.round(this.hp.max * ratio); } + +export function hasAugmentation(this: Person, augName: string, ignoreQueued: boolean = false) { + return this.augmentations.some((a) => a.name === augName && (ignoreQueued || !this.queuedAugmentations.includes(a))); +} diff --git a/src/PersonObjects/Player/PlayerObject.ts b/src/PersonObjects/Player/PlayerObject.ts index d193e13f1..7ee34ca1f 100644 --- a/src/PersonObjects/Player/PlayerObject.ts +++ b/src/PersonObjects/Player/PlayerObject.ts @@ -53,9 +53,7 @@ export class PlayerObject extends Person { moneySourceB = new MoneySourceTracker(); playtimeSinceLastAug = 0; playtimeSinceLastBitnode = 0; - purchasedServers: string[] = []; - queuedAugmentations: IPlayerOwnedAugmentation[] = []; - scriptProdSinceLastAug = 0; + purchasedServers: string[] = []; scriptProdSinceLastAug = 0; sleeves: Sleeve[] = []; sleevesFromCovenant = 0; sourceFiles: PlayerOwnedSourceFile[] = []; @@ -105,7 +103,6 @@ export class PlayerObject extends Person { getUpgradeHomeRamCost = serverMethods.getUpgradeHomeRamCost; getUpgradeHomeCoresCost = serverMethods.getUpgradeHomeCoresCost; gotoLocation = generalMethods.gotoLocation; - hasAugmentation = augmentationMethods.hasAugmentation; hasCorporation = corporationMethods.hasCorporation; hasGangWith = gangMethods.hasGangWith; hasTorRouter = serverMethods.hasTorRouter; diff --git a/src/PersonObjects/Player/PlayerObjectAugmentationMethods.ts b/src/PersonObjects/Player/PlayerObjectAugmentationMethods.ts index 45bfbd44a..a5da1c307 100644 --- a/src/PersonObjects/Player/PlayerObjectAugmentationMethods.ts +++ b/src/PersonObjects/Player/PlayerObjectAugmentationMethods.ts @@ -2,31 +2,8 @@ * Augmentation-related methods for the Player class (PlayerObject) */ import { PlayerObject } from "./PlayerObject"; - -import { Augmentation } from "../../Augmentation/Augmentation"; - import { calculateEntropy } from "../Grafting/EntropyAccumulation"; -export function hasAugmentation(this: PlayerObject, aug: string | Augmentation, ignoreQueued = false): boolean { - const augName: string = aug instanceof Augmentation ? aug.name : aug; - - for (const owned of this.augmentations) { - if (owned.name === augName) { - return true; - } - } - - if (!ignoreQueued) { - for (const owned of this.queuedAugmentations) { - if (owned.name === augName) { - return true; - } - } - } - - return false; -} - export function applyEntropy(this: PlayerObject, stacks = 1): void { // Re-apply all multipliers this.reapplyAllAugmentations();