refactor(battle-node): extract RetireKillHandler
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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) =>
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
using SVSim.BattleNode.Protocol;
|
||||
|
||||
namespace SVSim.BattleNode.Sessions.Dispatch.Handlers;
|
||||
|
||||
internal sealed class RetireKillHandler : IFrameHandler
|
||||
{
|
||||
public IReadOnlyList<DispatchRoute> 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),
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user