Skip to main content
The Deno 2 Release Candidate is here
Learn more
class RagfairPriceService
implements OnLoad
import { RagfairPriceService } from "https://deno.land/x/sptaki@1.2.0/services/RagfairPriceService.d.ts";

Stores flea prices for items as well as methods to interact with them

Constructors

new
RagfairPriceService(
handbookHelper: HandbookHelper,
databaseServer: DatabaseServer,
logger: ILogger,
itemHelper: ItemHelper,
presetHelper: PresetHelper,
traderHelper: TraderHelper,
randomUtil: RandomUtil,
localisationService: LocalisationService,
configServer: ConfigServer,
)

Properties

protected
configServer: ConfigServer
protected
databaseServer: DatabaseServer
protected
generatedDynamicPrices: boolean
protected
generatedStaticPrices: boolean
protected
handbookHelper: HandbookHelper
protected
itemHelper: ItemHelper
protected
localisationService: LocalisationService
protected
logger: ILogger
protected
presetHelper: PresetHelper
protected
prices: IRagfairServerPrices
protected
ragfairConfig: IRagfairConfig
protected
randomUtil: RandomUtil
protected
traderHelper: TraderHelper

Methods

protected
adjustPriceIfBelowHandbook(itemPrice: number, itemTpl: string): number

Check to see if an items price is below its handbook price and adjust according to values set to config/ragfair.json

protected
adjustUnreasonablePrice(
handbookPrices: HandbookItem[],
unreasonableItemChange: IUnreasonableModPrices,
itemTpl: string,
price: number,
): number

using data from config, adjust an items price to be relative to its handbook price

protected
getHighestHandbookOrTraderPriceAsRouble(itemTpl: string): number

Get the highest price for an item that is stored in handbook or trader assorts

protected
getOfferTypeRangeValues(isPreset: boolean, isPack: boolean): MinMax

Get different min/max price multipliers for different offer types (preset/pack/default)

protected
getPriceDifference(a: number, b: number): number

Get the percentage difference between two values

protected
getWeaponPreset(weapon: Item): { isDefault: boolean; preset: IPreset; }

Attempt to get the default preset for a weapon, failing that get the first preset in the array (assumes default = has encyclopedia entry)

protected
getWeaponPresetPrice(
weaponRootItem: Item,
weaponWithChildren: Item[],
existingPrice: number,
): number

Calculate the cost of a weapon preset by adding together the price of its mods + base price of default weapon preset

protected
randomiseOfferPrice(existingPrice: number, rangeValues: MinMax): number

Multiply the price by a randomised curve where n = 2, shift = 2

Create a dictionary and store prices from prices.json in it

Iterate over all items of type "Item" in db and get template price, store in cache

getAllFleaPrices(): Record<string, number>

Get prices for all items on flea, prioritize handbook prices first, use prices from prices.json if missing

getAllStaticPrices(): Record<string, number>
getBarterPrice(barterScheme: IBarterScheme[]): number

Get the rouble price for an assorts barter scheme

getDynamicItemPrice(
itemTemplateId: string,
desiredCurrency: string,
item?: Item,
offerItems?: Item[],
isPackOffer?: boolean,
): number
getDynamicOfferPriceForOffer(
offerItems: Item[],
desiredCurrency: string,
isPackOffer: boolean,
): number

Generate a currency cost for an item and its mods

getDynamicPriceForItem(itemTpl: string): number

get the dynamic (flea) price for an item Grabs prices from prices.json and stores in class if none currently exist

getFleaPriceForItem(tplId: string): number

Get the dynamic price for an item. If value doesn't exist, use static (handbook) value. if no static value, return 1

getFleaPriceForOfferItems(offerItems: Item[]): number

Get the flea price for an offers items + children

getRoute(): string
getStaticPriceForItem(itemTpl: string): number

Grab the static (handbook) for an item by its tplId

onLoad(): Promise<void>

Generate static (handbook) and dynamic (prices.json) flea prices, store inside class as dictionaries