Skip to main content
The Deno 2 Release Candidate is here
Learn more
class RagfairOfferGenerator
import { RagfairOfferGenerator } from "https://deno.land/x/sptaki@1.2.0/generators/mod.ts";

Constructors

new
RagfairOfferGenerator(
logger: ILogger,
jsonUtil: JsonUtil,
hashUtil: HashUtil,
randomUtil: RandomUtil,
timeUtil: TimeUtil,
databaseServer: DatabaseServer,
ragfairServerHelper: RagfairServerHelper,
handbookHelper: HandbookHelper,
saveServer: SaveServer,
presetHelper: PresetHelper,
ragfairAssortGenerator: RagfairAssortGenerator,
ragfairOfferService: RagfairOfferService,
ragfairPriceService: RagfairPriceService,
localisationService: LocalisationService,
paymentHelper: PaymentHelper,
fenceService: FenceService,
itemHelper: ItemHelper,
configServer: ConfigServer,
)

Properties

protected
allowedFleaPriceItemsForBarter: { tpl: string; price: number; }[]
protected
configServer: ConfigServer
protected
databaseServer: DatabaseServer
protected
fenceService: FenceService
protected
handbookHelper: HandbookHelper
protected
hashUtil: HashUtil
protected
itemHelper: ItemHelper
protected
jsonUtil: JsonUtil
protected
localisationService: LocalisationService
protected
logger: ILogger
protected
offerCounter: number

Internal counter to ensure each offer created has a unique value for its intId property

protected
paymentHelper: PaymentHelper
protected
presetHelper: PresetHelper
protected
ragfairAssortGenerator: RagfairAssortGenerator
protected
ragfairConfig: IRagfairConfig
protected
ragfairOfferService: RagfairOfferService
protected
ragfairPriceService: RagfairPriceService
protected
ragfairServerHelper: RagfairServerHelper
protected
randomUtil: RandomUtil
protected
saveServer: SaveServer
protected
timeUtil: TimeUtil

Methods

protected
addMissingConditions(item: Item): void

Add missing conditions to an item if needed Durabiltiy for repairable items HpResource for medical items

protected
calculateRoublePrice(currencyCount: number, currencyType: string): number

Convert a count of currency into roubles

protected
convertOfferRequirementsIntoRoubles(offerRequirements: OfferRequirement[]): number

Calculate the offer price that's listed on the flea listing

protected
createBarterBarterScheme(offerItems: Item[]): IBarterScheme[]

Create a barter-based barter scheme, if not possible, fall back to making barter scheme currency based

protected
createCurrencyBarterScheme(
offerWithChildren: Item[],
isPackOffer: boolean,
multipler?: number,
): IBarterScheme[]

Create a random currency-based barter scheme for an array of items

protected
createOffer(
userID: string,
time: number,
items: Item[],
barterScheme: IBarterScheme[],
loyalLevel: number,
sellInOnePiece?: boolean,
): IRagfairOffer

Create an offer object ready to send to ragfairOfferService.addOffer()

protected
createOffersFromAssort(
assortItemWithChildren: Item[],
isExpiredOffer: boolean,
config: Dynamic,
): Promise<void>
protected
createSingleOfferForItem(
itemWithChildren: Item[],
isPreset: boolean,
itemDetails: [boolean, ITemplateItem],
): Promise<void>

Create one flea offer for a specific item

protected
getAvatarUrl(isTrader: boolean, userId: string): string

Get avatar url from trader table in db

protected
getDynamicConditionIdForTpl(tpl: string): string

Get the relevant condition id if item tpl matches in ragfair.json/condition

protected
getFleaPricesAsArray(): { tpl: string; price: number; }[]

Get an array of flea prices + item tpl, cached in generator class inside allowedFleaPriceItemsForBarter

protected
getOfferEndTime(userID: string, time: number): number

Get number of section until offer should expire

protected
getRating(userId: string): number

Get a flea trading rating for the passed in user

protected
getRatingGrowing(userID: string): boolean

Is the offers user rating growing

protected
getTraderId(userId: string): string

Check userId, if its a player, return their pmc _id, otherwise return userId parameter

protected
randomiseArmorDurabilityValues(
armorWithMods: Item[],
currentMultiplier: number,
maxMultiplier: number,
): void

Randomise the durabiltiy values for an armors plates and soft inserts

protected
randomiseItemCondition(
conditionSettingsId: string,
itemWithMods: Item[],
itemDetails: ITemplateItem,
): void

Alter an items condition based on its item base type

protected
randomiseOfferItemUpdProperties(
userID: string,
itemWithMods: Item[],
itemDetails: ITemplateItem,
): void

Get array of an item with its mods + condition properties (e.g durability) Apply randomisation adjustments to condition if item base is found in ragfair.json/dynamic/condition

protected
randomiseWeaponDurability(
item: Item,
itemDbDetails: ITemplateItem,
maxMultiplier: number,
currentMultiplier: number,
): void

Adjust an items durability/maxDurability value

protected
removeBannedPlatesFromPreset(presetWithChildren: Item[], plateSettings: IArmorPlateBlacklistSettings): boolean

iterate over an items chidren and look for plates above desired level and remove them

createFleaOffer(
userID: string,
time: number,
items: Item[],
barterScheme: IBarterScheme[],
loyalLevel: number,
sellInOnePiece?: boolean,
): IRagfairOffer

Create a flea offer and store it in the Ragfair server offers array

generateDynamicOffers(expiredOffers?: Item[][]): Promise<void>

Create multiple offers for items by using a unique list of items we've generated previously

generateFleaOffersForTrader(traderID: string): void

Generate trader offers on flea using the traders assort data