merge encyclopedia dicts together post-raid

This commit is contained in:
Dev 2024-02-13 12:10:17 +00:00
parent 5f4dd8bb65
commit 1c63d85649

View File

@ -331,6 +331,8 @@ export class InraidController
this.inRaidHelper.updateProfileBaseStats(serverScavProfile, postRaidRequest, sessionID);
this.inRaidHelper.updateScavProfileDataPostRaid(serverScavProfile, postRaidRequest, sessionID);
this.mergePmcAndScavEncyclopedias(serverScavProfile.Encyclopedia, serverPmcProfile.Encyclopedia);
// Completing scav quests create ConditionCounters, these values need to be transported to the PMC profile
if (this.profileHasConditionCounters(serverScavProfile))
{
@ -355,6 +357,31 @@ export class InraidController
this.handlePostRaidPlayerScavProcess(serverScavProfile, sessionID, postRaidRequest, serverPmcProfile, isDead);
}
/**
* merge two dictionaries together
* Prioritise pair that has true as a value
* @param primary main dictionary
* @param secondary Secondary dictionary
*/
protected mergePmcAndScavEncyclopedias(primary: Record<string, boolean>, secondary: Record<string, boolean>): void
{
function extend(target: { [key: string]: boolean; }, source: Record<string, boolean>)
{
for (const key in source)
{
if (Object.hasOwn(source, key))
{
target[key] = source[key];
}
}
return target;
}
const merged = extend(extend({}, primary), secondary);
primary = merged;
secondary = merged;
}
/**
* Does provided profile contain any condition counters
* @param profile Profile to check for condition counters