using SVSim.BattleNode.Sessions;
namespace SVSim.BattleNode.Sessions.Dispatch;
/// 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 knownList. FUTURE: a token map (cardIds mined from
/// orderList add ops, idx>30) + a reveal-gate set land alongside .
internal sealed class BattleSessionState
{
public BattleSessionPhase SessionPhase { get; set; } = BattleSessionPhase.AwaitingInitNetwork;
public Dictionary PostSwapHands { get; } = new();
/// Per-side idx->cardId, seeded lazily from .
/// Deck cards only (idx 1..deckCount); tokens (idx>deckCount) are deferred.
public Dictionary> IdxToCardId { get; } = new();
/// The sender's idx->cardId map, seeding it from its on first
/// use. BuildPlayerDeck assigns deck idx = position+1, so entry (i+1) -> cardIds[i].
public IReadOnlyDictionary GetOrSeedDeckMap(IBattleParticipant side)
{
if (!IdxToCardId.TryGetValue(side, out var map))
{
map = new Dictionary();
var deck = side.Context.SelfDeckCardIds;
for (var i = 0; i < deck.Count; i++) map[i + 1] = deck[i];
IdxToCardId[side] = map;
}
return map;
}
}