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