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(), Stock.Normal) }; // 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, Stock.Normal), new DispatchRoute(ctx.From, BattleFrames.BuildBattleFinish(BattleResult.LifeWin), Stock.Bypass), new DispatchRoute(ctx.Other, BattleFrames.BuildBattleFinish(BattleResult.LifeLose), Stock.Bypass), }; } return Array.Empty(); } }