The IsScriptedBot(ctx.From) forwards in JudgeHandler/TurnStartHandler/TurnEndHandler and the 'if Type==Scripted' raw-forward only ever fired for ScriptedBotParticipant emissions; NoOpBot (Bot mode) never emits, so they are dead. Routing is now purely PvP-vs-Bot. Drops the IsScriptedBot helper. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
36 lines
1.8 KiB
C#
36 lines
1.8 KiB
C#
using SVSim.BattleNode.Lifecycle;
|
|
using SVSim.BattleNode.Protocol;
|
|
using SVSim.BattleNode.Sessions.Participants; // IHasHandshakePhase
|
|
|
|
namespace SVSim.BattleNode.Sessions.Dispatch;
|
|
|
|
/// <summary>Everything a handler reads or mutates for one inbound frame. <see cref="A"/>/<see cref="B"/>
|
|
/// are the session's positional participants (preserved so handlers that iterate participants in a
|
|
/// stable order — e.g. the mulligan barrier — match the legacy switch byte-for-byte). <see cref="From"/>
|
|
/// is the sender; <see cref="Other"/> is the non-sender.</summary>
|
|
internal sealed class FrameDispatchContext
|
|
{
|
|
internal required IBattleParticipant A { get; init; }
|
|
internal required IBattleParticipant B { get; init; }
|
|
internal required IBattleParticipant From { get; init; }
|
|
internal required IBattleParticipant Other { get; init; }
|
|
internal required MsgEnvelope Env { get; init; }
|
|
internal required BattleType Type { get; init; }
|
|
internal required string BattleId { get; init; }
|
|
internal required BattleSessionState State { get; init; }
|
|
|
|
/// <summary>Sender's per-side handshake phase (null for a non-IHasHandshakePhase participant,
|
|
/// e.g. NoOpBot or the dispatch-test scripted-bot stub). Setting it advances the sender.</summary>
|
|
internal BattleSessionPhase? SenderPhase
|
|
{
|
|
get => (From as IHasHandshakePhase)?.Phase;
|
|
set { if (From is IHasHandshakePhase p && value is { } v) p.Phase = v; }
|
|
}
|
|
|
|
/// <summary>Both participants have completed the handshake. Reads A/B (not From/Other) so the
|
|
/// result is identical regardless of which side sent the frame — matches legacy BothAfterReady.</summary>
|
|
internal bool BothAfterReady() =>
|
|
(A as IHasHandshakePhase)?.Phase == BattleSessionPhase.AfterReady &&
|
|
(B as IHasHandshakePhase)?.Phase == BattleSessionPhase.AfterReady;
|
|
}
|