feat(mission): wire Tier 1 emits — rank/free/challenge match events

Adds IMissionProgressService to RankBattle, FreeBattle, ArenaTwoPickBattle, and
ArenaTwoPick controllers. Each finish handler emits the appropriate
MissionEventKeys builder result:

- RankBattle.Finish (win) → Ranked.WinAll(classId)
  Includes AI-rank routes; on a private server AI wins count the same.
- FreeBattle.Finish (win) → Free.WinAll() (aggregates only)
- ArenaTwoPickBattle.Finish → Challenge.MatchPlayAll or MatchWinAll
  Always fires challenge_play; wins additionally fire challenge_win and
  the ranked/arena/daily aggregates.
- ArenaTwoPick.Finish (5-win full clear) → Challenge.FullClearAll
  Gated on RunFinishOutcome.WasFullClear from the previous commit.

This closes six of the eight remaining catalog wire-up gaps; class_level_up
and rank_achieved follow in Tier 2 (need pre-state detection).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
gamer147
2026-07-04 13:22:02 -04:00
parent 94622a526d
commit 42b0fd3d6e
4 changed files with 49 additions and 3 deletions

View File

@@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Mvc;
using SVSim.BattleNode.Bridge;
using SVSim.Database.Enums;
using SVSim.Database.Services;
using SVSim.Database.Services.Friend;
using SVSim.Database.Services.Replay;
using SVSim.EmulatedEntrypoint.Extensions;
@@ -20,6 +21,7 @@ public class ArenaTwoPickBattleController : SVSimController
private readonly IBattleContextStore _battleContextStore;
private readonly IBattleHistoryWriter _historyWriter;
private readonly IPlayedTogetherWriter _playedTogetherWriter;
private readonly IMissionProgressService _missionProgress;
public ArenaTwoPickBattleController(
IArenaTwoPickService svc,
@@ -27,7 +29,8 @@ public class ArenaTwoPickBattleController : SVSimController
IMatchingResolver resolver,
IBattleContextStore battleContextStore,
IBattleHistoryWriter historyWriter,
IPlayedTogetherWriter playedTogetherWriter)
IPlayedTogetherWriter playedTogetherWriter,
IMissionProgressService missionProgress)
{
_svc = svc;
_matchContextBuilder = matchContextBuilder;
@@ -35,6 +38,7 @@ public class ArenaTwoPickBattleController : SVSimController
_battleContextStore = battleContextStore;
_historyWriter = historyWriter;
_playedTogetherWriter = playedTogetherWriter;
_missionProgress = missionProgress;
}
[HttpPost("do_matching")]
@@ -117,6 +121,14 @@ public class ArenaTwoPickBattleController : SVSimController
}
var result = await _svc.RecordBattleResultAsync(vid, isWin);
// Mission counters — TK2 matches always advance challenge_play, wins additionally
// advance challenge_win + the ranked/arena/daily aggregates.
await _missionProgress.RecordEventAsync(
vid,
isWin ? MissionEventKeys.Challenge.MatchWinAll() : MissionEventKeys.Challenge.MatchPlayAll(),
ct: ct);
return Ok(new BattleFinishResponseDto
{
BattleResult = result.BattleResult,