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:
@@ -1,4 +1,5 @@
|
||||
using NUnit.Framework;
|
||||
using SVSim.BattleNode.Protocol;
|
||||
using SVSim.BattleNode.Protocol.Bodies;
|
||||
using SVSim.BattleNode.Sessions.Dispatch;
|
||||
|
||||
@@ -103,7 +104,7 @@ public class KnownListBuilderTests
|
||||
Assert.That(renamed, Is.Not.Null);
|
||||
Assert.That(renamed!.Count, Is.EqualTo(1));
|
||||
Assert.That(renamed[0].TargetIdx, Is.EqualTo(8));
|
||||
Assert.That(renamed[0].IsSelf, Is.EqualTo(0));
|
||||
Assert.That(renamed[0].IsSelf, Is.EqualTo(CardOwner.Opponent));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -316,7 +317,7 @@ public class KnownListBuilderTests
|
||||
|
||||
Assert.That(stripped![0].SelectCard, Is.Not.Null);
|
||||
Assert.That(stripped[0].SelectCard!.CardId, Is.EqualTo(new[] { 810041260L }));
|
||||
Assert.That(stripped[0].SelectCard.Open, Is.EqualTo(1));
|
||||
Assert.That(stripped[0].SelectCard.Open, Is.EqualTo(ChoiceVisibility.Open));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -447,7 +448,7 @@ public class KnownListBuilderTests
|
||||
Assert.That(e.IdxList, Is.EqualTo(new[] { 16, 22 }));
|
||||
Assert.That(e.From, Is.EqualTo(0));
|
||||
Assert.That(e.To, Is.EqualTo(10));
|
||||
Assert.That(e.IsSelf, Is.EqualTo(1));
|
||||
Assert.That(e.IsSelf, Is.EqualTo(CardOwner.Self));
|
||||
Assert.That(e.Skill, Is.EqualTo("37|36|0"));
|
||||
Assert.That(e.CardId, Is.Null);
|
||||
Assert.That(e.Clan, Is.Null);
|
||||
@@ -479,7 +480,7 @@ public class KnownListBuilderTests
|
||||
Assert.That(e.Cost, Is.EqualTo(2));
|
||||
Assert.That(e.SkillKeyCardIdx, Is.EqualTo(new[] { 7 }));
|
||||
Assert.That(e.RandomTargetIdx, Is.EqualTo(new[] { 2, 3 }));
|
||||
Assert.That(e.IsInvoke, Is.EqualTo(1));
|
||||
Assert.That(e.IsInvoke, Is.True);
|
||||
Assert.That(e.AttachTarget, Is.EqualTo("12,13"));
|
||||
}
|
||||
|
||||
@@ -496,7 +497,7 @@ public class KnownListBuilderTests
|
||||
Assert.That(relayed!.Count, Is.EqualTo(2));
|
||||
Assert.That(relayed[0].Skill, Is.EqualTo("a"));
|
||||
Assert.That(relayed[1].Skill, Is.EqualTo("b"));
|
||||
Assert.That(relayed[1].IsSelf, Is.EqualTo(0));
|
||||
Assert.That(relayed[1].IsSelf, Is.EqualTo(CardOwner.Opponent));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
Reference in New Issue
Block a user