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:
parent
da6244e1ac
commit
bba30d616b
@ -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;
|
||||||
|
@ -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,11 +375,13 @@ 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;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a quality value based on a repairable items (weapon/armor) current state between current and max durability
|
* Get a quality value based on a repairable items (weapon/armor) current state between current and max durability
|
||||||
* @param itemDetails Db details for item we want quality value for
|
* @param itemDetails Db details for item we want quality value for
|
||||||
|
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user