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:
gamer147
2026-06-01 12:44:42 -04:00
parent a0fdb0f3c5
commit 01f9bb722a
12 changed files with 144 additions and 44 deletions

View File

@@ -2,6 +2,7 @@ using System.Net.WebSockets;
using System.Security.Cryptography;
using System.Text;
using Microsoft.Extensions.Logging;
using SVSim.BattleNode.Bridge;
using SVSim.BattleNode.Lifecycle;
using SVSim.BattleNode.Protocol;
using SVSim.BattleNode.Protocol.Bodies;
@@ -37,12 +38,19 @@ public sealed class BattleSession
public InboundTracker Inbound { get; } = new();
public OutboundSequencer Outbound { get; } = new();
public BattleSession(WebSocket ws, string battleId, long viewerId, ILogger<BattleSession> log)
/// <summary>
/// Player-side snapshot captured at do_matching time. ScriptedLifecycle reads the player
/// half of Matched/BattleStart frames from here; opponent half stays in ScriptedProfiles.
/// </summary>
internal MatchContext Context { get; }
public BattleSession(WebSocket ws, string battleId, long viewerId, MatchContext context, ILogger<BattleSession> log)
{
_ws = ws;
_log = log;
BattleId = battleId;
ViewerId = viewerId;
Context = context;
}
/// <summary>