Skip to content

Commit

Permalink
move record mission progression calls
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeFZ committed Aug 9, 2023
1 parent a9eb251 commit 264e338
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public class DungeonRecordServiceTest
{
private readonly Mock<IDungeonRecordRewardService> mockDungeonRewardService;
private readonly Mock<IQuestService> mockQuestService;
private readonly Mock<IMissionProgressionService> mockMissionProgressionService;
private readonly Mock<IUserService> mockUserService;
private readonly Mock<ITutorialService> mockTutorialService;
private readonly Mock<ILogger<DungeonRecordService>> mockLogger;
Expand All @@ -33,15 +32,13 @@ 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);

this.dungeonRecordService = new DungeonRecordService(
this.mockDungeonRewardService.Object,
this.mockQuestService.Object,
this.mockMissionProgressionService.Object,
this.mockUserService.Object,
this.mockTutorialService.Object,
this.mockLogger.Object
Expand Down Expand Up @@ -157,8 +154,6 @@ public async Task GenerateIngameResultData_CallsExpectedMethods()
.Setup(x => x.ProcessQuestCompletion(lSurtrSoloId, 10))
.ReturnsAsync((mockQuest, true, new List<AtgenFirstClearSet>()));

this.mockMissionProgressionService.Setup(x => x.OnQuestCleared(lSurtrSoloId));

this.mockUserService
.Setup(x => x.RemoveStamina(StaminaType.Single, 40))
.Returns(Task.CompletedTask);
Expand Down Expand Up @@ -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();
Expand Down
11 changes: 0 additions & 11 deletions DragaliaAPI/Features/Dungeon/Record/DungeonRecordService.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using DragaliaAPI.Database.Entities;
using DragaliaAPI.Features.Missions;
using DragaliaAPI.Features.Player;
using DragaliaAPI.Features.Quest;
using DragaliaAPI.Models;
Expand All @@ -12,7 +11,6 @@ namespace DragaliaAPI.Features.Dungeon.Record;
public class DungeonRecordService(
IDungeonRecordRewardService dungeonRecordRewardService,
IQuestService questService,
IMissionProgressionService missionProgressionService,
IUserService userService,
ITutorialService tutorialService,
ILogger<DungeonRecordService> logger
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 9 additions & 1 deletion DragaliaAPI/Features/Quest/QuestService.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -18,7 +19,8 @@ public class QuestService(
IDateTimeProvider dateTimeProvider,
IResetHelper resetHelper,
IQuestCacheService questCacheService,
IRewardService rewardService
IRewardService rewardService,
IMissionProgressionService missionProgressionService
) : IQuestService
{
public async Task<(
Expand All @@ -30,6 +32,8 @@ IEnumerable<AtgenFirstClearSet> Bonus
DbQuest quest = await questRepository.GetQuestDataAsync(questId);
quest.State = 3;

missionProgressionService.OnQuestCleared(questId);

bool isBestClearTime = false;

if (0 > quest.BestClearTime || quest.BestClearTime > clearTime)
Expand Down Expand Up @@ -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];

Expand Down

0 comments on commit 264e338

Please sign in to comment.