From db2f711894572e74af6f5036bb1078b1246c722b Mon Sep 17 00:00:00 2001 From: gamer147 Date: Wed, 3 Jun 2026 14:30:40 -0400 Subject: [PATCH] refactor(battle-node): extract JudgeHandler Co-Authored-By: Claude Sonnet 4.6 --- SVSim.BattleNode/Sessions/BattleSession.cs | 1 + .../Sessions/Dispatch/Handlers/JudgeHandler.cs | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 SVSim.BattleNode/Sessions/Dispatch/Handlers/JudgeHandler.cs diff --git a/SVSim.BattleNode/Sessions/BattleSession.cs b/SVSim.BattleNode/Sessions/BattleSession.cs index a96f6a4..374714e 100644 --- a/SVSim.BattleNode/Sessions/BattleSession.cs +++ b/SVSim.BattleNode/Sessions/BattleSession.cs @@ -45,6 +45,7 @@ public sealed class BattleSession [NetworkBattleUri.Retire] = new RetireKillHandler(), [NetworkBattleUri.Kill] = new RetireKillHandler(), [NetworkBattleUri.TurnStart] = new TurnStartHandler(), + [NetworkBattleUri.Judge] = new JudgeHandler(), }; private FrameDispatchContext BuildContext(IBattleParticipant from, MsgEnvelope env) => diff --git a/SVSim.BattleNode/Sessions/Dispatch/Handlers/JudgeHandler.cs b/SVSim.BattleNode/Sessions/Dispatch/Handlers/JudgeHandler.cs new file mode 100644 index 0000000..4ba8146 --- /dev/null +++ b/SVSim.BattleNode/Sessions/Dispatch/Handlers/JudgeHandler.cs @@ -0,0 +1,14 @@ +using SVSim.BattleNode.Protocol; + +namespace SVSim.BattleNode.Sessions.Dispatch.Handlers; + +internal sealed class JudgeHandler : IFrameHandler +{ + public IReadOnlyList Handle(FrameDispatchContext ctx) + { + // Only a scripted-bot Judge is forwarded. A real player's Judge has no routing rule (drops). + if (ctx.IsScriptedBot(ctx.From)) + return new[] { new DispatchRoute(ctx.Other, ctx.Env, false) }; + return Array.Empty(); + } +}