Behavior-identical; 231 BattleNode tests green with ZERO test changes. The 10 handler arms no longer switch on BattleType: - 4 Bot arms gate on the new FrameDispatchContext.OpponentIsAckOnly (Other is not IHasHandshakePhase) — the participant property the audit asked for. - 6 relay arms drop the Type == Pvp guard; it was redundant with BothSidesAfterReady() (only a two-real-player session has both handshake phases). Its doc now records that. - FrameDispatchContext.Type removed (+ the Type = Type in BuildContext). BattleSession.Type stays for the session-level drop cascade. Zero test churn because the stubs already encode the split: FakeRealParticipant/ProbeParticipant implement IHasHandshakePhase, the bot stub FakeParticipant doesn't, and NewBotSession uses it as the opponent. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
32 lines
1.5 KiB
C#
32 lines
1.5 KiB
C#
using SVSim.BattleNode.Protocol;
|
|
using SVSim.BattleNode.Protocol.Bodies;
|
|
|
|
namespace SVSim.BattleNode.Sessions.Dispatch.Handlers;
|
|
|
|
internal sealed class TurnEndHandler : IFrameHandler
|
|
{
|
|
public IReadOnlyList<DispatchRoute> Handle(FrameDispatchContext ctx)
|
|
{
|
|
// case 4: Bot — Judge to sender only (no real opponent; client flips back to its local AI).
|
|
if (ctx.OpponentIsAckOnly && ctx.SenderIsAfterReady)
|
|
return new[] { new DispatchRoute(ctx.From, BattleFrames.BuildJudgeBroadcast(), Stock.Normal) };
|
|
|
|
// case 8: general AfterReady arm — PvP forwards a {turnState} TurnEnd to the opponent
|
|
// (handover gate). Any non-Pvp non-Bot type that reaches AfterReady consumes the frame.
|
|
if (ctx.SenderIsAfterReady)
|
|
{
|
|
if (ctx.BothSidesAfterReady())
|
|
{
|
|
// Opponent sees {turnState}; receiving TurnEnd drives ITS SendJudge (handover gate):
|
|
// the opponent (the turn taker-over) then sends a Judge, which JudgeHandler reflects
|
|
// back to it to start its turn. battleCode/actionSeq/cemetery are dropped.
|
|
var te = ctx.Env with { Body = new TurnEndBody(TurnState: TurnState.First) };
|
|
return new[] { new DispatchRoute(ctx.Other, te, Stock.Normal) };
|
|
}
|
|
return Array.Empty<DispatchRoute>(); // Pvp-not-both-ready → drop (Bot already returned above)
|
|
}
|
|
|
|
return Array.Empty<DispatchRoute>();
|
|
}
|
|
}
|