Quality pass from the 2026-06-04 BattleNode review (audit in the outer
repo). All changes are behavior-preserving — identical wire bytes,
verified by the full 1008-test suite staying green.
- Name scattered magic numbers: crypto key/IV lengths, outbound-sequencer
base, WS receive buffer / EIO ping / SID length, polite-close timeout,
upgrade-credential keys, battle-id digit math, deterministic-turn spin.
- resultCode = 1 -> (int)ReceiveNodeResultCode.Success across body records.
- Pong "3" -> EngineIoPacketType.Pong; remove dead NoOpBotParticipant.Touch
(replace with #pragma warning disable CS0067).
- Wire-flag enums, serialized as numbers via JsonNumberEnumConverter:
turnState -> TurnState{First,Second}, isSelf -> CardOwner{Opponent,Self},
open -> ChoiceVisibility{Hidden,Open}.
- isOfficial / isInvoke -> bool / bool? via new NumericBoolJsonConverter
(reads/writes 0/1; TDD'd). Scoped to the BattleNode wire boundary only;
MatchContext and the HTTP/AI-start path stay int (AI-start uses -1 as a
sentinel, so it is not boolean).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
39 lines
1.8 KiB
C#
39 lines
1.8 KiB
C#
using SVSim.BattleNode.Bridge;
|
|
using SVSim.BattleNode.Lifecycle;
|
|
using SVSim.BattleNode.Protocol;
|
|
|
|
namespace SVSim.BattleNode.Sessions.Participants;
|
|
|
|
/// <summary>
|
|
/// Silent participant — produces no frames, swallows everything pushed to it.
|
|
/// Used as the "other" participant in <see cref="BattleType.Bot"/> sessions, where
|
|
/// the real opponent runs in the client and the server has no opponent-side state
|
|
/// to model. ViewerId is <see cref="ServerBattleFrames.FakeOpponentViewerId"/>;
|
|
/// Context is a fixed stub (irrelevant — never read because no frames are pushed
|
|
/// to the other side).
|
|
/// </summary>
|
|
public sealed class NoOpBotParticipant : IBattleParticipant
|
|
{
|
|
/// <summary>Stub card-master id stamped on the bot's (never-read) MatchContext.</summary>
|
|
private const string BotCardMasterName = "card_master_node_10015";
|
|
|
|
public long ViewerId => ServerBattleFrames.FakeOpponentViewerId;
|
|
public MatchContext Context { get; } = new(
|
|
SelfDeckCardIds: Array.Empty<long>(),
|
|
ClassId: "0", CharaId: "0", CardMasterName: BotCardMasterName,
|
|
CountryCode: "", UserName: "Bot", SleeveId: "0",
|
|
EmblemId: "0", DegreeId: "0", FieldId: 0, IsOfficial: 0,
|
|
BattleType: 0);
|
|
|
|
// Required by IBattleParticipant, but a silent bot never raises it — suppress the
|
|
// "event is never used" warning rather than keeping a dead null-emitting method.
|
|
#pragma warning disable CS0067
|
|
public event Func<MsgEnvelope, CancellationToken, Task>? FrameEmitted;
|
|
#pragma warning restore CS0067
|
|
|
|
public Task PushAsync(MsgEnvelope envelope, bool noStock, CancellationToken ct) => Task.CompletedTask;
|
|
public Task RunAsync(CancellationToken ct) => Task.CompletedTask;
|
|
public Task TerminateAsync(BattleFinishReason reason) => Task.CompletedTask;
|
|
public ValueTask DisposeAsync() => ValueTask.CompletedTask;
|
|
}
|