Variable rename to aid in readability

This commit is contained in:
Dev 2023-10-11 10:47:54 +01:00
parent a19e322373
commit 2f2e7c2e32
3 changed files with 51 additions and 48 deletions

View File

@ -84,7 +84,7 @@ export class InraidController
*/ */
public savePostRaidProgress(offraidData: ISaveProgressRequestData, sessionID: string): void public savePostRaidProgress(offraidData: ISaveProgressRequestData, sessionID: string): void
{ {
this.logger.debug(`Raid outcome was: ${offraidData.exit}`); this.logger.debug(`Raid outcome: ${offraidData.exit}`);
if (!this.inraidConfig.save.loot) if (!this.inraidConfig.save.loot)
{ {
@ -103,37 +103,40 @@ export class InraidController
/** /**
* Handle updating player profile post-pmc raid * Handle updating player profile post-pmc raid
* @param sessionID session id * @param sessionID Session id
* @param offraidData post-raid data * @param postRaidRequest Post-raid data
*/ */
protected savePmcProgress(sessionID: string, offraidData: ISaveProgressRequestData): void protected savePmcProgress(sessionID: string, postRaidRequest: ISaveProgressRequestData): void
{ {
const preRaidProfile = this.saveServer.getProfile(sessionID); const serverProfile = this.saveServer.getProfile(sessionID);
const locationName = preRaidProfile.inraid.location.toLowerCase(); const locationName = serverProfile.inraid.location.toLowerCase();
const map: ILocationBase = this.databaseServer.getTables().locations[locationName].base; const map: ILocationBase = this.databaseServer.getTables().locations[locationName].base;
const mapHasInsuranceEnabled = map.Insurance; const mapHasInsuranceEnabled = map.Insurance;
let preRaidPmcData = preRaidProfile.characters.pmc;
const isDead = this.isPlayerDead(offraidData.exit);
const preRaidGear = this.inRaidHelper.getPlayerGear(preRaidPmcData.Inventory.items);
preRaidProfile.inraid.character = "pmc"; let serverPmcData = serverProfile.characters.pmc;
const isDead = this.isPlayerDead(postRaidRequest.exit);
const preRaidGear = this.inRaidHelper.getPlayerGear(serverPmcData.Inventory.items);
preRaidPmcData = this.inRaidHelper.updateProfileBaseStats(preRaidPmcData, offraidData, sessionID); serverProfile.inraid.character = "pmc";
serverPmcData = this.inRaidHelper.updateProfileBaseStats(serverPmcData, postRaidRequest, sessionID);
// Check for exit status // Check for exit status
this.markOrRemoveFoundInRaidItems(offraidData); this.markOrRemoveFoundInRaidItems(postRaidRequest);
offraidData.profile.Inventory.items = this.itemHelper.replaceIDs(offraidData.profile, offraidData.profile.Inventory.items, preRaidPmcData.InsuredItems, offraidData.profile.Inventory.fastPanel); postRaidRequest.profile.Inventory.items = this.itemHelper.replaceIDs(postRaidRequest.profile, postRaidRequest.profile.Inventory.items, serverPmcData.InsuredItems, postRaidRequest.profile.Inventory.fastPanel);
this.inRaidHelper.addUpdToMoneyFromRaid(offraidData.profile.Inventory.items); this.inRaidHelper.addUpdToMoneyFromRaid(postRaidRequest.profile.Inventory.items);
preRaidPmcData = this.inRaidHelper.setInventory(sessionID, preRaidPmcData, offraidData.profile); // Purge profile of equipment/container items
this.healthHelper.saveVitality(preRaidPmcData, offraidData.health, sessionID); serverPmcData = this.inRaidHelper.setInventory(sessionID, serverPmcData, postRaidRequest.profile);
this.healthHelper.saveVitality(serverPmcData, postRaidRequest.health, sessionID);
// Remove inventory if player died and send insurance items // Remove inventory if player died and send insurance items
if (mapHasInsuranceEnabled) if (mapHasInsuranceEnabled)
{ {
this.insuranceService.storeLostGear(preRaidPmcData, offraidData, preRaidGear, sessionID, isDead); this.insuranceService.storeLostGear(serverPmcData, postRaidRequest, preRaidGear, sessionID, isDead);
} }
else else
{ {
@ -141,10 +144,10 @@ export class InraidController
} }
// Edge case - Handle usec players leaving lighthouse with Rogues angry at them // Edge case - Handle usec players leaving lighthouse with Rogues angry at them
if (locationName === "lighthouse" && offraidData.profile.Info.Side.toLowerCase() === "usec") if (locationName === "lighthouse" && postRaidRequest.profile.Info.Side.toLowerCase() === "usec")
{ {
// Decrement counter if it exists, don't go below 0 // Decrement counter if it exists, don't go below 0
const remainingCounter = preRaidPmcData?.Stats.Eft.OverallCounters.Items.find(x => x.Key.includes("UsecRaidRemainKills")); const remainingCounter = serverPmcData?.Stats.Eft.OverallCounters.Items.find(x => x.Key.includes("UsecRaidRemainKills"));
if (remainingCounter?.Value > 0) if (remainingCounter?.Value > 0)
{ {
remainingCounter.Value --; remainingCounter.Value --;
@ -153,21 +156,21 @@ export class InraidController
if (isDead) if (isDead)
{ {
this.pmcChatResponseService.sendKillerResponse(sessionID, preRaidPmcData, offraidData.profile.Stats.Eft.Aggressor); this.pmcChatResponseService.sendKillerResponse(sessionID, serverPmcData, postRaidRequest.profile.Stats.Eft.Aggressor);
this.matchBotDetailsCacheService.clearCache(); this.matchBotDetailsCacheService.clearCache();
preRaidPmcData = this.performPostRaidActionsWhenDead(offraidData, preRaidPmcData, mapHasInsuranceEnabled, preRaidGear, sessionID); serverPmcData = this.performPostRaidActionsWhenDead(postRaidRequest, serverPmcData, mapHasInsuranceEnabled, preRaidGear, sessionID);
} }
const victims = offraidData.profile.Stats.Eft.Victims.filter(x => x.Role === "sptBear" || x.Role === "sptUsec"); const victims = postRaidRequest.profile.Stats.Eft.Victims.filter(x => ["sptbear", "sptusec"].includes(x.Role.toLowerCase()));
if (victims?.length > 0) if (victims?.length > 0)
{ {
this.pmcChatResponseService.sendVictimResponse(sessionID, victims, preRaidPmcData); this.pmcChatResponseService.sendVictimResponse(sessionID, victims, serverPmcData);
} }
if (mapHasInsuranceEnabled) if (mapHasInsuranceEnabled)
{ {
this.insuranceService.sendInsuredItems(preRaidPmcData, sessionID, map.Id); this.insuranceService.sendInsuredItems(serverPmcData, sessionID, map.Id);
} }
} }
@ -246,26 +249,26 @@ export class InraidController
/** /**
* Handle updating the profile post-pscav raid * Handle updating the profile post-pscav raid
* @param sessionID session id * @param sessionID Session id
* @param offraidData post-raid data of raid * @param postRaidRequest Post-raid data of raid
*/ */
protected savePlayerScavProgress(sessionID: string, offraidData: ISaveProgressRequestData): void protected savePlayerScavProgress(sessionID: string, postRaidRequest: ISaveProgressRequestData): void
{ {
const pmcData = this.profileHelper.getPmcProfile(sessionID); const pmcData = this.profileHelper.getPmcProfile(sessionID);
let scavData = this.profileHelper.getScavProfile(sessionID); let scavData = this.profileHelper.getScavProfile(sessionID);
const isDead = this.isPlayerDead(offraidData.exit); const isDead = this.isPlayerDead(postRaidRequest.exit);
this.saveServer.getProfile(sessionID).inraid.character = "scav"; this.saveServer.getProfile(sessionID).inraid.character = "scav";
scavData = this.inRaidHelper.updateProfileBaseStats(scavData, offraidData, sessionID); scavData = this.inRaidHelper.updateProfileBaseStats(scavData, postRaidRequest, sessionID);
// Check for exit status // Check for exit status
this.markOrRemoveFoundInRaidItems(offraidData); this.markOrRemoveFoundInRaidItems(postRaidRequest);
offraidData.profile.Inventory.items = this.itemHelper.replaceIDs(offraidData.profile, offraidData.profile.Inventory.items, pmcData.InsuredItems, offraidData.profile.Inventory.fastPanel); postRaidRequest.profile.Inventory.items = this.itemHelper.replaceIDs(postRaidRequest.profile, postRaidRequest.profile.Inventory.items, pmcData.InsuredItems, postRaidRequest.profile.Inventory.fastPanel);
this.inRaidHelper.addUpdToMoneyFromRaid(offraidData.profile.Inventory.items); this.inRaidHelper.addUpdToMoneyFromRaid(postRaidRequest.profile.Inventory.items);
this.handlePostRaidPlayerScavProcess(scavData, sessionID, offraidData, pmcData, isDead); this.handlePostRaidPlayerScavProcess(scavData, sessionID, postRaidRequest, pmcData, isDead);
} }
/** /**

View File

@ -172,10 +172,10 @@ export class MatchController
// Save time spent in raid // Save time spent in raid
pmcData.Stats.Eft.TotalInGameTime += info.raidSeconds; pmcData.Stats.Eft.TotalInGameTime += info.raidSeconds;
// clean up cached bots now raid is over // Clean up cached bots now raid is over
this.botGenerationCacheService.clearStoredBots(); this.botGenerationCacheService.clearStoredBots();
// clear bot loot cache // Clear bot loot cache
this.botLootCacheService.clearCache(); this.botLootCacheService.clearCache();
if (this.extractWasViaCar(extractName)) if (this.extractWasViaCar(extractName))

View File

@ -370,26 +370,26 @@ export class InRaidHelper
* Add new items found in raid to profile * Add new items found in raid to profile
* Store insurance items in profile * Store insurance items in profile
* @param sessionID Session id * @param sessionID Session id
* @param pmcData Profile to update * @param serverProfile Profile to update
* @param postRaidProfile Profile returned by client after a raid * @param postRaidProfile Profile returned by client after a raid
* @returns Updated profile * @returns Updated profile
*/ */
public setInventory(sessionID: string, pmcData: IPmcData, postRaidProfile: IPmcData): IPmcData public setInventory(sessionID: string, serverProfile: IPmcData, postRaidProfile: IPmcData): IPmcData
{ {
// store insurance (as removeItem removes insurance also) // Store insurance (as removeItem() removes insurance also)
const insured = this.jsonUtil.clone(pmcData.InsuredItems); const insured = this.jsonUtil.clone(serverProfile.InsuredItems);
// remove possible equipped items from before the raid // Remove possible equipped items from before the raid
this.inventoryHelper.removeItem(pmcData, pmcData.Inventory.equipment, sessionID); this.inventoryHelper.removeItem(serverProfile, serverProfile.Inventory.equipment, sessionID);
this.inventoryHelper.removeItem(pmcData, pmcData.Inventory.questRaidItems, sessionID); this.inventoryHelper.removeItem(serverProfile, serverProfile.Inventory.questRaidItems, sessionID);
this.inventoryHelper.removeItem(pmcData, pmcData.Inventory.sortingTable, sessionID); this.inventoryHelper.removeItem(serverProfile, serverProfile.Inventory.sortingTable, sessionID);
// add the new items // Add the new items
pmcData.Inventory.items = [...postRaidProfile.Inventory.items, ...pmcData.Inventory.items]; serverProfile.Inventory.items = [...postRaidProfile.Inventory.items, ...serverProfile.Inventory.items];
pmcData.Inventory.fastPanel = postRaidProfile.Inventory.fastPanel; serverProfile.Inventory.fastPanel = postRaidProfile.Inventory.fastPanel;
pmcData.InsuredItems = insured; serverProfile.InsuredItems = insured;
return pmcData; return serverProfile;
} }
/** /**