feat(missions): emit progress events on story/finish and practice/finish

Story emits story_chapter_finish:<main|limited|event>:<story_id>.
Practice emits practice_win:<difficulty>:<enemy_class_id> on win only.

Practice catalog rows use opponent NAMES (e.g. practice_win:elite:arisa)
not numeric class_ids, so captured catalog rows won't match yet. The
infrastructure is in place; bridging numeric→name is a follow-up.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
gamer147
2026-05-27 10:51:05 -04:00
parent 5693ec0302
commit 8e35501954
2 changed files with 52 additions and 6 deletions

View File

@@ -11,7 +11,12 @@ namespace SVSim.EmulatedEntrypoint.Controllers;
public class StoryController : SVSimController
{
private readonly IStoryService _service;
public StoryController(IStoryService service) { _service = service; }
private readonly IMissionProgressService _missionProgress;
public StoryController(IStoryService service, IMissionProgressService missionProgress)
{
_service = service;
_missionProgress = missionProgress;
}
[HttpPost("/story/section")]
[HttpPost("/main_story/section")]
@@ -65,7 +70,28 @@ public class StoryController : SVSimController
public async Task<ActionResult<FinishResponse>> Finish(FinishRequest req)
{
if (!TryGetViewerId(out long vid)) return Unauthorized();
return await _service.FinishAsync(ResolveApiType(), req, vid);
var result = await _service.FinishAsync(ResolveApiType(), req, vid);
// Emit story-chapter-finish events for mission/achievement progress.
var apiType = ResolveApiType();
var prefix = apiType switch
{
StoryApiType.Main => "main",
StoryApiType.Limited => "limited",
StoryApiType.Event => "event",
_ => null,
};
if (prefix is not null && req.StoryId != 0)
{
await _missionProgress.RecordEventAsync(vid, new[]
{
"story_chapter_finish",
$"story_chapter_finish:{prefix}",
$"story_chapter_finish:{prefix}:{req.StoryId}",
});
}
return result;
}
[HttpPost("/main_story/all_finish")]