From 264e3387f8c2c4298f35d521026bd37b991f8bc3 Mon Sep 17 00:00:00 2001 From: LukeFZ <17146677+LukeFZ@users.noreply.github.com> Date: Wed, 9 Aug 2023 16:06:41 +0200 Subject: [PATCH] move record mission progression calls --- .../Dungeon/Record/DungeonRecordServiceTest.cs | 6 ------ .../Features/Dungeon/Record/DungeonRecordService.cs | 11 ----------- DragaliaAPI/Features/Quest/QuestService.cs | 10 +++++++++- 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/DragaliaAPI.Test/Features/Dungeon/Record/DungeonRecordServiceTest.cs b/DragaliaAPI.Test/Features/Dungeon/Record/DungeonRecordServiceTest.cs index 8ac58effb..6c159f8cf 100644 --- a/DragaliaAPI.Test/Features/Dungeon/Record/DungeonRecordServiceTest.cs +++ b/DragaliaAPI.Test/Features/Dungeon/Record/DungeonRecordServiceTest.cs @@ -22,7 +22,6 @@ public class DungeonRecordServiceTest { private readonly Mock mockDungeonRewardService; private readonly Mock mockQuestService; - private readonly Mock mockMissionProgressionService; private readonly Mock mockUserService; private readonly Mock mockTutorialService; private readonly Mock> mockLogger; @@ -33,7 +32,6 @@ public DungeonRecordServiceTest() { this.mockDungeonRewardService = new(MockBehavior.Strict); this.mockQuestService = new(MockBehavior.Strict); - this.mockMissionProgressionService = new(MockBehavior.Strict); this.mockUserService = new(MockBehavior.Strict); this.mockTutorialService = new(MockBehavior.Strict); this.mockLogger = new(MockBehavior.Loose); @@ -41,7 +39,6 @@ public DungeonRecordServiceTest() this.dungeonRecordService = new DungeonRecordService( this.mockDungeonRewardService.Object, this.mockQuestService.Object, - this.mockMissionProgressionService.Object, this.mockUserService.Object, this.mockTutorialService.Object, this.mockLogger.Object @@ -157,8 +154,6 @@ public async Task GenerateIngameResultData_CallsExpectedMethods() .Setup(x => x.ProcessQuestCompletion(lSurtrSoloId, 10)) .ReturnsAsync((mockQuest, true, new List())); - this.mockMissionProgressionService.Setup(x => x.OnQuestCleared(lSurtrSoloId)); - this.mockUserService .Setup(x => x.RemoveStamina(StaminaType.Single, 40)) .Returns(Task.CompletedTask); @@ -239,7 +234,6 @@ await this.dungeonRecordService.GenerateIngameResultData( this.mockDungeonRewardService.VerifyAll(); this.mockQuestService.VerifyAll(); - this.mockMissionProgressionService.VerifyAll(); this.mockUserService.VerifyAll(); this.mockTutorialService.VerifyAll(); this.mockLogger.VerifyAll(); diff --git a/DragaliaAPI/Features/Dungeon/Record/DungeonRecordService.cs b/DragaliaAPI/Features/Dungeon/Record/DungeonRecordService.cs index e9a81da5a..2b0e875ff 100644 --- a/DragaliaAPI/Features/Dungeon/Record/DungeonRecordService.cs +++ b/DragaliaAPI/Features/Dungeon/Record/DungeonRecordService.cs @@ -1,5 +1,4 @@ using DragaliaAPI.Database.Entities; -using DragaliaAPI.Features.Missions; using DragaliaAPI.Features.Player; using DragaliaAPI.Features.Quest; using DragaliaAPI.Models; @@ -12,7 +11,6 @@ namespace DragaliaAPI.Features.Dungeon.Record; public class DungeonRecordService( IDungeonRecordRewardService dungeonRecordRewardService, IQuestService questService, - IMissionProgressionService missionProgressionService, IUserService userService, ITutorialService tutorialService, ILogger logger @@ -55,7 +53,6 @@ DungeonSession session ) = await questService.ProcessQuestCompletion(session.QuestData.Id, playRecord.time); this.ProcessClearTime(ingameResultData, playRecord.time, questData); - this.ProcessMissionProgression(session); await this.ProcessGrowth(ingameResultData.grow_record, session); await this.ProcessStaminaConsumption(session); await this.ProcessPlayerLevel( @@ -127,14 +124,6 @@ private Task ProcessGrowth(GrowRecord growRecord, DungeonSession session) return Task.CompletedTask; } - private void ProcessMissionProgression(DungeonSession session) - { - if (session.QuestData.IsPartOfVoidBattleGroups) - missionProgressionService.OnVoidBattleCleared(); - - missionProgressionService.OnQuestCleared(session.QuestData.Id); - } - private async Task ProcessStaminaConsumption(DungeonSession session) { StaminaType type = StaminaType.None; diff --git a/DragaliaAPI/Features/Quest/QuestService.cs b/DragaliaAPI/Features/Quest/QuestService.cs index ec3a4da1c..1d1613903 100644 --- a/DragaliaAPI/Features/Quest/QuestService.cs +++ b/DragaliaAPI/Features/Quest/QuestService.cs @@ -1,6 +1,7 @@ using System.Diagnostics; using DragaliaAPI.Database.Entities; using DragaliaAPI.Database.Repositories; +using DragaliaAPI.Features.Missions; using DragaliaAPI.Features.Reward; using DragaliaAPI.Helpers; using DragaliaAPI.Models; @@ -18,7 +19,8 @@ public class QuestService( IDateTimeProvider dateTimeProvider, IResetHelper resetHelper, IQuestCacheService questCacheService, - IRewardService rewardService + IRewardService rewardService, + IMissionProgressionService missionProgressionService ) : IQuestService { public async Task<( @@ -30,6 +32,8 @@ IEnumerable Bonus DbQuest quest = await questRepository.GetQuestDataAsync(questId); quest.State = 3; + missionProgressionService.OnQuestCleared(questId); + bool isBestClearTime = false; if (0 > quest.BestClearTime || quest.BestClearTime > clearTime) @@ -82,6 +86,10 @@ int questId { logger.LogTrace("Completing quest for quest group {eventGroupId}", eventGroupId); + // TODO: Remove when missions pr is merged + if (eventGroupId == 30000) + missionProgressionService.OnVoidBattleCleared(); + DbQuestEvent questEvent = await questRepository.GetQuestEventAsync(eventGroupId); QuestEvent questEventData = MasterAsset.QuestEvent[eventGroupId];