Skip to content

Commit

Permalink
Add logging to dungeon start and fail (#860)
Browse files Browse the repository at this point in the history
Investigating a reported issue with dungeon fail that happens
intermittently
  • Loading branch information
SapiensAnatis authored Jun 6, 2024
1 parent 80f199f commit e17e91b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using DragaliaAPI.Features.Dungeon;
using DragaliaAPI.Features.Dungeon.Record;
using DragaliaAPI.Features.Dungeon.Start;
using DragaliaAPI.Features.Quest;
using DragaliaAPI.Features.Reward;
using DragaliaAPI.Models;
Expand All @@ -8,6 +9,7 @@
using DragaliaAPI.Services.Photon;
using DragaliaAPI.Shared.Definitions.Enums;
using DragaliaAPI.Shared.MasterAsset;
using Microsoft.Extensions.Logging.Abstractions;

namespace DragaliaAPI.Test.Controllers;

Expand Down Expand Up @@ -40,7 +42,8 @@ public DungeonControllerTest()
this.mockUpdateDataService.Object,
this.mockRewardService.Object,
this.mockMatchingService.Object,
this.mockDungeonRecordHelperService.Object
this.mockDungeonRecordHelperService.Object,
NullLogger<DungeonController>.Instance
);
}

Expand Down
12 changes: 9 additions & 3 deletions DragaliaAPI/DragaliaAPI/Features/Dungeon/DungeonController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using DragaliaAPI.Models;
using DragaliaAPI.Models.Generated;
using DragaliaAPI.Services;
using DragaliaAPI.Services.Game;
using DragaliaAPI.Services.Photon;
using Microsoft.AspNetCore.Mvc;

Expand All @@ -18,7 +19,8 @@ public class DungeonController(
IUpdateDataService updateDataService,
IRewardService rewardService,
IMatchingService matchingService,
IDungeonRecordHelperService dungeonRecordHelperService
IDungeonRecordHelperService dungeonRecordHelperService,
ILogger<DungeonController> logger
) : DragaliaControllerBase
{
[HttpPost("get_area_odds")]
Expand All @@ -43,12 +45,12 @@ public async Task<DragaliaResult> Fail(DungeonFailRequest request)
{
DungeonSession session = await dungeonService.FinishDungeon(request.DungeonKey);

logger.LogDebug("Processing fail request for quest {QuestId}", session.QuestId);

DungeonFailResponse response =
new()
{
Result = 1,
FailHelperList = new List<UserSupportList>(),
FailHelperDetailList = new List<AtgenHelperDetailList>(),
FailQuestDetail = new()
{
QuestId = session.QuestId,
Expand All @@ -58,6 +60,8 @@ public async Task<DragaliaResult> Fail(DungeonFailRequest request)
}
};

logger.LogDebug("Session is multiplayer: {IsMulti}", session.IsMulti);

if (session.IsMulti)
{
response.FailQuestDetail.IsHost = await matchingService.GetIsHost();
Expand All @@ -70,6 +74,8 @@ public async Task<DragaliaResult> Fail(DungeonFailRequest request)
await dungeonRecordHelperService.ProcessHelperDataSolo(session.SupportViewerId);
}

logger.LogDebug("Final response: {@Response}", response);

return this.Ok(response);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ public async Task<DragaliaResult> Start(
CancellationToken cancellationToken
)
{
logger.LogDebug(
"Attempting to start quest {QuestId} with helper {SupportViewerId}",
request.QuestId,
request.SupportViewerId
);

if (!await dungeonStartService.ValidateStamina(request.QuestId, StaminaType.Single))
return this.Code(ResultCode.QuestStaminaSingleShort);

Expand Down

0 comments on commit e17e91b

Please sign in to comment.