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);
|
this.healthHelper.saveVitality(serverPmcProfile, postRaidRequest.health, sessionID);
|
||||||
|
|
||||||
// Remove inventory if player died and send insurance items
|
// Get array of insured items+child that were lost in raid
|
||||||
let insuredItemsLostCount = 0;
|
const gearToStore = this.insuranceService.getGearLostInRaid(
|
||||||
if (mapHasInsuranceEnabled)
|
|
||||||
{
|
|
||||||
insuredItemsLostCount = this.insuranceService.storeLostGear(
|
|
||||||
serverPmcProfile,
|
serverPmcProfile,
|
||||||
postRaidRequest,
|
postRaidRequest,
|
||||||
preRaidGear,
|
preRaidGear,
|
||||||
sessionID,
|
sessionID,
|
||||||
isDead,
|
isDead,
|
||||||
);
|
);
|
||||||
}
|
|
||||||
else
|
if (gearToStore.length > 0)
|
||||||
{
|
{
|
||||||
if (insuredItemsLostCount > 0)
|
mapHasInsuranceEnabled
|
||||||
{
|
? this.insuranceService.storeGearLostInRaidToSendLater(gearToStore)
|
||||||
this.insuranceService.sendLostInsuranceMessage(sessionID, locationName);
|
: this.insuranceService.sendLostInsuranceMessage(sessionID, locationName);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Edge case - Handle usec players leaving lighthouse with Rogues angry at them
|
// 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 sessionId Session id
|
||||||
* @param locationName name of map insurance was lost on
|
* @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
|
* Create an array of insured items lost in a raid player has just exited
|
||||||
* @param pmcData player profile to store gear in
|
* @param pmcData Player profile
|
||||||
* @param offraidData post-raid request object
|
* @param offraidData Post-raid data
|
||||||
* @param preRaidGear gear player wore prior to raid
|
* @param preRaidGear Pre-raid data
|
||||||
* @param sessionID Session id
|
* @param sessionID Session id
|
||||||
* @param playerDied did the player die in raid
|
* @param playerDied Did player die in raid
|
||||||
* @returns Count of insured items lost in raid
|
* @returns Array of insured items lost in raid
|
||||||
*/
|
*/
|
||||||
public storeLostGear(
|
public getGearLostInRaid(
|
||||||
pmcData: IPmcData,
|
pmcData: IPmcData,
|
||||||
offraidData: ISaveProgressRequestData,
|
offraidData: ISaveProgressRequestData,
|
||||||
preRaidGear: Item[],
|
preRaidGear: Item[],
|
||||||
sessionID: string,
|
sessionID: string,
|
||||||
playerDied: boolean,
|
playerDied: boolean,
|
||||||
): number
|
): any[]
|
||||||
{
|
{
|
||||||
let itemsLostCount = 0;
|
|
||||||
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);
|
||||||
|
|
||||||
@ -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
|
// Process all insured items lost in-raid
|
||||||
for (const gear of equipmentToSendToPlayer)
|
for (const gear of equipmentToSendToPlayer)
|
||||||
{
|
{
|
||||||
this.addGearToSend(gear);
|
this.addGearToSend(gear);
|
||||||
itemsLostCount++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return itemsLostCount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user