// ignore_for_file: avoid-late-keyword, avoid-non-null-assertion import 'package:test/test.dart'; import 'package:x_haven_server/core/commands/add_monster_command.dart'; import 'package:x_haven_server/core/commands/draw_ability_card_command.dart'; import 'package:x_haven_server/core/commands/shuffle_ability_card_command.dart'; import 'package:x_haven_server/core/commands/shuffle_amd_card_command.dart'; import 'package:x_haven_server/core/commands/shuffle_drawn_ability_card_command.dart'; import 'package:x_haven_server/core/game_methods.dart'; import 'package:x_haven_server/core/state/game_state.dart'; import 'package:x_haven_server/core/service_locator.dart'; import 'test_helpers.dart'; void main() { setUpAll(() async { await setUpGame(); }); late Monster monster; setUp(() { getIt().clearList(); AddMonsterCommand( 'Ancient Artillery (FH)', 1, false, gameState: getIt(), ).execute(); monster = getIt().currentList.firstWhere((e) => e is Monster) as Monster; }); group('ShuffleAbilityCardCommand', () { test('should shuffle ability deck (discard into draw pile)', () { // Draw some cards into discard DrawAbilityCardCommand(monster.id).execute(); DrawAbilityCardCommand(monster.id).execute(); final deck = GameMethods.getDeck(monster.type.deck)!; expect(deck.discardPileIsNotEmpty, isTrue); ShuffleAbilityCardCommand(monster.id).execute(); expect(deck.discardPileContents, isEmpty); checkSaveState(); }); test('describe returns correct string', () { expect( ShuffleAbilityCardCommand(monster.id).describe(), 'Extra ability deck shuffle', ); }); }); group('ShuffleDrawnAbilityCardCommand', () { test('should shuffle only undrawn part of ability deck', () { final deck = GameMethods.getDeck(monster.type.deck)!; final totalBefore = deck.drawPileSize + deck.discardPileSize; ShuffleDrawnAbilityCardCommand(monster.type.deck).execute(); final totalAfter = deck.drawPileSize + deck.discardPileSize; expect(totalAfter, totalBefore); }); test('describe returns correct string', () { expect( ShuffleDrawnAbilityCardCommand(monster.type.deck).describe(), 'Drawn ability deck shuffle', ); }); }); group('ShuffleAMDCardCommand', () { test('describe returns correct string', () { expect( ShuffleAMDCardCommand('', gameState: getIt()).describe(), 'Extra AMD deck shuffle', ); }); test('should shuffle modifier deck draw pile', () { final deck = getIt().modifierDeck; final sizeBefore = deck.drawPileSize; ShuffleAMDCardCommand('', gameState: getIt()).execute(); expect(deck.drawPileSize, sizeBefore); }); }); }