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

Constructors

new
InventoryHelper(
logger: ILogger,
jsonUtil: JsonUtil,
hashUtil: HashUtil,
httpResponse: HttpResponseUtil,
fenceService: FenceService,
databaseServer: DatabaseServer,
paymentHelper: PaymentHelper,
traderAssortHelper: TraderAssortHelper,
dialogueHelper: DialogueHelper,
itemHelper: ItemHelper,
containerHelper: ContainerHelper,
profileHelper: ProfileHelper,
presetHelper: PresetHelper,
localisationService: LocalisationService,
configServer: ConfigServer,
)

Properties

protected
configServer: ConfigServer
protected
containerHelper: ContainerHelper
protected
databaseServer: DatabaseServer
protected
dialogueHelper: DialogueHelper
protected
fenceService: FenceService
protected
hashUtil: HashUtil
protected
httpResponse: HttpResponseUtil
protected
inventoryConfig: IInventoryConfig
protected
itemHelper: ItemHelper
protected
jsonUtil: JsonUtil
protected
localisationService: LocalisationService
protected
logger: ILogger
protected
paymentHelper: PaymentHelper
protected
presetHelper: PresetHelper
protected
profileHelper: ProfileHelper
protected
traderAssortHelper: TraderAssortHelper

Methods

protected
getBlankContainerMap(containerH: number, containerY: number): number[][]

Get a blank two-dimentional representation of a container

protected
getInventoryItemHash(inventoryItem: Item[]): InventoryHelper.InventoryItemHash
protected
getPlayerStashSize(sessionID: string): Record<number, number>

Get Players Stash Size

protected
getSizeByInventoryItemHash(
itemTpl: string,
itemID: string,
inventoryItemHash: InventoryHelper.InventoryItemHash,
): number[]
protected
getSortingTableSlotMap(pmcData: IPmcData): number[][]

Get a two-dimensional array representation of the players sorting table

protected
getStashSlotMap(pmcData: IPmcData, sessionID: string): number[][]

Get a two dimensional array to represent stash slots 0 value = free, 1 = taken

protected
getStashType(sessionID: string): string

Get the players stash items tpl

protected
handleCartridges(items: Item[], body: IInventoryMoveRequestData): void

Internal helper function to handle cartridges in inventory if any of them exist.

protected
placeItemInInventory(
stashFS2D: number[][],
sortingTableFS2D: number[][],
itemWithChildren: Item[],
playerInventory: Inventory,
useSortingTable: boolean,
): void

Find a location to place an item into inventory and place it

Remove properties from a Upd object used by a trader/ragfair that are unnecessary to a player

protected
setFindInRaidStatusForItem(itemWithChildren: Item[], foundInRaid: boolean): void

Set FiR status for an item + its children

protected
splitStackIntoSmallerChildStacks(
assortItems: Item[],
requestItem: AddItem,
): void

Split an items stack size based on its StackMaxSize value

protected
updateFastPanelBinding(pmcData: IPmcData, itemBeingMoved: Item): void

Update fast panel bindings when an item is moved into a container that doesnt allow quick slot access

addItemsToStash(
sessionId: string,
pmcData: IPmcData,
): void

Add multiple items to player stash (assuming they all fit)

addItemToStash(
sessionId: string,
pmcData: IPmcData,
): void

Add whatever is passed in request.itemWithModsToAdd into player inventory (if it fits)

canPlaceItemInContainer(containerFS2D: number[][], itemWithChildren: Item[]): boolean

Does an item fit into a container grid

canPlaceItemsInContainer(containerFS2D: number[][], itemsWithChildren: Item[][]): boolean

Do the provided items all fit into the grid

canPlaceItemsInInventory(sessionId: string, itemsWithChildren: Item[][]): boolean

Can all probided items be added into player inventory

getContainerMap(
containerH: number,
containerV: number,
itemList: Item[],
containerId: string,
): number[][]
getContainerSlotMap(containerTpl: string): number[][]

Get a blank two-dimensional array representation of a container

getItemSize(
itemTpl: string,
itemID: string,
inventoryItems: Item[],
): number[]

Get the height and width of an item - can have children that alter size

Return the inventory that needs to be modified (scav/pmc etc) Changes made to result apply to character inventory Based on the item action, determine whose inventories we should be looking at for from and to.

Get details for how a random loot container should be handled, max rewards, possible reward tpls

isItemInStash(pmcData: IPmcData, itemToCheck: Item): boolean

Recursively checks if the given item is inside the stash, that is it has the stash as ancestor with slotId=hideout

moveItemInternal(
pmcData: IPmcData,
inventoryItems: Item[],
): { success: boolean; errorMessage?: string; }

Internal helper function to move item within the same profile_f.

moveItemToProfile(
fromItems: Item[],
toItems: Item[],
): void

Internal helper function to transfer an item from one profile to another.

placeItemInContainer(
containerFS2D: number[][],
itemWithChildren: Item[],
containerId: string,
desiredSlotId?: string,
): void

Find a free location inside a container to fit the item

removeItem(
profile: IPmcData,
itemId: string,
sessionID: string,
): void

Handle Remove event Remove item from player inventory + insured items array Also deletes child items

Delete desired item from a player profiles mail

removeItemByCount(
pmcData: IPmcData,
itemId: string,
countToRemove: number,
sessionID: string,
): IItemEventRouterResponse

Find item by id in player inventory and remove x of its count