// ignore_for_file: no-magic-number import 'package:test/test.dart'; import 'package:x_haven_server/core/commands/bad_omen_command.dart'; import 'package:x_haven_server/core/commands/change_stat_commands/change_curse_command.dart'; import 'package:x_haven_server/core/commands/set_scenario_command.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(); }); setUp(() { // Setting a scenario resets the modifier decks to their default state. final command = SetScenarioCommand( '#5 A Deeper Understanding', false, gameState: getIt(), ); command.execute(); }); group('BadOmenCommand', () { test('should increase badOmen value for monster deck', () { // Arrange final command = BadOmenCommand(false, gameState: getIt()); final monsterDeck = getIt().modifierDeck; final initialBadOmenValue = monsterDeck.badOmen; // Act command.execute(); // Assert expect(monsterDeck.badOmen, initialBadOmenValue + 6); checkSaveState(); }); test('should increase badOmen value for allies deck', () { // Arrange final command = BadOmenCommand(true, gameState: getIt()); final alliesDeck = getIt().modifierDeckAllies; final initialBadOmenValue = alliesDeck.badOmen; // Act command.execute(); // Assert expect(alliesDeck.badOmen, initialBadOmenValue + 6); checkSaveState(); }); test('should add curses on top', () { // Arrange final command = BadOmenCommand(false, gameState: getIt()); final monsterDeck = getIt().modifierDeck; final initialBadOmenValue = monsterDeck.badOmen; // Act command.execute(); // Assert expect(monsterDeck.badOmen, initialBadOmenValue + 6); ChangeCurseCommand( 1, "Zealot", "Zealot", gameState: getIt(), ).execute(); // Add a curse first expect(monsterDeck.drawPileContents.toList()[15].gfx, "curse"); expect(monsterDeck.badOmen, initialBadOmenValue + 5); ChangeCurseCommand( 1, "Zealot", "Zealot", gameState: getIt(), ).execute(); // Add a curse first expect(monsterDeck.drawPileContents.toList()[15].gfx, "curse"); expect(monsterDeck.badOmen, initialBadOmenValue + 4); ChangeCurseCommand( 1, "Zealot", "Zealot", gameState: getIt(), ).execute(); // Add a curse first expect(monsterDeck.drawPileContents.toList()[15].gfx, "curse"); expect(monsterDeck.badOmen, initialBadOmenValue + 3); ChangeCurseCommand( 1, "Zealot", "Zealot", gameState: getIt(), ).execute(); // Add a curse first expect(monsterDeck.drawPileContents.toList()[15].gfx, "curse"); expect(monsterDeck.badOmen, initialBadOmenValue + 2); ChangeCurseCommand( 1, "Zealot", "Zealot", gameState: getIt(), ).execute(); // Add a curse first expect(monsterDeck.drawPileContents.toList()[15].gfx, "curse"); expect(monsterDeck.badOmen, initialBadOmenValue + 1); checkSaveState(); }); test('describe should return correct string', () { // Arrange final command = BadOmenCommand(false, gameState: getIt()); // Act & Assert expect(command.describe(), 'Bad Omen'); }); }); }