From 2a98b0a1b94fc47dcc1a75af0faa05e68d148acc Mon Sep 17 00:00:00 2001 From: Dev Date: Fri, 4 Aug 2023 11:19:27 +0100 Subject: [PATCH] Move trader enum checking logic into traderHelper --- project/src/helpers/TraderHelper.ts | 10 ++++++++++ project/src/services/ProfileFixerService.ts | 6 ++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/project/src/helpers/TraderHelper.ts b/project/src/helpers/TraderHelper.ts index 0fe754a4..4610ea8e 100644 --- a/project/src/helpers/TraderHelper.ts +++ b/project/src/helpers/TraderHelper.ts @@ -416,4 +416,14 @@ export class TraderHelper return keys[0] as Traders; } + + /** + * Does the 'Traders' enum has a value that matches the passed in parameter + * @param value Value to check for + * @returns True, values exists in Traders enum as a value + */ + public traderEnumHasValue(value: string): boolean + { + return Object.values(Traders).some((x) => x === value); + } } \ No newline at end of file diff --git a/project/src/services/ProfileFixerService.ts b/project/src/services/ProfileFixerService.ts index 54eec43d..2f4b11db 100644 --- a/project/src/services/ProfileFixerService.ts +++ b/project/src/services/ProfileFixerService.ts @@ -3,6 +3,7 @@ import { inject, injectable } from "tsyringe"; import { HideoutHelper } from "../helpers/HideoutHelper"; import { InventoryHelper } from "../helpers/InventoryHelper"; import { ItemHelper } from "../helpers/ItemHelper"; +import { TraderHelper } from "../helpers/TraderHelper"; import { IPmcData } from "../models/eft/common/IPmcData"; import { Bonus, HideoutSlot } from "../models/eft/common/tables/IBotBase"; import { @@ -35,6 +36,7 @@ export class ProfileFixerService @inject("Watermark") protected watermark: Watermark, @inject("HideoutHelper") protected hideoutHelper: HideoutHelper, @inject("InventoryHelper") protected inventoryHelper: InventoryHelper, + @inject("TraderHelper") protected traderHelper: TraderHelper, @inject("ItemHelper") protected itemHelper: ItemHelper, @inject("LocalisationService") protected localisationService: LocalisationService, @inject("TimeUtil") protected timeUtil: TimeUtil, @@ -740,7 +742,7 @@ export class ProfileFixerService { for (const activeQuest of repeatable.activeQuests ?? []) { - if (!Object.values(Traders).some((x) => x === activeQuest.traderId)) + if (!this.traderHelper.traderEnumHasValue(activeQuest.traderId)) { this.logger.error(this.localisationService.getText("fixer-mod_item_found", activeQuest.traderId)); if (this.coreConfig.fixes.removeModItemsFromProfile) @@ -779,7 +781,7 @@ export class ProfileFixerService for (const traderId in fullProfile.traderPurchases) { - if (!Object.values(Traders).some((x) => x === traderId)) + if (!this.traderHelper.traderEnumHasValue(traderId)) { this.logger.error(this.localisationService.getText("fixer-mod_item_found", traderId)); if (this.coreConfig.fixes.removeModItemsFromProfile)