Save trader standing changes post-raid

This commit is contained in:
Dev 2023-07-30 11:30:31 +01:00
parent bb5a2f52cf
commit 6b8fadef40

View File

@ -1,7 +1,7 @@
import { inject, injectable } from "tsyringe";
import { IPmcData } from "../models/eft/common/IPmcData";
import { Quest, Victim } from "../models/eft/common/tables/IBotBase";
import { Quest, TraderInfo, Victim } from "../models/eft/common/tables/IBotBase";
import { Item } from "../models/eft/common/tables/IItem";
import { ISaveProgressRequestData } from "../models/eft/inRaid/ISaveProgressRequestData";
import { IFailQuestRequestData } from "../models/eft/quests/IFailQuestRequestData";
@ -145,6 +145,8 @@ export class InRaidHelper
// Transfer effects from request to profile
this.transferPostRaidLimbEffectsToProfile(saveProgressRequest, profileData);
this.applyTraderStandingAdjustments(profileData.TradersInfo, saveProgressRequest.profile.TradersInfo);
profileData.SurvivorClass = saveProgressRequest.profile.SurvivorClass;
// add experience points
@ -164,6 +166,7 @@ export class InRaidHelper
return profileData;
}
/**
* Look for quests not are now status = fail that were not failed pre-raid and run the failQuest() function
* @param sessionId Player id
@ -240,6 +243,25 @@ export class InRaidHelper
}
}
protected applyTraderStandingAdjustments(preRaid: Record<string, TraderInfo>, postRaid: Record<string, TraderInfo>): void
{
for (const traderId in postRaid)
{
const preRaidTrader = preRaid[traderId];
const postRaidTrader = postRaid[traderId];
if (!(preRaidTrader && postRaidTrader))
{
continue;
}
if (postRaidTrader.standing !== preRaidTrader.standing)
{
preRaidTrader.standing = postRaidTrader.standing;
}
}
}
/**
* Some maps have one-time-use keys (e.g. Labs
* Remove the relevant key from an inventory based on the post-raid request data passed in