feat(battle-node): cross-side gift + Echo-frame token mining
Close the two generated-token gaps that desynced PvP live test #3 (the Forestcraft Fairy), both sourced from the 2026-06-03 decomp-validation table. - MineAddOps now returns (idx, cardId, isSelf) and no longer drops isSelf:0. isSelf is the sender's perspective tag on CardObj.IsPlayer (RegisterToken.cs:22) and a card has one CardObj.Index, so an isSelf:0 add is the opponent's card. - New shared BattleSessionState.RecordTokensFrom routes isSelf:1 -> sender, isSelf:0 -> opponent (the gift lives in the recipient's map, consulted when they play it). PlayActionsHandler delegates to it. - EchoHandler now mines via the same helper but still returns no routes. An Echo's orderList carries the same add-op shape as a send (MakeEchoData -> MakeCommonSendAndEchoCardData), so MineAddOps applies verbatim; mining != relaying. Choice/copy/private-group adds stay skipped (no concrete cardId). Full solution 963/963 green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -42,17 +42,19 @@ internal static class KnownListBuilder
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>Mine generated-token identities from the sender's <c>add</c> ops: yields
|
||||
/// <c>(idx, cardId)</c> for every idx in each <c>{add:{idx:[...], isSelf:1, card:{cardId}}}</c>
|
||||
/// op. Skips <c>isSelf:0</c> adds (cross-side gifts — belong in the other side's map, deferred)
|
||||
/// and any add whose <c>card</c> has no concrete <c>cardId</c> — choice tokens
|
||||
/// (<c>card:{candidates}</c>, <c>RegisterChoiceAdd</c>), copy tokens (<c>card:{baseIdx}</c>,
|
||||
/// <c>RegisterCopyToken</c>), and private-group adds (string <c>idx</c>) — all deferred and all
|
||||
/// caught by the <c>cardId</c>-key / <c>idx</c>-is-list guards. This is the only place a
|
||||
/// freshly-generated card's identity exists on the wire (bullet-3 audit F1; producing code
|
||||
/// <c>RegisterToken</c>/<c>RegisterActionBase</c>) — the played-card op itself never carries a
|
||||
/// <c>cardId</c>.</summary>
|
||||
public static IEnumerable<(int Idx, long CardId)> MineAddOps(object? orderList)
|
||||
/// <summary>Mine generated-token identities from a sender's <c>add</c> ops: yields
|
||||
/// <c>(idx, cardId, isSelf)</c> for every idx in each <c>{add:{idx:[...], isSelf, card:{cardId}}}</c>
|
||||
/// op. <c>isSelf</c> is surfaced verbatim (the sender's perspective tag on <c>CardObj.IsPlayer</c>,
|
||||
/// <c>RegisterToken.cs:22</c>) so the caller can route the identity into the correct side's map —
|
||||
/// <c>isSelf:1</c> = the sender's own token, <c>isSelf:0</c> = a cross-side gift living at this idx
|
||||
/// in the OPPONENT's index space (<see cref="BattleSessionState.RecordTokensFrom"/>). Skips any add
|
||||
/// whose <c>card</c> has no concrete <c>cardId</c> — choice tokens (<c>card:{candidates}</c>,
|
||||
/// <c>RegisterChoiceAdd</c>), copy tokens (<c>card:{baseIdx}</c>, <c>RegisterCopyToken</c>), and
|
||||
/// private-group adds (string <c>idx</c>) — all deferred and all caught by the <c>cardId</c>-key /
|
||||
/// <c>idx</c>-is-list guards. This is the only place a freshly-generated card's identity exists on
|
||||
/// the wire (bullet-3 audit F1; producing code <c>RegisterToken</c>/<c>RegisterActionBase</c>) —
|
||||
/// the played-card op itself never carries a <c>cardId</c>.</summary>
|
||||
public static IEnumerable<(int Idx, long CardId, int IsSelf)> MineAddOps(object? orderList)
|
||||
{
|
||||
if (orderList is not IEnumerable<object?> ops) yield break;
|
||||
foreach (var op in ops)
|
||||
@@ -61,7 +63,7 @@ internal static class KnownListBuilder
|
||||
if (!opDict.TryGetValue("add", out var addRaw) || addRaw is not IDictionary<string, object?> add) continue;
|
||||
|
||||
add.TryGetValue("isSelf", out var isSelfRaw);
|
||||
if (AsLong(isSelfRaw) != 1) continue; // own tokens only; cross-side gifts deferred
|
||||
var isSelf = (int)AsLong(isSelfRaw);
|
||||
|
||||
if (!add.TryGetValue("card", out var cardRaw) || cardRaw is not IDictionary<string, object?> card) continue;
|
||||
if (!card.TryGetValue("cardId", out var cardIdRaw)) continue; // candidates/isChoice → no identity yet
|
||||
@@ -69,7 +71,7 @@ internal static class KnownListBuilder
|
||||
|
||||
if (!add.TryGetValue("idx", out var idxRaw) || idxRaw is not IEnumerable<object?> idxList) continue;
|
||||
foreach (var i in idxList)
|
||||
yield return ((int)AsLong(i), cardId);
|
||||
yield return ((int)AsLong(i), cardId, isSelf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user