Skip to content

Commit

Permalink
Fix quests not granting rupies and mana (#314)
Browse files Browse the repository at this point in the history
  • Loading branch information
SapiensAnatis authored Jul 19, 2023
1 parent e37f333 commit 7efb465
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions DragaliaAPI.Test/Controllers/DungeonRecordControllerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using DragaliaAPI.Database.Repositories;
using DragaliaAPI.Features.Dungeon;
using DragaliaAPI.Features.Missions;
using DragaliaAPI.Features.Reward;
using DragaliaAPI.Models;
using DragaliaAPI.Models.Generated;
using DragaliaAPI.Services;
Expand All @@ -24,6 +25,7 @@ public class DungeonRecordControllerTest
private readonly Mock<IUpdateDataService> mockUpdateDataService;
private readonly Mock<ITutorialService> mockTutorialService;
private readonly Mock<IMissionProgressionService> mockMissionProgressionService;
private readonly Mock<IRewardService> mockRewardService;
private readonly Mock<ILogger<DungeonRecordController>> mockLogger;

private const string dungeonKey = "key";
Expand All @@ -39,6 +41,7 @@ public DungeonRecordControllerTest()
this.mockUpdateDataService = new(MockBehavior.Strict);
this.mockTutorialService = new(MockBehavior.Strict);
this.mockMissionProgressionService = new(MockBehavior.Strict);
this.mockRewardService = new(MockBehavior.Loose); // This file is about to be overhauled anyway
this.mockLogger = new(MockBehavior.Loose);

this.dungeonRecordController = new(
Expand All @@ -49,6 +52,7 @@ public DungeonRecordControllerTest()
this.mockUpdateDataService.Object,
this.mockTutorialService.Object,
this.mockMissionProgressionService.Object,
this.mockRewardService.Object,
this.mockLogger.Object
);

Expand Down
7 changes: 7 additions & 0 deletions DragaliaAPI/Features/Dungeon/DungeonRecordController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using DragaliaAPI.Database.Entities;
using DragaliaAPI.Database.Repositories;
using DragaliaAPI.Features.Missions;
using DragaliaAPI.Features.Reward;
using DragaliaAPI.Middleware;
using DragaliaAPI.Models;
using DragaliaAPI.Models.Generated;
Expand All @@ -27,6 +28,7 @@ public class DungeonRecordController : DragaliaControllerBase
private readonly IUpdateDataService updateDataService;
private readonly ITutorialService tutorialService;
private readonly IMissionProgressionService missionProgressionService;
private readonly IRewardService rewardService;
private readonly ILogger<DungeonRecordController> logger;

public DungeonRecordController(
Expand All @@ -37,6 +39,7 @@ public DungeonRecordController(
IUpdateDataService updateDataService,
ITutorialService tutorialService,
IMissionProgressionService missionProgressionService,
IRewardService rewardService,
ILogger<DungeonRecordController> logger
)
{
Expand All @@ -47,6 +50,7 @@ ILogger<DungeonRecordController> logger
this.updateDataService = updateDataService;
this.tutorialService = tutorialService;
this.missionProgressionService = missionProgressionService;
this.rewardService = rewardService;
this.logger = logger;
}

Expand Down Expand Up @@ -182,6 +186,9 @@ await inventoryRepository.UpdateQuantity(
drops.Select(x => new KeyValuePair<Materials, int>((Materials)x.id, x.quantity))
);

await this.rewardService.GrantReward(new Entity(EntityTypes.Rupies, Quantity: coinDrop));
await this.rewardService.GrantReward(new Entity(EntityTypes.Mana, Quantity: manaDrop));

UpdateDataList updateDataList = await updateDataService.SaveChangesAsync();

return new DungeonRecordRecordData()
Expand Down

0 comments on commit 7efb465

Please sign in to comment.