summaryrefslogtreecommitdiff
path: root/server/test/command/remove_condition_command_test.dart
diff options
context:
space:
mode:
Diffstat (limited to 'server/test/command/remove_condition_command_test.dart')
-rw-r--r--server/test/command/remove_condition_command_test.dart129
1 files changed, 129 insertions, 0 deletions
diff --git a/server/test/command/remove_condition_command_test.dart b/server/test/command/remove_condition_command_test.dart
new file mode 100644
index 0000000..11bb79f
--- /dev/null
+++ b/server/test/command/remove_condition_command_test.dart
@@ -0,0 +1,129 @@
+// ignore_for_file: no-magic-number, avoid-late-keyword
+
+import 'package:test/test.dart';
+import 'package:x_haven_server/core/commands/add_character_command.dart';
+import 'package:x_haven_server/core/commands/add_condition_command.dart';
+import 'package:x_haven_server/core/commands/add_monster_command.dart';
+import 'package:x_haven_server/core/commands/add_standee_command.dart';
+import 'package:x_haven_server/core/commands/remove_condition_command.dart';
+import 'package:x_haven_server/core/enums.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 Character character;
+ late Monster monster;
+ late MonsterInstance monsterInstance;
+
+ setUp(() {
+ getIt<GameState>().clearList();
+ AddCharacterCommand('Blinkblade', 'Frosthaven', "", 1).execute();
+ AddMonsterCommand(
+ 'Ancient Artillery (FH)',
+ 1,
+ false,
+ gameState: getIt<GameState>(),
+ ).execute();
+ AddStandeeCommand(
+ 1,
+ null,
+ 'Ancient Artillery (FH)',
+ MonsterType.normal,
+ false,
+ gameState: getIt<GameState>(),
+ ).execute();
+
+ character =
+ getIt<GameState>().currentList.firstWhere((e) => e is Character)
+ as Character;
+ monster =
+ getIt<GameState>().currentList.firstWhere((e) => e is Monster)
+ as Monster;
+ monsterInstance = monster.monsterInstances.first;
+ });
+
+ group('RemoveConditionCommand', () {
+ test('should remove a condition from a character', () {
+ AddConditionCommand(
+ Condition.poison,
+ character.id,
+ character.id,
+ gameState: getIt<GameState>(),
+ ).execute();
+ expect(character.characterState.conditions, contains(Condition.poison));
+
+ RemoveConditionCommand(
+ Condition.poison,
+ character.id,
+ character.id,
+ gameState: getIt<GameState>(),
+ ).execute();
+
+ expect(
+ character.characterState.conditions,
+ isNot(contains(Condition.poison)),
+ );
+ checkSaveState();
+ });
+
+ test('should remove a condition from a monster instance', () {
+ AddConditionCommand(
+ Condition.wound,
+ monsterInstance.getId(),
+ monster.id,
+ gameState: getIt<GameState>(),
+ ).execute();
+ expect(monsterInstance.conditions, contains(Condition.wound));
+
+ RemoveConditionCommand(
+ Condition.wound,
+ monsterInstance.getId(),
+ monster.id,
+ gameState: getIt<GameState>(),
+ ).execute();
+
+ expect(monsterInstance.conditions, isNot(contains(Condition.wound)));
+ });
+
+ test('should decrement chill counter when removing chill', () {
+ AddConditionCommand(
+ Condition.chill,
+ character.id,
+ character.id,
+ gameState: getIt<GameState>(),
+ ).execute();
+ AddConditionCommand(
+ Condition.chill,
+ character.id,
+ character.id,
+ gameState: getIt<GameState>(),
+ ).execute();
+ expect(character.characterState.chill, 2);
+
+ RemoveConditionCommand(
+ Condition.chill,
+ character.id,
+ character.id,
+ gameState: getIt<GameState>(),
+ ).execute();
+
+ expect(character.characterState.chill, 1);
+ });
+
+ test('describe should return correct string', () {
+ final command = RemoveConditionCommand(
+ Condition.stun,
+ character.id,
+ character.id,
+ gameState: getIt<GameState>(),
+ );
+ expect(command.describe(), 'Remove condition: stun');
+ });
+ });
+}