diff options
Diffstat (limited to 'server/lib/core/state')
| -rw-r--r-- | server/lib/core/state/loot_deck_state.dart | 16 | ||||
| -rw-r--r-- | server/lib/core/state/modifier_deck.dart | 15 |
2 files changed, 31 insertions, 0 deletions
diff --git a/server/lib/core/state/loot_deck_state.dart b/server/lib/core/state/loot_deck_state.dart index 31c6df7..ccd1003 100644 --- a/server/lib/core/state/loot_deck_state.dart +++ b/server/lib/core/state/loot_deck_state.dart @@ -566,6 +566,22 @@ class LootDeck { 'enhancements': _enhancements, '1418': _hasCard1418, '1419': _hasCard1419, + // Pool card ids only: pool cards are the same live instances that enter + // the draw/discard piles (and mutate with them), so their full JSON would + // leak those mutations into the static pool. The enhancement menu needs + // the ids plus the `enhancements` map (card id → level). + 'pools': { + 'coin': _coinPool.map((c) => c.id).toList(), + 'lumber': _lumberPool.map((c) => c.id).toList(), + 'hide': _hidePool.map((c) => c.id).toList(), + 'metal': _metalPool.map((c) => c.id).toList(), + 'corpsecap': _corpsecapPool.map((c) => c.id).toList(), + 'arrowvine': _arrowvinePool.map((c) => c.id).toList(), + 'flamefruit': _flamefruitPool.map((c) => c.id).toList(), + 'axenut': _axenutPool.map((c) => c.id).toList(), + 'rockroot': _rockrootPool.map((c) => c.id).toList(), + 'snowthistle': _snowthistlePool.map((c) => c.id).toList(), + }, }; @override diff --git a/server/lib/core/state/modifier_deck.dart b/server/lib/core/state/modifier_deck.dart index 6575e01..b7c00f1 100644 --- a/server/lib/core/state/modifier_deck.dart +++ b/server/lib/core/state/modifier_deck.dart @@ -68,6 +68,10 @@ class ModifierDeck { int get revealedCount => _revealedCount; bool get cassandraSpecial => _cassandraSpecial; + /// The removable-card counter totals (bless / curse / empower / enfeeble + /// variants) — the client's deck-header counters read these. + Map<String, int> get removables => Map.unmodifiable(_removables); + ModifierDeck(this.name) { //build deck _initDeck(); @@ -141,6 +145,16 @@ class ModifierDeck { _addedMinusOnes = modifierDeckData.containsKey('addedMinusOnes') ? modifierDeckData["addedMinusOnes"] as int : 0; + + // The counter totals are the source of truth; the physical-card rebuild + // above already re-derived them for saves written before `removables` + // existed on the wire. + if (modifierDeckData.containsKey('removables')) { + final saved = modifierDeckData['removables'] as Map<String, dynamic>; + for (final key in _removables.keys) { + _removables[key] = (saved[key] as int?) ?? _removables[key]!; + } + } } void setRemovableValue(_StateModifier _, String id, int value) { @@ -551,6 +565,7 @@ class ModifierDeck { 'corrosiveSpew': _corrosiveSpew, 'revealed': _revealedCount, 'cassandra': _cassandraSpecial, + 'removables': _removables, 'drawPile': _drawPile.getList().map((c) => c.toJson()).toList(), 'removedPile': _removedPile.getList().map((c) => c.toJson()).toList(), 'discardPile': _discardPile.getList().map((c) => c.toJson()).toList(), |
