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

Constructors

new
BotLootCacheService(
logger: ILogger,
jsonUtil: JsonUtil,
itemHelper: ItemHelper,
databaseServer: DatabaseServer,
pmcLootGenerator: PMCLootGenerator,
localisationService: LocalisationService,
ragfairPriceService: RagfairPriceService,
)

Properties

protected
databaseServer: DatabaseServer
protected
itemHelper: ItemHelper
protected
jsonUtil: JsonUtil
protected
localisationService: LocalisationService
protected
logger: ILogger
protected
lootCache: Record<string, IBotLootCache>
protected
pmcLootGenerator: PMCLootGenerator
protected
ragfairPriceService: RagfairPriceService

Methods

protected
addItemsToPool(poolToAddTo: Record<string, number>, poolOfItemsToAdd: Record<string, number>): void
protected
addLootToCache(
botRole: string,
isPmc: boolean,
botJsonTemplate: IBotType,
): void

Generate loot for a bot and store inside a private class property

protected
addUniqueItemsToPool(poolToAddTo: ITemplateItem[], itemsToAdd: ITemplateItem[]): void

Add unique items into combined pool

protected
botRoleExistsInCache(botRole: string): boolean

Check if a bot type exists inside the loot cache

protected
compareByValue(itemAPrice: number, itemBPrice: number): number

Compares two item prices by their flea (or handbook if that doesnt exist) price -1 when a < b 0 when a === b 1 when a > b

protected
initCacheForBotRole(botRole: string): void

If lootcache is null, init with empty property arrays

protected
isBulletOrGrenade(props: Props): boolean

Ammo/grenades have this property

protected
isCurrency(tpl: string): boolean
protected
isDrink(tpl: string): boolean
protected
isFood(tpl: string): boolean
protected
isGrenade(props: Props): boolean

Grenades have this property (e.g. smoke/frag/flash grenades)

protected
isMagazine(props: Props): boolean

Internal and external magazine have this property

protected
isMedicalItem(props: Props): boolean

Medical use items (e.g. morphine/lip balm/grizzly)

clearCache(): void

Remove cached bot loot data

getLootFromCache(
botRole: string,
isPmc: boolean,
lootType: LootCacheType,
botJsonTemplate: IBotType,
): Record<string, number>

Get the fully created loot array, ordered by price low to high