Replace conditionCounters
array with with TaskConditionCounters
dictionary
This commit is contained in:
parent
084cf38582
commit
c39e331423
@ -316,11 +316,12 @@ export class InraidController
|
||||
*/
|
||||
protected profileHasConditionCounters(profile: IPmcData): boolean
|
||||
{
|
||||
if (!profile.ConditionCounters?.Counters)
|
||||
if (!profile.TaskConditionCounters?.Counters)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return profile.ConditionCounters.Counters.length > 0;
|
||||
|
||||
return Object.keys(profile.TaskConditionCounters).length > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -364,16 +365,16 @@ export class InraidController
|
||||
}
|
||||
|
||||
// Loop over all scav counters and add into pmc profile
|
||||
for (const scavCounter of scavProfile.ConditionCounters.Counters)
|
||||
for (const scavCounter of Object.values(scavProfile.TaskConditionCounters))
|
||||
{
|
||||
this.logger.debug(
|
||||
`Processing counter: ${scavCounter.id} value:${scavCounter.value} quest:${scavCounter.qid}`,
|
||||
`Processing counter: ${scavCounter.id} value: ${scavCounter.value} quest: ${scavCounter.sourceId}`,
|
||||
);
|
||||
const counterInPmcProfile = pmcProfile.ConditionCounters.Counters.find((x) => x.id === scavCounter.id);
|
||||
const counterInPmcProfile = pmcProfile.TaskConditionCounters.Counters[scavCounter.id];
|
||||
if (!counterInPmcProfile)
|
||||
{
|
||||
// Doesn't exist yet, push it straight in
|
||||
pmcProfile.ConditionCounters.Counters.push(scavCounter);
|
||||
pmcProfile.TaskConditionCounters[scavCounter.id] = scavCounter;
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -384,7 +385,7 @@ export class InraidController
|
||||
// Only adjust counter value if its changed
|
||||
if (counterInPmcProfile.value !== scavCounter.value)
|
||||
{
|
||||
this.logger.debug(`OVERWRITING with values: ${scavCounter.value} quest: ${scavCounter.qid}`);
|
||||
this.logger.debug(`OVERWRITING with values: ${scavCounter.value} quest: ${scavCounter.sourceId}`);
|
||||
counterInPmcProfile.value = scavCounter.value;
|
||||
}
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ export class PlayerScavGenerator
|
||||
scavData.Info.Level = this.getScavLevel(existingScavData);
|
||||
scavData.Info.Experience = this.getScavExperience(existingScavData);
|
||||
scavData.Quests = existingScavData.Quests ?? [];
|
||||
scavData.ConditionCounters = existingScavData.ConditionCounters ?? { Counters: [] };
|
||||
scavData.TaskConditionCounters = existingScavData.TaskConditionCounters ?? { };
|
||||
scavData.Notes = existingScavData.Notes ?? { Notes: [] };
|
||||
scavData.WishList = existingScavData.WishList ?? [];
|
||||
|
||||
|
@ -150,7 +150,7 @@ export class InRaidHelper
|
||||
profileData.Skills = saveProgressRequest.profile.Skills;
|
||||
profileData.Stats.Eft = saveProgressRequest.profile.Stats.Eft;
|
||||
profileData.Encyclopedia = saveProgressRequest.profile.Encyclopedia;
|
||||
profileData.ConditionCounters = saveProgressRequest.profile.ConditionCounters;
|
||||
profileData.TaskConditionCounters = saveProgressRequest.profile.TaskConditionCounters;
|
||||
|
||||
this.validateTaskConditionCounters(saveProgressRequest, profileData);
|
||||
|
||||
@ -196,7 +196,7 @@ export class InRaidHelper
|
||||
const matchingPreRaidCounter = profileData.TaskConditionCounters[backendCounterKey];
|
||||
if (!matchingPreRaidCounter)
|
||||
{
|
||||
this.logger.error(`Backendcounter: ${backendCounterKey} cannot be found in pre-raid data`);
|
||||
this.logger.error(`TaskConditionCounters: ${backendCounterKey} cannot be found in pre-raid data`);
|
||||
|
||||
continue;
|
||||
}
|
||||
@ -204,7 +204,7 @@ export class InRaidHelper
|
||||
if (matchingPreRaidCounter.value !== postRaidValue)
|
||||
{
|
||||
this.logger.error(
|
||||
`Backendcounter: ${backendCounterKey} value is different post raid, old: ${matchingPreRaidCounter.value} new: ${postRaidValue}`
|
||||
`TaskConditionCounters: ${backendCounterKey} value is different post raid, old: ${matchingPreRaidCounter.value} new: ${postRaidValue}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,6 @@ export interface IBotBase
|
||||
Stats: Stats;
|
||||
Encyclopedia: Record<string, boolean>;
|
||||
TaskConditionCounters: Record<string, ITaskConditionCounter>;
|
||||
ConditionCounters: ConditionCounters;
|
||||
InsuredItems: InsuredItem[];
|
||||
Hideout: Hideout;
|
||||
Quests: IQuestStatus[];
|
||||
|
@ -465,9 +465,16 @@ export class ProfileFixerService
|
||||
*/
|
||||
public removeDanglingConditionCounters(pmcProfile: IPmcData): void
|
||||
{
|
||||
if (pmcProfile.ConditionCounters)
|
||||
if (pmcProfile.TaskConditionCounters)
|
||||
{
|
||||
pmcProfile.ConditionCounters.Counters = pmcProfile.ConditionCounters.Counters.filter((c) => c.qid !== null);
|
||||
for (const counterId in pmcProfile.TaskConditionCounters)
|
||||
{
|
||||
const counter = pmcProfile.TaskConditionCounters[counterId];
|
||||
if (!counter.sourceId)
|
||||
{
|
||||
delete pmcProfile.TaskConditionCounters[counterId];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user