From c03fb3c139c628dde51ce0617af93af4de49920c Mon Sep 17 00:00:00 2001 From: gamer147 Date: Wed, 3 Jun 2026 14:24:35 -0400 Subject: [PATCH] refactor(battle-node): extract RetireKillHandler Co-Authored-By: Claude Sonnet 4.6 --- SVSim.BattleNode/Sessions/BattleSession.cs | 2 ++ .../Dispatch/Handlers/RetireKillHandler.cs | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 SVSim.BattleNode/Sessions/Dispatch/Handlers/RetireKillHandler.cs diff --git a/SVSim.BattleNode/Sessions/BattleSession.cs b/SVSim.BattleNode/Sessions/BattleSession.cs index 16c5932..d503b23 100644 --- a/SVSim.BattleNode/Sessions/BattleSession.cs +++ b/SVSim.BattleNode/Sessions/BattleSession.cs @@ -42,6 +42,8 @@ public sealed class BattleSession [NetworkBattleUri.Swap] = new SwapHandler(), [NetworkBattleUri.TurnEnd] = new TurnEndHandler(), [NetworkBattleUri.TurnEndFinal] = new TurnEndFinalHandler(), + [NetworkBattleUri.Retire] = new RetireKillHandler(), + [NetworkBattleUri.Kill] = new RetireKillHandler(), }; private FrameDispatchContext BuildContext(IBattleParticipant from, MsgEnvelope env) => diff --git a/SVSim.BattleNode/Sessions/Dispatch/Handlers/RetireKillHandler.cs b/SVSim.BattleNode/Sessions/Dispatch/Handlers/RetireKillHandler.cs new file mode 100644 index 0000000..b056d88 --- /dev/null +++ b/SVSim.BattleNode/Sessions/Dispatch/Handlers/RetireKillHandler.cs @@ -0,0 +1,16 @@ +using SVSim.BattleNode.Protocol; + +namespace SVSim.BattleNode.Sessions.Dispatch.Handlers; + +internal sealed class RetireKillHandler : IFrameHandler +{ + public IReadOnlyList Handle(FrameDispatchContext ctx) + { + ctx.State.SessionPhase = BattleSessionPhase.Terminal; + return new[] + { + new DispatchRoute(ctx.From, BattleFrames.BuildBattleFinish(BattleResult.RetireLose), true), + new DispatchRoute(ctx.Other, BattleFrames.BuildBattleFinish(BattleResult.RetireWin), true), + }; + } +}