// 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().clearList(); AddCharacterCommand('Blinkblade', 'Frosthaven', "", 1).execute(); AddMonsterCommand( 'Ancient Artillery (FH)', 1, false, gameState: getIt(), ).execute(); AddStandeeCommand( 1, null, 'Ancient Artillery (FH)', MonsterType.normal, false, gameState: getIt(), ).execute(); character = getIt().currentList.firstWhere((e) => e is Character) as Character; monster = getIt().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(), ).execute(); expect(character.characterState.conditions, contains(Condition.poison)); RemoveConditionCommand( Condition.poison, character.id, character.id, gameState: getIt(), ).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(), ).execute(); expect(monsterInstance.conditions, contains(Condition.wound)); RemoveConditionCommand( Condition.wound, monsterInstance.getId(), monster.id, gameState: getIt(), ).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(), ).execute(); AddConditionCommand( Condition.chill, character.id, character.id, gameState: getIt(), ).execute(); expect(character.characterState.chill, 2); RemoveConditionCommand( Condition.chill, character.id, character.id, gameState: getIt(), ).execute(); expect(character.characterState.chill, 1); }); test('describe should return correct string', () { final command = RemoveConditionCommand( Condition.stun, character.id, character.id, gameState: getIt(), ); expect(command.describe(), 'Remove condition: stun'); }); }); }