feat(battle-node): thread MatchContext through bridge to BattleSession
IMatchingBridge.RegisterPendingBattle now takes a MatchContext; PendingBattle carries it; BattleSession stores it. ArenaTwoPickBattleController builds ctx from IMatchContextBuilder. ScriptedLifecycle still uses ScriptedProfiles for the player half — Tasks 5/6 migrate the lifecycle. Existing tests updated: MatchingBridgeTests, BattleNodeFlowTests, InMemoryBattleSessionStoreTests, BattleSessionDispatchTests, BattleSession PumpTests, ArenaTwoPickBattleControllerTests (which now seeds a TK2 run + adds a no-active-run 400 case). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -11,24 +11,37 @@ public class ArenaTwoPickBattleController : SVSimController
|
||||
{
|
||||
private readonly IArenaTwoPickService _svc;
|
||||
private readonly IMatchingBridge _matching;
|
||||
private readonly IMatchContextBuilder _matchContextBuilder;
|
||||
|
||||
public ArenaTwoPickBattleController(IArenaTwoPickService svc, IMatchingBridge matching)
|
||||
public ArenaTwoPickBattleController(
|
||||
IArenaTwoPickService svc,
|
||||
IMatchingBridge matching,
|
||||
IMatchContextBuilder matchContextBuilder)
|
||||
{
|
||||
_svc = svc;
|
||||
_matching = matching;
|
||||
_matchContextBuilder = matchContextBuilder;
|
||||
}
|
||||
|
||||
[HttpPost("do_matching")]
|
||||
public IActionResult DoMatching([FromBody] DoMatchingRequest req)
|
||||
public async Task<IActionResult> DoMatching([FromBody] DoMatchingRequest req)
|
||||
{
|
||||
if (!TryGetViewerId(out var vid)) return Unauthorized();
|
||||
var match = _matching.RegisterPendingBattle(vid);
|
||||
return Ok(new DoMatchingResponseDto
|
||||
try
|
||||
{
|
||||
MatchingState = 3004,
|
||||
BattleId = match.BattleId,
|
||||
NodeServerUrl = match.NodeServerUrl,
|
||||
});
|
||||
var ctx = await _matchContextBuilder.BuildForTwoPickAsync(vid);
|
||||
var match = _matching.RegisterPendingBattle(vid, ctx);
|
||||
return Ok(new DoMatchingResponseDto
|
||||
{
|
||||
MatchingState = 3004,
|
||||
BattleId = match.BattleId,
|
||||
NodeServerUrl = match.NodeServerUrl,
|
||||
});
|
||||
}
|
||||
catch (ArenaTwoPickException ex)
|
||||
{
|
||||
return BadRequest(new { error_code = ex.ErrorCode });
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost("finish")]
|
||||
|
||||
Reference in New Issue
Block a user