Files
SVSimServer/SVSim.BattleNode/Lifecycle/BattleFrameDefaults.cs
gamer147 24180d5b4b 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>
2026-06-04 20:46:09 -04:00

35 lines
1.8 KiB
C#

namespace SVSim.BattleNode.Lifecycle;
/// <summary>
/// Default frame constants templated from TK2 prod captures, shared by the
/// server-authored battle-frame builders. Every value here originated in a real prod
/// frame in <c>data_dumps/captures/battle-traffic_tk2_regular.ndjson</c>; pulling them
/// out of <see cref="ServerBattleFrames"/> makes the magic numerics navigable. The shared effect
/// seed and the deck-shuffle/idxChangeSeed are now derived per-battle from a master seed (see
/// <see cref="BattleSeeds"/>) — only animation/UI constants remain here.
/// </summary>
internal static class BattleFrameDefaults
{
// From frame[5] (BattleStart). Hardcoded; see spec §Deferred plumbing — sourcing these
// from real per-viewer state needs a TK2 rank/battle-point tracker.
public const string PlayerRank = "10";
public const string PlayerBattlePoint = "6270";
// From frame[8] (Ready). Provenance is "what prod sent"; the client doesn't validate. This is
// an animation crank value (shared-RNG spin), NOT gameplay randomness — both clients crank it
// identically and stay synced, so it stays a constant. See the spin-rng audit.
public const int ReadySpin = 243;
/// <summary>
/// Server-pushed Judge frame spin value. Prod varies per push (55, 175, 73, ...) — it's
/// an animation seed, not a stateful value. Fixed at 100 here for test stability;
/// the client's <c>JudgeOperation</c> doesn't read it.
/// </summary>
public const int OpponentJudgeSpin = 100;
/// <summary>Spin value the PvP relay stamps on the Judge / OpponentTurnStart handover frames
/// in the deterministic-turn slice. 0 = no animation seed; per-turn spin is deferred
/// (see the real-spin design). The client self-generates its turn-open and doesn't read it.</summary>
public const int DeterministicTurnSpin = 0;
}