merge encyclopedia dicts together post-raid
This commit is contained in:
parent
5f4dd8bb65
commit
1c63d85649
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user