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:
@@ -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) =>
|
||||
|
||||
@@ -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>();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user