The IsScriptedBot(ctx.From) forwards in JudgeHandler/TurnStartHandler/TurnEndHandler and the 'if Type==Scripted' raw-forward only ever fired for ScriptedBotParticipant emissions; NoOpBot (Bot mode) never emits, so they are dead. Routing is now purely PvP-vs-Bot. Drops the IsScriptedBot helper. 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.Type == BattleType.Bot && ctx.SenderPhase == BattleSessionPhase.AfterReady)
|
|
return new[] { new DispatchRoute(ctx.From, BattleFrames.BuildJudgeBroadcast(), false) };
|
|
|
|
// 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.SenderPhase == BattleSessionPhase.AfterReady)
|
|
{
|
|
if (ctx.Type == BattleType.Pvp && ctx.BothAfterReady())
|
|
{
|
|
// 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: 0) };
|
|
return new[] { new DispatchRoute(ctx.Other, te, false) };
|
|
}
|
|
return Array.Empty<DispatchRoute>(); // Pvp-not-both-ready → drop (Bot already returned above)
|
|
}
|
|
|
|
return Array.Empty<DispatchRoute>();
|
|
}
|
|
}
|