From 71a2f8dae66321ff4efa465a5e53fb8a9530c952 Mon Sep 17 00:00:00 2001 From: Dev Date: Sun, 6 Aug 2023 16:20:08 +0100 Subject: [PATCH] Update types --- .../models/eft/common/tables/IBotBase.d.ts | 1 + .../types/models/eft/common/tables/IItem.d.ts | 1 + .../models/eft/inRaid/IInsuredItemsData.d.ts | 6 +++ .../eft/inRaid/ISaveProgressRequestData.d.ts | 2 + .../models/spt/config/IRagfairConfig.d.ts | 14 +++---- .../types/services/InsuranceService.d.ts | 41 +++++++++++++++---- .../models/eft/common/tables/IBotBase.d.ts | 1 + .../types/models/eft/common/tables/IItem.d.ts | 1 + .../models/eft/inRaid/IInsuredItemsData.d.ts | 6 +++ .../eft/inRaid/ISaveProgressRequestData.d.ts | 2 + .../models/spt/config/IRagfairConfig.d.ts | 14 +++---- .../types/services/InsuranceService.d.ts | 41 +++++++++++++++---- .../models/eft/common/tables/IBotBase.d.ts | 1 + .../types/models/eft/common/tables/IItem.d.ts | 1 + .../models/eft/inRaid/IInsuredItemsData.d.ts | 6 +++ .../eft/inRaid/ISaveProgressRequestData.d.ts | 2 + .../models/spt/config/IRagfairConfig.d.ts | 14 +++---- .../types/services/InsuranceService.d.ts | 41 +++++++++++++++---- .../models/eft/common/tables/IBotBase.d.ts | 1 + .../types/models/eft/common/tables/IItem.d.ts | 1 + .../models/eft/inRaid/IInsuredItemsData.d.ts | 6 +++ .../eft/inRaid/ISaveProgressRequestData.d.ts | 2 + .../models/spt/config/IRagfairConfig.d.ts | 14 +++---- .../types/services/InsuranceService.d.ts | 41 +++++++++++++++---- .../models/eft/common/tables/IBotBase.d.ts | 1 + .../types/models/eft/common/tables/IItem.d.ts | 1 + .../models/eft/inRaid/IInsuredItemsData.d.ts | 6 +++ .../eft/inRaid/ISaveProgressRequestData.d.ts | 2 + .../models/spt/config/IRagfairConfig.d.ts | 14 +++---- .../types/services/InsuranceService.d.ts | 41 +++++++++++++++---- .../models/eft/common/tables/IBotBase.d.ts | 1 + .../types/models/eft/common/tables/IItem.d.ts | 1 + .../models/eft/inRaid/IInsuredItemsData.d.ts | 6 +++ .../eft/inRaid/ISaveProgressRequestData.d.ts | 2 + .../models/spt/config/IRagfairConfig.d.ts | 14 +++---- .../types/services/InsuranceService.d.ts | 41 +++++++++++++++---- .../models/eft/common/tables/IBotBase.d.ts | 1 + .../types/models/eft/common/tables/IItem.d.ts | 1 + .../models/eft/inRaid/IInsuredItemsData.d.ts | 6 +++ .../eft/inRaid/ISaveProgressRequestData.d.ts | 2 + .../models/spt/config/IRagfairConfig.d.ts | 14 +++---- .../types/services/InsuranceService.d.ts | 41 +++++++++++++++---- .../models/eft/common/tables/IBotBase.d.ts | 1 + .../types/models/eft/common/tables/IItem.d.ts | 1 + .../models/eft/inRaid/IInsuredItemsData.d.ts | 6 +++ .../eft/inRaid/ISaveProgressRequestData.d.ts | 2 + .../models/spt/config/IRagfairConfig.d.ts | 14 +++---- .../types/services/InsuranceService.d.ts | 41 +++++++++++++++---- .../models/eft/common/tables/IBotBase.d.ts | 1 + .../types/models/eft/common/tables/IItem.d.ts | 1 + .../models/eft/inRaid/IInsuredItemsData.d.ts | 6 +++ .../eft/inRaid/ISaveProgressRequestData.d.ts | 2 + .../models/spt/config/IRagfairConfig.d.ts | 14 +++---- .../types/services/InsuranceService.d.ts | 41 +++++++++++++++---- .../models/eft/common/tables/IBotBase.d.ts | 1 + .../types/models/eft/common/tables/IItem.d.ts | 1 + .../models/eft/inRaid/IInsuredItemsData.d.ts | 6 +++ .../eft/inRaid/ISaveProgressRequestData.d.ts | 2 + .../models/spt/config/IRagfairConfig.d.ts | 14 +++---- .../types/services/InsuranceService.d.ts | 41 +++++++++++++++---- .../models/eft/common/tables/IBotBase.d.ts | 1 + .../types/models/eft/common/tables/IItem.d.ts | 1 + .../models/eft/inRaid/IInsuredItemsData.d.ts | 6 +++ .../eft/inRaid/ISaveProgressRequestData.d.ts | 2 + .../models/spt/config/IRagfairConfig.d.ts | 14 +++---- .../types/services/InsuranceService.d.ts | 41 +++++++++++++++---- .../models/eft/common/tables/IBotBase.d.ts | 1 + .../types/models/eft/common/tables/IItem.d.ts | 1 + .../models/eft/inRaid/IInsuredItemsData.d.ts | 6 +++ .../eft/inRaid/ISaveProgressRequestData.d.ts | 2 + .../models/spt/config/IRagfairConfig.d.ts | 14 +++---- .../types/services/InsuranceService.d.ts | 41 +++++++++++++++---- .../models/eft/common/tables/IBotBase.d.ts | 1 + .../types/models/eft/common/tables/IItem.d.ts | 1 + .../models/eft/inRaid/IInsuredItemsData.d.ts | 6 +++ .../eft/inRaid/ISaveProgressRequestData.d.ts | 2 + .../models/spt/config/IRagfairConfig.d.ts | 14 +++---- .../types/services/InsuranceService.d.ts | 41 +++++++++++++++---- .../models/eft/common/tables/IBotBase.d.ts | 1 + .../types/models/eft/common/tables/IItem.d.ts | 1 + .../models/eft/inRaid/IInsuredItemsData.d.ts | 6 +++ .../eft/inRaid/ISaveProgressRequestData.d.ts | 2 + .../models/spt/config/IRagfairConfig.d.ts | 14 +++---- .../types/services/InsuranceService.d.ts | 41 +++++++++++++++---- .../models/eft/common/tables/IBotBase.d.ts | 1 + .../types/models/eft/common/tables/IItem.d.ts | 1 + .../models/eft/inRaid/IInsuredItemsData.d.ts | 6 +++ .../eft/inRaid/ISaveProgressRequestData.d.ts | 2 + .../models/spt/config/IRagfairConfig.d.ts | 14 +++---- .../types/services/InsuranceService.d.ts | 41 +++++++++++++++---- .../models/eft/common/tables/IBotBase.d.ts | 1 + .../types/models/eft/common/tables/IItem.d.ts | 1 + .../models/eft/inRaid/IInsuredItemsData.d.ts | 6 +++ .../eft/inRaid/ISaveProgressRequestData.d.ts | 2 + .../models/spt/config/IRagfairConfig.d.ts | 14 +++---- .../types/services/InsuranceService.d.ts | 41 +++++++++++++++---- .../models/eft/common/tables/IBotBase.d.ts | 1 + .../types/models/eft/common/tables/IItem.d.ts | 1 + .../models/eft/inRaid/IInsuredItemsData.d.ts | 6 +++ .../eft/inRaid/ISaveProgressRequestData.d.ts | 2 + .../models/spt/config/IRagfairConfig.d.ts | 14 +++---- .../types/services/InsuranceService.d.ts | 41 +++++++++++++++---- .../models/eft/common/tables/IBotBase.d.ts | 1 + .../types/models/eft/common/tables/IItem.d.ts | 1 + .../models/eft/inRaid/IInsuredItemsData.d.ts | 6 +++ .../eft/inRaid/ISaveProgressRequestData.d.ts | 2 + .../models/spt/config/IRagfairConfig.d.ts | 14 +++---- .../types/services/InsuranceService.d.ts | 41 +++++++++++++++---- .../models/eft/common/tables/IBotBase.d.ts | 1 + .../types/models/eft/common/tables/IItem.d.ts | 1 + .../models/eft/inRaid/IInsuredItemsData.d.ts | 6 +++ .../eft/inRaid/ISaveProgressRequestData.d.ts | 2 + .../models/spt/config/IRagfairConfig.d.ts | 14 +++---- .../types/services/InsuranceService.d.ts | 41 +++++++++++++++---- 114 files changed, 969 insertions(+), 266 deletions(-) create mode 100644 TypeScript/10ScopesAndTypes/types/models/eft/inRaid/IInsuredItemsData.d.ts create mode 100644 TypeScript/11BundleLoadingSample/types/models/eft/inRaid/IInsuredItemsData.d.ts create mode 100644 TypeScript/12ClassExtensionOverride/types/models/eft/inRaid/IInsuredItemsData.d.ts create mode 100644 TypeScript/13AddTrader/types/models/eft/inRaid/IInsuredItemsData.d.ts create mode 100644 TypeScript/14AfterDBLoadHook/types/models/eft/inRaid/IInsuredItemsData.d.ts create mode 100644 TypeScript/15HttpListenerExample/types/models/eft/inRaid/IInsuredItemsData.d.ts create mode 100644 TypeScript/16ImporterUtil/types/models/eft/inRaid/IInsuredItemsData.d.ts create mode 100644 TypeScript/17AsyncImporterWithDependency1/types/models/eft/inRaid/IInsuredItemsData.d.ts create mode 100644 TypeScript/17AsyncImporterWithDependency2/types/models/eft/inRaid/IInsuredItemsData.d.ts create mode 100644 TypeScript/18CustomItemService/types/models/eft/inRaid/IInsuredItemsData.d.ts create mode 100644 TypeScript/1LogToConsole/types/models/eft/inRaid/IInsuredItemsData.d.ts create mode 100644 TypeScript/2EditDatabase/types/models/eft/inRaid/IInsuredItemsData.d.ts create mode 100644 TypeScript/3GetSptConfigFile/types/models/eft/inRaid/IInsuredItemsData.d.ts create mode 100644 TypeScript/4UseACustomConfigFile/types/models/eft/inRaid/IInsuredItemsData.d.ts create mode 100644 TypeScript/5ReplaceMethod/types/models/eft/inRaid/IInsuredItemsData.d.ts create mode 100644 TypeScript/6ReferenceAnotherClass/types/models/eft/inRaid/IInsuredItemsData.d.ts create mode 100644 TypeScript/7OnLoadHook/types/models/eft/inRaid/IInsuredItemsData.d.ts create mode 100644 TypeScript/8OnUpdateHook/types/models/eft/inRaid/IInsuredItemsData.d.ts create mode 100644 TypeScript/9RouterHooks/types/models/eft/inRaid/IInsuredItemsData.d.ts diff --git a/TypeScript/10ScopesAndTypes/types/models/eft/common/tables/IBotBase.d.ts b/TypeScript/10ScopesAndTypes/types/models/eft/common/tables/IBotBase.d.ts index e5d1c30..69e7e00 100644 --- a/TypeScript/10ScopesAndTypes/types/models/eft/common/tables/IBotBase.d.ts +++ b/TypeScript/10ScopesAndTypes/types/models/eft/common/tables/IBotBase.d.ts @@ -267,6 +267,7 @@ export interface BackendCounter { value: number; } export interface InsuredItem { + /** Trader Id item was insured by */ tid: string; itemId: string; } diff --git a/TypeScript/10ScopesAndTypes/types/models/eft/common/tables/IItem.d.ts b/TypeScript/10ScopesAndTypes/types/models/eft/common/tables/IItem.d.ts index ce00ae9..09a239c 100644 --- a/TypeScript/10ScopesAndTypes/types/models/eft/common/tables/IItem.d.ts +++ b/TypeScript/10ScopesAndTypes/types/models/eft/common/tables/IItem.d.ts @@ -12,6 +12,7 @@ export interface Upd { Togglable?: Togglable; Map?: Map; Tag?: Tag; + /** SPT specific property, not made by BSG */ sptPresetId?: string; FaceShield?: FaceShield; StackObjectsCount?: number; diff --git a/TypeScript/10ScopesAndTypes/types/models/eft/inRaid/IInsuredItemsData.d.ts b/TypeScript/10ScopesAndTypes/types/models/eft/inRaid/IInsuredItemsData.d.ts new file mode 100644 index 0000000..c49fb79 --- /dev/null +++ b/TypeScript/10ScopesAndTypes/types/models/eft/inRaid/IInsuredItemsData.d.ts @@ -0,0 +1,6 @@ +export interface IInsuredItemsData { + id: string; + durability?: number; + maxDurability?: number; + hits?: number; +} diff --git a/TypeScript/10ScopesAndTypes/types/models/eft/inRaid/ISaveProgressRequestData.d.ts b/TypeScript/10ScopesAndTypes/types/models/eft/inRaid/ISaveProgressRequestData.d.ts index 0b6f091..fd77c32 100644 --- a/TypeScript/10ScopesAndTypes/types/models/eft/inRaid/ISaveProgressRequestData.d.ts +++ b/TypeScript/10ScopesAndTypes/types/models/eft/inRaid/ISaveProgressRequestData.d.ts @@ -1,9 +1,11 @@ import { PlayerRaidEndState } from "../../../models/enums/PlayerRaidEndState"; import { IPmcData } from "../common/IPmcData"; import { ISyncHealthRequestData } from "../health/ISyncHealthRequestData"; +import { IInsuredItemsData } from "./IInsuredItemsData"; export interface ISaveProgressRequestData { exit: PlayerRaidEndState; profile: IPmcData; isPlayerScav: boolean; health: ISyncHealthRequestData; + insurance: IInsuredItemsData[]; } diff --git a/TypeScript/10ScopesAndTypes/types/models/spt/config/IRagfairConfig.d.ts b/TypeScript/10ScopesAndTypes/types/models/spt/config/IRagfairConfig.d.ts index 87e0173..7c04857 100644 --- a/TypeScript/10ScopesAndTypes/types/models/spt/config/IRagfairConfig.d.ts +++ b/TypeScript/10ScopesAndTypes/types/models/spt/config/IRagfairConfig.d.ts @@ -71,13 +71,8 @@ export interface Dynamic { removeSeasonalItemsWhenNotInEvent: boolean; /** Flea blacklist settings */ blacklist: Blacklist; - /** Should prices over the multiplier be adjusted */ - unreasonableModPrices: IUnreasonableModPrices; -} -export interface IUnreasonableModPrices { - enabled: boolean; - handbookPriceOverMultiplier: number; - newPriceHandbookMultiplier: number; + /** Dict of price limits keyed by item type */ + unreasonableModPrices: Record; } export interface Barter { /** Should barter offers be generated */ @@ -121,3 +116,8 @@ export interface Blacklist { /** Should trader items that are blacklisted by bsg */ traderItems: boolean; } +export interface IUnreasonableModPrices { + enabled: boolean; + handbookPriceOverMultiplier: number; + newPriceHandbookMultiplier: number; +} diff --git a/TypeScript/10ScopesAndTypes/types/services/InsuranceService.d.ts b/TypeScript/10ScopesAndTypes/types/services/InsuranceService.d.ts index 1d30f6d..5354cc0 100644 --- a/TypeScript/10ScopesAndTypes/types/services/InsuranceService.d.ts +++ b/TypeScript/10ScopesAndTypes/types/services/InsuranceService.d.ts @@ -6,14 +6,15 @@ import { NotificationSendHelper } from "../helpers/NotificationSendHelper"; import { SecureContainerHelper } from "../helpers/SecureContainerHelper"; import { TraderHelper } from "../helpers/TraderHelper"; import { IPmcData } from "../models/eft/common/IPmcData"; -import { InsuredItem } from "../models/eft/common/tables/IBotBase"; import { Item } from "../models/eft/common/tables/IItem"; +import { IInsuredItemsData } from "../models/eft/inRaid/IInsuredItemsData"; import { ISaveProgressRequestData } from "../models/eft/inRaid/ISaveProgressRequestData"; import { IInsuranceConfig } from "../models/spt/config/IInsuranceConfig"; import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { LocaleService } from "./LocaleService"; @@ -24,6 +25,7 @@ export declare class InsuranceService { protected secureContainerHelper: SecureContainerHelper; protected randomUtil: RandomUtil; protected itemHelper: ItemHelper; + protected jsonUtil: JsonUtil; protected timeUtil: TimeUtil; protected saveServer: SaveServer; protected traderHelper: TraderHelper; @@ -35,7 +37,12 @@ export declare class InsuranceService { protected configServer: ConfigServer; protected insured: Record>; protected insuranceConfig: IInsuranceConfig; - constructor(logger: ILogger, databaseServer: DatabaseServer, secureContainerHelper: SecureContainerHelper, randomUtil: RandomUtil, itemHelper: ItemHelper, timeUtil: TimeUtil, saveServer: SaveServer, traderHelper: TraderHelper, dialogueHelper: DialogueHelper, handbookHelper: HandbookHelper, localisationService: LocalisationService, localeService: LocaleService, notificationSendHelper: NotificationSendHelper, configServer: ConfigServer); + constructor(logger: ILogger, databaseServer: DatabaseServer, secureContainerHelper: SecureContainerHelper, randomUtil: RandomUtil, itemHelper: ItemHelper, jsonUtil: JsonUtil, timeUtil: TimeUtil, saveServer: SaveServer, traderHelper: TraderHelper, dialogueHelper: DialogueHelper, handbookHelper: HandbookHelper, localisationService: LocalisationService, localeService: LocaleService, notificationSendHelper: NotificationSendHelper, configServer: ConfigServer); + /** + * Does player have insurance array + * @param sessionId Player id + * @returns True if exists + */ insuranceExists(sessionId: string): boolean; /** * Get all insured items by all traders for a profile @@ -78,7 +85,7 @@ export declare class InsuranceService { */ protected getInsuranceReturnTimestamp(pmcData: IPmcData, trader: ITraderBase): number; /** - * Store lost gear post-raid inside profile + * Store lost gear post-raid inside profile, ready for later code to pick it up and mail it * @param pmcData player profile to store gear in * @param offraidData post-raid request object * @param preRaidGear gear player wore prior to raid @@ -86,6 +93,21 @@ export declare class InsuranceService { * @param playerDied did the player die in raid */ storeLostGear(pmcData: IPmcData, offraidData: ISaveProgressRequestData, preRaidGear: Item[], sessionID: string, playerDied: boolean): void; + /** + * Take preraid item and update properties to ensure its ready to be given to player in insurance return mail + * @param pmcData Player profile + * @param insuredItem Insured items properties + * @param preRaidItem Insured item as it was pre-raid + * @param insuredItemFromClient Item data when player left raid (durability values) + * @returns Item object + */ + protected getInsuredItemDetails(pmcData: IPmcData, preRaidItem: Item, insuredItemFromClient: IInsuredItemsData): Item; + /** + * Reset slotId property to "hideout" when necessary (used to be in ) + * @param pmcData Players pmcData.Inventory.equipment value + * @param itemToReturn item we will send to player as insurance return + */ + protected updateSlotIdValue(playerBaseInventoryEquipmentId: string, itemToReturn: Item): void; /** * Create a hash table for an array of items, keyed by items _id * @param items Items to hash @@ -94,12 +116,17 @@ export declare class InsuranceService { protected createItemHashTable(items: Item[]): Record; /** * Add gear item to InsuredItems array in player profile - * @param pmcData profile to store item in - * @param insuredItem Item to store in profile - * @param actualItem item to store * @param sessionID Session id + * @param pmcData Player profile + * @param itemToReturnToPlayer item to store + * @param traderId Id of trader item was insured with */ - protected addGearToSend(pmcData: IPmcData, insuredItem: InsuredItem, actualItem: Item, sessionID: string): void; + protected addGearToSend(gear: { + sessionID: string; + pmcData: IPmcData; + itemToReturnToPlayer: Item; + traderId: string; + }): void; /** * Does insurance exist for a player and by trader * @param sessionId Player id (session id) diff --git a/TypeScript/11BundleLoadingSample/types/models/eft/common/tables/IBotBase.d.ts b/TypeScript/11BundleLoadingSample/types/models/eft/common/tables/IBotBase.d.ts index e5d1c30..69e7e00 100644 --- a/TypeScript/11BundleLoadingSample/types/models/eft/common/tables/IBotBase.d.ts +++ b/TypeScript/11BundleLoadingSample/types/models/eft/common/tables/IBotBase.d.ts @@ -267,6 +267,7 @@ export interface BackendCounter { value: number; } export interface InsuredItem { + /** Trader Id item was insured by */ tid: string; itemId: string; } diff --git a/TypeScript/11BundleLoadingSample/types/models/eft/common/tables/IItem.d.ts b/TypeScript/11BundleLoadingSample/types/models/eft/common/tables/IItem.d.ts index ce00ae9..09a239c 100644 --- a/TypeScript/11BundleLoadingSample/types/models/eft/common/tables/IItem.d.ts +++ b/TypeScript/11BundleLoadingSample/types/models/eft/common/tables/IItem.d.ts @@ -12,6 +12,7 @@ export interface Upd { Togglable?: Togglable; Map?: Map; Tag?: Tag; + /** SPT specific property, not made by BSG */ sptPresetId?: string; FaceShield?: FaceShield; StackObjectsCount?: number; diff --git a/TypeScript/11BundleLoadingSample/types/models/eft/inRaid/IInsuredItemsData.d.ts b/TypeScript/11BundleLoadingSample/types/models/eft/inRaid/IInsuredItemsData.d.ts new file mode 100644 index 0000000..c49fb79 --- /dev/null +++ b/TypeScript/11BundleLoadingSample/types/models/eft/inRaid/IInsuredItemsData.d.ts @@ -0,0 +1,6 @@ +export interface IInsuredItemsData { + id: string; + durability?: number; + maxDurability?: number; + hits?: number; +} diff --git a/TypeScript/11BundleLoadingSample/types/models/eft/inRaid/ISaveProgressRequestData.d.ts b/TypeScript/11BundleLoadingSample/types/models/eft/inRaid/ISaveProgressRequestData.d.ts index 0b6f091..fd77c32 100644 --- a/TypeScript/11BundleLoadingSample/types/models/eft/inRaid/ISaveProgressRequestData.d.ts +++ b/TypeScript/11BundleLoadingSample/types/models/eft/inRaid/ISaveProgressRequestData.d.ts @@ -1,9 +1,11 @@ import { PlayerRaidEndState } from "../../../models/enums/PlayerRaidEndState"; import { IPmcData } from "../common/IPmcData"; import { ISyncHealthRequestData } from "../health/ISyncHealthRequestData"; +import { IInsuredItemsData } from "./IInsuredItemsData"; export interface ISaveProgressRequestData { exit: PlayerRaidEndState; profile: IPmcData; isPlayerScav: boolean; health: ISyncHealthRequestData; + insurance: IInsuredItemsData[]; } diff --git a/TypeScript/11BundleLoadingSample/types/models/spt/config/IRagfairConfig.d.ts b/TypeScript/11BundleLoadingSample/types/models/spt/config/IRagfairConfig.d.ts index 87e0173..7c04857 100644 --- a/TypeScript/11BundleLoadingSample/types/models/spt/config/IRagfairConfig.d.ts +++ b/TypeScript/11BundleLoadingSample/types/models/spt/config/IRagfairConfig.d.ts @@ -71,13 +71,8 @@ export interface Dynamic { removeSeasonalItemsWhenNotInEvent: boolean; /** Flea blacklist settings */ blacklist: Blacklist; - /** Should prices over the multiplier be adjusted */ - unreasonableModPrices: IUnreasonableModPrices; -} -export interface IUnreasonableModPrices { - enabled: boolean; - handbookPriceOverMultiplier: number; - newPriceHandbookMultiplier: number; + /** Dict of price limits keyed by item type */ + unreasonableModPrices: Record; } export interface Barter { /** Should barter offers be generated */ @@ -121,3 +116,8 @@ export interface Blacklist { /** Should trader items that are blacklisted by bsg */ traderItems: boolean; } +export interface IUnreasonableModPrices { + enabled: boolean; + handbookPriceOverMultiplier: number; + newPriceHandbookMultiplier: number; +} diff --git a/TypeScript/11BundleLoadingSample/types/services/InsuranceService.d.ts b/TypeScript/11BundleLoadingSample/types/services/InsuranceService.d.ts index 1d30f6d..5354cc0 100644 --- a/TypeScript/11BundleLoadingSample/types/services/InsuranceService.d.ts +++ b/TypeScript/11BundleLoadingSample/types/services/InsuranceService.d.ts @@ -6,14 +6,15 @@ import { NotificationSendHelper } from "../helpers/NotificationSendHelper"; import { SecureContainerHelper } from "../helpers/SecureContainerHelper"; import { TraderHelper } from "../helpers/TraderHelper"; import { IPmcData } from "../models/eft/common/IPmcData"; -import { InsuredItem } from "../models/eft/common/tables/IBotBase"; import { Item } from "../models/eft/common/tables/IItem"; +import { IInsuredItemsData } from "../models/eft/inRaid/IInsuredItemsData"; import { ISaveProgressRequestData } from "../models/eft/inRaid/ISaveProgressRequestData"; import { IInsuranceConfig } from "../models/spt/config/IInsuranceConfig"; import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { LocaleService } from "./LocaleService"; @@ -24,6 +25,7 @@ export declare class InsuranceService { protected secureContainerHelper: SecureContainerHelper; protected randomUtil: RandomUtil; protected itemHelper: ItemHelper; + protected jsonUtil: JsonUtil; protected timeUtil: TimeUtil; protected saveServer: SaveServer; protected traderHelper: TraderHelper; @@ -35,7 +37,12 @@ export declare class InsuranceService { protected configServer: ConfigServer; protected insured: Record>; protected insuranceConfig: IInsuranceConfig; - constructor(logger: ILogger, databaseServer: DatabaseServer, secureContainerHelper: SecureContainerHelper, randomUtil: RandomUtil, itemHelper: ItemHelper, timeUtil: TimeUtil, saveServer: SaveServer, traderHelper: TraderHelper, dialogueHelper: DialogueHelper, handbookHelper: HandbookHelper, localisationService: LocalisationService, localeService: LocaleService, notificationSendHelper: NotificationSendHelper, configServer: ConfigServer); + constructor(logger: ILogger, databaseServer: DatabaseServer, secureContainerHelper: SecureContainerHelper, randomUtil: RandomUtil, itemHelper: ItemHelper, jsonUtil: JsonUtil, timeUtil: TimeUtil, saveServer: SaveServer, traderHelper: TraderHelper, dialogueHelper: DialogueHelper, handbookHelper: HandbookHelper, localisationService: LocalisationService, localeService: LocaleService, notificationSendHelper: NotificationSendHelper, configServer: ConfigServer); + /** + * Does player have insurance array + * @param sessionId Player id + * @returns True if exists + */ insuranceExists(sessionId: string): boolean; /** * Get all insured items by all traders for a profile @@ -78,7 +85,7 @@ export declare class InsuranceService { */ protected getInsuranceReturnTimestamp(pmcData: IPmcData, trader: ITraderBase): number; /** - * Store lost gear post-raid inside profile + * Store lost gear post-raid inside profile, ready for later code to pick it up and mail it * @param pmcData player profile to store gear in * @param offraidData post-raid request object * @param preRaidGear gear player wore prior to raid @@ -86,6 +93,21 @@ export declare class InsuranceService { * @param playerDied did the player die in raid */ storeLostGear(pmcData: IPmcData, offraidData: ISaveProgressRequestData, preRaidGear: Item[], sessionID: string, playerDied: boolean): void; + /** + * Take preraid item and update properties to ensure its ready to be given to player in insurance return mail + * @param pmcData Player profile + * @param insuredItem Insured items properties + * @param preRaidItem Insured item as it was pre-raid + * @param insuredItemFromClient Item data when player left raid (durability values) + * @returns Item object + */ + protected getInsuredItemDetails(pmcData: IPmcData, preRaidItem: Item, insuredItemFromClient: IInsuredItemsData): Item; + /** + * Reset slotId property to "hideout" when necessary (used to be in ) + * @param pmcData Players pmcData.Inventory.equipment value + * @param itemToReturn item we will send to player as insurance return + */ + protected updateSlotIdValue(playerBaseInventoryEquipmentId: string, itemToReturn: Item): void; /** * Create a hash table for an array of items, keyed by items _id * @param items Items to hash @@ -94,12 +116,17 @@ export declare class InsuranceService { protected createItemHashTable(items: Item[]): Record; /** * Add gear item to InsuredItems array in player profile - * @param pmcData profile to store item in - * @param insuredItem Item to store in profile - * @param actualItem item to store * @param sessionID Session id + * @param pmcData Player profile + * @param itemToReturnToPlayer item to store + * @param traderId Id of trader item was insured with */ - protected addGearToSend(pmcData: IPmcData, insuredItem: InsuredItem, actualItem: Item, sessionID: string): void; + protected addGearToSend(gear: { + sessionID: string; + pmcData: IPmcData; + itemToReturnToPlayer: Item; + traderId: string; + }): void; /** * Does insurance exist for a player and by trader * @param sessionId Player id (session id) diff --git a/TypeScript/12ClassExtensionOverride/types/models/eft/common/tables/IBotBase.d.ts b/TypeScript/12ClassExtensionOverride/types/models/eft/common/tables/IBotBase.d.ts index e5d1c30..69e7e00 100644 --- a/TypeScript/12ClassExtensionOverride/types/models/eft/common/tables/IBotBase.d.ts +++ b/TypeScript/12ClassExtensionOverride/types/models/eft/common/tables/IBotBase.d.ts @@ -267,6 +267,7 @@ export interface BackendCounter { value: number; } export interface InsuredItem { + /** Trader Id item was insured by */ tid: string; itemId: string; } diff --git a/TypeScript/12ClassExtensionOverride/types/models/eft/common/tables/IItem.d.ts b/TypeScript/12ClassExtensionOverride/types/models/eft/common/tables/IItem.d.ts index ce00ae9..09a239c 100644 --- a/TypeScript/12ClassExtensionOverride/types/models/eft/common/tables/IItem.d.ts +++ b/TypeScript/12ClassExtensionOverride/types/models/eft/common/tables/IItem.d.ts @@ -12,6 +12,7 @@ export interface Upd { Togglable?: Togglable; Map?: Map; Tag?: Tag; + /** SPT specific property, not made by BSG */ sptPresetId?: string; FaceShield?: FaceShield; StackObjectsCount?: number; diff --git a/TypeScript/12ClassExtensionOverride/types/models/eft/inRaid/IInsuredItemsData.d.ts b/TypeScript/12ClassExtensionOverride/types/models/eft/inRaid/IInsuredItemsData.d.ts new file mode 100644 index 0000000..c49fb79 --- /dev/null +++ b/TypeScript/12ClassExtensionOverride/types/models/eft/inRaid/IInsuredItemsData.d.ts @@ -0,0 +1,6 @@ +export interface IInsuredItemsData { + id: string; + durability?: number; + maxDurability?: number; + hits?: number; +} diff --git a/TypeScript/12ClassExtensionOverride/types/models/eft/inRaid/ISaveProgressRequestData.d.ts b/TypeScript/12ClassExtensionOverride/types/models/eft/inRaid/ISaveProgressRequestData.d.ts index 0b6f091..fd77c32 100644 --- a/TypeScript/12ClassExtensionOverride/types/models/eft/inRaid/ISaveProgressRequestData.d.ts +++ b/TypeScript/12ClassExtensionOverride/types/models/eft/inRaid/ISaveProgressRequestData.d.ts @@ -1,9 +1,11 @@ import { PlayerRaidEndState } from "../../../models/enums/PlayerRaidEndState"; import { IPmcData } from "../common/IPmcData"; import { ISyncHealthRequestData } from "../health/ISyncHealthRequestData"; +import { IInsuredItemsData } from "./IInsuredItemsData"; export interface ISaveProgressRequestData { exit: PlayerRaidEndState; profile: IPmcData; isPlayerScav: boolean; health: ISyncHealthRequestData; + insurance: IInsuredItemsData[]; } diff --git a/TypeScript/12ClassExtensionOverride/types/models/spt/config/IRagfairConfig.d.ts b/TypeScript/12ClassExtensionOverride/types/models/spt/config/IRagfairConfig.d.ts index 87e0173..7c04857 100644 --- a/TypeScript/12ClassExtensionOverride/types/models/spt/config/IRagfairConfig.d.ts +++ b/TypeScript/12ClassExtensionOverride/types/models/spt/config/IRagfairConfig.d.ts @@ -71,13 +71,8 @@ export interface Dynamic { removeSeasonalItemsWhenNotInEvent: boolean; /** Flea blacklist settings */ blacklist: Blacklist; - /** Should prices over the multiplier be adjusted */ - unreasonableModPrices: IUnreasonableModPrices; -} -export interface IUnreasonableModPrices { - enabled: boolean; - handbookPriceOverMultiplier: number; - newPriceHandbookMultiplier: number; + /** Dict of price limits keyed by item type */ + unreasonableModPrices: Record; } export interface Barter { /** Should barter offers be generated */ @@ -121,3 +116,8 @@ export interface Blacklist { /** Should trader items that are blacklisted by bsg */ traderItems: boolean; } +export interface IUnreasonableModPrices { + enabled: boolean; + handbookPriceOverMultiplier: number; + newPriceHandbookMultiplier: number; +} diff --git a/TypeScript/12ClassExtensionOverride/types/services/InsuranceService.d.ts b/TypeScript/12ClassExtensionOverride/types/services/InsuranceService.d.ts index 1d30f6d..5354cc0 100644 --- a/TypeScript/12ClassExtensionOverride/types/services/InsuranceService.d.ts +++ b/TypeScript/12ClassExtensionOverride/types/services/InsuranceService.d.ts @@ -6,14 +6,15 @@ import { NotificationSendHelper } from "../helpers/NotificationSendHelper"; import { SecureContainerHelper } from "../helpers/SecureContainerHelper"; import { TraderHelper } from "../helpers/TraderHelper"; import { IPmcData } from "../models/eft/common/IPmcData"; -import { InsuredItem } from "../models/eft/common/tables/IBotBase"; import { Item } from "../models/eft/common/tables/IItem"; +import { IInsuredItemsData } from "../models/eft/inRaid/IInsuredItemsData"; import { ISaveProgressRequestData } from "../models/eft/inRaid/ISaveProgressRequestData"; import { IInsuranceConfig } from "../models/spt/config/IInsuranceConfig"; import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { LocaleService } from "./LocaleService"; @@ -24,6 +25,7 @@ export declare class InsuranceService { protected secureContainerHelper: SecureContainerHelper; protected randomUtil: RandomUtil; protected itemHelper: ItemHelper; + protected jsonUtil: JsonUtil; protected timeUtil: TimeUtil; protected saveServer: SaveServer; protected traderHelper: TraderHelper; @@ -35,7 +37,12 @@ export declare class InsuranceService { protected configServer: ConfigServer; protected insured: Record>; protected insuranceConfig: IInsuranceConfig; - constructor(logger: ILogger, databaseServer: DatabaseServer, secureContainerHelper: SecureContainerHelper, randomUtil: RandomUtil, itemHelper: ItemHelper, timeUtil: TimeUtil, saveServer: SaveServer, traderHelper: TraderHelper, dialogueHelper: DialogueHelper, handbookHelper: HandbookHelper, localisationService: LocalisationService, localeService: LocaleService, notificationSendHelper: NotificationSendHelper, configServer: ConfigServer); + constructor(logger: ILogger, databaseServer: DatabaseServer, secureContainerHelper: SecureContainerHelper, randomUtil: RandomUtil, itemHelper: ItemHelper, jsonUtil: JsonUtil, timeUtil: TimeUtil, saveServer: SaveServer, traderHelper: TraderHelper, dialogueHelper: DialogueHelper, handbookHelper: HandbookHelper, localisationService: LocalisationService, localeService: LocaleService, notificationSendHelper: NotificationSendHelper, configServer: ConfigServer); + /** + * Does player have insurance array + * @param sessionId Player id + * @returns True if exists + */ insuranceExists(sessionId: string): boolean; /** * Get all insured items by all traders for a profile @@ -78,7 +85,7 @@ export declare class InsuranceService { */ protected getInsuranceReturnTimestamp(pmcData: IPmcData, trader: ITraderBase): number; /** - * Store lost gear post-raid inside profile + * Store lost gear post-raid inside profile, ready for later code to pick it up and mail it * @param pmcData player profile to store gear in * @param offraidData post-raid request object * @param preRaidGear gear player wore prior to raid @@ -86,6 +93,21 @@ export declare class InsuranceService { * @param playerDied did the player die in raid */ storeLostGear(pmcData: IPmcData, offraidData: ISaveProgressRequestData, preRaidGear: Item[], sessionID: string, playerDied: boolean): void; + /** + * Take preraid item and update properties to ensure its ready to be given to player in insurance return mail + * @param pmcData Player profile + * @param insuredItem Insured items properties + * @param preRaidItem Insured item as it was pre-raid + * @param insuredItemFromClient Item data when player left raid (durability values) + * @returns Item object + */ + protected getInsuredItemDetails(pmcData: IPmcData, preRaidItem: Item, insuredItemFromClient: IInsuredItemsData): Item; + /** + * Reset slotId property to "hideout" when necessary (used to be in ) + * @param pmcData Players pmcData.Inventory.equipment value + * @param itemToReturn item we will send to player as insurance return + */ + protected updateSlotIdValue(playerBaseInventoryEquipmentId: string, itemToReturn: Item): void; /** * Create a hash table for an array of items, keyed by items _id * @param items Items to hash @@ -94,12 +116,17 @@ export declare class InsuranceService { protected createItemHashTable(items: Item[]): Record; /** * Add gear item to InsuredItems array in player profile - * @param pmcData profile to store item in - * @param insuredItem Item to store in profile - * @param actualItem item to store * @param sessionID Session id + * @param pmcData Player profile + * @param itemToReturnToPlayer item to store + * @param traderId Id of trader item was insured with */ - protected addGearToSend(pmcData: IPmcData, insuredItem: InsuredItem, actualItem: Item, sessionID: string): void; + protected addGearToSend(gear: { + sessionID: string; + pmcData: IPmcData; + itemToReturnToPlayer: Item; + traderId: string; + }): void; /** * Does insurance exist for a player and by trader * @param sessionId Player id (session id) diff --git a/TypeScript/13AddTrader/types/models/eft/common/tables/IBotBase.d.ts b/TypeScript/13AddTrader/types/models/eft/common/tables/IBotBase.d.ts index e5d1c30..69e7e00 100644 --- a/TypeScript/13AddTrader/types/models/eft/common/tables/IBotBase.d.ts +++ b/TypeScript/13AddTrader/types/models/eft/common/tables/IBotBase.d.ts @@ -267,6 +267,7 @@ export interface BackendCounter { value: number; } export interface InsuredItem { + /** Trader Id item was insured by */ tid: string; itemId: string; } diff --git a/TypeScript/13AddTrader/types/models/eft/common/tables/IItem.d.ts b/TypeScript/13AddTrader/types/models/eft/common/tables/IItem.d.ts index ce00ae9..09a239c 100644 --- a/TypeScript/13AddTrader/types/models/eft/common/tables/IItem.d.ts +++ b/TypeScript/13AddTrader/types/models/eft/common/tables/IItem.d.ts @@ -12,6 +12,7 @@ export interface Upd { Togglable?: Togglable; Map?: Map; Tag?: Tag; + /** SPT specific property, not made by BSG */ sptPresetId?: string; FaceShield?: FaceShield; StackObjectsCount?: number; diff --git a/TypeScript/13AddTrader/types/models/eft/inRaid/IInsuredItemsData.d.ts b/TypeScript/13AddTrader/types/models/eft/inRaid/IInsuredItemsData.d.ts new file mode 100644 index 0000000..c49fb79 --- /dev/null +++ b/TypeScript/13AddTrader/types/models/eft/inRaid/IInsuredItemsData.d.ts @@ -0,0 +1,6 @@ +export interface IInsuredItemsData { + id: string; + durability?: number; + maxDurability?: number; + hits?: number; +} diff --git a/TypeScript/13AddTrader/types/models/eft/inRaid/ISaveProgressRequestData.d.ts b/TypeScript/13AddTrader/types/models/eft/inRaid/ISaveProgressRequestData.d.ts index 0b6f091..fd77c32 100644 --- a/TypeScript/13AddTrader/types/models/eft/inRaid/ISaveProgressRequestData.d.ts +++ b/TypeScript/13AddTrader/types/models/eft/inRaid/ISaveProgressRequestData.d.ts @@ -1,9 +1,11 @@ import { PlayerRaidEndState } from "../../../models/enums/PlayerRaidEndState"; import { IPmcData } from "../common/IPmcData"; import { ISyncHealthRequestData } from "../health/ISyncHealthRequestData"; +import { IInsuredItemsData } from "./IInsuredItemsData"; export interface ISaveProgressRequestData { exit: PlayerRaidEndState; profile: IPmcData; isPlayerScav: boolean; health: ISyncHealthRequestData; + insurance: IInsuredItemsData[]; } diff --git a/TypeScript/13AddTrader/types/models/spt/config/IRagfairConfig.d.ts b/TypeScript/13AddTrader/types/models/spt/config/IRagfairConfig.d.ts index 87e0173..7c04857 100644 --- a/TypeScript/13AddTrader/types/models/spt/config/IRagfairConfig.d.ts +++ b/TypeScript/13AddTrader/types/models/spt/config/IRagfairConfig.d.ts @@ -71,13 +71,8 @@ export interface Dynamic { removeSeasonalItemsWhenNotInEvent: boolean; /** Flea blacklist settings */ blacklist: Blacklist; - /** Should prices over the multiplier be adjusted */ - unreasonableModPrices: IUnreasonableModPrices; -} -export interface IUnreasonableModPrices { - enabled: boolean; - handbookPriceOverMultiplier: number; - newPriceHandbookMultiplier: number; + /** Dict of price limits keyed by item type */ + unreasonableModPrices: Record; } export interface Barter { /** Should barter offers be generated */ @@ -121,3 +116,8 @@ export interface Blacklist { /** Should trader items that are blacklisted by bsg */ traderItems: boolean; } +export interface IUnreasonableModPrices { + enabled: boolean; + handbookPriceOverMultiplier: number; + newPriceHandbookMultiplier: number; +} diff --git a/TypeScript/13AddTrader/types/services/InsuranceService.d.ts b/TypeScript/13AddTrader/types/services/InsuranceService.d.ts index 1d30f6d..5354cc0 100644 --- a/TypeScript/13AddTrader/types/services/InsuranceService.d.ts +++ b/TypeScript/13AddTrader/types/services/InsuranceService.d.ts @@ -6,14 +6,15 @@ import { NotificationSendHelper } from "../helpers/NotificationSendHelper"; import { SecureContainerHelper } from "../helpers/SecureContainerHelper"; import { TraderHelper } from "../helpers/TraderHelper"; import { IPmcData } from "../models/eft/common/IPmcData"; -import { InsuredItem } from "../models/eft/common/tables/IBotBase"; import { Item } from "../models/eft/common/tables/IItem"; +import { IInsuredItemsData } from "../models/eft/inRaid/IInsuredItemsData"; import { ISaveProgressRequestData } from "../models/eft/inRaid/ISaveProgressRequestData"; import { IInsuranceConfig } from "../models/spt/config/IInsuranceConfig"; import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { LocaleService } from "./LocaleService"; @@ -24,6 +25,7 @@ export declare class InsuranceService { protected secureContainerHelper: SecureContainerHelper; protected randomUtil: RandomUtil; protected itemHelper: ItemHelper; + protected jsonUtil: JsonUtil; protected timeUtil: TimeUtil; protected saveServer: SaveServer; protected traderHelper: TraderHelper; @@ -35,7 +37,12 @@ export declare class InsuranceService { protected configServer: ConfigServer; protected insured: Record>; protected insuranceConfig: IInsuranceConfig; - constructor(logger: ILogger, databaseServer: DatabaseServer, secureContainerHelper: SecureContainerHelper, randomUtil: RandomUtil, itemHelper: ItemHelper, timeUtil: TimeUtil, saveServer: SaveServer, traderHelper: TraderHelper, dialogueHelper: DialogueHelper, handbookHelper: HandbookHelper, localisationService: LocalisationService, localeService: LocaleService, notificationSendHelper: NotificationSendHelper, configServer: ConfigServer); + constructor(logger: ILogger, databaseServer: DatabaseServer, secureContainerHelper: SecureContainerHelper, randomUtil: RandomUtil, itemHelper: ItemHelper, jsonUtil: JsonUtil, timeUtil: TimeUtil, saveServer: SaveServer, traderHelper: TraderHelper, dialogueHelper: DialogueHelper, handbookHelper: HandbookHelper, localisationService: LocalisationService, localeService: LocaleService, notificationSendHelper: NotificationSendHelper, configServer: ConfigServer); + /** + * Does player have insurance array + * @param sessionId Player id + * @returns True if exists + */ insuranceExists(sessionId: string): boolean; /** * Get all insured items by all traders for a profile @@ -78,7 +85,7 @@ export declare class InsuranceService { */ protected getInsuranceReturnTimestamp(pmcData: IPmcData, trader: ITraderBase): number; /** - * Store lost gear post-raid inside profile + * Store lost gear post-raid inside profile, ready for later code to pick it up and mail it * @param pmcData player profile to store gear in * @param offraidData post-raid request object * @param preRaidGear gear player wore prior to raid @@ -86,6 +93,21 @@ export declare class InsuranceService { * @param playerDied did the player die in raid */ storeLostGear(pmcData: IPmcData, offraidData: ISaveProgressRequestData, preRaidGear: Item[], sessionID: string, playerDied: boolean): void; + /** + * Take preraid item and update properties to ensure its ready to be given to player in insurance return mail + * @param pmcData Player profile + * @param insuredItem Insured items properties + * @param preRaidItem Insured item as it was pre-raid + * @param insuredItemFromClient Item data when player left raid (durability values) + * @returns Item object + */ + protected getInsuredItemDetails(pmcData: IPmcData, preRaidItem: Item, insuredItemFromClient: IInsuredItemsData): Item; + /** + * Reset slotId property to "hideout" when necessary (used to be in ) + * @param pmcData Players pmcData.Inventory.equipment value + * @param itemToReturn item we will send to player as insurance return + */ + protected updateSlotIdValue(playerBaseInventoryEquipmentId: string, itemToReturn: Item): void; /** * Create a hash table for an array of items, keyed by items _id * @param items Items to hash @@ -94,12 +116,17 @@ export declare class InsuranceService { protected createItemHashTable(items: Item[]): Record; /** * Add gear item to InsuredItems array in player profile - * @param pmcData profile to store item in - * @param insuredItem Item to store in profile - * @param actualItem item to store * @param sessionID Session id + * @param pmcData Player profile + * @param itemToReturnToPlayer item to store + * @param traderId Id of trader item was insured with */ - protected addGearToSend(pmcData: IPmcData, insuredItem: InsuredItem, actualItem: Item, sessionID: string): void; + protected addGearToSend(gear: { + sessionID: string; + pmcData: IPmcData; + itemToReturnToPlayer: Item; + traderId: string; + }): void; /** * Does insurance exist for a player and by trader * @param sessionId Player id (session id) diff --git a/TypeScript/14AfterDBLoadHook/types/models/eft/common/tables/IBotBase.d.ts b/TypeScript/14AfterDBLoadHook/types/models/eft/common/tables/IBotBase.d.ts index e5d1c30..69e7e00 100644 --- a/TypeScript/14AfterDBLoadHook/types/models/eft/common/tables/IBotBase.d.ts +++ b/TypeScript/14AfterDBLoadHook/types/models/eft/common/tables/IBotBase.d.ts @@ -267,6 +267,7 @@ export interface BackendCounter { value: number; } export interface InsuredItem { + /** Trader Id item was insured by */ tid: string; itemId: string; } diff --git a/TypeScript/14AfterDBLoadHook/types/models/eft/common/tables/IItem.d.ts b/TypeScript/14AfterDBLoadHook/types/models/eft/common/tables/IItem.d.ts index ce00ae9..09a239c 100644 --- a/TypeScript/14AfterDBLoadHook/types/models/eft/common/tables/IItem.d.ts +++ b/TypeScript/14AfterDBLoadHook/types/models/eft/common/tables/IItem.d.ts @@ -12,6 +12,7 @@ export interface Upd { Togglable?: Togglable; Map?: Map; Tag?: Tag; + /** SPT specific property, not made by BSG */ sptPresetId?: string; FaceShield?: FaceShield; StackObjectsCount?: number; diff --git a/TypeScript/14AfterDBLoadHook/types/models/eft/inRaid/IInsuredItemsData.d.ts b/TypeScript/14AfterDBLoadHook/types/models/eft/inRaid/IInsuredItemsData.d.ts new file mode 100644 index 0000000..c49fb79 --- /dev/null +++ b/TypeScript/14AfterDBLoadHook/types/models/eft/inRaid/IInsuredItemsData.d.ts @@ -0,0 +1,6 @@ +export interface IInsuredItemsData { + id: string; + durability?: number; + maxDurability?: number; + hits?: number; +} diff --git a/TypeScript/14AfterDBLoadHook/types/models/eft/inRaid/ISaveProgressRequestData.d.ts b/TypeScript/14AfterDBLoadHook/types/models/eft/inRaid/ISaveProgressRequestData.d.ts index 0b6f091..fd77c32 100644 --- a/TypeScript/14AfterDBLoadHook/types/models/eft/inRaid/ISaveProgressRequestData.d.ts +++ b/TypeScript/14AfterDBLoadHook/types/models/eft/inRaid/ISaveProgressRequestData.d.ts @@ -1,9 +1,11 @@ import { PlayerRaidEndState } from "../../../models/enums/PlayerRaidEndState"; import { IPmcData } from "../common/IPmcData"; import { ISyncHealthRequestData } from "../health/ISyncHealthRequestData"; +import { IInsuredItemsData } from "./IInsuredItemsData"; export interface ISaveProgressRequestData { exit: PlayerRaidEndState; profile: IPmcData; isPlayerScav: boolean; health: ISyncHealthRequestData; + insurance: IInsuredItemsData[]; } diff --git a/TypeScript/14AfterDBLoadHook/types/models/spt/config/IRagfairConfig.d.ts b/TypeScript/14AfterDBLoadHook/types/models/spt/config/IRagfairConfig.d.ts index 87e0173..7c04857 100644 --- a/TypeScript/14AfterDBLoadHook/types/models/spt/config/IRagfairConfig.d.ts +++ b/TypeScript/14AfterDBLoadHook/types/models/spt/config/IRagfairConfig.d.ts @@ -71,13 +71,8 @@ export interface Dynamic { removeSeasonalItemsWhenNotInEvent: boolean; /** Flea blacklist settings */ blacklist: Blacklist; - /** Should prices over the multiplier be adjusted */ - unreasonableModPrices: IUnreasonableModPrices; -} -export interface IUnreasonableModPrices { - enabled: boolean; - handbookPriceOverMultiplier: number; - newPriceHandbookMultiplier: number; + /** Dict of price limits keyed by item type */ + unreasonableModPrices: Record; } export interface Barter { /** Should barter offers be generated */ @@ -121,3 +116,8 @@ export interface Blacklist { /** Should trader items that are blacklisted by bsg */ traderItems: boolean; } +export interface IUnreasonableModPrices { + enabled: boolean; + handbookPriceOverMultiplier: number; + newPriceHandbookMultiplier: number; +} diff --git a/TypeScript/14AfterDBLoadHook/types/services/InsuranceService.d.ts b/TypeScript/14AfterDBLoadHook/types/services/InsuranceService.d.ts index 1d30f6d..5354cc0 100644 --- a/TypeScript/14AfterDBLoadHook/types/services/InsuranceService.d.ts +++ b/TypeScript/14AfterDBLoadHook/types/services/InsuranceService.d.ts @@ -6,14 +6,15 @@ import { NotificationSendHelper } from "../helpers/NotificationSendHelper"; import { SecureContainerHelper } from "../helpers/SecureContainerHelper"; import { TraderHelper } from "../helpers/TraderHelper"; import { IPmcData } from "../models/eft/common/IPmcData"; -import { InsuredItem } from "../models/eft/common/tables/IBotBase"; import { Item } from "../models/eft/common/tables/IItem"; +import { IInsuredItemsData } from "../models/eft/inRaid/IInsuredItemsData"; import { ISaveProgressRequestData } from "../models/eft/inRaid/ISaveProgressRequestData"; import { IInsuranceConfig } from "../models/spt/config/IInsuranceConfig"; import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { LocaleService } from "./LocaleService"; @@ -24,6 +25,7 @@ export declare class InsuranceService { protected secureContainerHelper: SecureContainerHelper; protected randomUtil: RandomUtil; protected itemHelper: ItemHelper; + protected jsonUtil: JsonUtil; protected timeUtil: TimeUtil; protected saveServer: SaveServer; protected traderHelper: TraderHelper; @@ -35,7 +37,12 @@ export declare class InsuranceService { protected configServer: ConfigServer; protected insured: Record>; protected insuranceConfig: IInsuranceConfig; - constructor(logger: ILogger, databaseServer: DatabaseServer, secureContainerHelper: SecureContainerHelper, randomUtil: RandomUtil, itemHelper: ItemHelper, timeUtil: TimeUtil, saveServer: SaveServer, traderHelper: TraderHelper, dialogueHelper: DialogueHelper, handbookHelper: HandbookHelper, localisationService: LocalisationService, localeService: LocaleService, notificationSendHelper: NotificationSendHelper, configServer: ConfigServer); + constructor(logger: ILogger, databaseServer: DatabaseServer, secureContainerHelper: SecureContainerHelper, randomUtil: RandomUtil, itemHelper: ItemHelper, jsonUtil: JsonUtil, timeUtil: TimeUtil, saveServer: SaveServer, traderHelper: TraderHelper, dialogueHelper: DialogueHelper, handbookHelper: HandbookHelper, localisationService: LocalisationService, localeService: LocaleService, notificationSendHelper: NotificationSendHelper, configServer: ConfigServer); + /** + * Does player have insurance array + * @param sessionId Player id + * @returns True if exists + */ insuranceExists(sessionId: string): boolean; /** * Get all insured items by all traders for a profile @@ -78,7 +85,7 @@ export declare class InsuranceService { */ protected getInsuranceReturnTimestamp(pmcData: IPmcData, trader: ITraderBase): number; /** - * Store lost gear post-raid inside profile + * Store lost gear post-raid inside profile, ready for later code to pick it up and mail it * @param pmcData player profile to store gear in * @param offraidData post-raid request object * @param preRaidGear gear player wore prior to raid @@ -86,6 +93,21 @@ export declare class InsuranceService { * @param playerDied did the player die in raid */ storeLostGear(pmcData: IPmcData, offraidData: ISaveProgressRequestData, preRaidGear: Item[], sessionID: string, playerDied: boolean): void; + /** + * Take preraid item and update properties to ensure its ready to be given to player in insurance return mail + * @param pmcData Player profile + * @param insuredItem Insured items properties + * @param preRaidItem Insured item as it was pre-raid + * @param insuredItemFromClient Item data when player left raid (durability values) + * @returns Item object + */ + protected getInsuredItemDetails(pmcData: IPmcData, preRaidItem: Item, insuredItemFromClient: IInsuredItemsData): Item; + /** + * Reset slotId property to "hideout" when necessary (used to be in ) + * @param pmcData Players pmcData.Inventory.equipment value + * @param itemToReturn item we will send to player as insurance return + */ + protected updateSlotIdValue(playerBaseInventoryEquipmentId: string, itemToReturn: Item): void; /** * Create a hash table for an array of items, keyed by items _id * @param items Items to hash @@ -94,12 +116,17 @@ export declare class InsuranceService { protected createItemHashTable(items: Item[]): Record; /** * Add gear item to InsuredItems array in player profile - * @param pmcData profile to store item in - * @param insuredItem Item to store in profile - * @param actualItem item to store * @param sessionID Session id + * @param pmcData Player profile + * @param itemToReturnToPlayer item to store + * @param traderId Id of trader item was insured with */ - protected addGearToSend(pmcData: IPmcData, insuredItem: InsuredItem, actualItem: Item, sessionID: string): void; + protected addGearToSend(gear: { + sessionID: string; + pmcData: IPmcData; + itemToReturnToPlayer: Item; + traderId: string; + }): void; /** * Does insurance exist for a player and by trader * @param sessionId Player id (session id) diff --git a/TypeScript/15HttpListenerExample/types/models/eft/common/tables/IBotBase.d.ts b/TypeScript/15HttpListenerExample/types/models/eft/common/tables/IBotBase.d.ts index e5d1c30..69e7e00 100644 --- a/TypeScript/15HttpListenerExample/types/models/eft/common/tables/IBotBase.d.ts +++ b/TypeScript/15HttpListenerExample/types/models/eft/common/tables/IBotBase.d.ts @@ -267,6 +267,7 @@ export interface BackendCounter { value: number; } export interface InsuredItem { + /** Trader Id item was insured by */ tid: string; itemId: string; } diff --git a/TypeScript/15HttpListenerExample/types/models/eft/common/tables/IItem.d.ts b/TypeScript/15HttpListenerExample/types/models/eft/common/tables/IItem.d.ts index ce00ae9..09a239c 100644 --- a/TypeScript/15HttpListenerExample/types/models/eft/common/tables/IItem.d.ts +++ b/TypeScript/15HttpListenerExample/types/models/eft/common/tables/IItem.d.ts @@ -12,6 +12,7 @@ export interface Upd { Togglable?: Togglable; Map?: Map; Tag?: Tag; + /** SPT specific property, not made by BSG */ sptPresetId?: string; FaceShield?: FaceShield; StackObjectsCount?: number; diff --git a/TypeScript/15HttpListenerExample/types/models/eft/inRaid/IInsuredItemsData.d.ts b/TypeScript/15HttpListenerExample/types/models/eft/inRaid/IInsuredItemsData.d.ts new file mode 100644 index 0000000..c49fb79 --- /dev/null +++ b/TypeScript/15HttpListenerExample/types/models/eft/inRaid/IInsuredItemsData.d.ts @@ -0,0 +1,6 @@ +export interface IInsuredItemsData { + id: string; + durability?: number; + maxDurability?: number; + hits?: number; +} diff --git a/TypeScript/15HttpListenerExample/types/models/eft/inRaid/ISaveProgressRequestData.d.ts b/TypeScript/15HttpListenerExample/types/models/eft/inRaid/ISaveProgressRequestData.d.ts index 0b6f091..fd77c32 100644 --- a/TypeScript/15HttpListenerExample/types/models/eft/inRaid/ISaveProgressRequestData.d.ts +++ b/TypeScript/15HttpListenerExample/types/models/eft/inRaid/ISaveProgressRequestData.d.ts @@ -1,9 +1,11 @@ import { PlayerRaidEndState } from "../../../models/enums/PlayerRaidEndState"; import { IPmcData } from "../common/IPmcData"; import { ISyncHealthRequestData } from "../health/ISyncHealthRequestData"; +import { IInsuredItemsData } from "./IInsuredItemsData"; export interface ISaveProgressRequestData { exit: PlayerRaidEndState; profile: IPmcData; isPlayerScav: boolean; health: ISyncHealthRequestData; + insurance: IInsuredItemsData[]; } diff --git a/TypeScript/15HttpListenerExample/types/models/spt/config/IRagfairConfig.d.ts b/TypeScript/15HttpListenerExample/types/models/spt/config/IRagfairConfig.d.ts index 87e0173..7c04857 100644 --- a/TypeScript/15HttpListenerExample/types/models/spt/config/IRagfairConfig.d.ts +++ b/TypeScript/15HttpListenerExample/types/models/spt/config/IRagfairConfig.d.ts @@ -71,13 +71,8 @@ export interface Dynamic { removeSeasonalItemsWhenNotInEvent: boolean; /** Flea blacklist settings */ blacklist: Blacklist; - /** Should prices over the multiplier be adjusted */ - unreasonableModPrices: IUnreasonableModPrices; -} -export interface IUnreasonableModPrices { - enabled: boolean; - handbookPriceOverMultiplier: number; - newPriceHandbookMultiplier: number; + /** Dict of price limits keyed by item type */ + unreasonableModPrices: Record; } export interface Barter { /** Should barter offers be generated */ @@ -121,3 +116,8 @@ export interface Blacklist { /** Should trader items that are blacklisted by bsg */ traderItems: boolean; } +export interface IUnreasonableModPrices { + enabled: boolean; + handbookPriceOverMultiplier: number; + newPriceHandbookMultiplier: number; +} diff --git a/TypeScript/15HttpListenerExample/types/services/InsuranceService.d.ts b/TypeScript/15HttpListenerExample/types/services/InsuranceService.d.ts index 1d30f6d..5354cc0 100644 --- a/TypeScript/15HttpListenerExample/types/services/InsuranceService.d.ts +++ b/TypeScript/15HttpListenerExample/types/services/InsuranceService.d.ts @@ -6,14 +6,15 @@ import { NotificationSendHelper } from "../helpers/NotificationSendHelper"; import { SecureContainerHelper } from "../helpers/SecureContainerHelper"; import { TraderHelper } from "../helpers/TraderHelper"; import { IPmcData } from "../models/eft/common/IPmcData"; -import { InsuredItem } from "../models/eft/common/tables/IBotBase"; import { Item } from "../models/eft/common/tables/IItem"; +import { IInsuredItemsData } from "../models/eft/inRaid/IInsuredItemsData"; import { ISaveProgressRequestData } from "../models/eft/inRaid/ISaveProgressRequestData"; import { IInsuranceConfig } from "../models/spt/config/IInsuranceConfig"; import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { LocaleService } from "./LocaleService"; @@ -24,6 +25,7 @@ export declare class InsuranceService { protected secureContainerHelper: SecureContainerHelper; protected randomUtil: RandomUtil; protected itemHelper: ItemHelper; + protected jsonUtil: JsonUtil; protected timeUtil: TimeUtil; protected saveServer: SaveServer; protected traderHelper: TraderHelper; @@ -35,7 +37,12 @@ export declare class InsuranceService { protected configServer: ConfigServer; protected insured: Record>; protected insuranceConfig: IInsuranceConfig; - constructor(logger: ILogger, databaseServer: DatabaseServer, secureContainerHelper: SecureContainerHelper, randomUtil: RandomUtil, itemHelper: ItemHelper, timeUtil: TimeUtil, saveServer: SaveServer, traderHelper: TraderHelper, dialogueHelper: DialogueHelper, handbookHelper: HandbookHelper, localisationService: LocalisationService, localeService: LocaleService, notificationSendHelper: NotificationSendHelper, configServer: ConfigServer); + constructor(logger: ILogger, databaseServer: DatabaseServer, secureContainerHelper: SecureContainerHelper, randomUtil: RandomUtil, itemHelper: ItemHelper, jsonUtil: JsonUtil, timeUtil: TimeUtil, saveServer: SaveServer, traderHelper: TraderHelper, dialogueHelper: DialogueHelper, handbookHelper: HandbookHelper, localisationService: LocalisationService, localeService: LocaleService, notificationSendHelper: NotificationSendHelper, configServer: ConfigServer); + /** + * Does player have insurance array + * @param sessionId Player id + * @returns True if exists + */ insuranceExists(sessionId: string): boolean; /** * Get all insured items by all traders for a profile @@ -78,7 +85,7 @@ export declare class InsuranceService { */ protected getInsuranceReturnTimestamp(pmcData: IPmcData, trader: ITraderBase): number; /** - * Store lost gear post-raid inside profile + * Store lost gear post-raid inside profile, ready for later code to pick it up and mail it * @param pmcData player profile to store gear in * @param offraidData post-raid request object * @param preRaidGear gear player wore prior to raid @@ -86,6 +93,21 @@ export declare class InsuranceService { * @param playerDied did the player die in raid */ storeLostGear(pmcData: IPmcData, offraidData: ISaveProgressRequestData, preRaidGear: Item[], sessionID: string, playerDied: boolean): void; + /** + * Take preraid item and update properties to ensure its ready to be given to player in insurance return mail + * @param pmcData Player profile + * @param insuredItem Insured items properties + * @param preRaidItem Insured item as it was pre-raid + * @param insuredItemFromClient Item data when player left raid (durability values) + * @returns Item object + */ + protected getInsuredItemDetails(pmcData: IPmcData, preRaidItem: Item, insuredItemFromClient: IInsuredItemsData): Item; + /** + * Reset slotId property to "hideout" when necessary (used to be in ) + * @param pmcData Players pmcData.Inventory.equipment value + * @param itemToReturn item we will send to player as insurance return + */ + protected updateSlotIdValue(playerBaseInventoryEquipmentId: string, itemToReturn: Item): void; /** * Create a hash table for an array of items, keyed by items _id * @param items Items to hash @@ -94,12 +116,17 @@ export declare class InsuranceService { protected createItemHashTable(items: Item[]): Record; /** * Add gear item to InsuredItems array in player profile - * @param pmcData profile to store item in - * @param insuredItem Item to store in profile - * @param actualItem item to store * @param sessionID Session id + * @param pmcData Player profile + * @param itemToReturnToPlayer item to store + * @param traderId Id of trader item was insured with */ - protected addGearToSend(pmcData: IPmcData, insuredItem: InsuredItem, actualItem: Item, sessionID: string): void; + protected addGearToSend(gear: { + sessionID: string; + pmcData: IPmcData; + itemToReturnToPlayer: Item; + traderId: string; + }): void; /** * Does insurance exist for a player and by trader * @param sessionId Player id (session id) diff --git a/TypeScript/16ImporterUtil/types/models/eft/common/tables/IBotBase.d.ts b/TypeScript/16ImporterUtil/types/models/eft/common/tables/IBotBase.d.ts index e5d1c30..69e7e00 100644 --- a/TypeScript/16ImporterUtil/types/models/eft/common/tables/IBotBase.d.ts +++ b/TypeScript/16ImporterUtil/types/models/eft/common/tables/IBotBase.d.ts @@ -267,6 +267,7 @@ export interface BackendCounter { value: number; } export interface InsuredItem { + /** Trader Id item was insured by */ tid: string; itemId: string; } diff --git a/TypeScript/16ImporterUtil/types/models/eft/common/tables/IItem.d.ts b/TypeScript/16ImporterUtil/types/models/eft/common/tables/IItem.d.ts index ce00ae9..09a239c 100644 --- a/TypeScript/16ImporterUtil/types/models/eft/common/tables/IItem.d.ts +++ b/TypeScript/16ImporterUtil/types/models/eft/common/tables/IItem.d.ts @@ -12,6 +12,7 @@ export interface Upd { Togglable?: Togglable; Map?: Map; Tag?: Tag; + /** SPT specific property, not made by BSG */ sptPresetId?: string; FaceShield?: FaceShield; StackObjectsCount?: number; diff --git a/TypeScript/16ImporterUtil/types/models/eft/inRaid/IInsuredItemsData.d.ts b/TypeScript/16ImporterUtil/types/models/eft/inRaid/IInsuredItemsData.d.ts new file mode 100644 index 0000000..c49fb79 --- /dev/null +++ b/TypeScript/16ImporterUtil/types/models/eft/inRaid/IInsuredItemsData.d.ts @@ -0,0 +1,6 @@ +export interface IInsuredItemsData { + id: string; + durability?: number; + maxDurability?: number; + hits?: number; +} diff --git a/TypeScript/16ImporterUtil/types/models/eft/inRaid/ISaveProgressRequestData.d.ts b/TypeScript/16ImporterUtil/types/models/eft/inRaid/ISaveProgressRequestData.d.ts index 0b6f091..fd77c32 100644 --- a/TypeScript/16ImporterUtil/types/models/eft/inRaid/ISaveProgressRequestData.d.ts +++ b/TypeScript/16ImporterUtil/types/models/eft/inRaid/ISaveProgressRequestData.d.ts @@ -1,9 +1,11 @@ import { PlayerRaidEndState } from "../../../models/enums/PlayerRaidEndState"; import { IPmcData } from "../common/IPmcData"; import { ISyncHealthRequestData } from "../health/ISyncHealthRequestData"; +import { IInsuredItemsData } from "./IInsuredItemsData"; export interface ISaveProgressRequestData { exit: PlayerRaidEndState; profile: IPmcData; isPlayerScav: boolean; health: ISyncHealthRequestData; + insurance: IInsuredItemsData[]; } diff --git a/TypeScript/16ImporterUtil/types/models/spt/config/IRagfairConfig.d.ts b/TypeScript/16ImporterUtil/types/models/spt/config/IRagfairConfig.d.ts index 87e0173..7c04857 100644 --- a/TypeScript/16ImporterUtil/types/models/spt/config/IRagfairConfig.d.ts +++ b/TypeScript/16ImporterUtil/types/models/spt/config/IRagfairConfig.d.ts @@ -71,13 +71,8 @@ export interface Dynamic { removeSeasonalItemsWhenNotInEvent: boolean; /** Flea blacklist settings */ blacklist: Blacklist; - /** Should prices over the multiplier be adjusted */ - unreasonableModPrices: IUnreasonableModPrices; -} -export interface IUnreasonableModPrices { - enabled: boolean; - handbookPriceOverMultiplier: number; - newPriceHandbookMultiplier: number; + /** Dict of price limits keyed by item type */ + unreasonableModPrices: Record; } export interface Barter { /** Should barter offers be generated */ @@ -121,3 +116,8 @@ export interface Blacklist { /** Should trader items that are blacklisted by bsg */ traderItems: boolean; } +export interface IUnreasonableModPrices { + enabled: boolean; + handbookPriceOverMultiplier: number; + newPriceHandbookMultiplier: number; +} diff --git a/TypeScript/16ImporterUtil/types/services/InsuranceService.d.ts b/TypeScript/16ImporterUtil/types/services/InsuranceService.d.ts index 1d30f6d..5354cc0 100644 --- a/TypeScript/16ImporterUtil/types/services/InsuranceService.d.ts +++ b/TypeScript/16ImporterUtil/types/services/InsuranceService.d.ts @@ -6,14 +6,15 @@ import { NotificationSendHelper } from "../helpers/NotificationSendHelper"; import { SecureContainerHelper } from "../helpers/SecureContainerHelper"; import { TraderHelper } from "../helpers/TraderHelper"; import { IPmcData } from "../models/eft/common/IPmcData"; -import { InsuredItem } from "../models/eft/common/tables/IBotBase"; import { Item } from "../models/eft/common/tables/IItem"; +import { IInsuredItemsData } from "../models/eft/inRaid/IInsuredItemsData"; import { ISaveProgressRequestData } from "../models/eft/inRaid/ISaveProgressRequestData"; import { IInsuranceConfig } from "../models/spt/config/IInsuranceConfig"; import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { LocaleService } from "./LocaleService"; @@ -24,6 +25,7 @@ export declare class InsuranceService { protected secureContainerHelper: SecureContainerHelper; protected randomUtil: RandomUtil; protected itemHelper: ItemHelper; + protected jsonUtil: JsonUtil; protected timeUtil: TimeUtil; protected saveServer: SaveServer; protected traderHelper: TraderHelper; @@ -35,7 +37,12 @@ export declare class InsuranceService { protected configServer: ConfigServer; protected insured: Record>; protected insuranceConfig: IInsuranceConfig; - constructor(logger: ILogger, databaseServer: DatabaseServer, secureContainerHelper: SecureContainerHelper, randomUtil: RandomUtil, itemHelper: ItemHelper, timeUtil: TimeUtil, saveServer: SaveServer, traderHelper: TraderHelper, dialogueHelper: DialogueHelper, handbookHelper: HandbookHelper, localisationService: LocalisationService, localeService: LocaleService, notificationSendHelper: NotificationSendHelper, configServer: ConfigServer); + constructor(logger: ILogger, databaseServer: DatabaseServer, secureContainerHelper: SecureContainerHelper, randomUtil: RandomUtil, itemHelper: ItemHelper, jsonUtil: JsonUtil, timeUtil: TimeUtil, saveServer: SaveServer, traderHelper: TraderHelper, dialogueHelper: DialogueHelper, handbookHelper: HandbookHelper, localisationService: LocalisationService, localeService: LocaleService, notificationSendHelper: NotificationSendHelper, configServer: ConfigServer); + /** + * Does player have insurance array + * @param sessionId Player id + * @returns True if exists + */ insuranceExists(sessionId: string): boolean; /** * Get all insured items by all traders for a profile @@ -78,7 +85,7 @@ export declare class InsuranceService { */ protected getInsuranceReturnTimestamp(pmcData: IPmcData, trader: ITraderBase): number; /** - * Store lost gear post-raid inside profile + * Store lost gear post-raid inside profile, ready for later code to pick it up and mail it * @param pmcData player profile to store gear in * @param offraidData post-raid request object * @param preRaidGear gear player wore prior to raid @@ -86,6 +93,21 @@ export declare class InsuranceService { * @param playerDied did the player die in raid */ storeLostGear(pmcData: IPmcData, offraidData: ISaveProgressRequestData, preRaidGear: Item[], sessionID: string, playerDied: boolean): void; + /** + * Take preraid item and update properties to ensure its ready to be given to player in insurance return mail + * @param pmcData Player profile + * @param insuredItem Insured items properties + * @param preRaidItem Insured item as it was pre-raid + * @param insuredItemFromClient Item data when player left raid (durability values) + * @returns Item object + */ + protected getInsuredItemDetails(pmcData: IPmcData, preRaidItem: Item, insuredItemFromClient: IInsuredItemsData): Item; + /** + * Reset slotId property to "hideout" when necessary (used to be in ) + * @param pmcData Players pmcData.Inventory.equipment value + * @param itemToReturn item we will send to player as insurance return + */ + protected updateSlotIdValue(playerBaseInventoryEquipmentId: string, itemToReturn: Item): void; /** * Create a hash table for an array of items, keyed by items _id * @param items Items to hash @@ -94,12 +116,17 @@ export declare class InsuranceService { protected createItemHashTable(items: Item[]): Record; /** * Add gear item to InsuredItems array in player profile - * @param pmcData profile to store item in - * @param insuredItem Item to store in profile - * @param actualItem item to store * @param sessionID Session id + * @param pmcData Player profile + * @param itemToReturnToPlayer item to store + * @param traderId Id of trader item was insured with */ - protected addGearToSend(pmcData: IPmcData, insuredItem: InsuredItem, actualItem: Item, sessionID: string): void; + protected addGearToSend(gear: { + sessionID: string; + pmcData: IPmcData; + itemToReturnToPlayer: Item; + traderId: string; + }): void; /** * Does insurance exist for a player and by trader * @param sessionId Player id (session id) diff --git a/TypeScript/17AsyncImporterWithDependency1/types/models/eft/common/tables/IBotBase.d.ts b/TypeScript/17AsyncImporterWithDependency1/types/models/eft/common/tables/IBotBase.d.ts index e5d1c30..69e7e00 100644 --- a/TypeScript/17AsyncImporterWithDependency1/types/models/eft/common/tables/IBotBase.d.ts +++ b/TypeScript/17AsyncImporterWithDependency1/types/models/eft/common/tables/IBotBase.d.ts @@ -267,6 +267,7 @@ export interface BackendCounter { value: number; } export interface InsuredItem { + /** Trader Id item was insured by */ tid: string; itemId: string; } diff --git a/TypeScript/17AsyncImporterWithDependency1/types/models/eft/common/tables/IItem.d.ts b/TypeScript/17AsyncImporterWithDependency1/types/models/eft/common/tables/IItem.d.ts index ce00ae9..09a239c 100644 --- a/TypeScript/17AsyncImporterWithDependency1/types/models/eft/common/tables/IItem.d.ts +++ b/TypeScript/17AsyncImporterWithDependency1/types/models/eft/common/tables/IItem.d.ts @@ -12,6 +12,7 @@ export interface Upd { Togglable?: Togglable; Map?: Map; Tag?: Tag; + /** SPT specific property, not made by BSG */ sptPresetId?: string; FaceShield?: FaceShield; StackObjectsCount?: number; diff --git a/TypeScript/17AsyncImporterWithDependency1/types/models/eft/inRaid/IInsuredItemsData.d.ts b/TypeScript/17AsyncImporterWithDependency1/types/models/eft/inRaid/IInsuredItemsData.d.ts new file mode 100644 index 0000000..c49fb79 --- /dev/null +++ b/TypeScript/17AsyncImporterWithDependency1/types/models/eft/inRaid/IInsuredItemsData.d.ts @@ -0,0 +1,6 @@ +export interface IInsuredItemsData { + id: string; + durability?: number; + maxDurability?: number; + hits?: number; +} diff --git a/TypeScript/17AsyncImporterWithDependency1/types/models/eft/inRaid/ISaveProgressRequestData.d.ts b/TypeScript/17AsyncImporterWithDependency1/types/models/eft/inRaid/ISaveProgressRequestData.d.ts index 0b6f091..fd77c32 100644 --- a/TypeScript/17AsyncImporterWithDependency1/types/models/eft/inRaid/ISaveProgressRequestData.d.ts +++ b/TypeScript/17AsyncImporterWithDependency1/types/models/eft/inRaid/ISaveProgressRequestData.d.ts @@ -1,9 +1,11 @@ import { PlayerRaidEndState } from "../../../models/enums/PlayerRaidEndState"; import { IPmcData } from "../common/IPmcData"; import { ISyncHealthRequestData } from "../health/ISyncHealthRequestData"; +import { IInsuredItemsData } from "./IInsuredItemsData"; export interface ISaveProgressRequestData { exit: PlayerRaidEndState; profile: IPmcData; isPlayerScav: boolean; health: ISyncHealthRequestData; + insurance: IInsuredItemsData[]; } diff --git a/TypeScript/17AsyncImporterWithDependency1/types/models/spt/config/IRagfairConfig.d.ts b/TypeScript/17AsyncImporterWithDependency1/types/models/spt/config/IRagfairConfig.d.ts index 87e0173..7c04857 100644 --- a/TypeScript/17AsyncImporterWithDependency1/types/models/spt/config/IRagfairConfig.d.ts +++ b/TypeScript/17AsyncImporterWithDependency1/types/models/spt/config/IRagfairConfig.d.ts @@ -71,13 +71,8 @@ export interface Dynamic { removeSeasonalItemsWhenNotInEvent: boolean; /** Flea blacklist settings */ blacklist: Blacklist; - /** Should prices over the multiplier be adjusted */ - unreasonableModPrices: IUnreasonableModPrices; -} -export interface IUnreasonableModPrices { - enabled: boolean; - handbookPriceOverMultiplier: number; - newPriceHandbookMultiplier: number; + /** Dict of price limits keyed by item type */ + unreasonableModPrices: Record; } export interface Barter { /** Should barter offers be generated */ @@ -121,3 +116,8 @@ export interface Blacklist { /** Should trader items that are blacklisted by bsg */ traderItems: boolean; } +export interface IUnreasonableModPrices { + enabled: boolean; + handbookPriceOverMultiplier: number; + newPriceHandbookMultiplier: number; +} diff --git a/TypeScript/17AsyncImporterWithDependency1/types/services/InsuranceService.d.ts b/TypeScript/17AsyncImporterWithDependency1/types/services/InsuranceService.d.ts index 1d30f6d..5354cc0 100644 --- a/TypeScript/17AsyncImporterWithDependency1/types/services/InsuranceService.d.ts +++ b/TypeScript/17AsyncImporterWithDependency1/types/services/InsuranceService.d.ts @@ -6,14 +6,15 @@ import { NotificationSendHelper } from "../helpers/NotificationSendHelper"; import { SecureContainerHelper } from "../helpers/SecureContainerHelper"; import { TraderHelper } from "../helpers/TraderHelper"; import { IPmcData } from "../models/eft/common/IPmcData"; -import { InsuredItem } from "../models/eft/common/tables/IBotBase"; import { Item } from "../models/eft/common/tables/IItem"; +import { IInsuredItemsData } from "../models/eft/inRaid/IInsuredItemsData"; import { ISaveProgressRequestData } from "../models/eft/inRaid/ISaveProgressRequestData"; import { IInsuranceConfig } from "../models/spt/config/IInsuranceConfig"; import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { LocaleService } from "./LocaleService"; @@ -24,6 +25,7 @@ export declare class InsuranceService { protected secureContainerHelper: SecureContainerHelper; protected randomUtil: RandomUtil; protected itemHelper: ItemHelper; + protected jsonUtil: JsonUtil; protected timeUtil: TimeUtil; protected saveServer: SaveServer; protected traderHelper: TraderHelper; @@ -35,7 +37,12 @@ export declare class InsuranceService { protected configServer: ConfigServer; protected insured: Record>; protected insuranceConfig: IInsuranceConfig; - constructor(logger: ILogger, databaseServer: DatabaseServer, secureContainerHelper: SecureContainerHelper, randomUtil: RandomUtil, itemHelper: ItemHelper, timeUtil: TimeUtil, saveServer: SaveServer, traderHelper: TraderHelper, dialogueHelper: DialogueHelper, handbookHelper: HandbookHelper, localisationService: LocalisationService, localeService: LocaleService, notificationSendHelper: NotificationSendHelper, configServer: ConfigServer); + constructor(logger: ILogger, databaseServer: DatabaseServer, secureContainerHelper: SecureContainerHelper, randomUtil: RandomUtil, itemHelper: ItemHelper, jsonUtil: JsonUtil, timeUtil: TimeUtil, saveServer: SaveServer, traderHelper: TraderHelper, dialogueHelper: DialogueHelper, handbookHelper: HandbookHelper, localisationService: LocalisationService, localeService: LocaleService, notificationSendHelper: NotificationSendHelper, configServer: ConfigServer); + /** + * Does player have insurance array + * @param sessionId Player id + * @returns True if exists + */ insuranceExists(sessionId: string): boolean; /** * Get all insured items by all traders for a profile @@ -78,7 +85,7 @@ export declare class InsuranceService { */ protected getInsuranceReturnTimestamp(pmcData: IPmcData, trader: ITraderBase): number; /** - * Store lost gear post-raid inside profile + * Store lost gear post-raid inside profile, ready for later code to pick it up and mail it * @param pmcData player profile to store gear in * @param offraidData post-raid request object * @param preRaidGear gear player wore prior to raid @@ -86,6 +93,21 @@ export declare class InsuranceService { * @param playerDied did the player die in raid */ storeLostGear(pmcData: IPmcData, offraidData: ISaveProgressRequestData, preRaidGear: Item[], sessionID: string, playerDied: boolean): void; + /** + * Take preraid item and update properties to ensure its ready to be given to player in insurance return mail + * @param pmcData Player profile + * @param insuredItem Insured items properties + * @param preRaidItem Insured item as it was pre-raid + * @param insuredItemFromClient Item data when player left raid (durability values) + * @returns Item object + */ + protected getInsuredItemDetails(pmcData: IPmcData, preRaidItem: Item, insuredItemFromClient: IInsuredItemsData): Item; + /** + * Reset slotId property to "hideout" when necessary (used to be in ) + * @param pmcData Players pmcData.Inventory.equipment value + * @param itemToReturn item we will send to player as insurance return + */ + protected updateSlotIdValue(playerBaseInventoryEquipmentId: string, itemToReturn: Item): void; /** * Create a hash table for an array of items, keyed by items _id * @param items Items to hash @@ -94,12 +116,17 @@ export declare class InsuranceService { protected createItemHashTable(items: Item[]): Record; /** * Add gear item to InsuredItems array in player profile - * @param pmcData profile to store item in - * @param insuredItem Item to store in profile - * @param actualItem item to store * @param sessionID Session id + * @param pmcData Player profile + * @param itemToReturnToPlayer item to store + * @param traderId Id of trader item was insured with */ - protected addGearToSend(pmcData: IPmcData, insuredItem: InsuredItem, actualItem: Item, sessionID: string): void; + protected addGearToSend(gear: { + sessionID: string; + pmcData: IPmcData; + itemToReturnToPlayer: Item; + traderId: string; + }): void; /** * Does insurance exist for a player and by trader * @param sessionId Player id (session id) diff --git a/TypeScript/17AsyncImporterWithDependency2/types/models/eft/common/tables/IBotBase.d.ts b/TypeScript/17AsyncImporterWithDependency2/types/models/eft/common/tables/IBotBase.d.ts index e5d1c30..69e7e00 100644 --- a/TypeScript/17AsyncImporterWithDependency2/types/models/eft/common/tables/IBotBase.d.ts +++ b/TypeScript/17AsyncImporterWithDependency2/types/models/eft/common/tables/IBotBase.d.ts @@ -267,6 +267,7 @@ export interface BackendCounter { value: number; } export interface InsuredItem { + /** Trader Id item was insured by */ tid: string; itemId: string; } diff --git a/TypeScript/17AsyncImporterWithDependency2/types/models/eft/common/tables/IItem.d.ts b/TypeScript/17AsyncImporterWithDependency2/types/models/eft/common/tables/IItem.d.ts index ce00ae9..09a239c 100644 --- a/TypeScript/17AsyncImporterWithDependency2/types/models/eft/common/tables/IItem.d.ts +++ b/TypeScript/17AsyncImporterWithDependency2/types/models/eft/common/tables/IItem.d.ts @@ -12,6 +12,7 @@ export interface Upd { Togglable?: Togglable; Map?: Map; Tag?: Tag; + /** SPT specific property, not made by BSG */ sptPresetId?: string; FaceShield?: FaceShield; StackObjectsCount?: number; diff --git a/TypeScript/17AsyncImporterWithDependency2/types/models/eft/inRaid/IInsuredItemsData.d.ts b/TypeScript/17AsyncImporterWithDependency2/types/models/eft/inRaid/IInsuredItemsData.d.ts new file mode 100644 index 0000000..c49fb79 --- /dev/null +++ b/TypeScript/17AsyncImporterWithDependency2/types/models/eft/inRaid/IInsuredItemsData.d.ts @@ -0,0 +1,6 @@ +export interface IInsuredItemsData { + id: string; + durability?: number; + maxDurability?: number; + hits?: number; +} diff --git a/TypeScript/17AsyncImporterWithDependency2/types/models/eft/inRaid/ISaveProgressRequestData.d.ts b/TypeScript/17AsyncImporterWithDependency2/types/models/eft/inRaid/ISaveProgressRequestData.d.ts index 0b6f091..fd77c32 100644 --- a/TypeScript/17AsyncImporterWithDependency2/types/models/eft/inRaid/ISaveProgressRequestData.d.ts +++ b/TypeScript/17AsyncImporterWithDependency2/types/models/eft/inRaid/ISaveProgressRequestData.d.ts @@ -1,9 +1,11 @@ import { PlayerRaidEndState } from "../../../models/enums/PlayerRaidEndState"; import { IPmcData } from "../common/IPmcData"; import { ISyncHealthRequestData } from "../health/ISyncHealthRequestData"; +import { IInsuredItemsData } from "./IInsuredItemsData"; export interface ISaveProgressRequestData { exit: PlayerRaidEndState; profile: IPmcData; isPlayerScav: boolean; health: ISyncHealthRequestData; + insurance: IInsuredItemsData[]; } diff --git a/TypeScript/17AsyncImporterWithDependency2/types/models/spt/config/IRagfairConfig.d.ts b/TypeScript/17AsyncImporterWithDependency2/types/models/spt/config/IRagfairConfig.d.ts index 87e0173..7c04857 100644 --- a/TypeScript/17AsyncImporterWithDependency2/types/models/spt/config/IRagfairConfig.d.ts +++ b/TypeScript/17AsyncImporterWithDependency2/types/models/spt/config/IRagfairConfig.d.ts @@ -71,13 +71,8 @@ export interface Dynamic { removeSeasonalItemsWhenNotInEvent: boolean; /** Flea blacklist settings */ blacklist: Blacklist; - /** Should prices over the multiplier be adjusted */ - unreasonableModPrices: IUnreasonableModPrices; -} -export interface IUnreasonableModPrices { - enabled: boolean; - handbookPriceOverMultiplier: number; - newPriceHandbookMultiplier: number; + /** Dict of price limits keyed by item type */ + unreasonableModPrices: Record; } export interface Barter { /** Should barter offers be generated */ @@ -121,3 +116,8 @@ export interface Blacklist { /** Should trader items that are blacklisted by bsg */ traderItems: boolean; } +export interface IUnreasonableModPrices { + enabled: boolean; + handbookPriceOverMultiplier: number; + newPriceHandbookMultiplier: number; +} diff --git a/TypeScript/17AsyncImporterWithDependency2/types/services/InsuranceService.d.ts b/TypeScript/17AsyncImporterWithDependency2/types/services/InsuranceService.d.ts index 1d30f6d..5354cc0 100644 --- a/TypeScript/17AsyncImporterWithDependency2/types/services/InsuranceService.d.ts +++ b/TypeScript/17AsyncImporterWithDependency2/types/services/InsuranceService.d.ts @@ -6,14 +6,15 @@ import { NotificationSendHelper } from "../helpers/NotificationSendHelper"; import { SecureContainerHelper } from "../helpers/SecureContainerHelper"; import { TraderHelper } from "../helpers/TraderHelper"; import { IPmcData } from "../models/eft/common/IPmcData"; -import { InsuredItem } from "../models/eft/common/tables/IBotBase"; import { Item } from "../models/eft/common/tables/IItem"; +import { IInsuredItemsData } from "../models/eft/inRaid/IInsuredItemsData"; import { ISaveProgressRequestData } from "../models/eft/inRaid/ISaveProgressRequestData"; import { IInsuranceConfig } from "../models/spt/config/IInsuranceConfig"; import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { LocaleService } from "./LocaleService"; @@ -24,6 +25,7 @@ export declare class InsuranceService { protected secureContainerHelper: SecureContainerHelper; protected randomUtil: RandomUtil; protected itemHelper: ItemHelper; + protected jsonUtil: JsonUtil; protected timeUtil: TimeUtil; protected saveServer: SaveServer; protected traderHelper: TraderHelper; @@ -35,7 +37,12 @@ export declare class InsuranceService { protected configServer: ConfigServer; protected insured: Record>; protected insuranceConfig: IInsuranceConfig; - constructor(logger: ILogger, databaseServer: DatabaseServer, secureContainerHelper: SecureContainerHelper, randomUtil: RandomUtil, itemHelper: ItemHelper, timeUtil: TimeUtil, saveServer: SaveServer, traderHelper: TraderHelper, dialogueHelper: DialogueHelper, handbookHelper: HandbookHelper, localisationService: LocalisationService, localeService: LocaleService, notificationSendHelper: NotificationSendHelper, configServer: ConfigServer); + constructor(logger: ILogger, databaseServer: DatabaseServer, secureContainerHelper: SecureContainerHelper, randomUtil: RandomUtil, itemHelper: ItemHelper, jsonUtil: JsonUtil, timeUtil: TimeUtil, saveServer: SaveServer, traderHelper: TraderHelper, dialogueHelper: DialogueHelper, handbookHelper: HandbookHelper, localisationService: LocalisationService, localeService: LocaleService, notificationSendHelper: NotificationSendHelper, configServer: ConfigServer); + /** + * Does player have insurance array + * @param sessionId Player id + * @returns True if exists + */ insuranceExists(sessionId: string): boolean; /** * Get all insured items by all traders for a profile @@ -78,7 +85,7 @@ export declare class InsuranceService { */ protected getInsuranceReturnTimestamp(pmcData: IPmcData, trader: ITraderBase): number; /** - * Store lost gear post-raid inside profile + * Store lost gear post-raid inside profile, ready for later code to pick it up and mail it * @param pmcData player profile to store gear in * @param offraidData post-raid request object * @param preRaidGear gear player wore prior to raid @@ -86,6 +93,21 @@ export declare class InsuranceService { * @param playerDied did the player die in raid */ storeLostGear(pmcData: IPmcData, offraidData: ISaveProgressRequestData, preRaidGear: Item[], sessionID: string, playerDied: boolean): void; + /** + * Take preraid item and update properties to ensure its ready to be given to player in insurance return mail + * @param pmcData Player profile + * @param insuredItem Insured items properties + * @param preRaidItem Insured item as it was pre-raid + * @param insuredItemFromClient Item data when player left raid (durability values) + * @returns Item object + */ + protected getInsuredItemDetails(pmcData: IPmcData, preRaidItem: Item, insuredItemFromClient: IInsuredItemsData): Item; + /** + * Reset slotId property to "hideout" when necessary (used to be in ) + * @param pmcData Players pmcData.Inventory.equipment value + * @param itemToReturn item we will send to player as insurance return + */ + protected updateSlotIdValue(playerBaseInventoryEquipmentId: string, itemToReturn: Item): void; /** * Create a hash table for an array of items, keyed by items _id * @param items Items to hash @@ -94,12 +116,17 @@ export declare class InsuranceService { protected createItemHashTable(items: Item[]): Record; /** * Add gear item to InsuredItems array in player profile - * @param pmcData profile to store item in - * @param insuredItem Item to store in profile - * @param actualItem item to store * @param sessionID Session id + * @param pmcData Player profile + * @param itemToReturnToPlayer item to store + * @param traderId Id of trader item was insured with */ - protected addGearToSend(pmcData: IPmcData, insuredItem: InsuredItem, actualItem: Item, sessionID: string): void; + protected addGearToSend(gear: { + sessionID: string; + pmcData: IPmcData; + itemToReturnToPlayer: Item; + traderId: string; + }): void; /** * Does insurance exist for a player and by trader * @param sessionId Player id (session id) diff --git a/TypeScript/18CustomItemService/types/models/eft/common/tables/IBotBase.d.ts b/TypeScript/18CustomItemService/types/models/eft/common/tables/IBotBase.d.ts index e5d1c30..69e7e00 100644 --- a/TypeScript/18CustomItemService/types/models/eft/common/tables/IBotBase.d.ts +++ b/TypeScript/18CustomItemService/types/models/eft/common/tables/IBotBase.d.ts @@ -267,6 +267,7 @@ export interface BackendCounter { value: number; } export interface InsuredItem { + /** Trader Id item was insured by */ tid: string; itemId: string; } diff --git a/TypeScript/18CustomItemService/types/models/eft/common/tables/IItem.d.ts b/TypeScript/18CustomItemService/types/models/eft/common/tables/IItem.d.ts index ce00ae9..09a239c 100644 --- a/TypeScript/18CustomItemService/types/models/eft/common/tables/IItem.d.ts +++ b/TypeScript/18CustomItemService/types/models/eft/common/tables/IItem.d.ts @@ -12,6 +12,7 @@ export interface Upd { Togglable?: Togglable; Map?: Map; Tag?: Tag; + /** SPT specific property, not made by BSG */ sptPresetId?: string; FaceShield?: FaceShield; StackObjectsCount?: number; diff --git a/TypeScript/18CustomItemService/types/models/eft/inRaid/IInsuredItemsData.d.ts b/TypeScript/18CustomItemService/types/models/eft/inRaid/IInsuredItemsData.d.ts new file mode 100644 index 0000000..c49fb79 --- /dev/null +++ b/TypeScript/18CustomItemService/types/models/eft/inRaid/IInsuredItemsData.d.ts @@ -0,0 +1,6 @@ +export interface IInsuredItemsData { + id: string; + durability?: number; + maxDurability?: number; + hits?: number; +} diff --git a/TypeScript/18CustomItemService/types/models/eft/inRaid/ISaveProgressRequestData.d.ts b/TypeScript/18CustomItemService/types/models/eft/inRaid/ISaveProgressRequestData.d.ts index 0b6f091..fd77c32 100644 --- a/TypeScript/18CustomItemService/types/models/eft/inRaid/ISaveProgressRequestData.d.ts +++ b/TypeScript/18CustomItemService/types/models/eft/inRaid/ISaveProgressRequestData.d.ts @@ -1,9 +1,11 @@ import { PlayerRaidEndState } from "../../../models/enums/PlayerRaidEndState"; import { IPmcData } from "../common/IPmcData"; import { ISyncHealthRequestData } from "../health/ISyncHealthRequestData"; +import { IInsuredItemsData } from "./IInsuredItemsData"; export interface ISaveProgressRequestData { exit: PlayerRaidEndState; profile: IPmcData; isPlayerScav: boolean; health: ISyncHealthRequestData; + insurance: IInsuredItemsData[]; } diff --git a/TypeScript/18CustomItemService/types/models/spt/config/IRagfairConfig.d.ts b/TypeScript/18CustomItemService/types/models/spt/config/IRagfairConfig.d.ts index 87e0173..7c04857 100644 --- a/TypeScript/18CustomItemService/types/models/spt/config/IRagfairConfig.d.ts +++ b/TypeScript/18CustomItemService/types/models/spt/config/IRagfairConfig.d.ts @@ -71,13 +71,8 @@ export interface Dynamic { removeSeasonalItemsWhenNotInEvent: boolean; /** Flea blacklist settings */ blacklist: Blacklist; - /** Should prices over the multiplier be adjusted */ - unreasonableModPrices: IUnreasonableModPrices; -} -export interface IUnreasonableModPrices { - enabled: boolean; - handbookPriceOverMultiplier: number; - newPriceHandbookMultiplier: number; + /** Dict of price limits keyed by item type */ + unreasonableModPrices: Record; } export interface Barter { /** Should barter offers be generated */ @@ -121,3 +116,8 @@ export interface Blacklist { /** Should trader items that are blacklisted by bsg */ traderItems: boolean; } +export interface IUnreasonableModPrices { + enabled: boolean; + handbookPriceOverMultiplier: number; + newPriceHandbookMultiplier: number; +} diff --git a/TypeScript/18CustomItemService/types/services/InsuranceService.d.ts b/TypeScript/18CustomItemService/types/services/InsuranceService.d.ts index 1d30f6d..5354cc0 100644 --- a/TypeScript/18CustomItemService/types/services/InsuranceService.d.ts +++ b/TypeScript/18CustomItemService/types/services/InsuranceService.d.ts @@ -6,14 +6,15 @@ import { NotificationSendHelper } from "../helpers/NotificationSendHelper"; import { SecureContainerHelper } from "../helpers/SecureContainerHelper"; import { TraderHelper } from "../helpers/TraderHelper"; import { IPmcData } from "../models/eft/common/IPmcData"; -import { InsuredItem } from "../models/eft/common/tables/IBotBase"; import { Item } from "../models/eft/common/tables/IItem"; +import { IInsuredItemsData } from "../models/eft/inRaid/IInsuredItemsData"; import { ISaveProgressRequestData } from "../models/eft/inRaid/ISaveProgressRequestData"; import { IInsuranceConfig } from "../models/spt/config/IInsuranceConfig"; import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { LocaleService } from "./LocaleService"; @@ -24,6 +25,7 @@ export declare class InsuranceService { protected secureContainerHelper: SecureContainerHelper; protected randomUtil: RandomUtil; protected itemHelper: ItemHelper; + protected jsonUtil: JsonUtil; protected timeUtil: TimeUtil; protected saveServer: SaveServer; protected traderHelper: TraderHelper; @@ -35,7 +37,12 @@ export declare class InsuranceService { protected configServer: ConfigServer; protected insured: Record>; protected insuranceConfig: IInsuranceConfig; - constructor(logger: ILogger, databaseServer: DatabaseServer, secureContainerHelper: SecureContainerHelper, randomUtil: RandomUtil, itemHelper: ItemHelper, timeUtil: TimeUtil, saveServer: SaveServer, traderHelper: TraderHelper, dialogueHelper: DialogueHelper, handbookHelper: HandbookHelper, localisationService: LocalisationService, localeService: LocaleService, notificationSendHelper: NotificationSendHelper, configServer: ConfigServer); + constructor(logger: ILogger, databaseServer: DatabaseServer, secureContainerHelper: SecureContainerHelper, randomUtil: RandomUtil, itemHelper: ItemHelper, jsonUtil: JsonUtil, timeUtil: TimeUtil, saveServer: SaveServer, traderHelper: TraderHelper, dialogueHelper: DialogueHelper, handbookHelper: HandbookHelper, localisationService: LocalisationService, localeService: LocaleService, notificationSendHelper: NotificationSendHelper, configServer: ConfigServer); + /** + * Does player have insurance array + * @param sessionId Player id + * @returns True if exists + */ insuranceExists(sessionId: string): boolean; /** * Get all insured items by all traders for a profile @@ -78,7 +85,7 @@ export declare class InsuranceService { */ protected getInsuranceReturnTimestamp(pmcData: IPmcData, trader: ITraderBase): number; /** - * Store lost gear post-raid inside profile + * Store lost gear post-raid inside profile, ready for later code to pick it up and mail it * @param pmcData player profile to store gear in * @param offraidData post-raid request object * @param preRaidGear gear player wore prior to raid @@ -86,6 +93,21 @@ export declare class InsuranceService { * @param playerDied did the player die in raid */ storeLostGear(pmcData: IPmcData, offraidData: ISaveProgressRequestData, preRaidGear: Item[], sessionID: string, playerDied: boolean): void; + /** + * Take preraid item and update properties to ensure its ready to be given to player in insurance return mail + * @param pmcData Player profile + * @param insuredItem Insured items properties + * @param preRaidItem Insured item as it was pre-raid + * @param insuredItemFromClient Item data when player left raid (durability values) + * @returns Item object + */ + protected getInsuredItemDetails(pmcData: IPmcData, preRaidItem: Item, insuredItemFromClient: IInsuredItemsData): Item; + /** + * Reset slotId property to "hideout" when necessary (used to be in ) + * @param pmcData Players pmcData.Inventory.equipment value + * @param itemToReturn item we will send to player as insurance return + */ + protected updateSlotIdValue(playerBaseInventoryEquipmentId: string, itemToReturn: Item): void; /** * Create a hash table for an array of items, keyed by items _id * @param items Items to hash @@ -94,12 +116,17 @@ export declare class InsuranceService { protected createItemHashTable(items: Item[]): Record; /** * Add gear item to InsuredItems array in player profile - * @param pmcData profile to store item in - * @param insuredItem Item to store in profile - * @param actualItem item to store * @param sessionID Session id + * @param pmcData Player profile + * @param itemToReturnToPlayer item to store + * @param traderId Id of trader item was insured with */ - protected addGearToSend(pmcData: IPmcData, insuredItem: InsuredItem, actualItem: Item, sessionID: string): void; + protected addGearToSend(gear: { + sessionID: string; + pmcData: IPmcData; + itemToReturnToPlayer: Item; + traderId: string; + }): void; /** * Does insurance exist for a player and by trader * @param sessionId Player id (session id) diff --git a/TypeScript/1LogToConsole/types/models/eft/common/tables/IBotBase.d.ts b/TypeScript/1LogToConsole/types/models/eft/common/tables/IBotBase.d.ts index e5d1c30..69e7e00 100644 --- a/TypeScript/1LogToConsole/types/models/eft/common/tables/IBotBase.d.ts +++ b/TypeScript/1LogToConsole/types/models/eft/common/tables/IBotBase.d.ts @@ -267,6 +267,7 @@ export interface BackendCounter { value: number; } export interface InsuredItem { + /** Trader Id item was insured by */ tid: string; itemId: string; } diff --git a/TypeScript/1LogToConsole/types/models/eft/common/tables/IItem.d.ts b/TypeScript/1LogToConsole/types/models/eft/common/tables/IItem.d.ts index ce00ae9..09a239c 100644 --- a/TypeScript/1LogToConsole/types/models/eft/common/tables/IItem.d.ts +++ b/TypeScript/1LogToConsole/types/models/eft/common/tables/IItem.d.ts @@ -12,6 +12,7 @@ export interface Upd { Togglable?: Togglable; Map?: Map; Tag?: Tag; + /** SPT specific property, not made by BSG */ sptPresetId?: string; FaceShield?: FaceShield; StackObjectsCount?: number; diff --git a/TypeScript/1LogToConsole/types/models/eft/inRaid/IInsuredItemsData.d.ts b/TypeScript/1LogToConsole/types/models/eft/inRaid/IInsuredItemsData.d.ts new file mode 100644 index 0000000..c49fb79 --- /dev/null +++ b/TypeScript/1LogToConsole/types/models/eft/inRaid/IInsuredItemsData.d.ts @@ -0,0 +1,6 @@ +export interface IInsuredItemsData { + id: string; + durability?: number; + maxDurability?: number; + hits?: number; +} diff --git a/TypeScript/1LogToConsole/types/models/eft/inRaid/ISaveProgressRequestData.d.ts b/TypeScript/1LogToConsole/types/models/eft/inRaid/ISaveProgressRequestData.d.ts index 0b6f091..fd77c32 100644 --- a/TypeScript/1LogToConsole/types/models/eft/inRaid/ISaveProgressRequestData.d.ts +++ b/TypeScript/1LogToConsole/types/models/eft/inRaid/ISaveProgressRequestData.d.ts @@ -1,9 +1,11 @@ import { PlayerRaidEndState } from "../../../models/enums/PlayerRaidEndState"; import { IPmcData } from "../common/IPmcData"; import { ISyncHealthRequestData } from "../health/ISyncHealthRequestData"; +import { IInsuredItemsData } from "./IInsuredItemsData"; export interface ISaveProgressRequestData { exit: PlayerRaidEndState; profile: IPmcData; isPlayerScav: boolean; health: ISyncHealthRequestData; + insurance: IInsuredItemsData[]; } diff --git a/TypeScript/1LogToConsole/types/models/spt/config/IRagfairConfig.d.ts b/TypeScript/1LogToConsole/types/models/spt/config/IRagfairConfig.d.ts index 87e0173..7c04857 100644 --- a/TypeScript/1LogToConsole/types/models/spt/config/IRagfairConfig.d.ts +++ b/TypeScript/1LogToConsole/types/models/spt/config/IRagfairConfig.d.ts @@ -71,13 +71,8 @@ export interface Dynamic { removeSeasonalItemsWhenNotInEvent: boolean; /** Flea blacklist settings */ blacklist: Blacklist; - /** Should prices over the multiplier be adjusted */ - unreasonableModPrices: IUnreasonableModPrices; -} -export interface IUnreasonableModPrices { - enabled: boolean; - handbookPriceOverMultiplier: number; - newPriceHandbookMultiplier: number; + /** Dict of price limits keyed by item type */ + unreasonableModPrices: Record; } export interface Barter { /** Should barter offers be generated */ @@ -121,3 +116,8 @@ export interface Blacklist { /** Should trader items that are blacklisted by bsg */ traderItems: boolean; } +export interface IUnreasonableModPrices { + enabled: boolean; + handbookPriceOverMultiplier: number; + newPriceHandbookMultiplier: number; +} diff --git a/TypeScript/1LogToConsole/types/services/InsuranceService.d.ts b/TypeScript/1LogToConsole/types/services/InsuranceService.d.ts index 1d30f6d..5354cc0 100644 --- a/TypeScript/1LogToConsole/types/services/InsuranceService.d.ts +++ b/TypeScript/1LogToConsole/types/services/InsuranceService.d.ts @@ -6,14 +6,15 @@ import { NotificationSendHelper } from "../helpers/NotificationSendHelper"; import { SecureContainerHelper } from "../helpers/SecureContainerHelper"; import { TraderHelper } from "../helpers/TraderHelper"; import { IPmcData } from "../models/eft/common/IPmcData"; -import { InsuredItem } from "../models/eft/common/tables/IBotBase"; import { Item } from "../models/eft/common/tables/IItem"; +import { IInsuredItemsData } from "../models/eft/inRaid/IInsuredItemsData"; import { ISaveProgressRequestData } from "../models/eft/inRaid/ISaveProgressRequestData"; import { IInsuranceConfig } from "../models/spt/config/IInsuranceConfig"; import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { LocaleService } from "./LocaleService"; @@ -24,6 +25,7 @@ export declare class InsuranceService { protected secureContainerHelper: SecureContainerHelper; protected randomUtil: RandomUtil; protected itemHelper: ItemHelper; + protected jsonUtil: JsonUtil; protected timeUtil: TimeUtil; protected saveServer: SaveServer; protected traderHelper: TraderHelper; @@ -35,7 +37,12 @@ export declare class InsuranceService { protected configServer: ConfigServer; protected insured: Record>; protected insuranceConfig: IInsuranceConfig; - constructor(logger: ILogger, databaseServer: DatabaseServer, secureContainerHelper: SecureContainerHelper, randomUtil: RandomUtil, itemHelper: ItemHelper, timeUtil: TimeUtil, saveServer: SaveServer, traderHelper: TraderHelper, dialogueHelper: DialogueHelper, handbookHelper: HandbookHelper, localisationService: LocalisationService, localeService: LocaleService, notificationSendHelper: NotificationSendHelper, configServer: ConfigServer); + constructor(logger: ILogger, databaseServer: DatabaseServer, secureContainerHelper: SecureContainerHelper, randomUtil: RandomUtil, itemHelper: ItemHelper, jsonUtil: JsonUtil, timeUtil: TimeUtil, saveServer: SaveServer, traderHelper: TraderHelper, dialogueHelper: DialogueHelper, handbookHelper: HandbookHelper, localisationService: LocalisationService, localeService: LocaleService, notificationSendHelper: NotificationSendHelper, configServer: ConfigServer); + /** + * Does player have insurance array + * @param sessionId Player id + * @returns True if exists + */ insuranceExists(sessionId: string): boolean; /** * Get all insured items by all traders for a profile @@ -78,7 +85,7 @@ export declare class InsuranceService { */ protected getInsuranceReturnTimestamp(pmcData: IPmcData, trader: ITraderBase): number; /** - * Store lost gear post-raid inside profile + * Store lost gear post-raid inside profile, ready for later code to pick it up and mail it * @param pmcData player profile to store gear in * @param offraidData post-raid request object * @param preRaidGear gear player wore prior to raid @@ -86,6 +93,21 @@ export declare class InsuranceService { * @param playerDied did the player die in raid */ storeLostGear(pmcData: IPmcData, offraidData: ISaveProgressRequestData, preRaidGear: Item[], sessionID: string, playerDied: boolean): void; + /** + * Take preraid item and update properties to ensure its ready to be given to player in insurance return mail + * @param pmcData Player profile + * @param insuredItem Insured items properties + * @param preRaidItem Insured item as it was pre-raid + * @param insuredItemFromClient Item data when player left raid (durability values) + * @returns Item object + */ + protected getInsuredItemDetails(pmcData: IPmcData, preRaidItem: Item, insuredItemFromClient: IInsuredItemsData): Item; + /** + * Reset slotId property to "hideout" when necessary (used to be in ) + * @param pmcData Players pmcData.Inventory.equipment value + * @param itemToReturn item we will send to player as insurance return + */ + protected updateSlotIdValue(playerBaseInventoryEquipmentId: string, itemToReturn: Item): void; /** * Create a hash table for an array of items, keyed by items _id * @param items Items to hash @@ -94,12 +116,17 @@ export declare class InsuranceService { protected createItemHashTable(items: Item[]): Record; /** * Add gear item to InsuredItems array in player profile - * @param pmcData profile to store item in - * @param insuredItem Item to store in profile - * @param actualItem item to store * @param sessionID Session id + * @param pmcData Player profile + * @param itemToReturnToPlayer item to store + * @param traderId Id of trader item was insured with */ - protected addGearToSend(pmcData: IPmcData, insuredItem: InsuredItem, actualItem: Item, sessionID: string): void; + protected addGearToSend(gear: { + sessionID: string; + pmcData: IPmcData; + itemToReturnToPlayer: Item; + traderId: string; + }): void; /** * Does insurance exist for a player and by trader * @param sessionId Player id (session id) diff --git a/TypeScript/2EditDatabase/types/models/eft/common/tables/IBotBase.d.ts b/TypeScript/2EditDatabase/types/models/eft/common/tables/IBotBase.d.ts index e5d1c30..69e7e00 100644 --- a/TypeScript/2EditDatabase/types/models/eft/common/tables/IBotBase.d.ts +++ b/TypeScript/2EditDatabase/types/models/eft/common/tables/IBotBase.d.ts @@ -267,6 +267,7 @@ export interface BackendCounter { value: number; } export interface InsuredItem { + /** Trader Id item was insured by */ tid: string; itemId: string; } diff --git a/TypeScript/2EditDatabase/types/models/eft/common/tables/IItem.d.ts b/TypeScript/2EditDatabase/types/models/eft/common/tables/IItem.d.ts index ce00ae9..09a239c 100644 --- a/TypeScript/2EditDatabase/types/models/eft/common/tables/IItem.d.ts +++ b/TypeScript/2EditDatabase/types/models/eft/common/tables/IItem.d.ts @@ -12,6 +12,7 @@ export interface Upd { Togglable?: Togglable; Map?: Map; Tag?: Tag; + /** SPT specific property, not made by BSG */ sptPresetId?: string; FaceShield?: FaceShield; StackObjectsCount?: number; diff --git a/TypeScript/2EditDatabase/types/models/eft/inRaid/IInsuredItemsData.d.ts b/TypeScript/2EditDatabase/types/models/eft/inRaid/IInsuredItemsData.d.ts new file mode 100644 index 0000000..c49fb79 --- /dev/null +++ b/TypeScript/2EditDatabase/types/models/eft/inRaid/IInsuredItemsData.d.ts @@ -0,0 +1,6 @@ +export interface IInsuredItemsData { + id: string; + durability?: number; + maxDurability?: number; + hits?: number; +} diff --git a/TypeScript/2EditDatabase/types/models/eft/inRaid/ISaveProgressRequestData.d.ts b/TypeScript/2EditDatabase/types/models/eft/inRaid/ISaveProgressRequestData.d.ts index 0b6f091..fd77c32 100644 --- a/TypeScript/2EditDatabase/types/models/eft/inRaid/ISaveProgressRequestData.d.ts +++ b/TypeScript/2EditDatabase/types/models/eft/inRaid/ISaveProgressRequestData.d.ts @@ -1,9 +1,11 @@ import { PlayerRaidEndState } from "../../../models/enums/PlayerRaidEndState"; import { IPmcData } from "../common/IPmcData"; import { ISyncHealthRequestData } from "../health/ISyncHealthRequestData"; +import { IInsuredItemsData } from "./IInsuredItemsData"; export interface ISaveProgressRequestData { exit: PlayerRaidEndState; profile: IPmcData; isPlayerScav: boolean; health: ISyncHealthRequestData; + insurance: IInsuredItemsData[]; } diff --git a/TypeScript/2EditDatabase/types/models/spt/config/IRagfairConfig.d.ts b/TypeScript/2EditDatabase/types/models/spt/config/IRagfairConfig.d.ts index 87e0173..7c04857 100644 --- a/TypeScript/2EditDatabase/types/models/spt/config/IRagfairConfig.d.ts +++ b/TypeScript/2EditDatabase/types/models/spt/config/IRagfairConfig.d.ts @@ -71,13 +71,8 @@ export interface Dynamic { removeSeasonalItemsWhenNotInEvent: boolean; /** Flea blacklist settings */ blacklist: Blacklist; - /** Should prices over the multiplier be adjusted */ - unreasonableModPrices: IUnreasonableModPrices; -} -export interface IUnreasonableModPrices { - enabled: boolean; - handbookPriceOverMultiplier: number; - newPriceHandbookMultiplier: number; + /** Dict of price limits keyed by item type */ + unreasonableModPrices: Record; } export interface Barter { /** Should barter offers be generated */ @@ -121,3 +116,8 @@ export interface Blacklist { /** Should trader items that are blacklisted by bsg */ traderItems: boolean; } +export interface IUnreasonableModPrices { + enabled: boolean; + handbookPriceOverMultiplier: number; + newPriceHandbookMultiplier: number; +} diff --git a/TypeScript/2EditDatabase/types/services/InsuranceService.d.ts b/TypeScript/2EditDatabase/types/services/InsuranceService.d.ts index 1d30f6d..5354cc0 100644 --- a/TypeScript/2EditDatabase/types/services/InsuranceService.d.ts +++ b/TypeScript/2EditDatabase/types/services/InsuranceService.d.ts @@ -6,14 +6,15 @@ import { NotificationSendHelper } from "../helpers/NotificationSendHelper"; import { SecureContainerHelper } from "../helpers/SecureContainerHelper"; import { TraderHelper } from "../helpers/TraderHelper"; import { IPmcData } from "../models/eft/common/IPmcData"; -import { InsuredItem } from "../models/eft/common/tables/IBotBase"; import { Item } from "../models/eft/common/tables/IItem"; +import { IInsuredItemsData } from "../models/eft/inRaid/IInsuredItemsData"; import { ISaveProgressRequestData } from "../models/eft/inRaid/ISaveProgressRequestData"; import { IInsuranceConfig } from "../models/spt/config/IInsuranceConfig"; import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { LocaleService } from "./LocaleService"; @@ -24,6 +25,7 @@ export declare class InsuranceService { protected secureContainerHelper: SecureContainerHelper; protected randomUtil: RandomUtil; protected itemHelper: ItemHelper; + protected jsonUtil: JsonUtil; protected timeUtil: TimeUtil; protected saveServer: SaveServer; protected traderHelper: TraderHelper; @@ -35,7 +37,12 @@ export declare class InsuranceService { protected configServer: ConfigServer; protected insured: Record>; protected insuranceConfig: IInsuranceConfig; - constructor(logger: ILogger, databaseServer: DatabaseServer, secureContainerHelper: SecureContainerHelper, randomUtil: RandomUtil, itemHelper: ItemHelper, timeUtil: TimeUtil, saveServer: SaveServer, traderHelper: TraderHelper, dialogueHelper: DialogueHelper, handbookHelper: HandbookHelper, localisationService: LocalisationService, localeService: LocaleService, notificationSendHelper: NotificationSendHelper, configServer: ConfigServer); + constructor(logger: ILogger, databaseServer: DatabaseServer, secureContainerHelper: SecureContainerHelper, randomUtil: RandomUtil, itemHelper: ItemHelper, jsonUtil: JsonUtil, timeUtil: TimeUtil, saveServer: SaveServer, traderHelper: TraderHelper, dialogueHelper: DialogueHelper, handbookHelper: HandbookHelper, localisationService: LocalisationService, localeService: LocaleService, notificationSendHelper: NotificationSendHelper, configServer: ConfigServer); + /** + * Does player have insurance array + * @param sessionId Player id + * @returns True if exists + */ insuranceExists(sessionId: string): boolean; /** * Get all insured items by all traders for a profile @@ -78,7 +85,7 @@ export declare class InsuranceService { */ protected getInsuranceReturnTimestamp(pmcData: IPmcData, trader: ITraderBase): number; /** - * Store lost gear post-raid inside profile + * Store lost gear post-raid inside profile, ready for later code to pick it up and mail it * @param pmcData player profile to store gear in * @param offraidData post-raid request object * @param preRaidGear gear player wore prior to raid @@ -86,6 +93,21 @@ export declare class InsuranceService { * @param playerDied did the player die in raid */ storeLostGear(pmcData: IPmcData, offraidData: ISaveProgressRequestData, preRaidGear: Item[], sessionID: string, playerDied: boolean): void; + /** + * Take preraid item and update properties to ensure its ready to be given to player in insurance return mail + * @param pmcData Player profile + * @param insuredItem Insured items properties + * @param preRaidItem Insured item as it was pre-raid + * @param insuredItemFromClient Item data when player left raid (durability values) + * @returns Item object + */ + protected getInsuredItemDetails(pmcData: IPmcData, preRaidItem: Item, insuredItemFromClient: IInsuredItemsData): Item; + /** + * Reset slotId property to "hideout" when necessary (used to be in ) + * @param pmcData Players pmcData.Inventory.equipment value + * @param itemToReturn item we will send to player as insurance return + */ + protected updateSlotIdValue(playerBaseInventoryEquipmentId: string, itemToReturn: Item): void; /** * Create a hash table for an array of items, keyed by items _id * @param items Items to hash @@ -94,12 +116,17 @@ export declare class InsuranceService { protected createItemHashTable(items: Item[]): Record; /** * Add gear item to InsuredItems array in player profile - * @param pmcData profile to store item in - * @param insuredItem Item to store in profile - * @param actualItem item to store * @param sessionID Session id + * @param pmcData Player profile + * @param itemToReturnToPlayer item to store + * @param traderId Id of trader item was insured with */ - protected addGearToSend(pmcData: IPmcData, insuredItem: InsuredItem, actualItem: Item, sessionID: string): void; + protected addGearToSend(gear: { + sessionID: string; + pmcData: IPmcData; + itemToReturnToPlayer: Item; + traderId: string; + }): void; /** * Does insurance exist for a player and by trader * @param sessionId Player id (session id) diff --git a/TypeScript/3GetSptConfigFile/types/models/eft/common/tables/IBotBase.d.ts b/TypeScript/3GetSptConfigFile/types/models/eft/common/tables/IBotBase.d.ts index e5d1c30..69e7e00 100644 --- a/TypeScript/3GetSptConfigFile/types/models/eft/common/tables/IBotBase.d.ts +++ b/TypeScript/3GetSptConfigFile/types/models/eft/common/tables/IBotBase.d.ts @@ -267,6 +267,7 @@ export interface BackendCounter { value: number; } export interface InsuredItem { + /** Trader Id item was insured by */ tid: string; itemId: string; } diff --git a/TypeScript/3GetSptConfigFile/types/models/eft/common/tables/IItem.d.ts b/TypeScript/3GetSptConfigFile/types/models/eft/common/tables/IItem.d.ts index ce00ae9..09a239c 100644 --- a/TypeScript/3GetSptConfigFile/types/models/eft/common/tables/IItem.d.ts +++ b/TypeScript/3GetSptConfigFile/types/models/eft/common/tables/IItem.d.ts @@ -12,6 +12,7 @@ export interface Upd { Togglable?: Togglable; Map?: Map; Tag?: Tag; + /** SPT specific property, not made by BSG */ sptPresetId?: string; FaceShield?: FaceShield; StackObjectsCount?: number; diff --git a/TypeScript/3GetSptConfigFile/types/models/eft/inRaid/IInsuredItemsData.d.ts b/TypeScript/3GetSptConfigFile/types/models/eft/inRaid/IInsuredItemsData.d.ts new file mode 100644 index 0000000..c49fb79 --- /dev/null +++ b/TypeScript/3GetSptConfigFile/types/models/eft/inRaid/IInsuredItemsData.d.ts @@ -0,0 +1,6 @@ +export interface IInsuredItemsData { + id: string; + durability?: number; + maxDurability?: number; + hits?: number; +} diff --git a/TypeScript/3GetSptConfigFile/types/models/eft/inRaid/ISaveProgressRequestData.d.ts b/TypeScript/3GetSptConfigFile/types/models/eft/inRaid/ISaveProgressRequestData.d.ts index 0b6f091..fd77c32 100644 --- a/TypeScript/3GetSptConfigFile/types/models/eft/inRaid/ISaveProgressRequestData.d.ts +++ b/TypeScript/3GetSptConfigFile/types/models/eft/inRaid/ISaveProgressRequestData.d.ts @@ -1,9 +1,11 @@ import { PlayerRaidEndState } from "../../../models/enums/PlayerRaidEndState"; import { IPmcData } from "../common/IPmcData"; import { ISyncHealthRequestData } from "../health/ISyncHealthRequestData"; +import { IInsuredItemsData } from "./IInsuredItemsData"; export interface ISaveProgressRequestData { exit: PlayerRaidEndState; profile: IPmcData; isPlayerScav: boolean; health: ISyncHealthRequestData; + insurance: IInsuredItemsData[]; } diff --git a/TypeScript/3GetSptConfigFile/types/models/spt/config/IRagfairConfig.d.ts b/TypeScript/3GetSptConfigFile/types/models/spt/config/IRagfairConfig.d.ts index 87e0173..7c04857 100644 --- a/TypeScript/3GetSptConfigFile/types/models/spt/config/IRagfairConfig.d.ts +++ b/TypeScript/3GetSptConfigFile/types/models/spt/config/IRagfairConfig.d.ts @@ -71,13 +71,8 @@ export interface Dynamic { removeSeasonalItemsWhenNotInEvent: boolean; /** Flea blacklist settings */ blacklist: Blacklist; - /** Should prices over the multiplier be adjusted */ - unreasonableModPrices: IUnreasonableModPrices; -} -export interface IUnreasonableModPrices { - enabled: boolean; - handbookPriceOverMultiplier: number; - newPriceHandbookMultiplier: number; + /** Dict of price limits keyed by item type */ + unreasonableModPrices: Record; } export interface Barter { /** Should barter offers be generated */ @@ -121,3 +116,8 @@ export interface Blacklist { /** Should trader items that are blacklisted by bsg */ traderItems: boolean; } +export interface IUnreasonableModPrices { + enabled: boolean; + handbookPriceOverMultiplier: number; + newPriceHandbookMultiplier: number; +} diff --git a/TypeScript/3GetSptConfigFile/types/services/InsuranceService.d.ts b/TypeScript/3GetSptConfigFile/types/services/InsuranceService.d.ts index 1d30f6d..5354cc0 100644 --- a/TypeScript/3GetSptConfigFile/types/services/InsuranceService.d.ts +++ b/TypeScript/3GetSptConfigFile/types/services/InsuranceService.d.ts @@ -6,14 +6,15 @@ import { NotificationSendHelper } from "../helpers/NotificationSendHelper"; import { SecureContainerHelper } from "../helpers/SecureContainerHelper"; import { TraderHelper } from "../helpers/TraderHelper"; import { IPmcData } from "../models/eft/common/IPmcData"; -import { InsuredItem } from "../models/eft/common/tables/IBotBase"; import { Item } from "../models/eft/common/tables/IItem"; +import { IInsuredItemsData } from "../models/eft/inRaid/IInsuredItemsData"; import { ISaveProgressRequestData } from "../models/eft/inRaid/ISaveProgressRequestData"; import { IInsuranceConfig } from "../models/spt/config/IInsuranceConfig"; import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { LocaleService } from "./LocaleService"; @@ -24,6 +25,7 @@ export declare class InsuranceService { protected secureContainerHelper: SecureContainerHelper; protected randomUtil: RandomUtil; protected itemHelper: ItemHelper; + protected jsonUtil: JsonUtil; protected timeUtil: TimeUtil; protected saveServer: SaveServer; protected traderHelper: TraderHelper; @@ -35,7 +37,12 @@ export declare class InsuranceService { protected configServer: ConfigServer; protected insured: Record>; protected insuranceConfig: IInsuranceConfig; - constructor(logger: ILogger, databaseServer: DatabaseServer, secureContainerHelper: SecureContainerHelper, randomUtil: RandomUtil, itemHelper: ItemHelper, timeUtil: TimeUtil, saveServer: SaveServer, traderHelper: TraderHelper, dialogueHelper: DialogueHelper, handbookHelper: HandbookHelper, localisationService: LocalisationService, localeService: LocaleService, notificationSendHelper: NotificationSendHelper, configServer: ConfigServer); + constructor(logger: ILogger, databaseServer: DatabaseServer, secureContainerHelper: SecureContainerHelper, randomUtil: RandomUtil, itemHelper: ItemHelper, jsonUtil: JsonUtil, timeUtil: TimeUtil, saveServer: SaveServer, traderHelper: TraderHelper, dialogueHelper: DialogueHelper, handbookHelper: HandbookHelper, localisationService: LocalisationService, localeService: LocaleService, notificationSendHelper: NotificationSendHelper, configServer: ConfigServer); + /** + * Does player have insurance array + * @param sessionId Player id + * @returns True if exists + */ insuranceExists(sessionId: string): boolean; /** * Get all insured items by all traders for a profile @@ -78,7 +85,7 @@ export declare class InsuranceService { */ protected getInsuranceReturnTimestamp(pmcData: IPmcData, trader: ITraderBase): number; /** - * Store lost gear post-raid inside profile + * Store lost gear post-raid inside profile, ready for later code to pick it up and mail it * @param pmcData player profile to store gear in * @param offraidData post-raid request object * @param preRaidGear gear player wore prior to raid @@ -86,6 +93,21 @@ export declare class InsuranceService { * @param playerDied did the player die in raid */ storeLostGear(pmcData: IPmcData, offraidData: ISaveProgressRequestData, preRaidGear: Item[], sessionID: string, playerDied: boolean): void; + /** + * Take preraid item and update properties to ensure its ready to be given to player in insurance return mail + * @param pmcData Player profile + * @param insuredItem Insured items properties + * @param preRaidItem Insured item as it was pre-raid + * @param insuredItemFromClient Item data when player left raid (durability values) + * @returns Item object + */ + protected getInsuredItemDetails(pmcData: IPmcData, preRaidItem: Item, insuredItemFromClient: IInsuredItemsData): Item; + /** + * Reset slotId property to "hideout" when necessary (used to be in ) + * @param pmcData Players pmcData.Inventory.equipment value + * @param itemToReturn item we will send to player as insurance return + */ + protected updateSlotIdValue(playerBaseInventoryEquipmentId: string, itemToReturn: Item): void; /** * Create a hash table for an array of items, keyed by items _id * @param items Items to hash @@ -94,12 +116,17 @@ export declare class InsuranceService { protected createItemHashTable(items: Item[]): Record; /** * Add gear item to InsuredItems array in player profile - * @param pmcData profile to store item in - * @param insuredItem Item to store in profile - * @param actualItem item to store * @param sessionID Session id + * @param pmcData Player profile + * @param itemToReturnToPlayer item to store + * @param traderId Id of trader item was insured with */ - protected addGearToSend(pmcData: IPmcData, insuredItem: InsuredItem, actualItem: Item, sessionID: string): void; + protected addGearToSend(gear: { + sessionID: string; + pmcData: IPmcData; + itemToReturnToPlayer: Item; + traderId: string; + }): void; /** * Does insurance exist for a player and by trader * @param sessionId Player id (session id) diff --git a/TypeScript/4UseACustomConfigFile/types/models/eft/common/tables/IBotBase.d.ts b/TypeScript/4UseACustomConfigFile/types/models/eft/common/tables/IBotBase.d.ts index e5d1c30..69e7e00 100644 --- a/TypeScript/4UseACustomConfigFile/types/models/eft/common/tables/IBotBase.d.ts +++ b/TypeScript/4UseACustomConfigFile/types/models/eft/common/tables/IBotBase.d.ts @@ -267,6 +267,7 @@ export interface BackendCounter { value: number; } export interface InsuredItem { + /** Trader Id item was insured by */ tid: string; itemId: string; } diff --git a/TypeScript/4UseACustomConfigFile/types/models/eft/common/tables/IItem.d.ts b/TypeScript/4UseACustomConfigFile/types/models/eft/common/tables/IItem.d.ts index ce00ae9..09a239c 100644 --- a/TypeScript/4UseACustomConfigFile/types/models/eft/common/tables/IItem.d.ts +++ b/TypeScript/4UseACustomConfigFile/types/models/eft/common/tables/IItem.d.ts @@ -12,6 +12,7 @@ export interface Upd { Togglable?: Togglable; Map?: Map; Tag?: Tag; + /** SPT specific property, not made by BSG */ sptPresetId?: string; FaceShield?: FaceShield; StackObjectsCount?: number; diff --git a/TypeScript/4UseACustomConfigFile/types/models/eft/inRaid/IInsuredItemsData.d.ts b/TypeScript/4UseACustomConfigFile/types/models/eft/inRaid/IInsuredItemsData.d.ts new file mode 100644 index 0000000..c49fb79 --- /dev/null +++ b/TypeScript/4UseACustomConfigFile/types/models/eft/inRaid/IInsuredItemsData.d.ts @@ -0,0 +1,6 @@ +export interface IInsuredItemsData { + id: string; + durability?: number; + maxDurability?: number; + hits?: number; +} diff --git a/TypeScript/4UseACustomConfigFile/types/models/eft/inRaid/ISaveProgressRequestData.d.ts b/TypeScript/4UseACustomConfigFile/types/models/eft/inRaid/ISaveProgressRequestData.d.ts index 0b6f091..fd77c32 100644 --- a/TypeScript/4UseACustomConfigFile/types/models/eft/inRaid/ISaveProgressRequestData.d.ts +++ b/TypeScript/4UseACustomConfigFile/types/models/eft/inRaid/ISaveProgressRequestData.d.ts @@ -1,9 +1,11 @@ import { PlayerRaidEndState } from "../../../models/enums/PlayerRaidEndState"; import { IPmcData } from "../common/IPmcData"; import { ISyncHealthRequestData } from "../health/ISyncHealthRequestData"; +import { IInsuredItemsData } from "./IInsuredItemsData"; export interface ISaveProgressRequestData { exit: PlayerRaidEndState; profile: IPmcData; isPlayerScav: boolean; health: ISyncHealthRequestData; + insurance: IInsuredItemsData[]; } diff --git a/TypeScript/4UseACustomConfigFile/types/models/spt/config/IRagfairConfig.d.ts b/TypeScript/4UseACustomConfigFile/types/models/spt/config/IRagfairConfig.d.ts index 87e0173..7c04857 100644 --- a/TypeScript/4UseACustomConfigFile/types/models/spt/config/IRagfairConfig.d.ts +++ b/TypeScript/4UseACustomConfigFile/types/models/spt/config/IRagfairConfig.d.ts @@ -71,13 +71,8 @@ export interface Dynamic { removeSeasonalItemsWhenNotInEvent: boolean; /** Flea blacklist settings */ blacklist: Blacklist; - /** Should prices over the multiplier be adjusted */ - unreasonableModPrices: IUnreasonableModPrices; -} -export interface IUnreasonableModPrices { - enabled: boolean; - handbookPriceOverMultiplier: number; - newPriceHandbookMultiplier: number; + /** Dict of price limits keyed by item type */ + unreasonableModPrices: Record; } export interface Barter { /** Should barter offers be generated */ @@ -121,3 +116,8 @@ export interface Blacklist { /** Should trader items that are blacklisted by bsg */ traderItems: boolean; } +export interface IUnreasonableModPrices { + enabled: boolean; + handbookPriceOverMultiplier: number; + newPriceHandbookMultiplier: number; +} diff --git a/TypeScript/4UseACustomConfigFile/types/services/InsuranceService.d.ts b/TypeScript/4UseACustomConfigFile/types/services/InsuranceService.d.ts index 1d30f6d..5354cc0 100644 --- a/TypeScript/4UseACustomConfigFile/types/services/InsuranceService.d.ts +++ b/TypeScript/4UseACustomConfigFile/types/services/InsuranceService.d.ts @@ -6,14 +6,15 @@ import { NotificationSendHelper } from "../helpers/NotificationSendHelper"; import { SecureContainerHelper } from "../helpers/SecureContainerHelper"; import { TraderHelper } from "../helpers/TraderHelper"; import { IPmcData } from "../models/eft/common/IPmcData"; -import { InsuredItem } from "../models/eft/common/tables/IBotBase"; import { Item } from "../models/eft/common/tables/IItem"; +import { IInsuredItemsData } from "../models/eft/inRaid/IInsuredItemsData"; import { ISaveProgressRequestData } from "../models/eft/inRaid/ISaveProgressRequestData"; import { IInsuranceConfig } from "../models/spt/config/IInsuranceConfig"; import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { LocaleService } from "./LocaleService"; @@ -24,6 +25,7 @@ export declare class InsuranceService { protected secureContainerHelper: SecureContainerHelper; protected randomUtil: RandomUtil; protected itemHelper: ItemHelper; + protected jsonUtil: JsonUtil; protected timeUtil: TimeUtil; protected saveServer: SaveServer; protected traderHelper: TraderHelper; @@ -35,7 +37,12 @@ export declare class InsuranceService { protected configServer: ConfigServer; protected insured: Record>; protected insuranceConfig: IInsuranceConfig; - constructor(logger: ILogger, databaseServer: DatabaseServer, secureContainerHelper: SecureContainerHelper, randomUtil: RandomUtil, itemHelper: ItemHelper, timeUtil: TimeUtil, saveServer: SaveServer, traderHelper: TraderHelper, dialogueHelper: DialogueHelper, handbookHelper: HandbookHelper, localisationService: LocalisationService, localeService: LocaleService, notificationSendHelper: NotificationSendHelper, configServer: ConfigServer); + constructor(logger: ILogger, databaseServer: DatabaseServer, secureContainerHelper: SecureContainerHelper, randomUtil: RandomUtil, itemHelper: ItemHelper, jsonUtil: JsonUtil, timeUtil: TimeUtil, saveServer: SaveServer, traderHelper: TraderHelper, dialogueHelper: DialogueHelper, handbookHelper: HandbookHelper, localisationService: LocalisationService, localeService: LocaleService, notificationSendHelper: NotificationSendHelper, configServer: ConfigServer); + /** + * Does player have insurance array + * @param sessionId Player id + * @returns True if exists + */ insuranceExists(sessionId: string): boolean; /** * Get all insured items by all traders for a profile @@ -78,7 +85,7 @@ export declare class InsuranceService { */ protected getInsuranceReturnTimestamp(pmcData: IPmcData, trader: ITraderBase): number; /** - * Store lost gear post-raid inside profile + * Store lost gear post-raid inside profile, ready for later code to pick it up and mail it * @param pmcData player profile to store gear in * @param offraidData post-raid request object * @param preRaidGear gear player wore prior to raid @@ -86,6 +93,21 @@ export declare class InsuranceService { * @param playerDied did the player die in raid */ storeLostGear(pmcData: IPmcData, offraidData: ISaveProgressRequestData, preRaidGear: Item[], sessionID: string, playerDied: boolean): void; + /** + * Take preraid item and update properties to ensure its ready to be given to player in insurance return mail + * @param pmcData Player profile + * @param insuredItem Insured items properties + * @param preRaidItem Insured item as it was pre-raid + * @param insuredItemFromClient Item data when player left raid (durability values) + * @returns Item object + */ + protected getInsuredItemDetails(pmcData: IPmcData, preRaidItem: Item, insuredItemFromClient: IInsuredItemsData): Item; + /** + * Reset slotId property to "hideout" when necessary (used to be in ) + * @param pmcData Players pmcData.Inventory.equipment value + * @param itemToReturn item we will send to player as insurance return + */ + protected updateSlotIdValue(playerBaseInventoryEquipmentId: string, itemToReturn: Item): void; /** * Create a hash table for an array of items, keyed by items _id * @param items Items to hash @@ -94,12 +116,17 @@ export declare class InsuranceService { protected createItemHashTable(items: Item[]): Record; /** * Add gear item to InsuredItems array in player profile - * @param pmcData profile to store item in - * @param insuredItem Item to store in profile - * @param actualItem item to store * @param sessionID Session id + * @param pmcData Player profile + * @param itemToReturnToPlayer item to store + * @param traderId Id of trader item was insured with */ - protected addGearToSend(pmcData: IPmcData, insuredItem: InsuredItem, actualItem: Item, sessionID: string): void; + protected addGearToSend(gear: { + sessionID: string; + pmcData: IPmcData; + itemToReturnToPlayer: Item; + traderId: string; + }): void; /** * Does insurance exist for a player and by trader * @param sessionId Player id (session id) diff --git a/TypeScript/5ReplaceMethod/types/models/eft/common/tables/IBotBase.d.ts b/TypeScript/5ReplaceMethod/types/models/eft/common/tables/IBotBase.d.ts index e5d1c30..69e7e00 100644 --- a/TypeScript/5ReplaceMethod/types/models/eft/common/tables/IBotBase.d.ts +++ b/TypeScript/5ReplaceMethod/types/models/eft/common/tables/IBotBase.d.ts @@ -267,6 +267,7 @@ export interface BackendCounter { value: number; } export interface InsuredItem { + /** Trader Id item was insured by */ tid: string; itemId: string; } diff --git a/TypeScript/5ReplaceMethod/types/models/eft/common/tables/IItem.d.ts b/TypeScript/5ReplaceMethod/types/models/eft/common/tables/IItem.d.ts index ce00ae9..09a239c 100644 --- a/TypeScript/5ReplaceMethod/types/models/eft/common/tables/IItem.d.ts +++ b/TypeScript/5ReplaceMethod/types/models/eft/common/tables/IItem.d.ts @@ -12,6 +12,7 @@ export interface Upd { Togglable?: Togglable; Map?: Map; Tag?: Tag; + /** SPT specific property, not made by BSG */ sptPresetId?: string; FaceShield?: FaceShield; StackObjectsCount?: number; diff --git a/TypeScript/5ReplaceMethod/types/models/eft/inRaid/IInsuredItemsData.d.ts b/TypeScript/5ReplaceMethod/types/models/eft/inRaid/IInsuredItemsData.d.ts new file mode 100644 index 0000000..c49fb79 --- /dev/null +++ b/TypeScript/5ReplaceMethod/types/models/eft/inRaid/IInsuredItemsData.d.ts @@ -0,0 +1,6 @@ +export interface IInsuredItemsData { + id: string; + durability?: number; + maxDurability?: number; + hits?: number; +} diff --git a/TypeScript/5ReplaceMethod/types/models/eft/inRaid/ISaveProgressRequestData.d.ts b/TypeScript/5ReplaceMethod/types/models/eft/inRaid/ISaveProgressRequestData.d.ts index 0b6f091..fd77c32 100644 --- a/TypeScript/5ReplaceMethod/types/models/eft/inRaid/ISaveProgressRequestData.d.ts +++ b/TypeScript/5ReplaceMethod/types/models/eft/inRaid/ISaveProgressRequestData.d.ts @@ -1,9 +1,11 @@ import { PlayerRaidEndState } from "../../../models/enums/PlayerRaidEndState"; import { IPmcData } from "../common/IPmcData"; import { ISyncHealthRequestData } from "../health/ISyncHealthRequestData"; +import { IInsuredItemsData } from "./IInsuredItemsData"; export interface ISaveProgressRequestData { exit: PlayerRaidEndState; profile: IPmcData; isPlayerScav: boolean; health: ISyncHealthRequestData; + insurance: IInsuredItemsData[]; } diff --git a/TypeScript/5ReplaceMethod/types/models/spt/config/IRagfairConfig.d.ts b/TypeScript/5ReplaceMethod/types/models/spt/config/IRagfairConfig.d.ts index 87e0173..7c04857 100644 --- a/TypeScript/5ReplaceMethod/types/models/spt/config/IRagfairConfig.d.ts +++ b/TypeScript/5ReplaceMethod/types/models/spt/config/IRagfairConfig.d.ts @@ -71,13 +71,8 @@ export interface Dynamic { removeSeasonalItemsWhenNotInEvent: boolean; /** Flea blacklist settings */ blacklist: Blacklist; - /** Should prices over the multiplier be adjusted */ - unreasonableModPrices: IUnreasonableModPrices; -} -export interface IUnreasonableModPrices { - enabled: boolean; - handbookPriceOverMultiplier: number; - newPriceHandbookMultiplier: number; + /** Dict of price limits keyed by item type */ + unreasonableModPrices: Record; } export interface Barter { /** Should barter offers be generated */ @@ -121,3 +116,8 @@ export interface Blacklist { /** Should trader items that are blacklisted by bsg */ traderItems: boolean; } +export interface IUnreasonableModPrices { + enabled: boolean; + handbookPriceOverMultiplier: number; + newPriceHandbookMultiplier: number; +} diff --git a/TypeScript/5ReplaceMethod/types/services/InsuranceService.d.ts b/TypeScript/5ReplaceMethod/types/services/InsuranceService.d.ts index 1d30f6d..5354cc0 100644 --- a/TypeScript/5ReplaceMethod/types/services/InsuranceService.d.ts +++ b/TypeScript/5ReplaceMethod/types/services/InsuranceService.d.ts @@ -6,14 +6,15 @@ import { NotificationSendHelper } from "../helpers/NotificationSendHelper"; import { SecureContainerHelper } from "../helpers/SecureContainerHelper"; import { TraderHelper } from "../helpers/TraderHelper"; import { IPmcData } from "../models/eft/common/IPmcData"; -import { InsuredItem } from "../models/eft/common/tables/IBotBase"; import { Item } from "../models/eft/common/tables/IItem"; +import { IInsuredItemsData } from "../models/eft/inRaid/IInsuredItemsData"; import { ISaveProgressRequestData } from "../models/eft/inRaid/ISaveProgressRequestData"; import { IInsuranceConfig } from "../models/spt/config/IInsuranceConfig"; import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { LocaleService } from "./LocaleService"; @@ -24,6 +25,7 @@ export declare class InsuranceService { protected secureContainerHelper: SecureContainerHelper; protected randomUtil: RandomUtil; protected itemHelper: ItemHelper; + protected jsonUtil: JsonUtil; protected timeUtil: TimeUtil; protected saveServer: SaveServer; protected traderHelper: TraderHelper; @@ -35,7 +37,12 @@ export declare class InsuranceService { protected configServer: ConfigServer; protected insured: Record>; protected insuranceConfig: IInsuranceConfig; - constructor(logger: ILogger, databaseServer: DatabaseServer, secureContainerHelper: SecureContainerHelper, randomUtil: RandomUtil, itemHelper: ItemHelper, timeUtil: TimeUtil, saveServer: SaveServer, traderHelper: TraderHelper, dialogueHelper: DialogueHelper, handbookHelper: HandbookHelper, localisationService: LocalisationService, localeService: LocaleService, notificationSendHelper: NotificationSendHelper, configServer: ConfigServer); + constructor(logger: ILogger, databaseServer: DatabaseServer, secureContainerHelper: SecureContainerHelper, randomUtil: RandomUtil, itemHelper: ItemHelper, jsonUtil: JsonUtil, timeUtil: TimeUtil, saveServer: SaveServer, traderHelper: TraderHelper, dialogueHelper: DialogueHelper, handbookHelper: HandbookHelper, localisationService: LocalisationService, localeService: LocaleService, notificationSendHelper: NotificationSendHelper, configServer: ConfigServer); + /** + * Does player have insurance array + * @param sessionId Player id + * @returns True if exists + */ insuranceExists(sessionId: string): boolean; /** * Get all insured items by all traders for a profile @@ -78,7 +85,7 @@ export declare class InsuranceService { */ protected getInsuranceReturnTimestamp(pmcData: IPmcData, trader: ITraderBase): number; /** - * Store lost gear post-raid inside profile + * Store lost gear post-raid inside profile, ready for later code to pick it up and mail it * @param pmcData player profile to store gear in * @param offraidData post-raid request object * @param preRaidGear gear player wore prior to raid @@ -86,6 +93,21 @@ export declare class InsuranceService { * @param playerDied did the player die in raid */ storeLostGear(pmcData: IPmcData, offraidData: ISaveProgressRequestData, preRaidGear: Item[], sessionID: string, playerDied: boolean): void; + /** + * Take preraid item and update properties to ensure its ready to be given to player in insurance return mail + * @param pmcData Player profile + * @param insuredItem Insured items properties + * @param preRaidItem Insured item as it was pre-raid + * @param insuredItemFromClient Item data when player left raid (durability values) + * @returns Item object + */ + protected getInsuredItemDetails(pmcData: IPmcData, preRaidItem: Item, insuredItemFromClient: IInsuredItemsData): Item; + /** + * Reset slotId property to "hideout" when necessary (used to be in ) + * @param pmcData Players pmcData.Inventory.equipment value + * @param itemToReturn item we will send to player as insurance return + */ + protected updateSlotIdValue(playerBaseInventoryEquipmentId: string, itemToReturn: Item): void; /** * Create a hash table for an array of items, keyed by items _id * @param items Items to hash @@ -94,12 +116,17 @@ export declare class InsuranceService { protected createItemHashTable(items: Item[]): Record; /** * Add gear item to InsuredItems array in player profile - * @param pmcData profile to store item in - * @param insuredItem Item to store in profile - * @param actualItem item to store * @param sessionID Session id + * @param pmcData Player profile + * @param itemToReturnToPlayer item to store + * @param traderId Id of trader item was insured with */ - protected addGearToSend(pmcData: IPmcData, insuredItem: InsuredItem, actualItem: Item, sessionID: string): void; + protected addGearToSend(gear: { + sessionID: string; + pmcData: IPmcData; + itemToReturnToPlayer: Item; + traderId: string; + }): void; /** * Does insurance exist for a player and by trader * @param sessionId Player id (session id) diff --git a/TypeScript/6ReferenceAnotherClass/types/models/eft/common/tables/IBotBase.d.ts b/TypeScript/6ReferenceAnotherClass/types/models/eft/common/tables/IBotBase.d.ts index e5d1c30..69e7e00 100644 --- a/TypeScript/6ReferenceAnotherClass/types/models/eft/common/tables/IBotBase.d.ts +++ b/TypeScript/6ReferenceAnotherClass/types/models/eft/common/tables/IBotBase.d.ts @@ -267,6 +267,7 @@ export interface BackendCounter { value: number; } export interface InsuredItem { + /** Trader Id item was insured by */ tid: string; itemId: string; } diff --git a/TypeScript/6ReferenceAnotherClass/types/models/eft/common/tables/IItem.d.ts b/TypeScript/6ReferenceAnotherClass/types/models/eft/common/tables/IItem.d.ts index ce00ae9..09a239c 100644 --- a/TypeScript/6ReferenceAnotherClass/types/models/eft/common/tables/IItem.d.ts +++ b/TypeScript/6ReferenceAnotherClass/types/models/eft/common/tables/IItem.d.ts @@ -12,6 +12,7 @@ export interface Upd { Togglable?: Togglable; Map?: Map; Tag?: Tag; + /** SPT specific property, not made by BSG */ sptPresetId?: string; FaceShield?: FaceShield; StackObjectsCount?: number; diff --git a/TypeScript/6ReferenceAnotherClass/types/models/eft/inRaid/IInsuredItemsData.d.ts b/TypeScript/6ReferenceAnotherClass/types/models/eft/inRaid/IInsuredItemsData.d.ts new file mode 100644 index 0000000..c49fb79 --- /dev/null +++ b/TypeScript/6ReferenceAnotherClass/types/models/eft/inRaid/IInsuredItemsData.d.ts @@ -0,0 +1,6 @@ +export interface IInsuredItemsData { + id: string; + durability?: number; + maxDurability?: number; + hits?: number; +} diff --git a/TypeScript/6ReferenceAnotherClass/types/models/eft/inRaid/ISaveProgressRequestData.d.ts b/TypeScript/6ReferenceAnotherClass/types/models/eft/inRaid/ISaveProgressRequestData.d.ts index 0b6f091..fd77c32 100644 --- a/TypeScript/6ReferenceAnotherClass/types/models/eft/inRaid/ISaveProgressRequestData.d.ts +++ b/TypeScript/6ReferenceAnotherClass/types/models/eft/inRaid/ISaveProgressRequestData.d.ts @@ -1,9 +1,11 @@ import { PlayerRaidEndState } from "../../../models/enums/PlayerRaidEndState"; import { IPmcData } from "../common/IPmcData"; import { ISyncHealthRequestData } from "../health/ISyncHealthRequestData"; +import { IInsuredItemsData } from "./IInsuredItemsData"; export interface ISaveProgressRequestData { exit: PlayerRaidEndState; profile: IPmcData; isPlayerScav: boolean; health: ISyncHealthRequestData; + insurance: IInsuredItemsData[]; } diff --git a/TypeScript/6ReferenceAnotherClass/types/models/spt/config/IRagfairConfig.d.ts b/TypeScript/6ReferenceAnotherClass/types/models/spt/config/IRagfairConfig.d.ts index 87e0173..7c04857 100644 --- a/TypeScript/6ReferenceAnotherClass/types/models/spt/config/IRagfairConfig.d.ts +++ b/TypeScript/6ReferenceAnotherClass/types/models/spt/config/IRagfairConfig.d.ts @@ -71,13 +71,8 @@ export interface Dynamic { removeSeasonalItemsWhenNotInEvent: boolean; /** Flea blacklist settings */ blacklist: Blacklist; - /** Should prices over the multiplier be adjusted */ - unreasonableModPrices: IUnreasonableModPrices; -} -export interface IUnreasonableModPrices { - enabled: boolean; - handbookPriceOverMultiplier: number; - newPriceHandbookMultiplier: number; + /** Dict of price limits keyed by item type */ + unreasonableModPrices: Record; } export interface Barter { /** Should barter offers be generated */ @@ -121,3 +116,8 @@ export interface Blacklist { /** Should trader items that are blacklisted by bsg */ traderItems: boolean; } +export interface IUnreasonableModPrices { + enabled: boolean; + handbookPriceOverMultiplier: number; + newPriceHandbookMultiplier: number; +} diff --git a/TypeScript/6ReferenceAnotherClass/types/services/InsuranceService.d.ts b/TypeScript/6ReferenceAnotherClass/types/services/InsuranceService.d.ts index 1d30f6d..5354cc0 100644 --- a/TypeScript/6ReferenceAnotherClass/types/services/InsuranceService.d.ts +++ b/TypeScript/6ReferenceAnotherClass/types/services/InsuranceService.d.ts @@ -6,14 +6,15 @@ import { NotificationSendHelper } from "../helpers/NotificationSendHelper"; import { SecureContainerHelper } from "../helpers/SecureContainerHelper"; import { TraderHelper } from "../helpers/TraderHelper"; import { IPmcData } from "../models/eft/common/IPmcData"; -import { InsuredItem } from "../models/eft/common/tables/IBotBase"; import { Item } from "../models/eft/common/tables/IItem"; +import { IInsuredItemsData } from "../models/eft/inRaid/IInsuredItemsData"; import { ISaveProgressRequestData } from "../models/eft/inRaid/ISaveProgressRequestData"; import { IInsuranceConfig } from "../models/spt/config/IInsuranceConfig"; import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { LocaleService } from "./LocaleService"; @@ -24,6 +25,7 @@ export declare class InsuranceService { protected secureContainerHelper: SecureContainerHelper; protected randomUtil: RandomUtil; protected itemHelper: ItemHelper; + protected jsonUtil: JsonUtil; protected timeUtil: TimeUtil; protected saveServer: SaveServer; protected traderHelper: TraderHelper; @@ -35,7 +37,12 @@ export declare class InsuranceService { protected configServer: ConfigServer; protected insured: Record>; protected insuranceConfig: IInsuranceConfig; - constructor(logger: ILogger, databaseServer: DatabaseServer, secureContainerHelper: SecureContainerHelper, randomUtil: RandomUtil, itemHelper: ItemHelper, timeUtil: TimeUtil, saveServer: SaveServer, traderHelper: TraderHelper, dialogueHelper: DialogueHelper, handbookHelper: HandbookHelper, localisationService: LocalisationService, localeService: LocaleService, notificationSendHelper: NotificationSendHelper, configServer: ConfigServer); + constructor(logger: ILogger, databaseServer: DatabaseServer, secureContainerHelper: SecureContainerHelper, randomUtil: RandomUtil, itemHelper: ItemHelper, jsonUtil: JsonUtil, timeUtil: TimeUtil, saveServer: SaveServer, traderHelper: TraderHelper, dialogueHelper: DialogueHelper, handbookHelper: HandbookHelper, localisationService: LocalisationService, localeService: LocaleService, notificationSendHelper: NotificationSendHelper, configServer: ConfigServer); + /** + * Does player have insurance array + * @param sessionId Player id + * @returns True if exists + */ insuranceExists(sessionId: string): boolean; /** * Get all insured items by all traders for a profile @@ -78,7 +85,7 @@ export declare class InsuranceService { */ protected getInsuranceReturnTimestamp(pmcData: IPmcData, trader: ITraderBase): number; /** - * Store lost gear post-raid inside profile + * Store lost gear post-raid inside profile, ready for later code to pick it up and mail it * @param pmcData player profile to store gear in * @param offraidData post-raid request object * @param preRaidGear gear player wore prior to raid @@ -86,6 +93,21 @@ export declare class InsuranceService { * @param playerDied did the player die in raid */ storeLostGear(pmcData: IPmcData, offraidData: ISaveProgressRequestData, preRaidGear: Item[], sessionID: string, playerDied: boolean): void; + /** + * Take preraid item and update properties to ensure its ready to be given to player in insurance return mail + * @param pmcData Player profile + * @param insuredItem Insured items properties + * @param preRaidItem Insured item as it was pre-raid + * @param insuredItemFromClient Item data when player left raid (durability values) + * @returns Item object + */ + protected getInsuredItemDetails(pmcData: IPmcData, preRaidItem: Item, insuredItemFromClient: IInsuredItemsData): Item; + /** + * Reset slotId property to "hideout" when necessary (used to be in ) + * @param pmcData Players pmcData.Inventory.equipment value + * @param itemToReturn item we will send to player as insurance return + */ + protected updateSlotIdValue(playerBaseInventoryEquipmentId: string, itemToReturn: Item): void; /** * Create a hash table for an array of items, keyed by items _id * @param items Items to hash @@ -94,12 +116,17 @@ export declare class InsuranceService { protected createItemHashTable(items: Item[]): Record; /** * Add gear item to InsuredItems array in player profile - * @param pmcData profile to store item in - * @param insuredItem Item to store in profile - * @param actualItem item to store * @param sessionID Session id + * @param pmcData Player profile + * @param itemToReturnToPlayer item to store + * @param traderId Id of trader item was insured with */ - protected addGearToSend(pmcData: IPmcData, insuredItem: InsuredItem, actualItem: Item, sessionID: string): void; + protected addGearToSend(gear: { + sessionID: string; + pmcData: IPmcData; + itemToReturnToPlayer: Item; + traderId: string; + }): void; /** * Does insurance exist for a player and by trader * @param sessionId Player id (session id) diff --git a/TypeScript/7OnLoadHook/types/models/eft/common/tables/IBotBase.d.ts b/TypeScript/7OnLoadHook/types/models/eft/common/tables/IBotBase.d.ts index e5d1c30..69e7e00 100644 --- a/TypeScript/7OnLoadHook/types/models/eft/common/tables/IBotBase.d.ts +++ b/TypeScript/7OnLoadHook/types/models/eft/common/tables/IBotBase.d.ts @@ -267,6 +267,7 @@ export interface BackendCounter { value: number; } export interface InsuredItem { + /** Trader Id item was insured by */ tid: string; itemId: string; } diff --git a/TypeScript/7OnLoadHook/types/models/eft/common/tables/IItem.d.ts b/TypeScript/7OnLoadHook/types/models/eft/common/tables/IItem.d.ts index ce00ae9..09a239c 100644 --- a/TypeScript/7OnLoadHook/types/models/eft/common/tables/IItem.d.ts +++ b/TypeScript/7OnLoadHook/types/models/eft/common/tables/IItem.d.ts @@ -12,6 +12,7 @@ export interface Upd { Togglable?: Togglable; Map?: Map; Tag?: Tag; + /** SPT specific property, not made by BSG */ sptPresetId?: string; FaceShield?: FaceShield; StackObjectsCount?: number; diff --git a/TypeScript/7OnLoadHook/types/models/eft/inRaid/IInsuredItemsData.d.ts b/TypeScript/7OnLoadHook/types/models/eft/inRaid/IInsuredItemsData.d.ts new file mode 100644 index 0000000..c49fb79 --- /dev/null +++ b/TypeScript/7OnLoadHook/types/models/eft/inRaid/IInsuredItemsData.d.ts @@ -0,0 +1,6 @@ +export interface IInsuredItemsData { + id: string; + durability?: number; + maxDurability?: number; + hits?: number; +} diff --git a/TypeScript/7OnLoadHook/types/models/eft/inRaid/ISaveProgressRequestData.d.ts b/TypeScript/7OnLoadHook/types/models/eft/inRaid/ISaveProgressRequestData.d.ts index 0b6f091..fd77c32 100644 --- a/TypeScript/7OnLoadHook/types/models/eft/inRaid/ISaveProgressRequestData.d.ts +++ b/TypeScript/7OnLoadHook/types/models/eft/inRaid/ISaveProgressRequestData.d.ts @@ -1,9 +1,11 @@ import { PlayerRaidEndState } from "../../../models/enums/PlayerRaidEndState"; import { IPmcData } from "../common/IPmcData"; import { ISyncHealthRequestData } from "../health/ISyncHealthRequestData"; +import { IInsuredItemsData } from "./IInsuredItemsData"; export interface ISaveProgressRequestData { exit: PlayerRaidEndState; profile: IPmcData; isPlayerScav: boolean; health: ISyncHealthRequestData; + insurance: IInsuredItemsData[]; } diff --git a/TypeScript/7OnLoadHook/types/models/spt/config/IRagfairConfig.d.ts b/TypeScript/7OnLoadHook/types/models/spt/config/IRagfairConfig.d.ts index 87e0173..7c04857 100644 --- a/TypeScript/7OnLoadHook/types/models/spt/config/IRagfairConfig.d.ts +++ b/TypeScript/7OnLoadHook/types/models/spt/config/IRagfairConfig.d.ts @@ -71,13 +71,8 @@ export interface Dynamic { removeSeasonalItemsWhenNotInEvent: boolean; /** Flea blacklist settings */ blacklist: Blacklist; - /** Should prices over the multiplier be adjusted */ - unreasonableModPrices: IUnreasonableModPrices; -} -export interface IUnreasonableModPrices { - enabled: boolean; - handbookPriceOverMultiplier: number; - newPriceHandbookMultiplier: number; + /** Dict of price limits keyed by item type */ + unreasonableModPrices: Record; } export interface Barter { /** Should barter offers be generated */ @@ -121,3 +116,8 @@ export interface Blacklist { /** Should trader items that are blacklisted by bsg */ traderItems: boolean; } +export interface IUnreasonableModPrices { + enabled: boolean; + handbookPriceOverMultiplier: number; + newPriceHandbookMultiplier: number; +} diff --git a/TypeScript/7OnLoadHook/types/services/InsuranceService.d.ts b/TypeScript/7OnLoadHook/types/services/InsuranceService.d.ts index 1d30f6d..5354cc0 100644 --- a/TypeScript/7OnLoadHook/types/services/InsuranceService.d.ts +++ b/TypeScript/7OnLoadHook/types/services/InsuranceService.d.ts @@ -6,14 +6,15 @@ import { NotificationSendHelper } from "../helpers/NotificationSendHelper"; import { SecureContainerHelper } from "../helpers/SecureContainerHelper"; import { TraderHelper } from "../helpers/TraderHelper"; import { IPmcData } from "../models/eft/common/IPmcData"; -import { InsuredItem } from "../models/eft/common/tables/IBotBase"; import { Item } from "../models/eft/common/tables/IItem"; +import { IInsuredItemsData } from "../models/eft/inRaid/IInsuredItemsData"; import { ISaveProgressRequestData } from "../models/eft/inRaid/ISaveProgressRequestData"; import { IInsuranceConfig } from "../models/spt/config/IInsuranceConfig"; import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { LocaleService } from "./LocaleService"; @@ -24,6 +25,7 @@ export declare class InsuranceService { protected secureContainerHelper: SecureContainerHelper; protected randomUtil: RandomUtil; protected itemHelper: ItemHelper; + protected jsonUtil: JsonUtil; protected timeUtil: TimeUtil; protected saveServer: SaveServer; protected traderHelper: TraderHelper; @@ -35,7 +37,12 @@ export declare class InsuranceService { protected configServer: ConfigServer; protected insured: Record>; protected insuranceConfig: IInsuranceConfig; - constructor(logger: ILogger, databaseServer: DatabaseServer, secureContainerHelper: SecureContainerHelper, randomUtil: RandomUtil, itemHelper: ItemHelper, timeUtil: TimeUtil, saveServer: SaveServer, traderHelper: TraderHelper, dialogueHelper: DialogueHelper, handbookHelper: HandbookHelper, localisationService: LocalisationService, localeService: LocaleService, notificationSendHelper: NotificationSendHelper, configServer: ConfigServer); + constructor(logger: ILogger, databaseServer: DatabaseServer, secureContainerHelper: SecureContainerHelper, randomUtil: RandomUtil, itemHelper: ItemHelper, jsonUtil: JsonUtil, timeUtil: TimeUtil, saveServer: SaveServer, traderHelper: TraderHelper, dialogueHelper: DialogueHelper, handbookHelper: HandbookHelper, localisationService: LocalisationService, localeService: LocaleService, notificationSendHelper: NotificationSendHelper, configServer: ConfigServer); + /** + * Does player have insurance array + * @param sessionId Player id + * @returns True if exists + */ insuranceExists(sessionId: string): boolean; /** * Get all insured items by all traders for a profile @@ -78,7 +85,7 @@ export declare class InsuranceService { */ protected getInsuranceReturnTimestamp(pmcData: IPmcData, trader: ITraderBase): number; /** - * Store lost gear post-raid inside profile + * Store lost gear post-raid inside profile, ready for later code to pick it up and mail it * @param pmcData player profile to store gear in * @param offraidData post-raid request object * @param preRaidGear gear player wore prior to raid @@ -86,6 +93,21 @@ export declare class InsuranceService { * @param playerDied did the player die in raid */ storeLostGear(pmcData: IPmcData, offraidData: ISaveProgressRequestData, preRaidGear: Item[], sessionID: string, playerDied: boolean): void; + /** + * Take preraid item and update properties to ensure its ready to be given to player in insurance return mail + * @param pmcData Player profile + * @param insuredItem Insured items properties + * @param preRaidItem Insured item as it was pre-raid + * @param insuredItemFromClient Item data when player left raid (durability values) + * @returns Item object + */ + protected getInsuredItemDetails(pmcData: IPmcData, preRaidItem: Item, insuredItemFromClient: IInsuredItemsData): Item; + /** + * Reset slotId property to "hideout" when necessary (used to be in ) + * @param pmcData Players pmcData.Inventory.equipment value + * @param itemToReturn item we will send to player as insurance return + */ + protected updateSlotIdValue(playerBaseInventoryEquipmentId: string, itemToReturn: Item): void; /** * Create a hash table for an array of items, keyed by items _id * @param items Items to hash @@ -94,12 +116,17 @@ export declare class InsuranceService { protected createItemHashTable(items: Item[]): Record; /** * Add gear item to InsuredItems array in player profile - * @param pmcData profile to store item in - * @param insuredItem Item to store in profile - * @param actualItem item to store * @param sessionID Session id + * @param pmcData Player profile + * @param itemToReturnToPlayer item to store + * @param traderId Id of trader item was insured with */ - protected addGearToSend(pmcData: IPmcData, insuredItem: InsuredItem, actualItem: Item, sessionID: string): void; + protected addGearToSend(gear: { + sessionID: string; + pmcData: IPmcData; + itemToReturnToPlayer: Item; + traderId: string; + }): void; /** * Does insurance exist for a player and by trader * @param sessionId Player id (session id) diff --git a/TypeScript/8OnUpdateHook/types/models/eft/common/tables/IBotBase.d.ts b/TypeScript/8OnUpdateHook/types/models/eft/common/tables/IBotBase.d.ts index e5d1c30..69e7e00 100644 --- a/TypeScript/8OnUpdateHook/types/models/eft/common/tables/IBotBase.d.ts +++ b/TypeScript/8OnUpdateHook/types/models/eft/common/tables/IBotBase.d.ts @@ -267,6 +267,7 @@ export interface BackendCounter { value: number; } export interface InsuredItem { + /** Trader Id item was insured by */ tid: string; itemId: string; } diff --git a/TypeScript/8OnUpdateHook/types/models/eft/common/tables/IItem.d.ts b/TypeScript/8OnUpdateHook/types/models/eft/common/tables/IItem.d.ts index ce00ae9..09a239c 100644 --- a/TypeScript/8OnUpdateHook/types/models/eft/common/tables/IItem.d.ts +++ b/TypeScript/8OnUpdateHook/types/models/eft/common/tables/IItem.d.ts @@ -12,6 +12,7 @@ export interface Upd { Togglable?: Togglable; Map?: Map; Tag?: Tag; + /** SPT specific property, not made by BSG */ sptPresetId?: string; FaceShield?: FaceShield; StackObjectsCount?: number; diff --git a/TypeScript/8OnUpdateHook/types/models/eft/inRaid/IInsuredItemsData.d.ts b/TypeScript/8OnUpdateHook/types/models/eft/inRaid/IInsuredItemsData.d.ts new file mode 100644 index 0000000..c49fb79 --- /dev/null +++ b/TypeScript/8OnUpdateHook/types/models/eft/inRaid/IInsuredItemsData.d.ts @@ -0,0 +1,6 @@ +export interface IInsuredItemsData { + id: string; + durability?: number; + maxDurability?: number; + hits?: number; +} diff --git a/TypeScript/8OnUpdateHook/types/models/eft/inRaid/ISaveProgressRequestData.d.ts b/TypeScript/8OnUpdateHook/types/models/eft/inRaid/ISaveProgressRequestData.d.ts index 0b6f091..fd77c32 100644 --- a/TypeScript/8OnUpdateHook/types/models/eft/inRaid/ISaveProgressRequestData.d.ts +++ b/TypeScript/8OnUpdateHook/types/models/eft/inRaid/ISaveProgressRequestData.d.ts @@ -1,9 +1,11 @@ import { PlayerRaidEndState } from "../../../models/enums/PlayerRaidEndState"; import { IPmcData } from "../common/IPmcData"; import { ISyncHealthRequestData } from "../health/ISyncHealthRequestData"; +import { IInsuredItemsData } from "./IInsuredItemsData"; export interface ISaveProgressRequestData { exit: PlayerRaidEndState; profile: IPmcData; isPlayerScav: boolean; health: ISyncHealthRequestData; + insurance: IInsuredItemsData[]; } diff --git a/TypeScript/8OnUpdateHook/types/models/spt/config/IRagfairConfig.d.ts b/TypeScript/8OnUpdateHook/types/models/spt/config/IRagfairConfig.d.ts index 87e0173..7c04857 100644 --- a/TypeScript/8OnUpdateHook/types/models/spt/config/IRagfairConfig.d.ts +++ b/TypeScript/8OnUpdateHook/types/models/spt/config/IRagfairConfig.d.ts @@ -71,13 +71,8 @@ export interface Dynamic { removeSeasonalItemsWhenNotInEvent: boolean; /** Flea blacklist settings */ blacklist: Blacklist; - /** Should prices over the multiplier be adjusted */ - unreasonableModPrices: IUnreasonableModPrices; -} -export interface IUnreasonableModPrices { - enabled: boolean; - handbookPriceOverMultiplier: number; - newPriceHandbookMultiplier: number; + /** Dict of price limits keyed by item type */ + unreasonableModPrices: Record; } export interface Barter { /** Should barter offers be generated */ @@ -121,3 +116,8 @@ export interface Blacklist { /** Should trader items that are blacklisted by bsg */ traderItems: boolean; } +export interface IUnreasonableModPrices { + enabled: boolean; + handbookPriceOverMultiplier: number; + newPriceHandbookMultiplier: number; +} diff --git a/TypeScript/8OnUpdateHook/types/services/InsuranceService.d.ts b/TypeScript/8OnUpdateHook/types/services/InsuranceService.d.ts index 1d30f6d..5354cc0 100644 --- a/TypeScript/8OnUpdateHook/types/services/InsuranceService.d.ts +++ b/TypeScript/8OnUpdateHook/types/services/InsuranceService.d.ts @@ -6,14 +6,15 @@ import { NotificationSendHelper } from "../helpers/NotificationSendHelper"; import { SecureContainerHelper } from "../helpers/SecureContainerHelper"; import { TraderHelper } from "../helpers/TraderHelper"; import { IPmcData } from "../models/eft/common/IPmcData"; -import { InsuredItem } from "../models/eft/common/tables/IBotBase"; import { Item } from "../models/eft/common/tables/IItem"; +import { IInsuredItemsData } from "../models/eft/inRaid/IInsuredItemsData"; import { ISaveProgressRequestData } from "../models/eft/inRaid/ISaveProgressRequestData"; import { IInsuranceConfig } from "../models/spt/config/IInsuranceConfig"; import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { LocaleService } from "./LocaleService"; @@ -24,6 +25,7 @@ export declare class InsuranceService { protected secureContainerHelper: SecureContainerHelper; protected randomUtil: RandomUtil; protected itemHelper: ItemHelper; + protected jsonUtil: JsonUtil; protected timeUtil: TimeUtil; protected saveServer: SaveServer; protected traderHelper: TraderHelper; @@ -35,7 +37,12 @@ export declare class InsuranceService { protected configServer: ConfigServer; protected insured: Record>; protected insuranceConfig: IInsuranceConfig; - constructor(logger: ILogger, databaseServer: DatabaseServer, secureContainerHelper: SecureContainerHelper, randomUtil: RandomUtil, itemHelper: ItemHelper, timeUtil: TimeUtil, saveServer: SaveServer, traderHelper: TraderHelper, dialogueHelper: DialogueHelper, handbookHelper: HandbookHelper, localisationService: LocalisationService, localeService: LocaleService, notificationSendHelper: NotificationSendHelper, configServer: ConfigServer); + constructor(logger: ILogger, databaseServer: DatabaseServer, secureContainerHelper: SecureContainerHelper, randomUtil: RandomUtil, itemHelper: ItemHelper, jsonUtil: JsonUtil, timeUtil: TimeUtil, saveServer: SaveServer, traderHelper: TraderHelper, dialogueHelper: DialogueHelper, handbookHelper: HandbookHelper, localisationService: LocalisationService, localeService: LocaleService, notificationSendHelper: NotificationSendHelper, configServer: ConfigServer); + /** + * Does player have insurance array + * @param sessionId Player id + * @returns True if exists + */ insuranceExists(sessionId: string): boolean; /** * Get all insured items by all traders for a profile @@ -78,7 +85,7 @@ export declare class InsuranceService { */ protected getInsuranceReturnTimestamp(pmcData: IPmcData, trader: ITraderBase): number; /** - * Store lost gear post-raid inside profile + * Store lost gear post-raid inside profile, ready for later code to pick it up and mail it * @param pmcData player profile to store gear in * @param offraidData post-raid request object * @param preRaidGear gear player wore prior to raid @@ -86,6 +93,21 @@ export declare class InsuranceService { * @param playerDied did the player die in raid */ storeLostGear(pmcData: IPmcData, offraidData: ISaveProgressRequestData, preRaidGear: Item[], sessionID: string, playerDied: boolean): void; + /** + * Take preraid item and update properties to ensure its ready to be given to player in insurance return mail + * @param pmcData Player profile + * @param insuredItem Insured items properties + * @param preRaidItem Insured item as it was pre-raid + * @param insuredItemFromClient Item data when player left raid (durability values) + * @returns Item object + */ + protected getInsuredItemDetails(pmcData: IPmcData, preRaidItem: Item, insuredItemFromClient: IInsuredItemsData): Item; + /** + * Reset slotId property to "hideout" when necessary (used to be in ) + * @param pmcData Players pmcData.Inventory.equipment value + * @param itemToReturn item we will send to player as insurance return + */ + protected updateSlotIdValue(playerBaseInventoryEquipmentId: string, itemToReturn: Item): void; /** * Create a hash table for an array of items, keyed by items _id * @param items Items to hash @@ -94,12 +116,17 @@ export declare class InsuranceService { protected createItemHashTable(items: Item[]): Record; /** * Add gear item to InsuredItems array in player profile - * @param pmcData profile to store item in - * @param insuredItem Item to store in profile - * @param actualItem item to store * @param sessionID Session id + * @param pmcData Player profile + * @param itemToReturnToPlayer item to store + * @param traderId Id of trader item was insured with */ - protected addGearToSend(pmcData: IPmcData, insuredItem: InsuredItem, actualItem: Item, sessionID: string): void; + protected addGearToSend(gear: { + sessionID: string; + pmcData: IPmcData; + itemToReturnToPlayer: Item; + traderId: string; + }): void; /** * Does insurance exist for a player and by trader * @param sessionId Player id (session id) diff --git a/TypeScript/9RouterHooks/types/models/eft/common/tables/IBotBase.d.ts b/TypeScript/9RouterHooks/types/models/eft/common/tables/IBotBase.d.ts index e5d1c30..69e7e00 100644 --- a/TypeScript/9RouterHooks/types/models/eft/common/tables/IBotBase.d.ts +++ b/TypeScript/9RouterHooks/types/models/eft/common/tables/IBotBase.d.ts @@ -267,6 +267,7 @@ export interface BackendCounter { value: number; } export interface InsuredItem { + /** Trader Id item was insured by */ tid: string; itemId: string; } diff --git a/TypeScript/9RouterHooks/types/models/eft/common/tables/IItem.d.ts b/TypeScript/9RouterHooks/types/models/eft/common/tables/IItem.d.ts index ce00ae9..09a239c 100644 --- a/TypeScript/9RouterHooks/types/models/eft/common/tables/IItem.d.ts +++ b/TypeScript/9RouterHooks/types/models/eft/common/tables/IItem.d.ts @@ -12,6 +12,7 @@ export interface Upd { Togglable?: Togglable; Map?: Map; Tag?: Tag; + /** SPT specific property, not made by BSG */ sptPresetId?: string; FaceShield?: FaceShield; StackObjectsCount?: number; diff --git a/TypeScript/9RouterHooks/types/models/eft/inRaid/IInsuredItemsData.d.ts b/TypeScript/9RouterHooks/types/models/eft/inRaid/IInsuredItemsData.d.ts new file mode 100644 index 0000000..c49fb79 --- /dev/null +++ b/TypeScript/9RouterHooks/types/models/eft/inRaid/IInsuredItemsData.d.ts @@ -0,0 +1,6 @@ +export interface IInsuredItemsData { + id: string; + durability?: number; + maxDurability?: number; + hits?: number; +} diff --git a/TypeScript/9RouterHooks/types/models/eft/inRaid/ISaveProgressRequestData.d.ts b/TypeScript/9RouterHooks/types/models/eft/inRaid/ISaveProgressRequestData.d.ts index 0b6f091..fd77c32 100644 --- a/TypeScript/9RouterHooks/types/models/eft/inRaid/ISaveProgressRequestData.d.ts +++ b/TypeScript/9RouterHooks/types/models/eft/inRaid/ISaveProgressRequestData.d.ts @@ -1,9 +1,11 @@ import { PlayerRaidEndState } from "../../../models/enums/PlayerRaidEndState"; import { IPmcData } from "../common/IPmcData"; import { ISyncHealthRequestData } from "../health/ISyncHealthRequestData"; +import { IInsuredItemsData } from "./IInsuredItemsData"; export interface ISaveProgressRequestData { exit: PlayerRaidEndState; profile: IPmcData; isPlayerScav: boolean; health: ISyncHealthRequestData; + insurance: IInsuredItemsData[]; } diff --git a/TypeScript/9RouterHooks/types/models/spt/config/IRagfairConfig.d.ts b/TypeScript/9RouterHooks/types/models/spt/config/IRagfairConfig.d.ts index 87e0173..7c04857 100644 --- a/TypeScript/9RouterHooks/types/models/spt/config/IRagfairConfig.d.ts +++ b/TypeScript/9RouterHooks/types/models/spt/config/IRagfairConfig.d.ts @@ -71,13 +71,8 @@ export interface Dynamic { removeSeasonalItemsWhenNotInEvent: boolean; /** Flea blacklist settings */ blacklist: Blacklist; - /** Should prices over the multiplier be adjusted */ - unreasonableModPrices: IUnreasonableModPrices; -} -export interface IUnreasonableModPrices { - enabled: boolean; - handbookPriceOverMultiplier: number; - newPriceHandbookMultiplier: number; + /** Dict of price limits keyed by item type */ + unreasonableModPrices: Record; } export interface Barter { /** Should barter offers be generated */ @@ -121,3 +116,8 @@ export interface Blacklist { /** Should trader items that are blacklisted by bsg */ traderItems: boolean; } +export interface IUnreasonableModPrices { + enabled: boolean; + handbookPriceOverMultiplier: number; + newPriceHandbookMultiplier: number; +} diff --git a/TypeScript/9RouterHooks/types/services/InsuranceService.d.ts b/TypeScript/9RouterHooks/types/services/InsuranceService.d.ts index 1d30f6d..5354cc0 100644 --- a/TypeScript/9RouterHooks/types/services/InsuranceService.d.ts +++ b/TypeScript/9RouterHooks/types/services/InsuranceService.d.ts @@ -6,14 +6,15 @@ import { NotificationSendHelper } from "../helpers/NotificationSendHelper"; import { SecureContainerHelper } from "../helpers/SecureContainerHelper"; import { TraderHelper } from "../helpers/TraderHelper"; import { IPmcData } from "../models/eft/common/IPmcData"; -import { InsuredItem } from "../models/eft/common/tables/IBotBase"; import { Item } from "../models/eft/common/tables/IItem"; +import { IInsuredItemsData } from "../models/eft/inRaid/IInsuredItemsData"; import { ISaveProgressRequestData } from "../models/eft/inRaid/ISaveProgressRequestData"; import { IInsuranceConfig } from "../models/spt/config/IInsuranceConfig"; import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { SaveServer } from "../servers/SaveServer"; +import { JsonUtil } from "../utils/JsonUtil"; import { RandomUtil } from "../utils/RandomUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { LocaleService } from "./LocaleService"; @@ -24,6 +25,7 @@ export declare class InsuranceService { protected secureContainerHelper: SecureContainerHelper; protected randomUtil: RandomUtil; protected itemHelper: ItemHelper; + protected jsonUtil: JsonUtil; protected timeUtil: TimeUtil; protected saveServer: SaveServer; protected traderHelper: TraderHelper; @@ -35,7 +37,12 @@ export declare class InsuranceService { protected configServer: ConfigServer; protected insured: Record>; protected insuranceConfig: IInsuranceConfig; - constructor(logger: ILogger, databaseServer: DatabaseServer, secureContainerHelper: SecureContainerHelper, randomUtil: RandomUtil, itemHelper: ItemHelper, timeUtil: TimeUtil, saveServer: SaveServer, traderHelper: TraderHelper, dialogueHelper: DialogueHelper, handbookHelper: HandbookHelper, localisationService: LocalisationService, localeService: LocaleService, notificationSendHelper: NotificationSendHelper, configServer: ConfigServer); + constructor(logger: ILogger, databaseServer: DatabaseServer, secureContainerHelper: SecureContainerHelper, randomUtil: RandomUtil, itemHelper: ItemHelper, jsonUtil: JsonUtil, timeUtil: TimeUtil, saveServer: SaveServer, traderHelper: TraderHelper, dialogueHelper: DialogueHelper, handbookHelper: HandbookHelper, localisationService: LocalisationService, localeService: LocaleService, notificationSendHelper: NotificationSendHelper, configServer: ConfigServer); + /** + * Does player have insurance array + * @param sessionId Player id + * @returns True if exists + */ insuranceExists(sessionId: string): boolean; /** * Get all insured items by all traders for a profile @@ -78,7 +85,7 @@ export declare class InsuranceService { */ protected getInsuranceReturnTimestamp(pmcData: IPmcData, trader: ITraderBase): number; /** - * Store lost gear post-raid inside profile + * Store lost gear post-raid inside profile, ready for later code to pick it up and mail it * @param pmcData player profile to store gear in * @param offraidData post-raid request object * @param preRaidGear gear player wore prior to raid @@ -86,6 +93,21 @@ export declare class InsuranceService { * @param playerDied did the player die in raid */ storeLostGear(pmcData: IPmcData, offraidData: ISaveProgressRequestData, preRaidGear: Item[], sessionID: string, playerDied: boolean): void; + /** + * Take preraid item and update properties to ensure its ready to be given to player in insurance return mail + * @param pmcData Player profile + * @param insuredItem Insured items properties + * @param preRaidItem Insured item as it was pre-raid + * @param insuredItemFromClient Item data when player left raid (durability values) + * @returns Item object + */ + protected getInsuredItemDetails(pmcData: IPmcData, preRaidItem: Item, insuredItemFromClient: IInsuredItemsData): Item; + /** + * Reset slotId property to "hideout" when necessary (used to be in ) + * @param pmcData Players pmcData.Inventory.equipment value + * @param itemToReturn item we will send to player as insurance return + */ + protected updateSlotIdValue(playerBaseInventoryEquipmentId: string, itemToReturn: Item): void; /** * Create a hash table for an array of items, keyed by items _id * @param items Items to hash @@ -94,12 +116,17 @@ export declare class InsuranceService { protected createItemHashTable(items: Item[]): Record; /** * Add gear item to InsuredItems array in player profile - * @param pmcData profile to store item in - * @param insuredItem Item to store in profile - * @param actualItem item to store * @param sessionID Session id + * @param pmcData Player profile + * @param itemToReturnToPlayer item to store + * @param traderId Id of trader item was insured with */ - protected addGearToSend(pmcData: IPmcData, insuredItem: InsuredItem, actualItem: Item, sessionID: string): void; + protected addGearToSend(gear: { + sessionID: string; + pmcData: IPmcData; + itemToReturnToPlayer: Item; + traderId: string; + }): void; /** * Does insurance exist for a player and by trader * @param sessionId Player id (session id)