summaryrefslogtreecommitdiff
path: root/server/test/command/bad_omen_command_test.dart
diff options
context:
space:
mode:
Diffstat (limited to 'server/test/command/bad_omen_command_test.dart')
-rw-r--r--server/test/command/bad_omen_command_test.dart124
1 files changed, 124 insertions, 0 deletions
diff --git a/server/test/command/bad_omen_command_test.dart b/server/test/command/bad_omen_command_test.dart
new file mode 100644
index 0000000..1741099
--- /dev/null
+++ b/server/test/command/bad_omen_command_test.dart
@@ -0,0 +1,124 @@
+// 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<GameState>(),
+ );
+ command.execute();
+ });
+
+ group('BadOmenCommand', () {
+ test('should increase badOmen value for monster deck', () {
+ // Arrange
+ final command = BadOmenCommand(false, gameState: getIt<GameState>());
+ final monsterDeck = getIt<GameState>().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<GameState>());
+ final alliesDeck = getIt<GameState>().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<GameState>());
+ final monsterDeck = getIt<GameState>().modifierDeck;
+ final initialBadOmenValue = monsterDeck.badOmen;
+
+ // Act
+ command.execute();
+
+ // Assert
+ expect(monsterDeck.badOmen, initialBadOmenValue + 6);
+
+ ChangeCurseCommand(
+ 1,
+ "Zealot",
+ "Zealot",
+ gameState: getIt<GameState>(),
+ ).execute(); // Add a curse first
+ expect(monsterDeck.drawPileContents.toList()[15].gfx, "curse");
+ expect(monsterDeck.badOmen, initialBadOmenValue + 5);
+
+ ChangeCurseCommand(
+ 1,
+ "Zealot",
+ "Zealot",
+ gameState: getIt<GameState>(),
+ ).execute(); // Add a curse first
+ expect(monsterDeck.drawPileContents.toList()[15].gfx, "curse");
+ expect(monsterDeck.badOmen, initialBadOmenValue + 4);
+
+ ChangeCurseCommand(
+ 1,
+ "Zealot",
+ "Zealot",
+ gameState: getIt<GameState>(),
+ ).execute(); // Add a curse first
+ expect(monsterDeck.drawPileContents.toList()[15].gfx, "curse");
+ expect(monsterDeck.badOmen, initialBadOmenValue + 3);
+
+ ChangeCurseCommand(
+ 1,
+ "Zealot",
+ "Zealot",
+ gameState: getIt<GameState>(),
+ ).execute(); // Add a curse first
+ expect(monsterDeck.drawPileContents.toList()[15].gfx, "curse");
+ expect(monsterDeck.badOmen, initialBadOmenValue + 2);
+
+ ChangeCurseCommand(
+ 1,
+ "Zealot",
+ "Zealot",
+ gameState: getIt<GameState>(),
+ ).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<GameState>());
+
+ // Act & Assert
+ expect(command.describe(), 'Bad Omen');
+ });
+ });
+}