Fix some armor not showing up on the flea when Operational filter is enabled (!228)

Some plate carriers have no required plates, and thus were failing the functional check. I've changed it to check for an item count greater than the required plate count (Since `items` also contains the carrier itself).

Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/228
Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
This commit is contained in:
DrakiaXYZ 2024-02-17 10:48:22 +00:00 committed by chomp
parent 64810f7216
commit 91c154daa8

View File

@ -606,7 +606,7 @@ export class RagfairOfferHelper
return false;
}
if (searchRequest.onlyFunctional && this.presetHelper.hasPreset(offerRootItem._tpl) && offer.items.length === 1)
if (searchRequest.onlyFunctional && !this.isItemFunctional(offerRootItem, offer))
{
// don't include non-functional items
return false;
@ -664,6 +664,36 @@ export class RagfairOfferHelper
return true;
}
/**
* Check that the passed in offer item is functional
* @param offerRootItem The root item of the offer
* @param offer The flea offer
* @returns True if the given item is functional
*/
public isItemFunctional(
offerRootItem: Item,
offer: IRagfairOffer
): boolean
{
// Non-presets are always functional
if (!this.presetHelper.hasPreset(offerRootItem._tpl))
{
return true;
}
// For armor items that can hold mods, make sure the item count is atleast the amount of required plates
if (this.itemHelper.armorItemCanHoldMods(offerRootItem._tpl))
{
const offerRootTemplate = this.itemHelper.getItem(offerRootItem._tpl)[1];
const requiredPlateCount = offerRootTemplate._props.Slots?.filter(item => item._required)?.length;
return offer.items.length > requiredPlateCount;
}
// For other presets, make sure the offer has more than 1 item
return offer.items.length > 1;
}
/**
* Should a ragfair offer be visible to the player
* @param searchRequest Search request