25 lines
966 B
C#
25 lines
966 B
C#
using SVSim.BattleNode.Protocol;
|
|
using SVSim.BattleNode.Protocol.Bodies;
|
|
|
|
namespace SVSim.BattleNode.Sessions.Dispatch.Handlers;
|
|
|
|
internal sealed class TurnStartHandler : IFrameHandler
|
|
{
|
|
public IReadOnlyList<DispatchRoute> Handle(FrameDispatchContext ctx)
|
|
{
|
|
// 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>();
|
|
}
|
|
}
|