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

Handle the creation of randomised scav case rewards

Constructors

new
ScavCaseRewardGenerator(
logger: ILogger,
randomUtil: RandomUtil,
jsonUtil: JsonUtil,
hashUtil: HashUtil,
itemHelper: ItemHelper,
presetHelper: PresetHelper,
databaseServer: DatabaseServer,
ragfairPriceService: RagfairPriceService,
seasonalEventService: SeasonalEventService,
itemFilterService: ItemFilterService,
configServer: ConfigServer,
)

Properties

protected
configServer: ConfigServer
protected
databaseServer: DatabaseServer
protected
dbAmmoItemsCache: ITemplateItem[]
protected
dbItemsCache: ITemplateItem[]
protected
hashUtil: HashUtil
protected
itemFilterService: ItemFilterService
protected
itemHelper: ItemHelper
protected
jsonUtil: JsonUtil
protected
logger: ILogger
protected
presetHelper: PresetHelper
protected
ragfairPriceService: RagfairPriceService
protected
randomUtil: RandomUtil
protected
scavCaseConfig: IScavCaseConfig
protected
seasonalEventService: SeasonalEventService

Methods

protected
cacheDbItems(): void

Get all db items that are not blacklisted in scavcase config or global blacklist Store in class field

protected
getRandomAmmo(rarity: string): ITemplateItem

Get a random ammo from items.json that is not in the ammo blacklist AND inside the price rage defined in scavcase.json config

protected
getRandomAmountRewardForScavCase(itemToCalculate: ITemplateItem, rarity: string): number

Randomises the size of ammo and money stacks

Choose from rouble/dollar/euro at random

Gathers the reward min and max count params for each reward quality level from config and scavcase.json into a single object

protected
pickRandomRewards(
items: ITemplateItem[],
rarity: string,
): ITemplateItem[]

Pick a number of items to be rewards, the count is defined by the values in itemFilters param

protected
randomiseContainerItemRewards(rewardItems: ITemplateItem[], rarity: string): Item[][]

Take all the rewards picked create the Product object array ready to return to calling code Also add a stack count to ammo and money

protected
rewardShouldBeAmmo(): boolean

Choose if ammo should be a reward based on the ammoRewardChancePercent config chance in scavCaseConfig

protected
rewardShouldBeMoney(): boolean

Choose if money should be a reward based on the moneyRewardChancePercent config chance in scavCaseConfig

generate(recipeId: string): Item[][]

Create an array of rewards that will be given to the player upon completing their scav case build