From 6b82663ee18a8b6e7ca09d2ab49fb12b3a537849 Mon Sep 17 00:00:00 2001 From: Dev Date: Mon, 18 Dec 2023 11:18:13 +0000 Subject: [PATCH] Fix items with a condition property not being correctly classified by ragfair code --- project/src/helpers/RagfairOfferHelper.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/project/src/helpers/RagfairOfferHelper.ts b/project/src/helpers/RagfairOfferHelper.ts index 235ec317..ee93d04a 100644 --- a/project/src/helpers/RagfairOfferHelper.ts +++ b/project/src/helpers/RagfairOfferHelper.ts @@ -597,8 +597,7 @@ export class RagfairOfferHelper return false; } - if ( - (item.upd.MedKit || item.upd.Repairable) + if (this.isConditionItem(item) && !this.itemQualityInRange(item, searchRequest.conditionFrom, searchRequest.conditionTo) ) { @@ -668,6 +667,20 @@ export class RagfairOfferHelper return true; } + /** + * Does the passed in item have a condition property + * @param item Item to check + * @returns True if has condition + */ + protected isConditionItem(item: Item): boolean + { + // thanks typescript, undefined assertion is not returnable since it + // tries to return a multitype object + return (item.upd.MedKit || item.upd.Repairable || item.upd.Resource || item.upd.FoodDrink || item.upd.Key || item.upd.RepairKit) + ? true + : false; + } + /** * Is items quality value within desired range * @param item Item to check quality of