refactor(battlenode): centralize inbound wire-key literals in WireKeys (§C)
Behavior-preserving; 231 BattleNode tests green (capture-conformance suite drives
real prod frames, so a wrong constant would fail).
New Sessions/Dispatch/WireKeys.cs holds the 28 inbound-body read keys (orderList /
keyAction / targetList / uList field names). KnownListBuilder, PlayActionsHandler,
EchoHandler, and BattleFrames.ExtractIdxList now read through it instead of repeated
inline strings, so a parse-side typo ("isSelf" vs "IsSelf") can no longer silently
degrade token resolution. Outbound [JsonPropertyName] attributes left as-is (already
single-source per DTO).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -15,7 +15,7 @@ internal sealed class EchoHandler : IFrameHandler
|
||||
{
|
||||
if (ctx.Type == BattleType.Pvp && ctx.BothAfterReady())
|
||||
{
|
||||
var orderList = (ctx.Env.Body as RawBody)?.Entries.GetValueOrDefault("orderList");
|
||||
var orderList = (ctx.Env.Body as RawBody)?.Entries.GetValueOrDefault(WireKeys.OrderList);
|
||||
ctx.State.RecordTokensFrom(ctx.From, ctx.Other, orderList);
|
||||
// Copy tokens ride Echo too (same add-op shape); resolve baseIdx against the side's map.
|
||||
ctx.State.RecordCopyTokensFrom(ctx.From, ctx.Other, orderList);
|
||||
|
||||
@@ -18,11 +18,11 @@ internal sealed class PlayActionsHandler : IFrameHandler
|
||||
return Array.Empty<DispatchRoute>();
|
||||
|
||||
var entries = (ctx.Env.Body as RawBody)?.Entries ?? new Dictionary<string, object?>();
|
||||
var playIdx = (int)KnownListBuilder.AsLong(entries.GetValueOrDefault("playIdx"));
|
||||
var type = (int)KnownListBuilder.AsLong(entries.GetValueOrDefault("type"));
|
||||
var playIdx = (int)KnownListBuilder.AsLong(entries.GetValueOrDefault(WireKeys.PlayIdx));
|
||||
var type = (int)KnownListBuilder.AsLong(entries.GetValueOrDefault(WireKeys.Type));
|
||||
|
||||
var orderList = entries.GetValueOrDefault("orderList");
|
||||
var keyAction = entries.GetValueOrDefault("keyAction");
|
||||
var orderList = entries.GetValueOrDefault(WireKeys.OrderList);
|
||||
var keyAction = entries.GetValueOrDefault(WireKeys.KeyAction);
|
||||
|
||||
// Mine generated-token identities from this frame's add ops into the right side's idx->cardId
|
||||
// map (isSelf:1 → sender; isSelf:0 → opponent, a cross-side gift), so a token played in a LATER
|
||||
@@ -40,13 +40,13 @@ internal sealed class PlayActionsHandler : IFrameHandler
|
||||
|
||||
var deckMap = ctx.State.GetOrSeedDeckMap(ctx.From);
|
||||
var played = KnownListBuilder.BuildPlayedCard(deckMap, playIdx, orderList);
|
||||
var oppoTargets = KnownListBuilder.RenameTargets(entries.GetValueOrDefault("targetList"));
|
||||
var oppoTargets = KnownListBuilder.RenameTargets(entries.GetValueOrDefault(WireKeys.TargetList));
|
||||
|
||||
// Deck-sourced movements (fetch / search / summon-from-deck) ride the uList — a verbatim,
|
||||
// separate receive slot the node forwards unchanged (bullet-3 audit F1). The node makes no
|
||||
// reveal decision; cardId presence is the sender's call. Coexists with the synthesized
|
||||
// knownList in the same frame (capture line 75).
|
||||
var uList = KnownListBuilder.RelayUList(entries.GetValueOrDefault("uList"));
|
||||
var uList = KnownListBuilder.RelayUList(entries.GetValueOrDefault(WireKeys.UList));
|
||||
|
||||
var body = new PlayActionsBroadcastBody(
|
||||
PlayIdx: playIdx,
|
||||
|
||||
Reference in New Issue
Block a user