summaryrefslogtreecommitdiff
path: root/server/test/command/bad_omen_command_test.dart
blob: 1741099c95029e540c51373520b693d9bea59d3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
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');
    });
  });
}