feat(battle-node): TurnEndActionsHandler emits empty body to opponent in PvP

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
gamer147
2026-06-03 18:11:41 -04:00
parent 58994a53c9
commit f9c671c089
3 changed files with 25 additions and 3 deletions

View File

@@ -51,7 +51,7 @@ public sealed class BattleSession
[NetworkBattleUri.Judge] = new JudgeHandler(),
[NetworkBattleUri.PlayActions] = new PlayActionsHandler(),
[NetworkBattleUri.Echo] = new EchoHandler(),
[NetworkBattleUri.TurnEndActions] = forwardWhenReady,
[NetworkBattleUri.TurnEndActions] = new TurnEndActionsHandler(),
[NetworkBattleUri.JudgeResult] = forwardWhenReady,
};
}

View File

@@ -0,0 +1,19 @@
using SVSim.BattleNode.Protocol;
namespace SVSim.BattleNode.Sessions.Dispatch.Handlers;
/// <summary>PvP TurnEndActions: the sender's orderList is dropped; the opponent receives an
/// empty body (it only flips _sendEcho + runs the opponent's end-of-turn triggers via the
/// opponent's own engine). Scripted/Bot drop.</summary>
internal sealed class TurnEndActionsHandler : IFrameHandler
{
public IReadOnlyList<DispatchRoute> Handle(FrameDispatchContext ctx)
{
if (ctx.Type == BattleType.Pvp && ctx.BothAfterReady())
{
var frame = ctx.Env with { Body = new RawBody(new Dictionary<string, object?>()) };
return new[] { new DispatchRoute(ctx.Other, frame, false) };
}
return Array.Empty<DispatchRoute>();
}
}