Use correct dictionary for storing data in profile TaskConditionCounters
instead of BackendCounters
This commit is contained in:
parent
2dc172297f
commit
eca799d606
@ -3,7 +3,7 @@
|
|||||||
"descriptionLocaleKey": "launcher-profile-edgeofdarkness",
|
"descriptionLocaleKey": "launcher-profile-edgeofdarkness",
|
||||||
"bear": {
|
"bear": {
|
||||||
"character": {
|
"character": {
|
||||||
"BackendCounters": {},
|
"TaskConditionCounters": {},
|
||||||
"Bonuses": [{
|
"Bonuses": [{
|
||||||
"id": "64f5b9e5fa34f11b380756c0",
|
"id": "64f5b9e5fa34f11b380756c0",
|
||||||
"templateId": "566abbc34bdc2d92178b4576",
|
"templateId": "566abbc34bdc2d92178b4576",
|
||||||
@ -4290,7 +4290,7 @@
|
|||||||
},
|
},
|
||||||
"usec": {
|
"usec": {
|
||||||
"character": {
|
"character": {
|
||||||
"BackendCounters": {},
|
"TaskConditionCounters": {},
|
||||||
"Bonuses": [{
|
"Bonuses": [{
|
||||||
"id": "64f5b9e5fa34f11b380756c0",
|
"id": "64f5b9e5fa34f11b380756c0",
|
||||||
"templateId": "566abbc34bdc2d92178b4576",
|
"templateId": "566abbc34bdc2d92178b4576",
|
||||||
@ -8714,7 +8714,7 @@
|
|||||||
"descriptionLocaleKey": "launcher-profile_leftbehind",
|
"descriptionLocaleKey": "launcher-profile_leftbehind",
|
||||||
"bear": {
|
"bear": {
|
||||||
"character": {
|
"character": {
|
||||||
"BackendCounters": {},
|
"TaskConditionCounters": {},
|
||||||
"Bonuses": [{
|
"Bonuses": [{
|
||||||
"id": "64f5b9e5fa34f11b380756c0",
|
"id": "64f5b9e5fa34f11b380756c0",
|
||||||
"templateId": "566abbc34bdc2d92178b4576",
|
"templateId": "566abbc34bdc2d92178b4576",
|
||||||
@ -11892,7 +11892,7 @@
|
|||||||
},
|
},
|
||||||
"usec": {
|
"usec": {
|
||||||
"character": {
|
"character": {
|
||||||
"BackendCounters": {},
|
"TaskConditionCounters": {},
|
||||||
"Bonuses": [{
|
"Bonuses": [{
|
||||||
"id": "64f5b9e5fa34f11b380756c0",
|
"id": "64f5b9e5fa34f11b380756c0",
|
||||||
"templateId": "566abbc34bdc2d92178b4576",
|
"templateId": "566abbc34bdc2d92178b4576",
|
||||||
@ -15175,7 +15175,7 @@
|
|||||||
"descriptionLocaleKey": "launcher-profile_preparetoescape",
|
"descriptionLocaleKey": "launcher-profile_preparetoescape",
|
||||||
"bear": {
|
"bear": {
|
||||||
"character": {
|
"character": {
|
||||||
"BackendCounters": {},
|
"TaskConditionCounters": {},
|
||||||
"Bonuses": [{
|
"Bonuses": [{
|
||||||
"id": "64f5b9e5fa34f11b380756c0",
|
"id": "64f5b9e5fa34f11b380756c0",
|
||||||
"templateId": "566abbc34bdc2d92178b4576",
|
"templateId": "566abbc34bdc2d92178b4576",
|
||||||
@ -18811,7 +18811,7 @@
|
|||||||
},
|
},
|
||||||
"usec": {
|
"usec": {
|
||||||
"character": {
|
"character": {
|
||||||
"BackendCounters": {},
|
"TaskConditionCounters": {},
|
||||||
"Bonuses": [{
|
"Bonuses": [{
|
||||||
"id": "64f5b9e5fa34f11b380756c0",
|
"id": "64f5b9e5fa34f11b380756c0",
|
||||||
"templateId": "566abbc34bdc2d92178b4576",
|
"templateId": "566abbc34bdc2d92178b4576",
|
||||||
@ -22650,7 +22650,7 @@
|
|||||||
"descriptionLocaleKey": "launcher-profile_sptdeveloper",
|
"descriptionLocaleKey": "launcher-profile_sptdeveloper",
|
||||||
"bear": {
|
"bear": {
|
||||||
"character": {
|
"character": {
|
||||||
"BackendCounters": {},
|
"TaskConditionCounters": {},
|
||||||
"Bonuses": [{
|
"Bonuses": [{
|
||||||
"id": "64f5b9e5fa34f11b380756c0",
|
"id": "64f5b9e5fa34f11b380756c0",
|
||||||
"templateId": "566abbc34bdc2d92178b4576",
|
"templateId": "566abbc34bdc2d92178b4576",
|
||||||
@ -25682,7 +25682,7 @@
|
|||||||
},
|
},
|
||||||
"usec": {
|
"usec": {
|
||||||
"character": {
|
"character": {
|
||||||
"BackendCounters": {},
|
"TaskConditionCounters": {},
|
||||||
"Bonuses": [{
|
"Bonuses": [{
|
||||||
"id": "64f5b9e5fa34f11b380756c0",
|
"id": "64f5b9e5fa34f11b380756c0",
|
||||||
"templateId": "566abbc34bdc2d92178b4576",
|
"templateId": "566abbc34bdc2d92178b4576",
|
||||||
@ -28683,7 +28683,7 @@
|
|||||||
"descriptionLocaleKey": "launcher-profile_spteasystart",
|
"descriptionLocaleKey": "launcher-profile_spteasystart",
|
||||||
"bear": {
|
"bear": {
|
||||||
"character": {
|
"character": {
|
||||||
"BackendCounters": {},
|
"TaskConditionCounters": {},
|
||||||
"Bonuses": [{
|
"Bonuses": [{
|
||||||
"id": "64f5b9e5fa34f11b380756c0",
|
"id": "64f5b9e5fa34f11b380756c0",
|
||||||
"templateId": "566abbc34bdc2d92178b4576",
|
"templateId": "566abbc34bdc2d92178b4576",
|
||||||
@ -32024,7 +32024,7 @@
|
|||||||
},
|
},
|
||||||
"usec": {
|
"usec": {
|
||||||
"character": {
|
"character": {
|
||||||
"BackendCounters": {},
|
"TaskConditionCounters": {},
|
||||||
"Bonuses": [{
|
"Bonuses": [{
|
||||||
"id": "64f5b9e5fa34f11b380756c0",
|
"id": "64f5b9e5fa34f11b380756c0",
|
||||||
"templateId": "566abbc34bdc2d92178b4576",
|
"templateId": "566abbc34bdc2d92178b4576",
|
||||||
@ -35368,7 +35368,7 @@
|
|||||||
"descriptionLocaleKey": "launcher-profile_sptzerotohero",
|
"descriptionLocaleKey": "launcher-profile_sptzerotohero",
|
||||||
"bear": {
|
"bear": {
|
||||||
"character": {
|
"character": {
|
||||||
"BackendCounters": {},
|
"TaskConditionCounters": {},
|
||||||
"Bonuses": [{
|
"Bonuses": [{
|
||||||
"id": "64f5b9e5fa34f11b380756c0",
|
"id": "64f5b9e5fa34f11b380756c0",
|
||||||
"templateId": "566abbc34bdc2d92178b4576",
|
"templateId": "566abbc34bdc2d92178b4576",
|
||||||
@ -36268,7 +36268,7 @@
|
|||||||
},
|
},
|
||||||
"usec": {
|
"usec": {
|
||||||
"character": {
|
"character": {
|
||||||
"BackendCounters": {},
|
"TaskConditionCounters": {},
|
||||||
"Bonuses": [{
|
"Bonuses": [{
|
||||||
"id": "64f5b9e5fa34f11b380756c0",
|
"id": "64f5b9e5fa34f11b380756c0",
|
||||||
"templateId": "566abbc34bdc2d92178b4576",
|
"templateId": "566abbc34bdc2d92178b4576",
|
||||||
@ -37182,7 +37182,7 @@
|
|||||||
"descriptionLocaleKey": "launcher-profile_standard",
|
"descriptionLocaleKey": "launcher-profile_standard",
|
||||||
"bear": {
|
"bear": {
|
||||||
"character": {
|
"character": {
|
||||||
"BackendCounters": {},
|
"TaskConditionCounters": {},
|
||||||
"Bonuses": [{
|
"Bonuses": [{
|
||||||
"id": "64f5b9e5fa34f11b380756c0",
|
"id": "64f5b9e5fa34f11b380756c0",
|
||||||
"templateId": "566abbc34bdc2d92178b4576",
|
"templateId": "566abbc34bdc2d92178b4576",
|
||||||
@ -39801,7 +39801,7 @@
|
|||||||
},
|
},
|
||||||
"usec": {
|
"usec": {
|
||||||
"character": {
|
"character": {
|
||||||
"BackendCounters": {},
|
"TaskConditionCounters": {},
|
||||||
"Bonuses": [{
|
"Bonuses": [{
|
||||||
"id": "64f5b9e5fa34f11b380756c0",
|
"id": "64f5b9e5fa34f11b380756c0",
|
||||||
"templateId": "566abbc34bdc2d92178b4576",
|
"templateId": "566abbc34bdc2d92178b4576",
|
||||||
|
@ -47,7 +47,7 @@ import { TimeUtil } from "@spt-aki/utils/TimeUtil";
|
|||||||
@injectable()
|
@injectable()
|
||||||
export class HideoutController
|
export class HideoutController
|
||||||
{
|
{
|
||||||
protected static nameBackendCountersCrafting = "CounterHoursCrafting";
|
protected static nameTaskConditionCountersCrafting = "CounterHoursCrafting";
|
||||||
protected hideoutConfig: IHideoutConfig;
|
protected hideoutConfig: IHideoutConfig;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@ -770,15 +770,17 @@ export class HideoutController
|
|||||||
// Variables for managemnet of skill
|
// Variables for managemnet of skill
|
||||||
let craftingExpAmount = 0;
|
let craftingExpAmount = 0;
|
||||||
|
|
||||||
// ? move the logic of BackendCounters in new method?
|
// ? move the logic of TaskConditionCounters in new method?
|
||||||
let counterHoursCrafting = pmcData.BackendCounters[HideoutController.nameBackendCountersCrafting];
|
let counterHoursCrafting = pmcData.TaskConditionCounters[HideoutController.nameTaskConditionCountersCrafting];
|
||||||
if (!counterHoursCrafting)
|
if (!counterHoursCrafting)
|
||||||
{
|
{
|
||||||
pmcData.BackendCounters[HideoutController.nameBackendCountersCrafting] = {
|
pmcData.TaskConditionCounters[HideoutController.nameTaskConditionCountersCrafting] = {
|
||||||
id: HideoutController.nameBackendCountersCrafting,
|
id: recipe._id,
|
||||||
|
type: HideoutController.nameTaskConditionCountersCrafting,
|
||||||
|
sourceId: "CounterCrafting",
|
||||||
value: 0,
|
value: 0,
|
||||||
};
|
};
|
||||||
counterHoursCrafting = pmcData.BackendCounters[HideoutController.nameBackendCountersCrafting];
|
counterHoursCrafting = pmcData.TaskConditionCounters[HideoutController.nameTaskConditionCountersCrafting];
|
||||||
}
|
}
|
||||||
let hoursCrafting = counterHoursCrafting.value;
|
let hoursCrafting = counterHoursCrafting.value;
|
||||||
|
|
||||||
|
@ -772,8 +772,8 @@ export class QuestController
|
|||||||
isItemHandoverQuest = condition.conditionType === handoverQuestTypes[0];
|
isItemHandoverQuest = condition.conditionType === handoverQuestTypes[0];
|
||||||
handoverRequirements = condition;
|
handoverRequirements = condition;
|
||||||
|
|
||||||
const profileCounter = (handoverQuestRequest.conditionId in pmcData.BackendCounters)
|
const profileCounter = (handoverQuestRequest.conditionId in pmcData.TaskConditionCounters)
|
||||||
? pmcData.BackendCounters[handoverQuestRequest.conditionId].value
|
? pmcData.TaskConditionCounters[handoverQuestRequest.conditionId].value
|
||||||
: 0;
|
: 0;
|
||||||
handedInCount -= profileCounter;
|
handedInCount -= profileCounter;
|
||||||
|
|
||||||
@ -856,7 +856,7 @@ export class QuestController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.updateProfileBackendCounterValue(
|
this.updateProfileTaskConditionCounterValue(
|
||||||
pmcData,
|
pmcData,
|
||||||
handoverQuestRequest.conditionId,
|
handoverQuestRequest.conditionId,
|
||||||
handoverQuestRequest.qid,
|
handoverQuestRequest.qid,
|
||||||
@ -919,19 +919,24 @@ export class QuestController
|
|||||||
* @param questId quest id counter is associated with
|
* @param questId quest id counter is associated with
|
||||||
* @param counterValue value to increment the backend counter with
|
* @param counterValue value to increment the backend counter with
|
||||||
*/
|
*/
|
||||||
protected updateProfileBackendCounterValue(
|
protected updateProfileTaskConditionCounterValue(
|
||||||
pmcData: IPmcData,
|
pmcData: IPmcData,
|
||||||
conditionId: string,
|
conditionId: string,
|
||||||
questId: string,
|
questId: string,
|
||||||
counterValue: number,
|
counterValue: number,
|
||||||
): void
|
): void
|
||||||
{
|
{
|
||||||
if (pmcData.BackendCounters[conditionId] !== undefined)
|
if (pmcData.TaskConditionCounters[conditionId] !== undefined)
|
||||||
{
|
{
|
||||||
pmcData.BackendCounters[conditionId].value += counterValue;
|
pmcData.TaskConditionCounters[conditionId].value += counterValue;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pmcData.BackendCounters[conditionId] = { id: conditionId, qid: questId, value: counterValue };
|
pmcData.TaskConditionCounters[conditionId] = {
|
||||||
|
id: conditionId,
|
||||||
|
sourceId: questId,
|
||||||
|
type: "HandoverItem",
|
||||||
|
value: counterValue };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -152,7 +152,7 @@ export class InRaidHelper
|
|||||||
profileData.Encyclopedia = saveProgressRequest.profile.Encyclopedia;
|
profileData.Encyclopedia = saveProgressRequest.profile.Encyclopedia;
|
||||||
profileData.ConditionCounters = saveProgressRequest.profile.ConditionCounters;
|
profileData.ConditionCounters = saveProgressRequest.profile.ConditionCounters;
|
||||||
|
|
||||||
this.validateBackendCounters(saveProgressRequest, profileData);
|
this.validateTaskConditionCounters(saveProgressRequest, profileData);
|
||||||
|
|
||||||
profileData.SurvivorClass = saveProgressRequest.profile.SurvivorClass;
|
profileData.SurvivorClass = saveProgressRequest.profile.SurvivorClass;
|
||||||
|
|
||||||
@ -176,24 +176,24 @@ export class InRaidHelper
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Check counters are correct in profile */
|
/** Check counters are correct in profile */
|
||||||
protected validateBackendCounters(saveProgressRequest: ISaveProgressRequestData, profileData: IPmcData): void
|
protected validateTaskConditionCounters(saveProgressRequest: ISaveProgressRequestData, profileData: IPmcData): void
|
||||||
{
|
{
|
||||||
for (const backendCounterKey in saveProgressRequest.profile.BackendCounters)
|
for (const backendCounterKey in saveProgressRequest.profile.TaskConditionCounters)
|
||||||
{
|
{
|
||||||
// Skip counters with no id
|
// Skip counters with no id
|
||||||
if (!saveProgressRequest.profile.BackendCounters[backendCounterKey].id)
|
if (!saveProgressRequest.profile.TaskConditionCounters[backendCounterKey].id)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const postRaidValue = saveProgressRequest.profile.BackendCounters[backendCounterKey]?.value;
|
const postRaidValue = saveProgressRequest.profile.TaskConditionCounters[backendCounterKey]?.value;
|
||||||
if (typeof postRaidValue === "undefined")
|
if (typeof postRaidValue === "undefined")
|
||||||
{
|
{
|
||||||
// No value, skip
|
// No value, skip
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const matchingPreRaidCounter = profileData.BackendCounters[backendCounterKey];
|
const matchingPreRaidCounter = profileData.TaskConditionCounters[backendCounterKey];
|
||||||
if (!matchingPreRaidCounter)
|
if (!matchingPreRaidCounter)
|
||||||
{
|
{
|
||||||
this.logger.error(`Backendcounter: ${backendCounterKey} cannot be found in pre-raid data`);
|
this.logger.error(`Backendcounter: ${backendCounterKey} cannot be found in pre-raid data`);
|
||||||
|
@ -21,7 +21,6 @@ export interface IBotBase
|
|||||||
Encyclopedia: Record<string, boolean>;
|
Encyclopedia: Record<string, boolean>;
|
||||||
TaskConditionCounters: Record<string, ITaskConditionCounter>;
|
TaskConditionCounters: Record<string, ITaskConditionCounter>;
|
||||||
ConditionCounters: ConditionCounters;
|
ConditionCounters: ConditionCounters;
|
||||||
BackendCounters: Record<string, BackendCounter>;
|
|
||||||
InsuredItems: InsuredItem[];
|
InsuredItems: InsuredItem[];
|
||||||
Hideout: Hideout;
|
Hideout: Hideout;
|
||||||
Quests: IQuestStatus[];
|
Quests: IQuestStatus[];
|
||||||
@ -46,6 +45,7 @@ export interface ITaskConditionCounter
|
|||||||
id: string
|
id: string
|
||||||
type: string
|
type: string
|
||||||
value: number
|
value: number
|
||||||
|
/** Quest id */
|
||||||
sourceId: string
|
sourceId: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ export class ProfileFixerService
|
|||||||
public checkForAndFixPmcProfileIssues(pmcProfile: IPmcData): void
|
public checkForAndFixPmcProfileIssues(pmcProfile: IPmcData): void
|
||||||
{
|
{
|
||||||
this.removeDanglingConditionCounters(pmcProfile);
|
this.removeDanglingConditionCounters(pmcProfile);
|
||||||
this.removeDanglingBackendCounters(pmcProfile);
|
this.removeDanglingTaskConditionCounters(pmcProfile);
|
||||||
this.addMissingRepeatableQuestsProperty(pmcProfile);
|
this.addMissingRepeatableQuestsProperty(pmcProfile);
|
||||||
this.addLighthouseKeeperIfMissing(pmcProfile);
|
this.addLighthouseKeeperIfMissing(pmcProfile);
|
||||||
this.addUnlockedInfoObjectIfMissing(pmcProfile);
|
this.addUnlockedInfoObjectIfMissing(pmcProfile);
|
||||||
@ -502,18 +502,18 @@ export class ProfileFixerService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected removeDanglingBackendCounters(pmcProfile: IPmcData): void
|
protected removeDanglingTaskConditionCounters(pmcProfile: IPmcData): void
|
||||||
{
|
{
|
||||||
if (pmcProfile.BackendCounters)
|
if (pmcProfile.TaskConditionCounters)
|
||||||
{
|
{
|
||||||
const counterKeysToRemove: string[] = [];
|
const counterKeysToRemove: string[] = [];
|
||||||
const activeQuests = this.getActiveRepeatableQuests(pmcProfile.RepeatableQuests);
|
const activeQuests = this.getActiveRepeatableQuests(pmcProfile.RepeatableQuests);
|
||||||
for (const [key, backendCounter] of Object.entries(pmcProfile.BackendCounters))
|
for (const [key, backendCounter] of Object.entries(pmcProfile.TaskConditionCounters))
|
||||||
{
|
{
|
||||||
if (pmcProfile.RepeatableQuests && activeQuests.length > 0)
|
if (pmcProfile.RepeatableQuests && activeQuests.length > 0)
|
||||||
{
|
{
|
||||||
const existsInActiveRepeatableQuests = activeQuests.some((x) => x._id === backendCounter.qid);
|
const existsInActiveRepeatableQuests = activeQuests.some((x) => x._id === backendCounter.sourceId);
|
||||||
const existsInQuests = pmcProfile.Quests.some((q) => q.qid === backendCounter.qid);
|
const existsInQuests = pmcProfile.Quests.some((q) => q.qid === backendCounter.sourceId);
|
||||||
|
|
||||||
// if BackendCounter's quest is neither in activeQuests nor Quests it's stale
|
// if BackendCounter's quest is neither in activeQuests nor Quests it's stale
|
||||||
if (!(existsInActiveRepeatableQuests || existsInQuests))
|
if (!(existsInActiveRepeatableQuests || existsInQuests))
|
||||||
@ -526,7 +526,7 @@ export class ProfileFixerService
|
|||||||
for (const counterKeyToRemove of counterKeysToRemove)
|
for (const counterKeyToRemove of counterKeysToRemove)
|
||||||
{
|
{
|
||||||
this.logger.debug(`Removed ${counterKeyToRemove} backend count object`);
|
this.logger.debug(`Removed ${counterKeyToRemove} backend count object`);
|
||||||
delete pmcProfile.BackendCounters[counterKeyToRemove];
|
delete pmcProfile.TaskConditionCounters[counterKeyToRemove];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user