Revert "Store the location insured gear was lost on + time it was lost against insured items in profile"

This reverts commit 77508ace73.
This commit is contained in:
Dev 2023-05-27 22:39:32 +01:00
parent 72239e4434
commit a4efdf9b43
3 changed files with 17 additions and 47 deletions

View File

@ -135,7 +135,7 @@ export class InraidController
// Remove inventory if player died and send insurance items // Remove inventory if player died and send insurance items
if (insuranceEnabled) if (insuranceEnabled)
{ {
this.insuranceService.storeLostGear(pmcData, offraidData, preRaidGear, sessionID, isDead, locationName); this.insuranceService.storeLostGear(pmcData, offraidData, preRaidGear, sessionID, isDead);
} }
else else
{ {

View File

@ -230,8 +230,6 @@ export interface Insurance
traderId: string traderId: string
messageContent: MessageContent messageContent: MessageContent
items: Item[] items: Item[]
locationlost?: string
timeStampLost?: number
} }
export interface MessageContent export interface MessageContent

View File

@ -20,17 +20,10 @@ import { RandomUtil } from "../utils/RandomUtil";
import { TimeUtil } from "../utils/TimeUtil"; import { TimeUtil } from "../utils/TimeUtil";
import { LocalisationService } from "./LocalisationService"; import { LocalisationService } from "./LocalisationService";
export interface IInsuranceData
{
locationLost?: string
timestampLost?: number
items: Item[]
}
@injectable() @injectable()
export class InsuranceService export class InsuranceService
{ {
protected insured: Record<string, Record<string, IInsuranceData>> = {}; protected insured: Record<string, Record<string, Item[]>> = {};
protected insuranceConfig: IInsuranceConfig; protected insuranceConfig: IInsuranceConfig;
constructor( constructor(
@ -60,14 +53,14 @@ export class InsuranceService
return this.insured[sessionId][traderId] !== undefined; return this.insured[sessionId][traderId] !== undefined;
} }
public getInsurance(sessionId: string): Record<string, IInsuranceData> public getInsurance(sessionId: string): Record<string, Item[]>
{ {
return this.insured[sessionId]; return this.insured[sessionId];
} }
public getInsuranceItems(sessionId: string, traderId: string): Item[] public getInsuranceItems(sessionId: string, traderId: string): Item[]
{ {
return this.insured[sessionId][traderId].items; return this.insured[sessionId][traderId];
} }
public resetInsurance(sessionId: string): void public resetInsurance(sessionId: string): void
@ -77,22 +70,12 @@ export class InsuranceService
public resetInsuranceTraderArray(sessionId: string, traderId: string): void 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); this.insured[sessionId][traderId].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;
} }
/** /**
@ -123,9 +106,7 @@ export class InsuranceService
{ {
const trader = this.traderHelper.getTrader(traderId, sessionID); const trader = this.traderHelper.getTrader(traderId, sessionID);
const insuranceReturnTimestamp = this.getInsuranceReturnTimestamp(pmcData, trader); const insuranceReturnTimestamp = this.getInsuranceReturnTimestamp(pmcData, trader);
const insurance = this.getInsurance(sessionID)[traderId];
const dialogueTemplates = this.databaseServer.getTables().traders[traderId].dialogue; 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); let messageContent = this.dialogueHelper.createMessageContext(this.randomUtil.getArrayValue(dialogueTemplates.insuranceStart), MessageType.NPC_TRADER, trader.insurance.max_storage_time);
this.dialogueHelper.addDialogueMessage(traderId, messageContent, sessionID); this.dialogueHelper.addDialogueMessage(traderId, messageContent, sessionID);
@ -150,9 +131,7 @@ export class InsuranceService
scheduledTime: insuranceReturnTimestamp, scheduledTime: insuranceReturnTimestamp,
traderId: traderId, traderId: traderId,
messageContent: messageContent, messageContent: messageContent,
items: insurance.items, items: this.getInsurance(sessionID)[traderId]
locationlost: insurance.locationLost,
timeStampLost: insurance.timestampLost
}); });
} }
@ -161,8 +140,8 @@ export class InsuranceService
protected removeLocationProperty(sessionId: string, traderId: string): void protected removeLocationProperty(sessionId: string, traderId: string): void
{ {
const insuredItems = this.getInsurance(sessionId)[traderId].items; const insuredItems = this.getInsurance(sessionId)[traderId];
for (const insuredItem of this.getInsurance(sessionId)[traderId].items) for (const insuredItem of this.getInsurance(sessionId)[traderId])
{ {
const isParentHere = insuredItems.find(isParent => isParent._id === insuredItem.parentId); const isParentHere = insuredItems.find(isParent => isParent._id === insuredItem.parentId);
if (!isParentHere) if (!isParentHere)
@ -205,9 +184,8 @@ export class InsuranceService
* @param preRaidGear gear player wore prior to raid * @param preRaidGear gear player wore prior to raid
* @param sessionID Session id * @param sessionID Session id
* @param playerDied did the player die in raid * @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 preRaidGearHash = this.createItemHashTable(preRaidGear);
const offRaidGearHash = this.createItemHashTable(offraidData.profile.Inventory.items); const offRaidGearHash = this.createItemHashTable(offraidData.profile.Inventory.items);
@ -235,7 +213,7 @@ export class InsuranceService
// Process all insured items lost in-raid // Process all insured items lost in-raid
for (const gear of equipmentToSendToPlayer) 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 * 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 pmcData profile to store item in
* @param locationName Name of map gear was lost on * @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 // Skip items defined in config
if (this.insuranceConfig.blacklistedEquipment.includes(actualItem.slotId)) if (this.insuranceConfig.blacklistedEquipment.includes(actualItem.slotId))
{ {
@ -316,9 +291,6 @@ export class InsuranceService
} }
this.addInsuranceItemToArray(sessionID, insuredItem.tid, actualItem); 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 // Remove processed item from array
pmcData.InsuredItems = pmcData.InsuredItems.filter((item) => pmcData.InsuredItems = pmcData.InsuredItems.filter((item) =>