diff --git a/project/assets/database/templates/profiles.json b/project/assets/database/templates/profiles.json index 4b26274e..fa8bceb2 100644 --- a/project/assets/database/templates/profiles.json +++ b/project/assets/database/templates/profiles.json @@ -3,7 +3,7 @@ "descriptionLocaleKey": "launcher-profile-edgeofdarkness", "bear": { "character": { - "BackendCounters": {}, + "TaskConditionCounters": {}, "Bonuses": [{ "id": "64f5b9e5fa34f11b380756c0", "templateId": "566abbc34bdc2d92178b4576", @@ -4290,7 +4290,7 @@ }, "usec": { "character": { - "BackendCounters": {}, + "TaskConditionCounters": {}, "Bonuses": [{ "id": "64f5b9e5fa34f11b380756c0", "templateId": "566abbc34bdc2d92178b4576", @@ -8714,7 +8714,7 @@ "descriptionLocaleKey": "launcher-profile_leftbehind", "bear": { "character": { - "BackendCounters": {}, + "TaskConditionCounters": {}, "Bonuses": [{ "id": "64f5b9e5fa34f11b380756c0", "templateId": "566abbc34bdc2d92178b4576", @@ -11892,7 +11892,7 @@ }, "usec": { "character": { - "BackendCounters": {}, + "TaskConditionCounters": {}, "Bonuses": [{ "id": "64f5b9e5fa34f11b380756c0", "templateId": "566abbc34bdc2d92178b4576", @@ -15175,7 +15175,7 @@ "descriptionLocaleKey": "launcher-profile_preparetoescape", "bear": { "character": { - "BackendCounters": {}, + "TaskConditionCounters": {}, "Bonuses": [{ "id": "64f5b9e5fa34f11b380756c0", "templateId": "566abbc34bdc2d92178b4576", @@ -18811,7 +18811,7 @@ }, "usec": { "character": { - "BackendCounters": {}, + "TaskConditionCounters": {}, "Bonuses": [{ "id": "64f5b9e5fa34f11b380756c0", "templateId": "566abbc34bdc2d92178b4576", @@ -22650,7 +22650,7 @@ "descriptionLocaleKey": "launcher-profile_sptdeveloper", "bear": { "character": { - "BackendCounters": {}, + "TaskConditionCounters": {}, "Bonuses": [{ "id": "64f5b9e5fa34f11b380756c0", "templateId": "566abbc34bdc2d92178b4576", @@ -25682,7 +25682,7 @@ }, "usec": { "character": { - "BackendCounters": {}, + "TaskConditionCounters": {}, "Bonuses": [{ "id": "64f5b9e5fa34f11b380756c0", "templateId": "566abbc34bdc2d92178b4576", @@ -28683,7 +28683,7 @@ "descriptionLocaleKey": "launcher-profile_spteasystart", "bear": { "character": { - "BackendCounters": {}, + "TaskConditionCounters": {}, "Bonuses": [{ "id": "64f5b9e5fa34f11b380756c0", "templateId": "566abbc34bdc2d92178b4576", @@ -32024,7 +32024,7 @@ }, "usec": { "character": { - "BackendCounters": {}, + "TaskConditionCounters": {}, "Bonuses": [{ "id": "64f5b9e5fa34f11b380756c0", "templateId": "566abbc34bdc2d92178b4576", @@ -35368,7 +35368,7 @@ "descriptionLocaleKey": "launcher-profile_sptzerotohero", "bear": { "character": { - "BackendCounters": {}, + "TaskConditionCounters": {}, "Bonuses": [{ "id": "64f5b9e5fa34f11b380756c0", "templateId": "566abbc34bdc2d92178b4576", @@ -36268,7 +36268,7 @@ }, "usec": { "character": { - "BackendCounters": {}, + "TaskConditionCounters": {}, "Bonuses": [{ "id": "64f5b9e5fa34f11b380756c0", "templateId": "566abbc34bdc2d92178b4576", @@ -37182,7 +37182,7 @@ "descriptionLocaleKey": "launcher-profile_standard", "bear": { "character": { - "BackendCounters": {}, + "TaskConditionCounters": {}, "Bonuses": [{ "id": "64f5b9e5fa34f11b380756c0", "templateId": "566abbc34bdc2d92178b4576", @@ -39801,7 +39801,7 @@ }, "usec": { "character": { - "BackendCounters": {}, + "TaskConditionCounters": {}, "Bonuses": [{ "id": "64f5b9e5fa34f11b380756c0", "templateId": "566abbc34bdc2d92178b4576", diff --git a/project/src/controllers/HideoutController.ts b/project/src/controllers/HideoutController.ts index 9867a932..006fa5de 100644 --- a/project/src/controllers/HideoutController.ts +++ b/project/src/controllers/HideoutController.ts @@ -47,7 +47,7 @@ import { TimeUtil } from "@spt-aki/utils/TimeUtil"; @injectable() export class HideoutController { - protected static nameBackendCountersCrafting = "CounterHoursCrafting"; + protected static nameTaskConditionCountersCrafting = "CounterHoursCrafting"; protected hideoutConfig: IHideoutConfig; constructor( @@ -770,15 +770,17 @@ export class HideoutController // Variables for managemnet of skill let craftingExpAmount = 0; - // ? move the logic of BackendCounters in new method? - let counterHoursCrafting = pmcData.BackendCounters[HideoutController.nameBackendCountersCrafting]; + // ? move the logic of TaskConditionCounters in new method? + let counterHoursCrafting = pmcData.TaskConditionCounters[HideoutController.nameTaskConditionCountersCrafting]; if (!counterHoursCrafting) { - pmcData.BackendCounters[HideoutController.nameBackendCountersCrafting] = { - id: HideoutController.nameBackendCountersCrafting, + pmcData.TaskConditionCounters[HideoutController.nameTaskConditionCountersCrafting] = { + id: recipe._id, + type: HideoutController.nameTaskConditionCountersCrafting, + sourceId: "CounterCrafting", value: 0, }; - counterHoursCrafting = pmcData.BackendCounters[HideoutController.nameBackendCountersCrafting]; + counterHoursCrafting = pmcData.TaskConditionCounters[HideoutController.nameTaskConditionCountersCrafting]; } let hoursCrafting = counterHoursCrafting.value; diff --git a/project/src/controllers/QuestController.ts b/project/src/controllers/QuestController.ts index de4f0212..7f0b3d6c 100644 --- a/project/src/controllers/QuestController.ts +++ b/project/src/controllers/QuestController.ts @@ -772,8 +772,8 @@ export class QuestController isItemHandoverQuest = condition.conditionType === handoverQuestTypes[0]; handoverRequirements = condition; - const profileCounter = (handoverQuestRequest.conditionId in pmcData.BackendCounters) - ? pmcData.BackendCounters[handoverQuestRequest.conditionId].value + const profileCounter = (handoverQuestRequest.conditionId in pmcData.TaskConditionCounters) + ? pmcData.TaskConditionCounters[handoverQuestRequest.conditionId].value : 0; handedInCount -= profileCounter; @@ -856,7 +856,7 @@ export class QuestController } } - this.updateProfileBackendCounterValue( + this.updateProfileTaskConditionCounterValue( pmcData, handoverQuestRequest.conditionId, handoverQuestRequest.qid, @@ -919,19 +919,24 @@ export class QuestController * @param questId quest id counter is associated with * @param counterValue value to increment the backend counter with */ - protected updateProfileBackendCounterValue( + protected updateProfileTaskConditionCounterValue( pmcData: IPmcData, conditionId: string, questId: string, counterValue: number, ): void { - if (pmcData.BackendCounters[conditionId] !== undefined) + if (pmcData.TaskConditionCounters[conditionId] !== undefined) { - pmcData.BackendCounters[conditionId].value += counterValue; + pmcData.TaskConditionCounters[conditionId].value += counterValue; + return; } - pmcData.BackendCounters[conditionId] = { id: conditionId, qid: questId, value: counterValue }; + pmcData.TaskConditionCounters[conditionId] = { + id: conditionId, + sourceId: questId, + type: "HandoverItem", + value: counterValue }; } } diff --git a/project/src/helpers/InRaidHelper.ts b/project/src/helpers/InRaidHelper.ts index 70c87008..ed0126a1 100644 --- a/project/src/helpers/InRaidHelper.ts +++ b/project/src/helpers/InRaidHelper.ts @@ -152,7 +152,7 @@ export class InRaidHelper profileData.Encyclopedia = saveProgressRequest.profile.Encyclopedia; profileData.ConditionCounters = saveProgressRequest.profile.ConditionCounters; - this.validateBackendCounters(saveProgressRequest, profileData); + this.validateTaskConditionCounters(saveProgressRequest, profileData); profileData.SurvivorClass = saveProgressRequest.profile.SurvivorClass; @@ -176,24 +176,24 @@ export class InRaidHelper } /** 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 - if (!saveProgressRequest.profile.BackendCounters[backendCounterKey].id) + if (!saveProgressRequest.profile.TaskConditionCounters[backendCounterKey].id) { continue; } - const postRaidValue = saveProgressRequest.profile.BackendCounters[backendCounterKey]?.value; + const postRaidValue = saveProgressRequest.profile.TaskConditionCounters[backendCounterKey]?.value; if (typeof postRaidValue === "undefined") { // No value, skip continue; } - const matchingPreRaidCounter = profileData.BackendCounters[backendCounterKey]; + const matchingPreRaidCounter = profileData.TaskConditionCounters[backendCounterKey]; if (!matchingPreRaidCounter) { this.logger.error(`Backendcounter: ${backendCounterKey} cannot be found in pre-raid data`); diff --git a/project/src/models/eft/common/tables/IBotBase.ts b/project/src/models/eft/common/tables/IBotBase.ts index 2834e5ee..9373e9a0 100644 --- a/project/src/models/eft/common/tables/IBotBase.ts +++ b/project/src/models/eft/common/tables/IBotBase.ts @@ -21,7 +21,6 @@ export interface IBotBase Encyclopedia: Record; TaskConditionCounters: Record; ConditionCounters: ConditionCounters; - BackendCounters: Record; InsuredItems: InsuredItem[]; Hideout: Hideout; Quests: IQuestStatus[]; @@ -46,6 +45,7 @@ export interface ITaskConditionCounter id: string type: string value: number + /** Quest id */ sourceId: string } diff --git a/project/src/services/ProfileFixerService.ts b/project/src/services/ProfileFixerService.ts index f2123155..3b95a294 100644 --- a/project/src/services/ProfileFixerService.ts +++ b/project/src/services/ProfileFixerService.ts @@ -59,7 +59,7 @@ export class ProfileFixerService public checkForAndFixPmcProfileIssues(pmcProfile: IPmcData): void { this.removeDanglingConditionCounters(pmcProfile); - this.removeDanglingBackendCounters(pmcProfile); + this.removeDanglingTaskConditionCounters(pmcProfile); this.addMissingRepeatableQuestsProperty(pmcProfile); this.addLighthouseKeeperIfMissing(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 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) { - const existsInActiveRepeatableQuests = activeQuests.some((x) => x._id === backendCounter.qid); - const existsInQuests = pmcProfile.Quests.some((q) => q.qid === backendCounter.qid); + const existsInActiveRepeatableQuests = activeQuests.some((x) => x._id === backendCounter.sourceId); + const existsInQuests = pmcProfile.Quests.some((q) => q.qid === backendCounter.sourceId); // if BackendCounter's quest is neither in activeQuests nor Quests it's stale if (!(existsInActiveRepeatableQuests || existsInQuests)) @@ -526,7 +526,7 @@ export class ProfileFixerService for (const counterKeyToRemove of counterKeysToRemove) { this.logger.debug(`Removed ${counterKeyToRemove} backend count object`); - delete pmcProfile.BackendCounters[counterKeyToRemove]; + delete pmcProfile.TaskConditionCounters[counterKeyToRemove]; } } }