From a4efdf9b4377b49cd2b0bed30b22714e6b9dd9fb Mon Sep 17 00:00:00 2001 From: Dev Date: Sat, 27 May 2023 22:39:32 +0100 Subject: [PATCH] Revert "Store the location insured gear was lost on + time it was lost against insured items in profile" This reverts commit 77508ace73cf4e315f244300e375b28632fcc0a0. --- project/src/controllers/InraidController.ts | 2 +- project/src/models/eft/profile/IAkiProfile.ts | 2 - project/src/services/InsuranceService.ts | 60 +++++-------------- 3 files changed, 17 insertions(+), 47 deletions(-) diff --git a/project/src/controllers/InraidController.ts b/project/src/controllers/InraidController.ts index 51859dc2..f34dae42 100644 --- a/project/src/controllers/InraidController.ts +++ b/project/src/controllers/InraidController.ts @@ -135,7 +135,7 @@ export class InraidController // Remove inventory if player died and send insurance items if (insuranceEnabled) { - this.insuranceService.storeLostGear(pmcData, offraidData, preRaidGear, sessionID, isDead, locationName); + this.insuranceService.storeLostGear(pmcData, offraidData, preRaidGear, sessionID, isDead); } else { diff --git a/project/src/models/eft/profile/IAkiProfile.ts b/project/src/models/eft/profile/IAkiProfile.ts index 6e5ffb0b..7156aa6d 100644 --- a/project/src/models/eft/profile/IAkiProfile.ts +++ b/project/src/models/eft/profile/IAkiProfile.ts @@ -230,8 +230,6 @@ export interface Insurance traderId: string messageContent: MessageContent items: Item[] - locationlost?: string - timeStampLost?: number } export interface MessageContent diff --git a/project/src/services/InsuranceService.ts b/project/src/services/InsuranceService.ts index 2939e477..66cadd4b 100644 --- a/project/src/services/InsuranceService.ts +++ b/project/src/services/InsuranceService.ts @@ -20,17 +20,10 @@ import { RandomUtil } from "../utils/RandomUtil"; import { TimeUtil } from "../utils/TimeUtil"; import { LocalisationService } from "./LocalisationService"; -export interface IInsuranceData -{ - locationLost?: string - timestampLost?: number - items: Item[] -} - @injectable() export class InsuranceService { - protected insured: Record> = {}; + protected insured: Record> = {}; protected insuranceConfig: IInsuranceConfig; constructor( @@ -60,14 +53,14 @@ export class InsuranceService return this.insured[sessionId][traderId] !== undefined; } - public getInsurance(sessionId: string): Record + public getInsurance(sessionId: string): Record { return this.insured[sessionId]; } public getInsuranceItems(sessionId: string, traderId: string): Item[] { - return this.insured[sessionId][traderId].items; + return this.insured[sessionId][traderId]; } public resetInsurance(sessionId: string): void @@ -77,22 +70,12 @@ export class InsuranceService public resetInsuranceTraderArray(sessionId: string, traderId: string): void { - this.insured[sessionId][traderId] = {items: []}; + this.insured[sessionId][traderId] = []; } - public addInsuranceItemToArray(sessionId: string, traderId: string, itemToAdd: Item): void + public addInsuranceItemToArray(sessionId: string, traderId: string, itemToAdd: any): void { - this.insured[sessionId][traderId].items.push(itemToAdd); - } - - public addLocationLostToInsuranceItem(sessionId: string, traderId: string, locationName: string): void - { - this.insured[sessionId][traderId].locationLost = locationName; - } - - public addTimestampLostToInsuranceItem(sessionId: string, traderId: string, timestampLost: number): void - { - this.insured[sessionId][traderId].timestampLost = timestampLost; + this.insured[sessionId][traderId].push(itemToAdd); } /** @@ -123,9 +106,7 @@ export class InsuranceService { const trader = this.traderHelper.getTrader(traderId, sessionID); const insuranceReturnTimestamp = this.getInsuranceReturnTimestamp(pmcData, trader); - const insurance = this.getInsurance(sessionID)[traderId]; const dialogueTemplates = this.databaseServer.getTables().traders[traderId].dialogue; - let messageContent = this.dialogueHelper.createMessageContext(this.randomUtil.getArrayValue(dialogueTemplates.insuranceStart), MessageType.NPC_TRADER, trader.insurance.max_storage_time); this.dialogueHelper.addDialogueMessage(traderId, messageContent, sessionID); @@ -150,9 +131,7 @@ export class InsuranceService scheduledTime: insuranceReturnTimestamp, traderId: traderId, messageContent: messageContent, - items: insurance.items, - locationlost: insurance.locationLost, - timeStampLost: insurance.timestampLost + items: this.getInsurance(sessionID)[traderId] }); } @@ -161,8 +140,8 @@ export class InsuranceService protected removeLocationProperty(sessionId: string, traderId: string): void { - const insuredItems = this.getInsurance(sessionId)[traderId].items; - for (const insuredItem of this.getInsurance(sessionId)[traderId].items) + const insuredItems = this.getInsurance(sessionId)[traderId]; + for (const insuredItem of this.getInsurance(sessionId)[traderId]) { const isParentHere = insuredItems.find(isParent => isParent._id === insuredItem.parentId); if (!isParentHere) @@ -205,9 +184,8 @@ export class InsuranceService * @param preRaidGear gear player wore prior to raid * @param sessionID Session id * @param playerDied did the player die in raid - * @param locationName Name of map gear was lost on */ - public storeLostGear(pmcData: IPmcData, offraidData: ISaveProgressRequestData, preRaidGear: Item[], sessionID: string, playerDied: boolean, locationName: string): void + public storeLostGear(pmcData: IPmcData, offraidData: ISaveProgressRequestData, preRaidGear: Item[], sessionID: string, playerDied: boolean): void { const preRaidGearHash = this.createItemHashTable(preRaidGear); const offRaidGearHash = this.createItemHashTable(offraidData.profile.Inventory.items); @@ -235,7 +213,7 @@ export class InsuranceService // Process all insured items lost in-raid for (const gear of equipmentToSendToPlayer) { - this.addGearToSend(gear, locationName); + this.addGearToSend(gear.pmcData, gear.insuredItem, gear.item, gear.sessionID); } } @@ -257,16 +235,13 @@ export class InsuranceService /** * Add gear item to InsuredItems array in player profile - * @param gear Details on what item to store (player profile/item to store in profile/item db details/session id) - * @param locationName Name of map gear was lost on + * @param pmcData profile to store item in + * @param insuredItem Item to store in profile + * @param actualItem item to store + * @param sessionID Session id */ - protected addGearToSend(gear: { pmcData: any; insuredItem: InsuredItem, item: Item, sessionID: string; }, locationName: string): void + protected addGearToSend(pmcData: IPmcData, insuredItem: InsuredItem, actualItem: Item, sessionID: string): void { - const pmcData = gear.pmcData; - const insuredItem = gear.insuredItem; - const actualItem = gear.item; - const sessionID = gear.sessionID; - // Skip items defined in config if (this.insuranceConfig.blacklistedEquipment.includes(actualItem.slotId)) { @@ -316,9 +291,6 @@ export class InsuranceService } this.addInsuranceItemToArray(sessionID, insuredItem.tid, actualItem); - - this.addLocationLostToInsuranceItem(sessionID, insuredItem.tid, locationName); - this.addTimestampLostToInsuranceItem(sessionID, insuredItem.tid, this.timeUtil.getTimestamp()); // Remove processed item from array pmcData.InsuredItems = pmcData.InsuredItems.filter((item) =>