feat(battle-node): reveal generated tokens on play via remembered identity
PlayActionsHandler mines add ops into BattleSessionState.RecordToken each frame; a token played in a later frame now synthesizes a knownList from the remembered cardId instead of degrading. Bullet-3 audit F1. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -4,15 +4,17 @@ namespace SVSim.BattleNode.Sessions.Dispatch;
|
||||
|
||||
/// <summary>Mutable per-session state shared across frame handlers. The mulligan barrier's
|
||||
/// post-swap hands, plus (PvP-equivalency, vanilla slice) the per-side idx->cardId map used to
|
||||
/// synthesize the opponent-facing <c>knownList</c>. FUTURE: a token map (cardIds mined from
|
||||
/// orderList <c>add</c> ops, idx>30) + a reveal-gate set land alongside <see cref="IdxToCardId"/>.</summary>
|
||||
/// synthesize the opponent-facing <c>knownList</c>. Generated tokens (cardIds mined from
|
||||
/// orderList <c>add</c> ops) are recorded into the SAME
|
||||
/// <see cref="IdxToCardId"/> map via <see cref="RecordToken"/>; a reveal-gate set is still future.</summary>
|
||||
internal sealed class BattleSessionState
|
||||
{
|
||||
public BattleSessionPhase SessionPhase { get; set; } = BattleSessionPhase.AwaitingInitNetwork;
|
||||
public Dictionary<IBattleParticipant, long[]> PostSwapHands { get; } = new();
|
||||
|
||||
/// <summary>Per-side idx->cardId, seeded lazily from <see cref="MatchContext.SelfDeckCardIds"/>.
|
||||
/// Deck cards only (idx 1..deckCount); tokens (idx>deckCount) are deferred.</summary>
|
||||
/// Holds deck cards (idx 1..deckCount, seeded) and generated tokens (idx>deckCount, recorded
|
||||
/// from add ops via <see cref="RecordToken"/>).</summary>
|
||||
public Dictionary<IBattleParticipant, Dictionary<int, long>> IdxToCardId { get; } = new();
|
||||
|
||||
/// <summary>The sender's idx->cardId map, seeding it from its <see cref="MatchContext"/> on first
|
||||
@@ -28,4 +30,15 @@ internal sealed class BattleSessionState
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/// <summary>Record a generated token's identity into the side's idx->cardId map (the same map
|
||||
/// that holds deck cards). Mined from the sender's <c>orderList</c> <c>add</c> ops by
|
||||
/// <see cref="KnownListBuilder.MineAddOps"/>; surfaced later by <c>BuildPlayedCard</c> when the
|
||||
/// token is the played card. Deck idxs (1..deckCount) and token idxs (>deckCount) don't
|
||||
/// collide — the client allocates token idxs after the deck.</summary>
|
||||
public void RecordToken(IBattleParticipant side, int idx, long cardId)
|
||||
{
|
||||
GetOrSeedDeckMap(side); // ensure the per-side map exists (deck-seeded)
|
||||
IdxToCardId[side][idx] = cardId; // overwrite-on-conflict: latest identity wins
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user