diff options
| author | Joel Klinghed <the_jk@spawned.biz> | 2026-11-12 00:28:50 +0100 |
|---|---|---|
| committer | Joel Klinghed <the_jk@spawned.biz> | 2026-11-12 00:28:50 +0100 |
| commit | 808294adad3f378ad8d66b698acf8df7f49c2302 (patch) | |
| tree | cfd11a1395a8ad482311969f86abbbad97e7e0b4 /server/lib/core/state/modifier_deck.dart | |
| parent | f6955e34489c79f6d5b764cb6a39b1387366b433 (diff) | |
Phase 1: headless game engine on the server (M1)
Complete mechanical port of the reference app's game engine to
server/lib/core/ so later phases are UI-only:
- models/ (7), state/ (GameState + 18 part files), methods/ (7),
game_methods, 79 command files, enums, card_stack, stat_calculator,
action_handler (index, 250-deep history, save-per-action, undo/redo),
disk-based game_data, l10n, translation_service, service_locator
- ValueNotifier/ChangeNotifier removed in favor of plain fields with a
minimal GameState listener hook for the Phase 2 broadcast layer;
shared_preferences replaced by the SaveStore abstraction
(InMemory for tests, File-backed for bin/main.dart)
- command registry: 82 entries mapping wire names to constructors with
arg validation; live-object args (loot/ability cards, figure lists)
travel as id/name/nr and resolve against live state, enums by name,
injected singletons never serialize
- line_builder ported to Phase 1 scope: stat_applier + minimal
LineBuilder (isElement, tokens); widget rendering deferred to Phase 4
- ported test suite: 81 test files, 562 tests green (command tests 1:1
with the reference, resource tests, registry smoke tests)
- new headless integration test drives a full round: scenario setup,
characters + standee, secret-initiative gate, draw, every figure's
turn (incl. undo/redo), next round, round 2, round 3
- PORTING.md: the conventions contract used for the port
- bin/main.dart boots the engine (file save store, assets/data) before
serving; pubspec gains built_collection, collection, get_it, intl
- dart format drift on pre-existing net/test files from the current
formatter (whitespace only)
dart analyze warning-free; dart test 562/562.
Diffstat (limited to 'server/lib/core/state/modifier_deck.dart')
| -rw-r--r-- | server/lib/core/state/modifier_deck.dart | 758 |
1 files changed, 758 insertions, 0 deletions
diff --git a/server/lib/core/state/modifier_deck.dart b/server/lib/core/state/modifier_deck.dart new file mode 100644 index 0000000..6575e01 --- /dev/null +++ b/server/lib/core/state/modifier_deck.dart @@ -0,0 +1,758 @@ +part of 'game_state.dart'; + +// ignore_for_file: library_private_types_in_public_api + +class ModifierDeck { + static const int _kImbuementLevel1 = 1; + static const int _kImbuementLevel2 = 2; + static const int _kPlusMinus1Count = 5; + static const int _kPlus0Count = 6; + static const int _kCursePosition = 5; + + final String name; + final CardStack<ModifierCard> _drawPile = CardStack<ModifierCard>(); + final CardStack<ModifierCard> _discardPile = CardStack<ModifierCard>(); + final CardStack<ModifierCard> _removedPile = CardStack<ModifierCard>(); + final Map<String, int> _removables = { + "curse": 0, + "bless": 0, + "in-enfeeble": 0, + "vi-enfeeble": 0, + "vi-gr-enfeeble": 0, + "li-enfeeble": 0, + "in-empower": 0, + "rm-empower": 0, + "vi-empower": 0, + "vi-gr-empower": 0, + }; + + /// Removable gfx keys that get physical draw-pile card sync. In the + /// reference app this is exactly the set of counters that have a + /// `_handleRemovableCards` listener attached in `_initListeners()`, i.e. the + /// keys present at construction. Entries added later by `getRemovable()` + /// (e.g. "enfeeble") never trigger physical card sync. + final Set<String> _syncedRemovables = {}; + + int _badOmen = 0; + bool _corrosiveSpew = false; + int _addedMinusOnes = 0; + int _imbuement = 0; + + int _revealedCount = 0; + bool _cassandraSpecial = false; + + bool _needsShuffle = false; + bool get needsShuffle => _needsShuffle; + + BuiltList<ModifierCard> get drawPileContents => + BuiltList.of(_drawPile.getList()); + BuiltList<ModifierCard> get discardPileContents => + BuiltList.of(_discardPile.getList()); + BuiltList<ModifierCard> get removedPileContents => + BuiltList.of(_removedPile.getList()); + bool get drawPileIsEmpty => _drawPile.isEmpty; + bool get drawPileIsNotEmpty => _drawPile.isNotEmpty; + bool get discardPileIsEmpty => _discardPile.isEmpty; + bool get discardPileIsNotEmpty => _discardPile.isNotEmpty; + int get drawPileSize => _drawPile.size(); + int get discardPileSize => _discardPile.size(); + int get removedPileSize => _removedPile.size(); + ModifierCard get discardPileTop => _discardPile.peek; + ModifierCard get drawPileTop => _drawPile.peek; + + CardStack<ModifierCard> get drawPileNotifier => _drawPile; + int get badOmen => _badOmen; + bool get corrosiveSpew => _corrosiveSpew; + int get addedMinusOnes => _addedMinusOnes; + int get imbuement => _imbuement; + int get revealedCount => _revealedCount; + bool get cassandraSpecial => _cassandraSpecial; + + ModifierDeck(this.name) { + //build deck + _initDeck(); + _initListeners(); + } + + ModifierDeck.fromJson(this.name, Map<String, dynamic> modifierDeckData) { + _initDeck(); + _initListeners(); + updateFromJson(modifierDeckData); + } + + /// Resets this deck to the default 20-card state. + void resetToDefault() { + _initDeck(); + _cassandraSpecial = false; + } + + /// Updates this deck in-place from [modifierDeckData]. + void updateFromJson(Map<String, dynamic> modifierDeckData) { + // Reset removable counts first (the piles are fully replaced below + // anyway, so no physical card sync is needed here). + for (final key in _removables.keys) { + _removables[key] = 0; + } + _needsShuffle = false; + + for (final item in modifierDeckData["drawPile"] as List) { + String gfx = item["gfx"]; + if (gfx == "curse" || + gfx.contains("empower") || + gfx.contains("enfeeble") || + gfx == "bless") { + addRemovableValue(_StateModifier(), gfx, 1); + } + } + for (final item in modifierDeckData["discardPile"] as List) { + String gfx = item["gfx"]; + if (_isMultiplyType(gfx)) { + _needsShuffle = true; + } + } + + _drawPile.clear(); + _discardPile.clear(); + _removedPile.clear(); + _drawPile.setList(_getCardsFromJson(modifierDeckData, "drawPile")); + _discardPile.setList(_getCardsFromJson(modifierDeckData, "discardPile")); + if (modifierDeckData.containsKey('removedPile')) { + _removedPile.setList(_getCardsFromJson(modifierDeckData, "removedPile")); + } + + _imbuement = modifierDeckData.containsKey("imbuement") + ? modifierDeckData['imbuement'] as int + : 0; + _badOmen = modifierDeckData.containsKey('badOmen') + ? modifierDeckData["badOmen"] as int + : 0; + _corrosiveSpew = modifierDeckData.containsKey('corrosiveSpew') + ? modifierDeckData["corrosiveSpew"] as bool + : false; + _revealedCount = min( + modifierDeckData.containsKey('revealed') + ? modifierDeckData["revealed"] as int + : 0, + drawPileSize, + ); + _cassandraSpecial = modifierDeckData.containsKey('cassandra') + ? modifierDeckData["cassandra"] as bool + : false; + _addedMinusOnes = modifierDeckData.containsKey('addedMinusOnes') + ? modifierDeckData["addedMinusOnes"] as int + : 0; + } + + void setRemovableValue(_StateModifier _, String id, int value) { + if (_removables.containsKey(id)) { + _removables[id] = value; + if (_syncedRemovables.contains(id)) { + _handleRemovableCards(value, id); + } + } + } + + void addRemovableValue(_StateModifier _, String id, int value) { + final current = _removables[id]; + if (current != null) { + final newValue = current + value; + _removables[id] = newValue; + if (_syncedRemovables.contains(id)) { + _handleRemovableCards(newValue, id); + } + } + } + + int getRemovable(String id) { + _removables[id] ??= 0; + return _removables[id] ?? 0; + } + + void moveCardToRemovedPile(_StateModifier s, String gfx) { + if (hasCard(gfx)) { + removeCard(s, gfx); + _removedPile.add(ModifierCard(CardType.add, gfx)); + } + } + + void restoreCardFromRemovedPile(_StateModifier s, String gfx, CardType type) { + addCard(s, gfx, type); + _removedPile.removeFirstWhere((card) => card.gfx == gfx); + } + + void setBadOmen(_StateModifier _, int value) { + _badOmen = value; + } + + void setCorrosiveSpew(_StateModifier _) { + _corrosiveSpew = true; + } + + void addCSSanctuary(_StateModifier s, {GameState? gameState}) { + //adds one of each + final gs = gameState ?? getIt<GameState>(); + _drawPile.add(gs._sanctuaryDeck.drawFlip(s)); + _drawPile.add(gs._sanctuaryDeck.drawMult(s)); + _drawPile.shuffle(); + } + + void removeCSSanctuary(_StateModifier _, {GameState? gameState}) { + var list = _drawPile.getList(); + final gs = gameState ?? getIt<GameState>(); + for (int i = list.length - 1; i >= 0; i--) { + if (list[i].gfx.startsWith("sanctuary")) { + gs._sanctuaryDeck.returnCard(list[i].gfx); + _drawPile.removeAt(i); + } + } + list = _discardPile.getList(); + for (int i = list.length - 1; i >= 0; i--) { + if (list[i].gfx.startsWith("sanctuary")) { + gs._sanctuaryDeck.returnCard(list[i].gfx); + _discardPile.removeAt(i); + } + } + } + + bool hasCSSanctuary() { + if (_drawPile.getList().firstWhereOrNull((test) { + return test.gfx.startsWith("sanctuary"); + }) != + null || + _discardPile.getList().firstWhereOrNull((test) { + return test.gfx.startsWith("sanctuary"); + }) != + null) { + return true; + } + return false; + } + + void addCSPartyCard(_StateModifier s, int type) { + addCard(s, "party/$type", CardType.remove); + } + + void removeCSPartyCard(_StateModifier _) { + _drawPile.removeWhere((test) { + return test.gfx.startsWith("party/"); + }); + _discardPile.removeWhere((test) { + return test.gfx.startsWith("party/"); + }); + } + + bool hasPartyCard() { + if (_drawPile.getList().firstWhereOrNull((test) { + return test.gfx.startsWith("party/"); + }) != + null || + _discardPile.getList().firstWhereOrNull((test) { + return test.gfx.startsWith("party/"); + }) != + null) { + return true; + } + return false; + } + + void addHailSpecial(_StateModifier s) { + addCard(s, "special/hail", CardType.add); + } + + void removeHailSpecial(_StateModifier s) { + removeCard(s, "special/hail"); + } + + void revealCards(_StateModifier _, int amount) { + _revealedCount = amount; + } + + void setCassandraSpecial(_StateModifier _, bool on) { + _cassandraSpecial = on; + } + + bool hasHail() { + if (_discardPile.getList().firstWhereOrNull( + (item) => item.gfx == "special/hail", + ) != + null) { + return true; + } + if (_drawPile.getList().firstWhereOrNull( + (item) => item.gfx == "special/hail", + ) != + null) { + return true; + } + return false; + } + + void addMinusOne(_StateModifier _) { + _addedMinusOnes++; + _drawPile.insert(0, ModifierCard(CardType.add, "minus1")); + _shuffleDrawPileRespectCassandra(); + _revealedCount = 0; + if (_addedMinusOnes < 0) { + //do not add/remove extra minus ones to removed pile + _removedPile.removeFirstWhere((item) => item.gfx == "minus1"); + } + } + + void removeMinusOne(_StateModifier _) { + _shuffle(); + + final card = _removeCardFromDrawPile("minus1"); + if (card != null) { + _addedMinusOnes--; + if (_addedMinusOnes < 0) { + _removedPile.add(card); + } + } + } + + bool hasMinus1() { + return _drawPile.getList().firstWhereOrNull( + (element) => element.gfx == "minus1", + ) != + null || + _discardPile.getList().firstWhereOrNull( + (element) => element.gfx == "minus1", + ) != + null; + } + + bool hasMinus2() { + return !(_removedPile.getList().firstWhereOrNull( + (element) => element.gfx == "minus2", + ) != + null); + } + + bool hasNull() { + return _drawPile.getList().firstWhereOrNull( + (element) => element.gfx == "nullAttack", + ) != + null || + _discardPile.getList().firstWhereOrNull( + (element) => element.gfx == "nullAttack", + ) != + null; + } + + void removeNull(_StateModifier _) { + _shuffle(); + final card = _removeCardFromDrawPile("nullAttack"); + if (card != null) { + _removedPile.add(card); + } + } + + void addNull(_StateModifier _) { + _drawPile.add(ModifierCard(CardType.multiply, "nullAttack")); + _removedPile.removeFirstWhere((item) => item.gfx == "nullAttack"); + _shuffle(); + } + + bool hasCard(String gfx) { + final drawPileHas = + _drawPile.getList().firstWhereOrNull((test) => test.gfx == gfx) != null; + final discardPileHas = + _discardPile.getList().firstWhereOrNull((test) => test.gfx == gfx) != + null; + return (drawPileHas || discardPileHas); + } + + void removeCard(_StateModifier _, String gfx) { + _shuffle(); + _removeCardFromDrawPile(gfx); + _shuffle(); + } + + void removeCardFromDiscard(_StateModifier _, int index) { + final card = _discardPile.removeAt(index); + _removedPile.add(card); + if (card.gfx == "minus1") { + _addedMinusOnes--; + } + } + + void removeCardFromDrawPile(_StateModifier _, int index) { + final card = _drawPile.removeAt(index); + _removedPile.add(card); + if (card.gfx == "minus1") { + _addedMinusOnes--; + } + if (_revealedCount > _drawPile.size() - 1 - index) { + _revealedCount--; + } + } + + void returnCardToDiscard(_StateModifier _, int index) { + final card = _removedPile.removeAt(index); + _discardPile.add(card); + if (card.gfx == "minus1") { + _addedMinusOnes++; + } + } + + void returnCardToDrawPileFromRemoved(_StateModifier _, int index) { + final card = _removedPile.removeAt(index); + _drawPile.add(card); + _revealedCount++; + if (card.gfx == "minus1") { + _addedMinusOnes++; + } + } + + void returnCardToDrawPile(_StateModifier _) { + final card = _discardPile.pop(); + _drawPile.push(card); + //todo: how to tell if revealed should change? if it is over 0? + } + + void addCard(_StateModifier _, String id, CardType type) { + _drawPile.add(ModifierCard(type, id)); + _shuffle(); + } + + void removeMinusTwo(_StateModifier _) { + _shuffle(); + final card = _removeCardFromDrawPile("minus2"); + if (card != null) { + _removedPile.add(card); + } + } + + void addMinusTwo(_StateModifier _) { + _drawPile.add(ModifierCard(CardType.add, "minus2")); + _removedPile.removeFirstWhere((item) => item.gfx == "minus2"); + _shuffle(); + } + + void setImbue1(_StateModifier _) { + assert(name.isEmpty); //only basic deck for this feature + + _shuffle(); + _removeCardFromDrawPile("minus1"); + _removeCardFromDrawPile("minus1"); + _removeCardFromDrawPile("minus1"); + _drawPile.add(ModifierCard(CardType.add, "imbue-plus1")); + _drawPile.add(ModifierCard(CardType.add, "imbue-plus1")); + _drawPile.add(ModifierCard(CardType.add, "imbue-plus1")); + _drawPile.add(ModifierCard(CardType.add, "imbue-plus2muddle")); + _drawPile.add(ModifierCard(CardType.add, "imbue-plus0poison")); + _shuffle(); + _imbuement = _kImbuementLevel1; + } + + void setImbue2(_StateModifier m) { + assert(name.isEmpty); //only basic deck for this feature + + if (_imbuement == 0) { + setImbue1(m); + } + + _shuffle(); + _removeCardFromDrawPile("minus2"); + _removeCardFromDrawPile("plus0"); + _removeCardFromDrawPile("plus0"); + + _drawPile.add(ModifierCard(CardType.add, "imbue2-plus3")); + _drawPile.add(ModifierCard(CardType.add, "imbue2-plus1heal1")); + _drawPile.add(ModifierCard(CardType.add, "imbue2-plus1heal1")); + _drawPile.add(ModifierCard(CardType.add, "imbue2-plus1curse")); + _drawPile.add(ModifierCard(CardType.add, "imbue2-plus0wound")); + _shuffle(); + _imbuement = _kImbuementLevel2; + } + + void resetImbue(_StateModifier _) { + assert(name.isEmpty); //only basic deck for this feature + + if (_imbuement != 0) { + _shuffle(); + _drawPile.removeWhere((element) => element.gfx.startsWith("imbue")); + + _drawPile.add(ModifierCard(CardType.add, "minus1")); + _drawPile.add(ModifierCard(CardType.add, "minus1")); + _drawPile.add(ModifierCard(CardType.add, "minus1")); + if (_imbuement == _kImbuementLevel2) { + if (hasMinus2()) { + //if minus2 has not been separately removed + _drawPile.add(ModifierCard(CardType.add, "minus2")); + } + _drawPile.add(ModifierCard(CardType.add, "plus0")); + _drawPile.add(ModifierCard(CardType.add, "plus0")); + } + _imbuement = 0; + _shuffle(); + } + } + + void shuffle(_StateModifier _) { + if (_cassandraSpecial) { + //dont shuffle the revealed cards + _shuffleOnlyBelowRevealed(); + } else { + _shuffle(); + } + } + + void shuffleUnDrawn(_StateModifier _) { + _drawPile.shuffle(); + _revealedCount = 0; + } + + void draw(_StateModifier _) { + if (_revealedCount > 0) { + _revealedCount--; + } + //shuffle deck, for the case the deck ends during play + if (_drawPile.isEmpty) { + _shuffle(); + } + //put top of draw pile on discard pile + if (_drawPile.isNotEmpty) { + ModifierCard card = _drawPile.pop(); + if (card.type == CardType.multiply) { + _needsShuffle = true; + } + + if (_removables[card.gfx] != null) { + addRemovableValue(_StateModifier(), card.gfx, -1); + } + _discardPile.push(card); + } + } + + void reorderCards(_StateModifier s, int newIndex, int oldIndex) { + List<ModifierCard> list = List.of(_drawPile.getList()); + final item = list.removeAt(oldIndex); + list.insert(newIndex, item); + _drawPile.setList(list); + + //if rearranging between revealed and unrevealed then un-reveal everything below the unknown moved card. + final revertOldIndex = _drawPile.size() - oldIndex; + final revertNewIndex = _drawPile.size() - newIndex; + if (revertOldIndex <= revealedCount && revertNewIndex > revealedCount) { + //moving one revealed card to unrevealed area - hide one + revealCards(s, revealedCount - 1); + } + if (revertNewIndex <= revealedCount && revertOldIndex > revealedCount) { + //hide new index card and those below + revealCards(s, revertNewIndex - 1); + } + } + + Map<String, dynamic> toJson() => { + 'addedMinusOnes': _addedMinusOnes, + 'imbuement': _imbuement, + 'badOmen': _badOmen, + 'corrosiveSpew': _corrosiveSpew, + 'revealed': _revealedCount, + 'cassandra': _cassandraSpecial, + 'drawPile': _drawPile.getList().map((c) => c.toJson()).toList(), + 'removedPile': _removedPile.getList().map((c) => c.toJson()).toList(), + 'discardPile': _discardPile.getList().map((c) => c.toJson()).toList(), + }; + + @override + String toString() => json.encode(toJson()); + + void _initListeners() { + // UI-only in the reference app. In the reference this attached the + // _handleRemovableCards listener to each counter notifier, so physical + // card sync only ever happened for the keys present here (always the ten + // initial ones); record that set for set/addRemovableValue. + _syncedRemovables + ..clear() + ..addAll(_removables.keys); + } + + List<ModifierCard> _getCardsFromJson( + Map<String, dynamic> modifierDeckData, + String deckId, + ) { + List<ModifierCard> newList = []; + for (final item in modifierDeckData[deckId] as List) { + String gfx = item["gfx"]; + gfx = gfx.replaceAll("-allies", ""); + if (gfx == "curse") { + newList.add(ModifierCard(CardType.remove, gfx)); + } else if (gfx.contains("enfeeble")) { + if (gfx == "enfeeble") { + //if updating from old version + gfx = "in-enfeeble"; + } + newList.add(ModifierCard(CardType.remove, gfx)); + } else if (gfx.contains("empower")) { + newList.add(ModifierCard(CardType.remove, gfx)); + } else if (gfx == "bless") { + newList.add(ModifierCard(CardType.remove, gfx)); + } else if (_isMultiplyType(gfx)) { + newList.add(ModifierCard(CardType.multiply, gfx)); + } else { + newList.add(ModifierCard(CardType.add, gfx)); + } + } + return newList; + } + + void _initDeck() { + List<ModifierCard> cards = []; + cards.add(ModifierCard(CardType.add, "minus2")); + cards.add(ModifierCard(CardType.add, "plus2")); + cards.add(ModifierCard(CardType.multiply, "doubleAttack")); + cards.add(ModifierCard(CardType.multiply, "nullAttack")); + for (int i = 0; i < _kPlusMinus1Count; i++) { + cards.add(ModifierCard(CardType.add, "minus1")); + cards.add(ModifierCard(CardType.add, "plus1")); + } + for (int i = 0; i < _kPlus0Count; i++) { + cards.add(ModifierCard(CardType.add, "plus0")); + } + _drawPile.setList(cards); + _discardPile.setList([]); + _removedPile.setList([]); + _shuffle(); + _badOmen = 0; + _corrosiveSpew = false; + _addedMinusOnes = 0; + _imbuement = 0; + _needsShuffle = false; + for (final item in _removables.keys) { + _removables[item] = 0; + } + } + + ModifierCard? _removeCardFromDrawPile(String gfx) { + final card = _drawPile.getList().lastWhereOrNull( + (element) => element.gfx == gfx, + ); + if (card != null) { + _drawPile.remove(card); + _drawPile.shuffle(); + } + return card; + } + + /// Syncs the physical removable cards in the draw pile with the + /// [notifierValue] stored in [_removables] for [gfx]. In the reference app + /// this ran as a listener on the removable counter notifiers; it is now + /// called directly from [setRemovableValue] and [addRemovableValue]. + void _handleRemovableCards(int notifierValue, String gfx) { + //count and add or remove, then shuffle + int count = 0; + bool shuffle = true; + for (final item in _drawPile.getList()) { + if (item.gfx == gfx) { + count++; + } + } + if (count == notifierValue) { + shuffle = false; + } else if (count < notifierValue) { + for (int i = count; i < notifierValue; i++) { + if (gfx == "rm-empower" && corrosiveSpew) { + shuffle = false; + //put on top + //_drawPile.insert(0, ModifierCard(CardType.remove, gfx)); + _drawPile.push(ModifierCard(CardType.remove, gfx)); + } else if (gfx == "curse" && _badOmen > 0) { + _badOmen--; + shuffle = false; + //put in sixth or as far down as it goes. + int position = _kCursePosition; + final size = _drawPile.getList().length; + if (size < _kPlus0Count) { + position = size; + } + _drawPile.insert(size - position, ModifierCard(CardType.remove, gfx)); + } else { + _drawPile.insert(0, ModifierCard(CardType.remove, gfx)); + } + } + } else { + int toRemove = count - notifierValue; + for (int i = 0; i < toRemove; i++) { + _drawPile.removeFirstWhere((card) => card.gfx == gfx); + } + } + if (shuffle) { + _shuffleDrawPileRespectCassandra(); + } + } + + void _shuffle() { + while (_discardPile.isNotEmpty) { + ModifierCard card = _discardPile.pop(); + //remove curse and bless + if (card.type != CardType.remove) { + _drawPile.push(card); + } + } + _drawPile.shuffle(); + + _needsShuffle = false; + _revealedCount = 0; + } + + void _shuffleOnlyBelowRevealed() { + final revealCount = _revealedCount; + List<ModifierCard> revealed = []; + for (int i = 0; i < _revealedCount; i++) { + revealed.insert(0, _drawPile.pop()); + } + _shuffle(); + _revealedCount = revealCount; + for (int i = 0; i < _revealedCount; i++) { + _drawPile.add(revealed[i]); + } + } + + void _shuffleDrawPileRespectCassandra() { + if (_cassandraSpecial) { + //dont shuffle the revealed cards + List<ModifierCard> revealed = []; + for (int i = 0; i < _revealedCount; i++) { + revealed.insert(0, _drawPile.pop()); + } + _drawPile.shuffle(); + for (int i = 0; i < _revealedCount; i++) { + _drawPile.add(revealed[i]); + } + } else { + _revealedCount = 0; + _drawPile.shuffle(); + } + } + + bool _isMultiplyType(String gfx) { + if (gfx.contains("nullAttack") || gfx.contains("doubleAttack")) { + return true; + } + if (gfx == "P4" && name == "Nightshroud") { + if (GameMethods.getCharacterByName( + "Nightshroud", + )?.characterClass.edition == + "Gloomhaven 2nd Edition") { + return true; + } + } + return false; + } +} + +enum CardType { add, multiply, remove } + +class ModifierCard { + final CardType type; + final String gfx; + + ModifierCard(this.type, this.gfx); + + Map<String, dynamic> toJson() => {'gfx': gfx}; + + @override + String toString() => '{"gfx": "$gfx" }'; +} |
