Fix durability filtering on flea not working for helmets / armors

Updated  `getItemQualityModifierForOfferItems()` to return root items quality modifer when its a weapon
Fixed `getItemQualityModifierForOfferItems()` assuming quality started at 1
This commit is contained in:
Dev 2024-02-11 14:59:25 +00:00
parent da6244e1ac
commit bba30d616b
3 changed files with 13 additions and 5 deletions

View File

@ -163,12 +163,13 @@ export class FenceBaseAssortGenerator
// Calculate preset price (root item + child items) // Calculate preset price (root item + child items)
const price = this.handbookHelper.getTemplatePriceForItems(itemAndChildren); const price = this.handbookHelper.getTemplatePriceForItems(itemAndChildren);
const itemQualityModifier = this.itemHelper.getItemQualityModifierForOfferItems(itemAndChildren);
// Multiply weapon+mods rouble price by quality modifier // Multiply weapon+mods rouble price by quality modifier
baseFenceAssort.barter_scheme[itemAndChildren[0]._id] = [[]]; baseFenceAssort.barter_scheme[itemAndChildren[0]._id] = [[]];
baseFenceAssort.barter_scheme[itemAndChildren[0]._id][0][0] = { baseFenceAssort.barter_scheme[itemAndChildren[0]._id][0][0] = {
_tpl: Money.ROUBLES, _tpl: Money.ROUBLES,
count: Math.round(price * this.itemHelper.getItemQualityModifierForOfferItems(itemAndChildren)), count: Math.round(price * itemQualityModifier),
}; };
baseFenceAssort.loyal_level_items[itemAndChildren[0]._id] = 1; baseFenceAssort.loyal_level_items[itemAndChildren[0]._id] = 1;

View File

@ -304,7 +304,12 @@ export class ItemHelper
*/ */
public getItemQualityModifierForOfferItems(items: Item[]): number public getItemQualityModifierForOfferItems(items: Item[]): number
{ {
let qualityModifier = 1; if (this.isOfBaseclass(items[0]._tpl, BaseClasses.WEAPON))
{
return this.getItemQualityModifier(items[0]);
}
let qualityModifier = 0;
for (const item of items) for (const item of items)
{ {
qualityModifier += this.getItemQualityModifier(item); qualityModifier += this.getItemQualityModifier(item);
@ -370,9 +375,11 @@ export class ItemHelper
// make item non-zero but still very low // make item non-zero but still very low
result = 0.01; result = 0.01;
} }
return result;
} }
return result; return 1;
} }
/** /**

View File

@ -612,9 +612,9 @@ export class RagfairOfferHelper
return false; return false;
} }
if (offer.items.length === 1 || this.itemHelper.isOfBaseclass(offerRootItem._tpl, BaseClasses.WEAPON)) if (offer.items.length === 1)
{ {
// Single item or weapon // Single item
if ( if (
this.isConditionItem(offerRootItem) this.isConditionItem(offerRootItem)
&& !this.itemQualityInRange(offerRootItem, searchRequest.conditionFrom, searchRequest.conditionTo) && !this.itemQualityInRange(offerRootItem, searchRequest.conditionFrom, searchRequest.conditionTo)