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

Constructors

new
InsuranceService(
logger: ILogger,
databaseServer: DatabaseServer,
secureContainerHelper: SecureContainerHelper,
randomUtil: RandomUtil,
itemHelper: ItemHelper,
hashUtil: HashUtil,
jsonUtil: JsonUtil,
timeUtil: TimeUtil,
saveServer: SaveServer,
traderHelper: TraderHelper,
dialogueHelper: DialogueHelper,
handbookHelper: HandbookHelper,
localisationService: LocalisationService,
localeService: LocaleService,
mailSendService: MailSendService,
configServer: ConfigServer,
)

Properties

protected
configServer: ConfigServer
protected
databaseServer: DatabaseServer
protected
dialogueHelper: DialogueHelper
protected
handbookHelper: HandbookHelper
protected
hashUtil: HashUtil
protected
insuranceConfig: IInsuranceConfig
protected
insured: Record<string, Record<string, Item[]>>
protected
itemHelper: ItemHelper
protected
jsonUtil: JsonUtil
protected
localeService: LocaleService
protected
localisationService: LocalisationService
protected
logger: ILogger
protected
lostOnDeathConfig: ILostOnDeathConfig
protected
mailSendService: MailSendService
protected
randomUtil: RandomUtil
protected
saveServer: SaveServer
protected
secureContainerHelper: SecureContainerHelper
protected
timeUtil: TimeUtil
protected
traderHelper: TraderHelper

Methods

Add gear item to InsuredItems array in player profile

protected
adoptOrphanedInsEquipment(sessionID: string): void

Take the insurance item packages within a profile session and ensure that each of the items in that package are not orphaned from their parent ID.

protected
getInsuranceReturnTimestamp(pmcData: IPmcData, trader: ITraderBase): number

Get a timestamp of when insurance items should be sent to player based on trader used to insure Apply insurance return bonus if found in profile

protected
getInsuredItemDetails(
pmcData: IPmcData,
preRaidItem: Item,
insuredItemFromClient: IInsuredItemsData,
): Item

Take preraid item and update properties to ensure its ready to be given to player in insurance return mail

protected
insuranceTraderArrayExists(sessionId: string, traderId: string): boolean

Does insurance exist for a player and by trader

protected
removeLocationProperty(sessionId: string, traderId: string): void

Check all root insured items and remove location property + set slotId to 'hideout'

protected
updateSlotIdValue(playerBaseInventoryEquipmentId: string, itemToReturn: Item): void

Reset slotId property to "hideout" when necessary (used to be in )

addInsuranceItemToArray(
sessionId: string,
traderId: string,
itemToAdd: Item,
): void

Store insured item

getGearLostInRaid(
pmcData: IPmcData,
preRaidGear: Item[],
sessionID: string,
playerDied: boolean,
): IInsuranceEquipmentPkg[]

Create insurance equipment packages that should be sent to the user. The packages should contain items that have been lost in a raid and should be returned to the player through the insurance system.

NOTE: We do not have data on items that were dropped in a raid. This means we have to pull item data from the profile at the start of the raid to return to the player in insurance. Because of this, the item positioning may differ from the position the item was in when the player died. Apart from removing all positioning, this is the best we can do. >:{}

getInsurance(sessionId: string): Record<string, Item[]>

Get all insured items by all traders for a profile

getInsuranceItems(sessionId: string, traderId: string): Item[]

Get insured items by profile id + trader id

getPremium(
pmcData: IPmcData,
inventoryItem: Item,
traderId: string,
): number

Get price of insurance * multiplier from config

getRootItemParentID(sessionID: string): string

Returns the ID that should be used for a root-level Item's parentId property value within in the context of insurance.

insuranceExists(sessionId: string): boolean

Does player have insurance array

resetInsurance(sessionId: string): void
resetInsuranceTraderArray(sessionId: string, traderId: string): void

Empty out array holding insured items by sessionid + traderid

sendInsuredItems(
pmcData: IPmcData,
sessionID: string,
mapId: string,
): void

Sends stored insured items as message to player

storeGearLostInRaidToSendLater(sessionID: string, equipmentPkg: IInsuranceEquipmentPkg[]): void

Store lost gear post-raid inside profile, ready for later code to pick it up and mail it