Adjusted how item quality % is calculated for player flea offers. Now excludes items without any quality modifier from calculation instead of assuming 100% (slightly lowers sell chance of things like armors)
Renamed `getItemQualityModifierForOfferItems()` to `getItemQualityModifierForItems()`
This commit is contained in:
parent
43a09c29c2
commit
cf5411336f
@ -439,7 +439,7 @@ export class RagfairController
|
|||||||
const rootItem = offer.items[0];
|
const rootItem = offer.items[0];
|
||||||
|
|
||||||
// Get average of items quality+children
|
// Get average of items quality+children
|
||||||
const qualityMultiplier = this.itemHelper.getItemQualityModifierForOfferItems(offer.items);
|
const qualityMultiplier = this.itemHelper.getItemQualityModifierForItems(offer.items, true);
|
||||||
let averageOfferPrice = this.ragfairPriceService.getFleaPriceForOfferItems(offer.items);
|
let averageOfferPrice = this.ragfairPriceService.getFleaPriceForOfferItems(offer.items);
|
||||||
|
|
||||||
// Check for and apply item price modifer if it exists
|
// Check for and apply item price modifer if it exists
|
||||||
|
@ -178,7 +178,7 @@ 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);
|
const itemQualityModifier = this.itemHelper.getItemQualityModifierForItems(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] = [[]];
|
||||||
|
@ -503,9 +503,10 @@ export class ItemHelper
|
|||||||
/**
|
/**
|
||||||
* Calcualte the average quality of an item and its children
|
* Calcualte the average quality of an item and its children
|
||||||
* @param items An offers item to process
|
* @param items An offers item to process
|
||||||
|
* @param nonQualityItemsReturnNegative Treat items without a quality property as non-existant
|
||||||
* @returns % quality modifer between 0 and 1
|
* @returns % quality modifer between 0 and 1
|
||||||
*/
|
*/
|
||||||
public getItemQualityModifierForOfferItems(items: Item[]): number
|
public getItemQualityModifierForItems(items: Item[], nonQualityItemsReturnNegative = false): number
|
||||||
{
|
{
|
||||||
if (this.isOfBaseclass(items[0]._tpl, BaseClasses.WEAPON))
|
if (this.isOfBaseclass(items[0]._tpl, BaseClasses.WEAPON))
|
||||||
{
|
{
|
||||||
@ -513,12 +514,20 @@ export class ItemHelper
|
|||||||
}
|
}
|
||||||
|
|
||||||
let qualityModifier = 0;
|
let qualityModifier = 0;
|
||||||
|
let itemsWithQualityCount = 0;
|
||||||
for (const item of items)
|
for (const item of items)
|
||||||
{
|
{
|
||||||
qualityModifier += this.getItemQualityModifier(item);
|
const result = this.getItemQualityModifier(item, nonQualityItemsReturnNegative);
|
||||||
|
if (result === -1)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Math.min(qualityModifier / items.length, 1);
|
qualityModifier += result;
|
||||||
|
itemsWithQualityCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Math.min(qualityModifier / itemsWithQualityCount, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -526,7 +535,7 @@ export class ItemHelper
|
|||||||
* @param item
|
* @param item
|
||||||
* @returns number between 0 and 1
|
* @returns number between 0 and 1
|
||||||
*/
|
*/
|
||||||
public getItemQualityModifier(item: Item): number
|
public getItemQualityModifier(item: Item, nonQualityItemsReturnNegative = false): number
|
||||||
{
|
{
|
||||||
// Default to 100%
|
// Default to 100%
|
||||||
let result = 1;
|
let result = 1;
|
||||||
@ -573,6 +582,12 @@ export class ItemHelper
|
|||||||
result = repairKit.Resource / itemDetails._props.MaxRepairResource;
|
result = repairKit.Resource / itemDetails._props.MaxRepairResource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Not handled by any of the above + default value
|
||||||
|
if (nonQualityItemsReturnNegative && result === 1)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (result === 0)
|
if (result === 0)
|
||||||
{
|
{
|
||||||
// make item non-zero but still very low
|
// make item non-zero but still very low
|
||||||
@ -582,7 +597,7 @@ export class ItemHelper
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -644,7 +644,7 @@ export class RagfairOfferHelper
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const itemQualityPercent = this.itemHelper.getItemQualityModifierForOfferItems(offer.items) * 100;
|
const itemQualityPercent = this.itemHelper.getItemQualityModifierForItems(offer.items) * 100;
|
||||||
if (itemQualityPercent < searchRequest.conditionFrom)
|
if (itemQualityPercent < searchRequest.conditionFrom)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -1035,7 +1035,7 @@ export class FenceService
|
|||||||
const priceLimitRouble = this.traderConfig.fence.itemCategoryRoublePriceLimit[rootItemDb._parent];
|
const priceLimitRouble = this.traderConfig.fence.itemCategoryRoublePriceLimit[rootItemDb._parent];
|
||||||
const itemPrice
|
const itemPrice
|
||||||
= this.handbookHelper.getTemplatePriceForItems(presetWithChildrenClone)
|
= this.handbookHelper.getTemplatePriceForItems(presetWithChildrenClone)
|
||||||
* this.itemHelper.getItemQualityModifierForOfferItems(presetWithChildrenClone);
|
* this.itemHelper.getItemQualityModifierForItems(presetWithChildrenClone);
|
||||||
if (priceLimitRouble)
|
if (priceLimitRouble)
|
||||||
{
|
{
|
||||||
if (itemPrice > priceLimitRouble)
|
if (itemPrice > priceLimitRouble)
|
||||||
@ -1100,7 +1100,7 @@ export class FenceService
|
|||||||
const priceLimitRouble = this.traderConfig.fence.itemCategoryRoublePriceLimit[rootItemDb._parent];
|
const priceLimitRouble = this.traderConfig.fence.itemCategoryRoublePriceLimit[rootItemDb._parent];
|
||||||
const itemPrice
|
const itemPrice
|
||||||
= this.handbookHelper.getTemplatePriceForItems(presetWithChildrenClone)
|
= this.handbookHelper.getTemplatePriceForItems(presetWithChildrenClone)
|
||||||
* this.itemHelper.getItemQualityModifierForOfferItems(presetWithChildrenClone);
|
* this.itemHelper.getItemQualityModifierForItems(presetWithChildrenClone);
|
||||||
if (priceLimitRouble)
|
if (priceLimitRouble)
|
||||||
{
|
{
|
||||||
if (itemPrice > priceLimitRouble)
|
if (itemPrice > priceLimitRouble)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user