refactor(battle-node): extract TurnStartHandler

Unions the two legacy TurnStart arms (IsRealForwardableFromScripted case 11 +
BothAfterReady case 12) into TurnStartHandler. Both arms produce (Other, Env, false)
with no extra guards or state mutations — union is behavior-equivalent.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
gamer147
2026-06-03 14:27:17 -04:00
parent c03fb3c139
commit aacd7b56ad
2 changed files with 16 additions and 0 deletions

View File

@@ -44,6 +44,7 @@ public sealed class BattleSession
[NetworkBattleUri.TurnEndFinal] = new TurnEndFinalHandler(),
[NetworkBattleUri.Retire] = new RetireKillHandler(),
[NetworkBattleUri.Kill] = new RetireKillHandler(),
[NetworkBattleUri.TurnStart] = new TurnStartHandler(),
};
private FrameDispatchContext BuildContext(IBattleParticipant from, MsgEnvelope env) =>

View File

@@ -0,0 +1,15 @@
using SVSim.BattleNode.Protocol;
namespace SVSim.BattleNode.Sessions.Dispatch.Handlers;
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))
return new[] { new DispatchRoute(ctx.Other, ctx.Env, false) };
return Array.Empty<DispatchRoute>();
}
}