using SVSim.BattleNode.Protocol; namespace SVSim.BattleNode.Sessions.Dispatch.Handlers; internal sealed class TurnEndFinalHandler : IFrameHandler { public IReadOnlyList Handle(FrameDispatchContext ctx) { // case 4: Bot — Judge to sender only. if (ctx.Type == BattleType.Bot && ctx.SenderPhase == BattleSessionPhase.AfterReady) return new[] { new DispatchRoute(ctx.From, BattleFrames.BuildJudgeBroadcast(), false) }; // case 9: general — forward the envelope to other + paired BattleFinish + Terminal. if (ctx.SenderPhase == BattleSessionPhase.AfterReady) { ctx.State.SessionPhase = BattleSessionPhase.Terminal; return new[] { new DispatchRoute(ctx.Other, ctx.Env, false), new DispatchRoute(ctx.From, BattleFrames.BuildBattleFinish(BattleResult.LifeWin), true), new DispatchRoute(ctx.Other, BattleFrames.BuildBattleFinish(BattleResult.LifeLose), true), }; } return Array.Empty(); } }