feat(battle-node): TurnStartHandler 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:05:15 -04:00
parent 6b580c622d
commit 6e85a6b2db
2 changed files with 15 additions and 4 deletions

View File

@@ -1,4 +1,5 @@
using SVSim.BattleNode.Protocol;
using SVSim.BattleNode.Protocol.Bodies;
namespace SVSim.BattleNode.Sessions.Dispatch.Handlers;
@@ -6,10 +7,18 @@ internal sealed class TurnStartHandler : IFrameHandler
{
public IReadOnlyList<DispatchRoute> Handle(FrameDispatchContext ctx)
{
// Forward the opponent's turn-open to the other side. Union of the two legacy arms:
// BothAfterReady (PvP / scripted real player) OR a scripted-bot emission (test stub path).
if (ctx.BothAfterReady() || ctx.IsScriptedBot(ctx.From))
// PvP: the active player's TurnStart{orderList} is dropped; the opponent receives {spin}
// (spin=0 for the deterministic-turn slice) and self-generates its turn-open.
if (ctx.Type == BattleType.Pvp && ctx.BothAfterReady())
{
var frame = ctx.Env with { Body = new OpponentTurnStartBody(Spin: 0) };
return new[] { new DispatchRoute(ctx.Other, frame, false) };
}
// Scripted-bot emission (test stub path): the bot already emits the {spin} shape — forward.
if (ctx.IsScriptedBot(ctx.From))
return new[] { new DispatchRoute(ctx.Other, ctx.Env, false) };
return Array.Empty<DispatchRoute>();
}
}