Refactor insurance item checking code into 2 functions to allow checking if any items were lost before sending Insurance lost
mail
This commit is contained in:
parent
afce41d68b
commit
cfe470029f
@ -153,24 +153,20 @@ export class InraidController
|
||||
|
||||
this.healthHelper.saveVitality(serverPmcProfile, postRaidRequest.health, sessionID);
|
||||
|
||||
// Remove inventory if player died and send insurance items
|
||||
let insuredItemsLostCount = 0;
|
||||
if (mapHasInsuranceEnabled)
|
||||
{
|
||||
insuredItemsLostCount = this.insuranceService.storeLostGear(
|
||||
// Get array of insured items+child that were lost in raid
|
||||
const gearToStore = this.insuranceService.getGearLostInRaid(
|
||||
serverPmcProfile,
|
||||
postRaidRequest,
|
||||
preRaidGear,
|
||||
sessionID,
|
||||
isDead,
|
||||
);
|
||||
}
|
||||
else
|
||||
|
||||
if (gearToStore.length > 0)
|
||||
{
|
||||
if (insuredItemsLostCount > 0)
|
||||
{
|
||||
this.insuranceService.sendLostInsuranceMessage(sessionID, locationName);
|
||||
}
|
||||
mapHasInsuranceEnabled
|
||||
? this.insuranceService.storeGearLostInRaidToSendLater(gearToStore)
|
||||
: this.insuranceService.sendLostInsuranceMessage(sessionID, locationName);
|
||||
}
|
||||
|
||||
// Edge case - Handle usec players leaving lighthouse with Rogues angry at them
|
||||
|
@ -138,7 +138,7 @@ export class InsuranceService
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to player informing them gear was lost
|
||||
* Send a message to player informing them gear was completely lost
|
||||
* @param sessionId Session id
|
||||
* @param locationName name of map insurance was lost on
|
||||
*/
|
||||
@ -212,23 +212,22 @@ export class InsuranceService
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* Create an array of insured items lost in a raid player has just exited
|
||||
* @param pmcData Player profile
|
||||
* @param offraidData Post-raid data
|
||||
* @param preRaidGear Pre-raid data
|
||||
* @param sessionID Session id
|
||||
* @param playerDied did the player die in raid
|
||||
* @returns Count of insured items lost in raid
|
||||
* @param playerDied Did player die in raid
|
||||
* @returns Array of insured items lost in raid
|
||||
*/
|
||||
public storeLostGear(
|
||||
public getGearLostInRaid(
|
||||
pmcData: IPmcData,
|
||||
offraidData: ISaveProgressRequestData,
|
||||
preRaidGear: Item[],
|
||||
sessionID: string,
|
||||
playerDied: boolean,
|
||||
): number
|
||||
): any[]
|
||||
{
|
||||
let itemsLostCount = 0;
|
||||
const preRaidGearHash = this.createItemHashTable(preRaidGear);
|
||||
const offRaidGearHash = this.createItemHashTable(offraidData.profile.Inventory.items);
|
||||
|
||||
@ -275,14 +274,21 @@ export class InsuranceService
|
||||
}
|
||||
}
|
||||
|
||||
return equipmentToSendToPlayer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store lost gear post-raid inside profile, ready for later code to pick it up and mail it
|
||||
* @param equipmentToSendToPlayer Gear to store - generated by getGearLostInRaid()
|
||||
* TODO: add type to equipmentToSendToPlayer
|
||||
*/
|
||||
public storeGearLostInRaidToSendLater(equipmentToSendToPlayer: any[]): void
|
||||
{
|
||||
// Process all insured items lost in-raid
|
||||
for (const gear of equipmentToSendToPlayer)
|
||||
{
|
||||
this.addGearToSend(gear);
|
||||
itemsLostCount++;
|
||||
}
|
||||
|
||||
return itemsLostCount;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user