Files
SVSimServer/SVSim.BattleNode/Sessions/Dispatch/Handlers/LoadedHandler.cs
gamer147 ba18790156 refactor(battle-node): rename ScriptedLifecycle->ServerBattleFrames, ScriptedProfiles->BattleFrameDefaults
Pure rename. These hold the shared server-authored frame builders used by every
battle mode's handshake/mulligan dispatch — the 'Scripted' name was a historical
accident that hid the PvP/Bot crossover. No behavior change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-03 20:36:32 -04:00

35 lines
1.3 KiB
C#

using SVSim.BattleNode.Lifecycle;
using SVSim.BattleNode.Protocol;
namespace SVSim.BattleNode.Sessions.Dispatch.Handlers;
internal sealed class LoadedHandler : IFrameHandler
{
public IReadOnlyList<DispatchRoute> Handle(FrameDispatchContext ctx)
{
// case 3: Bot — silent (client populates opponent state from AIBattleStart HTTP data).
if (ctx.Type == BattleType.Bot && ctx.SenderPhase == BattleSessionPhase.AwaitingLoaded)
{
ctx.SenderPhase = BattleSessionPhase.AwaitingSwap;
return Array.Empty<DispatchRoute>();
}
// case 6: general — BattleStart (per-perspective) + Deal to the sender.
if (ctx.SenderPhase == BattleSessionPhase.AwaitingLoaded)
{
// A goes first deterministically (turnState 0); B goes second (turnState 1).
var turnState = ReferenceEquals(ctx.From, ctx.A) ? 0 : 1;
var r = new List<DispatchRoute>
{
new(ctx.From, ServerBattleFrames.BuildBattleStart(
ctx.From.Context, ctx.Other.Context, ctx.From.ViewerId, turnState), false),
new(ctx.From, ServerBattleFrames.BuildDeal(), false),
};
ctx.SenderPhase = BattleSessionPhase.AwaitingSwap;
return r;
}
return Array.Empty<DispatchRoute>();
}
}