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), + }; + } +}