refactor(battlenode): split BattleSessionPhase into HandshakePhase + SessionLifecycle
Behavior-preserving; 231 BattleNode tests green. One enum conflated two axes. Split: - HandshakePhase (per participant): AwaitingInitNetwork..AfterReady. On IHasHandshakePhase.Phase, FrameDispatchContext.SenderPhase, the handler gates. - SessionLifecycle (per battle): Active | Terminal. On the renamed BattleSessionState.Lifecycle (was SessionPhase, defaulting to a handshake value) and BattleSession.Lifecycle (was Phase). Reads are only != Terminal, so the Active default is behavior-identical. OpponentTurn was dead (never assigned) -> dropped. BattleSessionPhase deleted; the two axes can no longer be cross-assigned. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -8,18 +8,18 @@ internal sealed class InitBattleHandler : IFrameHandler
|
||||
public IReadOnlyList<DispatchRoute> Handle(FrameDispatchContext ctx)
|
||||
{
|
||||
// case 2: Bot — ack only, NO Matched (Matched would corrupt client opponent info).
|
||||
if (ctx.Type == BattleType.Bot && ctx.SenderPhase == BattleSessionPhase.AwaitingInitBattle)
|
||||
if (ctx.Type == BattleType.Bot && ctx.SenderPhase == HandshakePhase.AwaitingInitBattle)
|
||||
{
|
||||
var r = new List<DispatchRoute>
|
||||
{
|
||||
new(ctx.From, BattleFrames.BuildAck(NetworkBattleUri.InitBattle), Stock.Bypass),
|
||||
};
|
||||
ctx.SenderPhase = BattleSessionPhase.AwaitingLoaded;
|
||||
ctx.SenderPhase = HandshakePhase.AwaitingLoaded;
|
||||
return r;
|
||||
}
|
||||
|
||||
// case 5: general — push Matched (per-perspective) to the sender only.
|
||||
if (ctx.SenderPhase == BattleSessionPhase.AwaitingInitBattle)
|
||||
if (ctx.SenderPhase == HandshakePhase.AwaitingInitBattle)
|
||||
{
|
||||
var r = new List<DispatchRoute>
|
||||
{
|
||||
@@ -28,7 +28,7 @@ internal sealed class InitBattleHandler : IFrameHandler
|
||||
ctx.BattleId, BattleSeeds.Stable(ctx.State.MasterSeed),
|
||||
ctx.State.GetShuffledDeck(ctx.From)), Stock.Normal),
|
||||
};
|
||||
ctx.SenderPhase = BattleSessionPhase.AwaitingLoaded;
|
||||
ctx.SenderPhase = HandshakePhase.AwaitingLoaded;
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user