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:
@@ -21,7 +21,7 @@ public class BattleSessionDispatchTests
|
||||
var routes = s.ComputeFrames(a, NewEnvelope(NetworkBattleUri.Loaded));
|
||||
|
||||
var bs = (BattleStartBody)routes[0].Frame.Body;
|
||||
Assert.That(bs.TurnState, Is.EqualTo(0), "A (first arriver) goes first.");
|
||||
Assert.That(bs.TurnState, Is.EqualTo(TurnState.First), "A (first arriver) goes first.");
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -33,7 +33,7 @@ public class BattleSessionDispatchTests
|
||||
var routes = s.ComputeFrames(b, NewEnvelope(NetworkBattleUri.Loaded));
|
||||
|
||||
var bs = (BattleStartBody)routes[0].Frame.Body;
|
||||
Assert.That(bs.TurnState, Is.EqualTo(1), "B (second arriver) goes second.");
|
||||
Assert.That(bs.TurnState, Is.EqualTo(TurnState.Second), "B (second arriver) goes second.");
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -281,7 +281,7 @@ public class BattleSessionDispatchTests
|
||||
|
||||
Assert.That(pb.OppoTargetList!.Count, Is.EqualTo(1));
|
||||
Assert.That(pb.OppoTargetList[0].TargetIdx, Is.EqualTo(8));
|
||||
Assert.That(pb.OppoTargetList[0].IsSelf, Is.EqualTo(0));
|
||||
Assert.That(pb.OppoTargetList[0].IsSelf, Is.EqualTo(CardOwner.Opponent));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -316,7 +316,7 @@ public class BattleSessionDispatchTests
|
||||
Assert.That(pb.UList[0].IdxList, Is.EqualTo(new[] { 16, 22 }));
|
||||
Assert.That(pb.UList[0].From, Is.EqualTo(0));
|
||||
Assert.That(pb.UList[0].To, Is.EqualTo(10));
|
||||
Assert.That(pb.UList[0].IsSelf, Is.EqualTo(1));
|
||||
Assert.That(pb.UList[0].IsSelf, Is.EqualTo(CardOwner.Self));
|
||||
Assert.That(pb.UList[0].Skill, Is.EqualTo("37|36|0"));
|
||||
}
|
||||
|
||||
@@ -807,7 +807,7 @@ public class BattleSessionDispatchTests
|
||||
Assert.That(routes[0].Target, Is.SameAs(b));
|
||||
Assert.That(routes[0].Frame.Uri, Is.EqualTo(NetworkBattleUri.TurnEnd));
|
||||
var body = (SVSim.BattleNode.Protocol.Bodies.TurnEndBody)routes[0].Frame.Body;
|
||||
Assert.That(body.TurnState, Is.EqualTo(0));
|
||||
Assert.That(body.TurnState, Is.EqualTo(TurnState.First));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
Reference in New Issue
Block a user