fix(battlenode): emit real spellboost count in played-card knownList

The node hardcoded knownList.spellboost=0 on every played card. Prod sends
the true accumulated count, which the client reads straight into the card's
cost model; with 0 the opponent computes the card at full price and silently
rejects the play in OperateReceiveChecker.IsPlayCard (PP-over -> ConductError
-> NullOperationCollection -> no render/echo), desyncing the board.

Mine spellboost-count changes from the sender''s orderList alter ops
(MineAlterSpellboosts: a/s/h ops), accumulate per-side idx->count in
BattleSessionState (RecordSpellboostFrom), and surface the current count on
the played card via BuildPlayedCard. Recorded from the authoritative
PlayActions only (never the Echo) and folded in AFTER the played card is
built, since a card''s cost is fixed as it leaves hand and a play that grants
spellboost targets the rest of the hand.

Also adds a [sio-in-body] full-body inbound log to RealParticipant to capture
both clients'' re-simulated responses for PvP RNG verification.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
gamer147
2026-06-05 13:51:40 -04:00
parent 2d32051cc0
commit 13f902ce58
7 changed files with 211 additions and 5 deletions

View File

@@ -104,6 +104,48 @@ internal sealed class BattleSessionState
RecordToken(isSelf == CardOwner.Self ? from : other, idx, cardId);
}
/// <summary>Per-side idx-&gt;spellboost COUNT, accumulated from <c>orderList</c> <c>alter</c> ops via
/// <see cref="RecordSpellboostFrom"/>. Separate from <see cref="IdxToCardId"/> because spellboost is a
/// mutable counter, not an identity. Surfaced by <c>BuildPlayedCard</c> as the played card's
/// <c>knownList.spellboost</c> so the opponent computes its discounted cost (see that method).</summary>
public Dictionary<IBattleParticipant, Dictionary<int, int>> IdxToSpellboost { get; } = new();
private Dictionary<int, int> SpellboostMap(IBattleParticipant side)
{
if (!IdxToSpellboost.TryGetValue(side, out var map))
IdxToSpellboost[side] = map = new Dictionary<int, int>();
return map;
}
/// <summary>The side's idx-&gt;spellboost map (empty if nothing recorded yet). Read by
/// <c>PlayActionsHandler</c> to feed <c>BuildPlayedCard</c>.</summary>
public IReadOnlyDictionary<int, int> GetSpellboostMap(IBattleParticipant side) => SpellboostMap(side);
/// <summary>Apply a frame's spellboost <c>alter</c> ops to the per-side maps. Routed by <c>isSelf</c>
/// (the sender's perspective) exactly like <see cref="RecordTokensFrom"/>: <c>isSelf:1</c> → the
/// sender's own hand (<paramref name="from"/>); <c>isSelf:0</c> → the opponent's hand
/// (<paramref name="other"/>) for the rare cross-side spellboost. Ops: <c>'a'</c> add, <c>'s'</c> set,
/// <c>'h'</c> half. Call this AFTER <c>BuildPlayedCard</c> for the same frame: a card's cost is fixed
/// when it leaves hand, so the played card's emitted count must reflect state BEFORE this frame's
/// grant (Fate's Hand plays, then spellboosts the rest of the hand). Recorded only from the
/// authoritative PlayActions, never the Echo, to avoid double-counting the same alter.
/// Known gap: a card bounced back to hand keeps its stale count (no reset on zone-exit) — not yet
/// observed in capture, left for when a bounce desync actually shows up.</summary>
public void RecordSpellboostFrom(IBattleParticipant from, IBattleParticipant other, object? orderList)
{
foreach (var (idx, isSelf, op, amount) in KnownListBuilder.MineAlterSpellboosts(orderList))
{
var map = SpellboostMap(isSelf == CardOwner.Self ? from : other);
map.TryGetValue(idx, out var cur);
map[idx] = op switch
{
's' => amount, // set
'h' => cur / 2, // half
_ => cur + amount, // 'a' add (the only form seen in capture)
};
}
}
/// <summary>Mine + record copy/clone-token identities (<see cref="KnownListBuilder.MineCopyTokens"/>)
/// into the correct side's map. A copy's source lives at <c>baseIdx</c> in the actor's own index
/// space, so the resolution side == the record side, both selected by the same <c>isSelf</c> routing