diff --git a/project/src/controllers/RagfairController.ts b/project/src/controllers/RagfairController.ts index f6b6d412..3422a1b5 100644 --- a/project/src/controllers/RagfairController.ts +++ b/project/src/controllers/RagfairController.ts @@ -352,7 +352,21 @@ export class RagfairController const min = offers[0].requirementsCost; // Get first item from array as its pre-sorted const max = offers.at(-1).requirementsCost; // Get last item from array as its pre-sorted - return { avg: (min + max) / 2, min: min, max: max }; + // Get the average offer price, excluding barter offers + let avgOfferCount = 0; + const avg = offers.reduce((sum, offer) => + { + // Exclude barter items + if (offer.requirements.some((req) => !this.paymentHelper.isMoneyTpl(req._tpl))) + { + return sum; + } + + avgOfferCount++; + return sum + offer.requirementsCost; + }, 0) / Math.max(avgOfferCount, 1); + + return { avg: avg, min: min, max: max }; } // No offers listed, get price from live ragfair price list prices.json diff --git a/project/src/services/RagfairPriceService.ts b/project/src/services/RagfairPriceService.ts index 36f8c8fb..e05e2e3b 100644 --- a/project/src/services/RagfairPriceService.ts +++ b/project/src/services/RagfairPriceService.ts @@ -171,13 +171,14 @@ export class RagfairPriceService implements OnLoad } /** - * Get prices for all items on flea, priorities dynamic prices from prices.json, use handbook prices if missing + * Get prices for all items on flea, prioritize handbook prices first, use prices from prices.json if missing * @returns Dictionary of item tpls and rouble cost */ public getAllFleaPrices(): Record { - // assign static values first, then overwrite them with dynamic, any values not stored in dynamic data will be covered by static data - return { ...this.prices.static, ...this.prices.dynamic }; + // assign dynamic (prices.json) values first, then overwrite them with static (handbook.json) + // any values not stored in static data will be covered by dynamic data + return { ...this.prices.dynamic, ...this.prices.static }; } public getAllStaticPrices(): Record