refactor(battle-node): de-magic wire flags and scattered constants
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>
This commit is contained in:
@@ -32,7 +32,8 @@ public sealed record KeyActionEntry(
|
||||
/// Only emitted for the open:1 pass-through case (open:0 strips the whole <c>selectCard</c>).</summary>
|
||||
public sealed record SelectCardEntry(
|
||||
[property: JsonPropertyName("cardId")] IReadOnlyList<long> CardId,
|
||||
[property: JsonPropertyName("open")] int Open);
|
||||
[property: JsonPropertyName("open")]
|
||||
[property: JsonConverter(typeof(JsonNumberEnumConverter<ChoiceVisibility>))] ChoiceVisibility Open);
|
||||
|
||||
/// <summary>One revealed card in a <c>knownList</c>. Vanilla slice fills cardId from the sender's
|
||||
/// deck map and leaves spellboost 0 / attachTarget "" (cost/clan/tribe deferred to the card-master
|
||||
@@ -48,7 +49,8 @@ public sealed record KnownCardEntry(
|
||||
/// verbatim — no perspective flip (bullet-3 audit F2).</summary>
|
||||
public sealed record OppoTargetEntry(
|
||||
[property: JsonPropertyName("targetIdx")] int TargetIdx,
|
||||
[property: JsonPropertyName("isSelf")] int IsSelf);
|
||||
[property: JsonPropertyName("isSelf")]
|
||||
[property: JsonConverter(typeof(JsonNumberEnumConverter<CardOwner>))] CardOwner IsSelf);
|
||||
|
||||
/// <summary>One entry in a relayed <c>uList</c> (the unapproved-movement list) — a skill-driven
|
||||
/// card movement (fetch / search / summon-from-deck / discard-reveal) the node forwards VERBATIM
|
||||
@@ -60,12 +62,14 @@ public sealed record UnapprovedCardEntry(
|
||||
[property: JsonPropertyName("idxList")] IReadOnlyList<int> IdxList,
|
||||
[property: JsonPropertyName("from")] int From,
|
||||
[property: JsonPropertyName("to")] int To,
|
||||
[property: JsonPropertyName("isSelf")] int IsSelf,
|
||||
[property: JsonPropertyName("isSelf")]
|
||||
[property: JsonConverter(typeof(JsonNumberEnumConverter<CardOwner>))] CardOwner IsSelf,
|
||||
[property: JsonPropertyName("skill")] string Skill,
|
||||
[property: JsonPropertyName("cardId")] long? CardId = null,
|
||||
[property: JsonPropertyName("clan")] int? Clan = null,
|
||||
[property: JsonPropertyName("cost")] int? Cost = null,
|
||||
[property: JsonPropertyName("skillKeyCardIdx")] IReadOnlyList<int>? SkillKeyCardIdx = null,
|
||||
[property: JsonPropertyName("randomTargetIdx")] IReadOnlyList<int>? RandomTargetIdx = null,
|
||||
[property: JsonPropertyName("isInvoke")] int? IsInvoke = null,
|
||||
[property: JsonPropertyName("isInvoke")]
|
||||
[property: JsonConverter(typeof(NumericBoolJsonConverter))] bool? IsInvoke = null,
|
||||
[property: JsonPropertyName("attachTarget")] string? AttachTarget = null);
|
||||
|
||||
Reference in New Issue
Block a user