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:
@@ -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>
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
using SVSim.BattleNode.Bridge;
|
||||
|
||||
namespace SVSim.BattleNode.Sessions;
|
||||
|
||||
/// <summary>
|
||||
/// Sparse pre-connect record: enough to validate the incoming WS connect and resolve
|
||||
/// the viewer. Full BattleSession is created on connect.
|
||||
/// Sparse pre-connect record: viewer id + the per-battle MatchContext snapshot. Enough to
|
||||
/// validate the incoming WS connect, resolve the viewer, and seed the BattleSession with the
|
||||
/// player-half lifecycle data. Full BattleSession is created on connect.
|
||||
/// </summary>
|
||||
public sealed record PendingBattle(string BattleId, long ViewerId);
|
||||
public sealed record PendingBattle(string BattleId, long ViewerId, MatchContext Context);
|
||||
|
||||
Reference in New Issue
Block a user