feat(battle-node): JudgeHandler emits {spin:0} to opponent in PvP

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
gamer147
2026-06-03 18:09:44 -04:00
parent 3c8a00c928
commit 58994a53c9
2 changed files with 27 additions and 1 deletions

View File

@@ -1,4 +1,5 @@
using SVSim.BattleNode.Protocol;
using SVSim.BattleNode.Protocol.Bodies;
namespace SVSim.BattleNode.Sessions.Dispatch.Handlers;
@@ -6,9 +7,18 @@ internal sealed class JudgeHandler : IFrameHandler
{
public IReadOnlyList<DispatchRoute> Handle(FrameDispatchContext ctx)
{
// Only a scripted-bot Judge is forwarded. A real player's Judge has no routing rule (drops).
// Scripted-bot Judge (test stub): forward verbatim (carries the {spin} shape already).
if (ctx.IsScriptedBot(ctx.From))
return new[] { new DispatchRoute(ctx.Other, ctx.Env, false) };
// PvP: active player's Judge{battleCode} -> opponent {spin} (RNG catch-up; spin=0 for the
// deterministic-turn slice). Receiving Judge starts the opponent's own turn.
if (ctx.Type == BattleType.Pvp && ctx.BothAfterReady())
{
var frame = ctx.Env with { Body = new JudgeBody(Spin: 0) };
return new[] { new DispatchRoute(ctx.Other, frame, false) };
}
return Array.Empty<DispatchRoute>();
}
}