diff options
| author | Joel Klinghed <the_jk@spawned.biz> | 2026-11-23 15:38:13 +0100 |
|---|---|---|
| committer | Joel Klinghed <the_jk@spawned.biz> | 2026-11-23 15:38:13 +0100 |
| commit | 7ee14396b1f1f96ed0472b5949ce82a7f9313276 (patch) | |
| tree | cddf00fe4049908155a15e813bb8d226ad710f81 /server | |
| parent | 4a45fe143bd050d89183427443dedfd656f507bc (diff) | |
server: make local variables final (prefer_final_locals)
270 locals across 52 files. Six of them were declared with an
unnecessarily nullable type (ModifierDeck? / LootDeckModel?) although
the initializer is non-nullable; non-final locals were silently
flow-promoted to the initializer's type, but final locals are not, so
the nullability is dropped where it was wrong.
Diffstat (limited to 'server')
52 files changed, 270 insertions, 270 deletions
diff --git a/server/lib/core/action_handler.dart b/server/lib/core/action_handler.dart index 5b3f8d4..8bf6655 100644 --- a/server/lib/core/action_handler.dart +++ b/server/lib/core/action_handler.dart @@ -168,8 +168,8 @@ class ActionHandler { _gameState.save(); //save after each action //send last game state if connected - String description = command.describe(); - String eventJson = command.event.toJsonString(); + final String description = command.describe(); + final String eventJson = command.event.toJsonString(); _log.info('server sends, index: $commandIndex, description:$description'); onAction?.call(commandIndex, description, eventJson); diff --git a/server/lib/core/commands/add_condition_command.dart b/server/lib/core/commands/add_condition_command.dart index 663d6b0..a352abc 100644 --- a/server/lib/core/commands/add_condition_command.dart +++ b/server/lib/core/commands/add_condition_command.dart @@ -18,9 +18,9 @@ class AddConditionCommand extends Command { @override void execute() { - FigureState? figure = GameMethods.getFigure(ownerId, figureId); + final FigureState? figure = GameMethods.getFigure(ownerId, figureId); if (figure != null) { - List<Condition> newList = []; + final List<Condition> newList = []; newList.addAll(figure.conditions); if (!newList.contains(condition) || //block from adding same condition condition == Condition.chill || diff --git a/server/lib/core/commands/add_cs_party_card_command.dart b/server/lib/core/commands/add_cs_party_card_command.dart index 4f59e4b..2628d03 100644 --- a/server/lib/core/commands/add_cs_party_card_command.dart +++ b/server/lib/core/commands/add_cs_party_card_command.dart @@ -15,7 +15,7 @@ class AddCSPartyCardCommand extends Command { @override void execute() { - ModifierDeck? deck = GameMethods.getModifierDeck(characterId, _gameState); + final ModifierDeck deck = GameMethods.getModifierDeck(characterId, _gameState); deck.addCSPartyCard(stateAccess, type); } diff --git a/server/lib/core/commands/add_faction_card_command.dart b/server/lib/core/commands/add_faction_card_command.dart index 00bbf0d..6848c9d 100644 --- a/server/lib/core/commands/add_faction_card_command.dart +++ b/server/lib/core/commands/add_faction_card_command.dart @@ -17,7 +17,7 @@ class AddFactionCardCommand extends Command { @override void execute() { - ModifierDeck? deck = GameMethods.getModifierDeck(characterId, _gameState); + final ModifierDeck deck = GameMethods.getModifierDeck(characterId, _gameState); if (add) { deck.addCard(stateAccess, cardId, CardType.add); } else { diff --git a/server/lib/core/commands/add_perk_command.dart b/server/lib/core/commands/add_perk_command.dart index c961e05..1b654b6 100644 --- a/server/lib/core/commands/add_perk_command.dart +++ b/server/lib/core/commands/add_perk_command.dart @@ -10,7 +10,7 @@ class AddPerkCommand extends Command { @override void execute() { - Character? character = GameMethods.getCharacterByName(characterId); + final Character? character = GameMethods.getCharacterByName(characterId); if (character != null) { character.flipPerk(stateAccess, index); } @@ -18,7 +18,7 @@ class AddPerkCommand extends Command { @override String describe() { - Character? character = GameMethods.getCharacterByName(characterId); + final Character? character = GameMethods.getCharacterByName(characterId); final charId = character?.id ?? characterId; if (character != null && !character.characterState.perkList[index]) { return commandL10n.cmdRemovePerk(charId, index); diff --git a/server/lib/core/commands/add_standee_command.dart b/server/lib/core/commands/add_standee_command.dart index ec10701..51c7ab5 100644 --- a/server/lib/core/commands/add_standee_command.dart +++ b/server/lib/core/commands/add_standee_command.dart @@ -37,7 +37,7 @@ class AddStandeeCommand extends Command { @override String describe() { final sum = summon; - String name = sum == null ? ownerId : sum.name; + final String name = sum == null ? ownerId : sum.name; return commandL10n.cmdAddStandee(name, nr); } diff --git a/server/lib/core/commands/amd_cassandra_special_command.dart b/server/lib/core/commands/amd_cassandra_special_command.dart index b1d1d5f..69bcea2 100644 --- a/server/lib/core/commands/amd_cassandra_special_command.dart +++ b/server/lib/core/commands/amd_cassandra_special_command.dart @@ -16,7 +16,7 @@ class AMDCassandraSpecialCommand extends Command { @override void execute() { - ModifierDeck deck = GameMethods.getModifierDeck(deckId, _gameState); + final ModifierDeck deck = GameMethods.getModifierDeck(deckId, _gameState); deck.setCassandraSpecial(stateAccess, on); } diff --git a/server/lib/core/commands/amd_imbue1_command.dart b/server/lib/core/commands/amd_imbue1_command.dart index 3cf52bc..d678979 100644 --- a/server/lib/core/commands/amd_imbue1_command.dart +++ b/server/lib/core/commands/amd_imbue1_command.dart @@ -8,7 +8,7 @@ class AMDImbue1Command extends Command { @override void execute() { - ModifierDeck deck = _gameState.modifierDeck; + final ModifierDeck deck = _gameState.modifierDeck; deck.setImbue1(stateAccess); } diff --git a/server/lib/core/commands/amd_imbue2_command.dart b/server/lib/core/commands/amd_imbue2_command.dart index 891d1f0..14e9bde 100644 --- a/server/lib/core/commands/amd_imbue2_command.dart +++ b/server/lib/core/commands/amd_imbue2_command.dart @@ -8,7 +8,7 @@ class AMDImbue2Command extends Command { @override void execute() { - ModifierDeck deck = _gameState.modifierDeck; + final ModifierDeck deck = _gameState.modifierDeck; deck.setImbue2(stateAccess); } diff --git a/server/lib/core/commands/amd_remove_imbue_command.dart b/server/lib/core/commands/amd_remove_imbue_command.dart index 0b37b5b..bb7219c 100644 --- a/server/lib/core/commands/amd_remove_imbue_command.dart +++ b/server/lib/core/commands/amd_remove_imbue_command.dart @@ -9,7 +9,7 @@ class AMDRemoveImbueCommand extends Command { @override void execute() { - ModifierDeck deck = _gameState.modifierDeck; + final ModifierDeck deck = _gameState.modifierDeck; deck.resetImbue(stateAccess); } diff --git a/server/lib/core/commands/amd_reveal_command.dart b/server/lib/core/commands/amd_reveal_command.dart index 1a0a1a3..a000b5c 100644 --- a/server/lib/core/commands/amd_reveal_command.dart +++ b/server/lib/core/commands/amd_reveal_command.dart @@ -16,7 +16,7 @@ class AMDRevealCommand extends Command { @override void execute() { - ModifierDeck deck = GameMethods.getModifierDeck(name, _gameState); + final ModifierDeck deck = GameMethods.getModifierDeck(name, _gameState); deck.revealCards(stateAccess, amount); } diff --git a/server/lib/core/commands/change_stat_commands/change_health_command.dart b/server/lib/core/commands/change_stat_commands/change_health_command.dart index 8d6b6f4..2ee11df 100644 --- a/server/lib/core/commands/change_stat_commands/change_health_command.dart +++ b/server/lib/core/commands/change_stat_commands/change_health_command.dart @@ -14,7 +14,7 @@ class ChangeHealthCommand extends ChangeStatCommand { @override void execute() { - FigureState? figure = GameMethods.getFigure(ownerId, figureId); + final FigureState? figure = GameMethods.getFigure(ownerId, figureId); if (figure != null) { final previousValue = figure.health; if (previousValue + change < 0) { @@ -44,7 +44,7 @@ class ChangeHealthCommand extends ChangeStatCommand { //TODO: looks bad return commandL10n.cmdIncreaseHealth(figureId, change); } - FigureState? figure = GameMethods.getFigure(ownerId, figureId); + final FigureState? figure = GameMethods.getFigure(ownerId, figureId); if (figure == null || figure.health <= 0) { return commandL10n.cmdKill(ownerId ?? ''); } diff --git a/server/lib/core/commands/change_stat_commands/change_max_health_command.dart b/server/lib/core/commands/change_stat_commands/change_max_health_command.dart index 70b26d9..38ad118 100644 --- a/server/lib/core/commands/change_stat_commands/change_max_health_command.dart +++ b/server/lib/core/commands/change_stat_commands/change_max_health_command.dart @@ -16,7 +16,7 @@ class ChangeMaxHealthCommand extends ChangeStatCommand { final FigureState? figure = GameMethods.getFigure(ownerId, figureId); if (figure == null) return; - int newValue = figure.maxHealth + change; + final int newValue = figure.maxHealth + change; if (newValue <= 0) { //can't lower maxvalue less than 1 return; diff --git a/server/lib/core/commands/donate_cs_sanctuary_command.dart b/server/lib/core/commands/donate_cs_sanctuary_command.dart index c1fdd0f..013850f 100644 --- a/server/lib/core/commands/donate_cs_sanctuary_command.dart +++ b/server/lib/core/commands/donate_cs_sanctuary_command.dart @@ -11,7 +11,7 @@ class DonateCSSanctuaryCommand extends Command { @override void execute() { - ModifierDeck? deck = GameMethods.getModifierDeck(characterId, _gameState); + final ModifierDeck deck = GameMethods.getModifierDeck(characterId, _gameState); deck.addCSSanctuary(stateAccess); } diff --git a/server/lib/core/commands/load_character_save_command.dart b/server/lib/core/commands/load_character_save_command.dart index 6014c47..6ca4d82 100644 --- a/server/lib/core/commands/load_character_save_command.dart +++ b/server/lib/core/commands/load_character_save_command.dart @@ -18,7 +18,7 @@ class LoadCharacterSaveCommand extends Command { @override void execute() { final data = json.decode(saveData) as Map<String, dynamic>; - Character character = Character.fromSave(data); + final Character character = Character.fromSave(data); //add new character on top of list, if not present. final Character? currentCharacter = GameMethods.getCharacterByName( diff --git a/server/lib/core/commands/next_round_command.dart b/server/lib/core/commands/next_round_command.dart index 22385fa..0c0c218 100644 --- a/server/lib/core/commands/next_round_command.dart +++ b/server/lib/core/commands/next_round_command.dart @@ -110,11 +110,11 @@ class NextRoundCommand extends Command { if (_settings.autoAddSpawns) { if (rule.name.isNotEmpty) { //get room data and deal with spawns - ScenarioModel? scenario = _gameData + final ScenarioModel? scenario = _gameData .modelData[_gameState.currentCampaign] ?.scenarios[_gameState.scenario]; if (scenario != null) { - ScenarioModel? spawnSection = scenario.sections.firstWhereOrNull( + final ScenarioModel? spawnSection = scenario.sections.firstWhereOrNull( (element) => element.name.substring(1) == rule.name, ); if (spawnSection != null) { diff --git a/server/lib/core/commands/remove_condition_command.dart b/server/lib/core/commands/remove_condition_command.dart index 04cdd40..c7bfa3e 100644 --- a/server/lib/core/commands/remove_condition_command.dart +++ b/server/lib/core/commands/remove_condition_command.dart @@ -18,9 +18,9 @@ class RemoveConditionCommand extends Command { @override void execute() { - FigureState? figure = GameMethods.getFigure(ownerId, figureId); + final FigureState? figure = GameMethods.getFigure(ownerId, figureId); if (figure != null) { - List<Condition> newList = []; + final List<Condition> newList = []; newList.addAll(figure.conditions); newList.remove(condition); figure.setConditions(stateAccess, newList); diff --git a/server/lib/core/commands/remove_cs_party_card_command.dart b/server/lib/core/commands/remove_cs_party_card_command.dart index 64f03bf..fa1a896 100644 --- a/server/lib/core/commands/remove_cs_party_card_command.dart +++ b/server/lib/core/commands/remove_cs_party_card_command.dart @@ -11,7 +11,7 @@ class RemoveCSPartyCardCommand extends Command { @override void execute() { - ModifierDeck? deck = GameMethods.getModifierDeck(characterId, _gameState); + final ModifierDeck deck = GameMethods.getModifierDeck(characterId, _gameState); deck.removeCSPartyCard(stateAccess); } diff --git a/server/lib/core/commands/remove_cs_sanctuary_donation_command.dart b/server/lib/core/commands/remove_cs_sanctuary_donation_command.dart index 3751097..4d9c246 100644 --- a/server/lib/core/commands/remove_cs_sanctuary_donation_command.dart +++ b/server/lib/core/commands/remove_cs_sanctuary_donation_command.dart @@ -13,7 +13,7 @@ class RemoveCSSanctuaryDonationCommand extends Command { @override void execute() { - ModifierDeck? deck = GameMethods.getModifierDeck(characterId, _gameState); + final ModifierDeck deck = GameMethods.getModifierDeck(characterId, _gameState); deck.removeCSSanctuary(stateAccess); } diff --git a/server/lib/core/commands/shuffle_drawn_ability_card_command.dart b/server/lib/core/commands/shuffle_drawn_ability_card_command.dart index 795b9b4..e9b6f8c 100644 --- a/server/lib/core/commands/shuffle_drawn_ability_card_command.dart +++ b/server/lib/core/commands/shuffle_drawn_ability_card_command.dart @@ -10,11 +10,11 @@ class ShuffleDrawnAbilityCardCommand extends Command { @override void execute() { - Monster? monster = GameMethods.getCurrentMonsters().firstWhereOrNull( + final Monster? monster = GameMethods.getCurrentMonsters().firstWhereOrNull( (element) => element.type.deck == deck, ); if (monster != null) { - MonsterAbilityState? deck = GameMethods.getDeck(monster.type.deck); + final MonsterAbilityState? deck = GameMethods.getDeck(monster.type.deck); deck?.shuffleUnDrawn(stateAccess); } } diff --git a/server/lib/core/commands/use_fh_perks_command.dart b/server/lib/core/commands/use_fh_perks_command.dart index 8200ae7..b857e45 100644 --- a/server/lib/core/commands/use_fh_perks_command.dart +++ b/server/lib/core/commands/use_fh_perks_command.dart @@ -9,7 +9,7 @@ class UseFHPerksCommand extends Command { @override void execute() { - Character? character = GameMethods.getCharacterByName(characterId); + final Character? character = GameMethods.getCharacterByName(characterId); if (character != null) { character.flipUseFHPerks(stateAccess); } @@ -17,7 +17,7 @@ class UseFHPerksCommand extends Command { @override String describe() { - Character? character = GameMethods.getCharacterByName(characterId); + final Character? character = GameMethods.getCharacterByName(characterId); final charId = character?.id ?? characterId; final use = character?.characterState.useFHPerks ?? false; if (use) { diff --git a/server/lib/core/enums.dart b/server/lib/core/enums.dart index 590f825..997dbe0 100644 --- a/server/lib/core/enums.dart +++ b/server/lib/core/enums.dart @@ -48,7 +48,7 @@ enum Condition { static const int _kChar4Index = 3; String _getCharacterName(int index) { - List<Character> characters = GameMethods.getCurrentCharacters(); + final List<Character> characters = GameMethods.getCurrentCharacters(); characters.sortBy((element) => element.characterClass.name); if (characters.length > index) { return characters[index].characterClass.name; diff --git a/server/lib/core/game_data.dart b/server/lib/core/game_data.dart index 65b4c59..db0ad68 100644 --- a/server/lib/core/game_data.dart +++ b/server/lib/core/game_data.dart @@ -29,24 +29,24 @@ class GameData { if (data.containsKey('summons')) { final summons = data['summons'] as Map<dynamic, dynamic>; - List<SummonModel> summonModels = []; + final List<SummonModel> summonModels = []; for (String key in summons.keys) { summonModels.add(SummonModel.fromJson(summons[key], key)); } itemSummonData = summonModels; } - Map<String, CampaignModel> map = {}; + final Map<String, CampaignModel> map = {}; final String editionsJson = File( p.join(root, 'editions', 'editions.json'), ).readAsStringSync(); final Map<String, dynamic> editionData = await json.decode(editionsJson); - List<String> editionList = []; + final List<String> editionList = []; for (String item in editionData["editions"]) { editionList.add(item); - List<RoomsModel> roomData = []; + final List<RoomsModel> roomData = []; final roomDataResult = await fetchRoomData(item, root); if (roomDataResult != null) roomData.addAll(roomDataResult.roomData); diff --git a/server/lib/core/game_methods.dart b/server/lib/core/game_methods.dart index cf43ab7..646a9f2 100644 --- a/server/lib/core/game_methods.dart +++ b/server/lib/core/game_methods.dart @@ -47,7 +47,7 @@ class GameMethods { static int getCoinValue({GameState? gameState}) { final gs = gameState ?? getIt<GameState>(); - int level = gs.level; + final int level = gs.level; if (level == _kCoinMaxLevel) { return _kCoinMaxValue; } @@ -162,7 +162,7 @@ class GameMethods { } static List<Character> getCurrentCharactersForState(GameState state) { - List<Character> characters = []; + final List<Character> characters = []; for (ListItemData data in state.currentList) { if (data is Character && !GameMethods.isObjectiveOrEscort(data.characterClass)) { @@ -291,7 +291,7 @@ class GameMethods { } static List<Monster> getCurrentMonsters({GameState? gameState}) { - List<Monster> monsters = []; + final List<Monster> monsters = []; final gs = gameState ?? getIt<GameState>(); for (ListItemData data in gs.currentList) { if (data is Monster) { @@ -304,7 +304,7 @@ class GameMethods { static int getNextAvailableBnBStandee(Monster data, {GameState? gameState}) { final gs = gameState ?? getIt<GameState>(); - int nrOfStandees = data.type.count; + final int nrOfStandees = data.type.count; for (int i = 0; i < nrOfStandees; i++) { bool isAvailable = true; for (final item in data.monsterInstances) { @@ -346,7 +346,7 @@ class GameMethods { nrOfStandees = _kPolarBearStandees; //for the special case where there are only 4 standees in first printing } - List<int> available = []; + final List<int> available = []; for (int i = 0; i < nrOfStandees; i++) { bool isAvailable = true; for (final item in data.monsterInstances) { @@ -400,7 +400,7 @@ class GameMethods { if (item.id == ownerId) { if (item is Monster) { for (final instance in item.monsterInstances) { - String id = + final String id = instance.name + instance.gfx + instance.standeeNr.toString(); if (id == figureId) { return instance; @@ -408,7 +408,7 @@ class GameMethods { } } else if (item is Character) { for (final instance in item.characterState.summonList) { - String id = + final String id = instance.name + instance.gfx + instance.standeeNr.toString(); if (id == figureId) { return instance; @@ -488,7 +488,7 @@ class GameMethods { GameState? gameState, }) { final gs = gameState ?? getIt<GameState>(); - String scenario = gs.scenario; + final String scenario = gs.scenario; if (edition == "Solo") { if (scenario.contains("${"#19"} ")) { return false; //this is forgotten circles @@ -584,7 +584,7 @@ class GameMethods { } static List<ModifierCard> getFactionCards(String faction) { - List<ModifierCard> retVal = []; + final List<ModifierCard> retVal = []; if (faction == "Demons") { retVal.add(ModifierCard(CardType.add, "Demons-perks/plus1any")); retVal.add( diff --git a/server/lib/core/line_builder/stat_applier.dart b/server/lib/core/line_builder/stat_applier.dart index 436e7ef..e706a73 100644 --- a/server/lib/core/line_builder/stat_applier.dart +++ b/server/lib/core/line_builder/stat_applier.dart @@ -49,7 +49,7 @@ class StatApplier { final normalTokens = _getStatTokens(monster, false); final eliteTokens = _getStatTokens(monster, true); - RegExp regExpNumbers = RegExp(r'^[\d ()xCL/*+-]+$'); + final RegExp regExpNumbers = RegExp(r'^[\d ()xCL/*+-]+$'); //first pass fix values only String lastToken = ""; //turn this into move or attack or whatever, then apply correct monster stat @@ -81,11 +81,11 @@ class StatApplier { ' ') //supposing there is always a leading whitespace to any formula ) { String formula = line[i]; - int startIndex = i; + final int startIndex = i; int endIndex = i; for (int j = i + 1; j < lineInput.length; j++) { - String val = lineInput[j]; + final String val = lineInput[j]; if (val.contains(regExpNumbers) || val == "d") { if (val != ' ') formula += val; endIndex = j; @@ -172,7 +172,7 @@ class StatApplier { } for (String item in data.attributes) { //remove size modifiers (only used for immobilize since it's so long it overflows.) - String sizeMod = (item.substring(0, 1)); + final String sizeMod = (item.substring(0, 1)); if (sizeMod == "^" || sizeMod == "*" && item.length > 1) { item = item.substring(1); } @@ -181,14 +181,14 @@ class StatApplier { //parse item and then parse number; for (int i = 1; i < item.length; i++) { if (item[i] == '%') { - String token = item.substring(1, i); + final String token = item.substring(1, i); int number = 0; if (i != item.length - 1) { for (int j = i + _kTokenEndOffset; j < item.length; j++) { if (item[j] == ' ' || j == item.length - 1) { //need to find end of nr and ignore the rest - String nr = item.substring(i + 1, j + 1); - int? res = StatCalculator.calculateFormula(nr); + final String nr = item.substring(i + 1, j + 1); + final int? res = StatCalculator.calculateFormula(nr); if (res != null) { number = res; } else { @@ -233,15 +233,15 @@ class StatApplier { return [line]; } - List<String> retVal = []; - List<String> tokens = []; - List<String> eTokens = []; + final List<String> retVal = []; + final List<String> tokens = []; + final List<String> eTokens = []; int normalValue = 0; int eliteValue = 0; bool skipCalculation = false; //in case un-calculable final level = monster.type.levels[monster.level]; - MonsterStatsModel? normal = level.boss ?? level.normal; - MonsterStatsModel? elite = level.elite; + final MonsterStatsModel? normal = level.boss ?? level.normal; + final MonsterStatsModel? elite = level.elite; if (lastToken == "attack") { if (normal == null) return []; int? calc = StatCalculator.calculateFormula(normal.attack); @@ -257,7 +257,7 @@ class StatApplier { } } - RegExp regEx = RegExp( + final RegExp regEx = RegExp( r"(?=.*[a-z])", ); //not sure why I do this. only letters? for (final item in normalTokens.keys) { @@ -296,8 +296,8 @@ class StatApplier { eliteValue = StatCalculator.calculateFormula(elite.move) ?? 0; } } else if (lastToken == "shield") { - int? value = normalTokens["shield"]; - int? eValue = eliteTokens["shield"]; + final int? value = normalTokens["shield"]; + final int? eValue = eliteTokens["shield"]; if (elite != null && eValue != null) { eliteValue = eValue; } @@ -305,8 +305,8 @@ class StatApplier { normalValue = value; } } else if (lastToken == "retaliate") { - int? value = normalTokens["retaliate"]; - int? eValue = eliteTokens["retaliate"]; + final int? value = normalTokens["retaliate"]; + final int? eValue = eliteTokens["retaliate"]; if (elite != null && eValue != null) { eliteValue = eValue; } @@ -336,8 +336,8 @@ class StatApplier { for (final item in tokens) { newStartOfLine += "|$item"; //add nr if applicable - String key = item.substring(1, item.length - 1); - int value = normalTokens[key] ?? 0; + final String key = item.substring(1, item.length - 1); + final int value = normalTokens[key] ?? 0; if (value > 0) { newStartOfLine += "$value"; } @@ -366,8 +366,8 @@ class StatApplier { eliteString += "|$item"; //add nr if applicable - String key = item.substring(1, item.length - 1); - int value = eliteTokens[key]!; + final String key = item.substring(1, item.length - 1); + final int value = eliteTokens[key]!; if (value > 0) { eliteString += "$value"; } @@ -377,7 +377,7 @@ class StatApplier { retVal.add(newStartOfLine); } if (endIndex < line.length) { - String leftOver = + final String leftOver = "!$sizeModifier${line.substring(endIndex + 1, line.length)}"; retVal.add(leftOver); diff --git a/server/lib/core/methods/character_methods.dart b/server/lib/core/methods/character_methods.dart index 9c2705a..6cd6c10 100644 --- a/server/lib/core/methods/character_methods.dart +++ b/server/lib/core/methods/character_methods.dart @@ -193,7 +193,7 @@ class CharacterMethods { final list = character.characterState.summonList; if (list.isNotEmpty && list.first.name == name) { - int hp = health + character.characterState.level * multiplier; + final int hp = health + character.characterState.level * multiplier; list.first.setMaxHealth(s, hp); list.first.setHealth(s, hp); } @@ -261,7 +261,7 @@ class CharacterMethods { } if (name.isNotEmpty) { - MonsterInstance summon = MonsterInstance.summon( + final MonsterInstance summon = MonsterInstance.summon( _kSpecialSummonStandeeNr, MonsterType.summon, name, @@ -282,7 +282,7 @@ class CharacterMethods { List<Character> characters, { GameState? gameState, }) { - List<ListItemData> newList = []; + final List<ListItemData> newList = []; final gs = gameState ?? getIt<GameState>(); for (final item in gs.currentList) { if (item is Character) { @@ -314,7 +314,7 @@ class CharacterMethods { GameData? gameData, }) { Character? character; - List<CharacterClass> characters = []; + final List<CharacterClass> characters = []; final gd = gameData ?? getIt<GameData>(); final modelData = gd.modelData; for (String key in modelData.keys) { @@ -371,7 +371,7 @@ class CharacterMethods { } if (name.isNotEmpty) { - MonsterInstance summon = MonsterInstance.summon( + final MonsterInstance summon = MonsterInstance.summon( _kSpecialSummonStandeeNr, MonsterType.summon, name, diff --git a/server/lib/core/methods/deck_methods.dart b/server/lib/core/methods/deck_methods.dart index 535324f..a501d23 100644 --- a/server/lib/core/methods/deck_methods.dart +++ b/server/lib/core/methods/deck_methods.dart @@ -35,7 +35,7 @@ class DeckMethods { for (final item in gs.currentList) { if (item is Monster) { if (item.type.deck == deck.name) { - bool specialInactive = GameMethods.isInactiveForRule( + final bool specialInactive = GameMethods.isInactiveForRule( item.type.name, ); if ((item.monsterInstances.isNotEmpty && !specialInactive) || diff --git a/server/lib/core/methods/element_methods.dart b/server/lib/core/methods/element_methods.dart index 5da97a3..c65d53c 100644 --- a/server/lib/core/methods/element_methods.dart +++ b/server/lib/core/methods/element_methods.dart @@ -13,7 +13,7 @@ class ElementMethods { static void updateElements(_StateModifier _, {GameState? gameState}) { //elementalist special: bool elementalistPerk = false; - Character? elementalist = GameMethods.getCharacterByName("Elementalist"); + final Character? elementalist = GameMethods.getCharacterByName("Elementalist"); if (elementalist != null && elementalist.characterState.perkList[15]) { if (elementalist.characterClass.edition == "Gloomhaven 2nd Edition") { elementalistPerk = true; diff --git a/server/lib/core/methods/monster_methods.dart b/server/lib/core/methods/monster_methods.dart index c0743b3..5ba936e 100644 --- a/server/lib/core/methods/monster_methods.dart +++ b/server/lib/core/methods/monster_methods.dart @@ -29,7 +29,7 @@ class MonsterMethods { GameData? gameData, }) { final gd = gameData ?? getIt<GameData>(); - Map<String, MonsterModel> monsters = {}; + final Map<String, MonsterModel> monsters = {}; final modelData = gd.modelData; for (String key in modelData.keys) { monsters.addAll(modelData[key]?.monsters ?? {}); @@ -43,8 +43,8 @@ class MonsterMethods { List<Monster> items, { GameState? gameState, }) { - List<String> deckIds = []; - List<ListItemData> newList = []; + final List<String> deckIds = []; + final List<ListItemData> newList = []; final gs = gameState ?? getIt<GameState>(); for (final item in gs.currentList) { if (item is Monster) { @@ -235,7 +235,7 @@ class MonsterMethods { GameState? gameState, }) { int levelAdjust = 0; - Set<String> alliedMonsters = {}; + final Set<String> alliedMonsters = {}; for (final rule in specialRules) { if (rule.name == monster || rule.name == "Enemies") { if (rule.type == "LevelAdjust") { @@ -285,7 +285,7 @@ class MonsterMethods { }) { final gs = gameState ?? getIt<GameState>(); //handle room data - int characterIndex = + final int characterIndex = GameMethods.getCurrentCharacterAmount().clamp( _kMinCharacters, _kMaxCharacters, @@ -295,7 +295,7 @@ class MonsterMethods { final roomMonsters = roomMonsterData[i]; addMonster(stateModifier, roomMonsters.name, gs._scenarioSpecialRules); } - bool addSorted = gs.currentCampaign == "Buttons and Bugs"; + final bool addSorted = gs.currentCampaign == "Buttons and Bugs"; final s = settings ?? getIt<Settings>(); if (!s.noStandees && s.autoAddStandees) { if (s.randomStandees || addSorted) { @@ -303,17 +303,17 @@ class MonsterMethods { initMessage += "\n"; } for (int i = 0; i < roomMonsterData.length; i++) { - List<int> normals = []; - List<int> elites = []; + final List<int> normals = []; + final List<int> elites = []; final roomMonsters = roomMonsterData[i]; - Monster data = + final Monster data = gs.currentList.firstWhereOrNull( (element) => element.id == roomMonsters.name, ) as Monster; - int eliteAmount = roomMonsters.elite[characterIndex]; - int normalAmount = roomMonsters.normal[characterIndex]; + final int eliteAmount = roomMonsters.elite[characterIndex]; + final int normalAmount = roomMonsters.normal[characterIndex]; bool isBoss = false; if (data.type.levels.first.boss != null) { @@ -321,7 +321,7 @@ class MonsterMethods { } for (int i = 0; i < eliteAmount; i++) { - int randomNr = GameMethods.getRandomStandee(data); + final int randomNr = GameMethods.getRandomStandee(data); if (randomNr != 0) { elites.add(randomNr); executeAddStandee( diff --git a/server/lib/core/methods/round_methods.dart b/server/lib/core/methods/round_methods.dart index 4ad146d..5102fb2 100644 --- a/server/lib/core/methods/round_methods.dart +++ b/server/lib/core/methods/round_methods.dart @@ -96,8 +96,8 @@ class RoundMethods { int init = 0; for (int i = 0; i < newList.length; i++) { - ListItemData currentItem = newList[i]; - int currentItemInitiative = GameMethods.getInitiative(currentItem); + final ListItemData currentItem = newList[i]; + final int currentItemInitiative = GameMethods.getInitiative(currentItem); if (currentItemInitiative > initiative && currentItemInitiative > init) { if (i > currentTurnItemIndex) { newList.insert(i, item); @@ -265,18 +265,18 @@ class RoundMethods { }) { final gs = gameState ?? getIt<GameState>(); final gd = gameData ?? getIt<GameData>(); - List<SpecialRule>? rules = + final List<SpecialRule>? rules = gd.modelData[gs.currentCampaign]?.scenarios[gs.scenario]?.specialRules; if (rules != null) { for (SpecialRule rule in rules) { if (rule.type == "Objective" || rule.type == "Escort") { - Character? character = + final Character? character = gs.currentList.firstWhereOrNull( (element) => element.id == rule.name, ) as Character?; if (character != null) { - int? newHealth = StatCalculator.calculateFormula( + final int? newHealth = StatCalculator.calculateFormula( rule.health.toString(), ); if (newHealth != character.characterState.maxHealth && @@ -286,14 +286,14 @@ class RoundMethods { } } } else if (rule.type == "LevelAdjust") { - Monster? monster = + final Monster? monster = gs.currentList.firstWhereOrNull( (element) => element.id == rule.name, ) as Monster?; if (monster != null) { if (gs.level == monster.level) { - int newLevel = (monster.level + rule.level).clamp( + final int newLevel = (monster.level + rule.level).clamp( _kMinLevel, _kMaxLevel, ); @@ -361,7 +361,7 @@ class RoundMethods { final conditions = figure._conditions; //handle chill separately - int nrOfChills = figure.conditions + final int nrOfChills = figure.conditions .where((a) => a == Condition.chill) .length; if (nrOfChills > 0) { @@ -380,7 +380,7 @@ class RoundMethods { .length; for (int i = conditions.length - 1; i >= 0; i--) { - Condition item = conditions[i]; + final Condition item = conditions[i]; if (GameMethods.canExpire(item)) { if (item != Condition.chill) { if (!figure.conditionsAddedThisTurn.contains(item)) { @@ -463,7 +463,7 @@ class RoundMethods { //get next active item and set to current for (; newIndex < gs.currentList.length; newIndex++) { - ListItemData data = gs.currentList[newIndex]; + final ListItemData data = gs.currentList[newIndex]; if (data is Monster) { if (data.isActive && !GameMethods.isInactiveForRule(data.type.name)) { if (data.turnState == TurnsState.done) { diff --git a/server/lib/core/methods/scenario_methods.dart b/server/lib/core/methods/scenario_methods.dart index 257d076..a75fc80 100644 --- a/server/lib/core/methods/scenario_methods.dart +++ b/server/lib/core/methods/scenario_methods.dart @@ -107,7 +107,7 @@ class ScenarioMethods { gs._scenario = scenario; gs._scenarioSectionsAdded = []; - List<ListItemData> newList = []; + final List<ListItemData> newList = []; for (final item in gs.currentList) { if (item is Character) { if (!GameMethods.isObjectiveOrEscort(item.characterClass)) { @@ -127,14 +127,14 @@ class ScenarioMethods { static void _initLootDeck(String scenario, GameState gs, GameData gd) { if (scenario != "custom") { final campaignModel = gd.modelData[gs.currentCampaign]; - LootDeckModel? lootDeckModel = + final LootDeckModel? lootDeckModel = campaignModel?.scenarios[scenario]?.lootDeck; lootDeckModel != null ? gs._lootDeck = LootDeck(lootDeckModel, gs.lootDeck) : gs._lootDeck = LootDeck.from(gs.lootDeck); } else { if (gs.currentCampaign == "Frosthaven") { - LootDeckModel? lootDeckModel = const LootDeckModel( + final LootDeckModel lootDeckModel = const LootDeckModel( 2, 2, 2, @@ -171,7 +171,7 @@ class ScenarioMethods { List<String> monsters = []; List<SpecialRule> specialRules = []; List<RoomMonsterData> roomMonsterData = []; - List<String> subSections = []; + final List<String> subSections = []; String initMessage = ""; if (section) { @@ -256,7 +256,7 @@ class ScenarioMethods { if (item.type == "Objective") { if (item.condition == "" || StatCalculator.evaluateCondition(item.condition as Object)) { - Character? objective = CharacterMethods.createCharacter( + final Character? objective = CharacterMethods.createCharacter( s, "Objective", null, diff --git a/server/lib/core/models/campaign.dart b/server/lib/core/models/campaign.dart index 0a393d3..02a87d0 100644 --- a/server/lib/core/models/campaign.dart +++ b/server/lib/core/models/campaign.dart @@ -32,30 +32,30 @@ class CampaignModel { final edition = data['edition'] as String; final monsterAbilities = (data['monsterAbilities'] as List<Object?>) .cast<Map<String, dynamic>>(); - List<MonsterAbilityDeckModel> deckDataList = []; + final List<MonsterAbilityDeckModel> deckDataList = []; for (final item in monsterAbilities) { deckDataList.add(MonsterAbilityDeckModel.fromJson(item, edition)); } - Map<String, MonsterModel> monsterMap = HashMap(); + final Map<String, MonsterModel> monsterMap = HashMap(); final monsters = data['monsters'] as Map<dynamic, dynamic>; for (String key in monsters.keys) { monsterMap[key] = MonsterModel.fromJson(monsters[key], key, edition); } - List<CharacterClass> characterDataList = []; + final List<CharacterClass> characterDataList = []; final classes = (data['classes'] as List<Object?>) .cast<Map<String, dynamic>>(); for (final item in classes) { characterDataList.add(CharacterClass.fromJson(item)); } - Map<String, ScenarioModel> scenarioMap = HashMap(); + final Map<String, ScenarioModel> scenarioMap = HashMap(); final scenarios = data['scenarios'] as Map<dynamic, dynamic>; for (String key in scenarios.keys) { //find right room if exists - RoomsModel? rooms = roomsData.firstWhereOrNull( + final RoomsModel? rooms = roomsData.firstWhereOrNull( (element) => element.scenarioName == key.substring(1).split(" ").first, ); scenarioMap[key] = ScenarioModel.fromJson(key, scenarios[key], rooms); diff --git a/server/lib/core/models/character_class.dart b/server/lib/core/models/character_class.dart index 12f4285..def0354 100644 --- a/server/lib/core/models/character_class.dart +++ b/server/lib/core/models/character_class.dart @@ -39,9 +39,9 @@ class CharacterClass { } //TODO: color array + gradiantType support final healthByLevel = (data['health'] as List<Object?>).cast<int>(); - int radix = 16; + final int radix = 16; final colorValue = data['color']; - Color color = (colorValue is List<Object?>) + final Color color = (colorValue is List<Object?>) ? Color(int.parse(colorValue.first as String, radix: radix)) : Color(int.parse(colorValue as String, radix: radix)); @@ -54,7 +54,7 @@ class CharacterClass { : Color(int.parse(data['colorSecondary'], radix: radix)); } - List<SummonModel> summonList = []; + final List<SummonModel> summonList = []; if (data.containsKey('summons')) { final summons = data['summons'] as Map<dynamic, dynamic>; for (String key in summons.keys) { @@ -62,7 +62,7 @@ class CharacterClass { } } - List<PerkModel> perkList = []; + final List<PerkModel> perkList = []; if (data.containsKey('perks')) { final perks = (data['perks'] as List<Object?>) .cast<Map<String, dynamic>>(); @@ -71,7 +71,7 @@ class CharacterClass { } } - List<PerkModel> perkFHList = []; + final List<PerkModel> perkFHList = []; if (data.containsKey('perks_fh')) { final perks = (data['perks_fh'] as List<Object?>) .cast<Map<String, dynamic>>(); @@ -107,7 +107,7 @@ class PerkModel { text = data['text']; } - List<String> addList = []; + final List<String> addList = []; if (data.containsKey('adds')) { final adds = (data['adds'] as List<Object?>).cast<String>(); for (String item in adds) { @@ -115,7 +115,7 @@ class PerkModel { } } - List<String> removeList = []; + final List<String> removeList = []; if (data.containsKey('removes')) { final removes = (data['removes'] as List<Object?>).cast<String>(); for (String item in removes) { diff --git a/server/lib/core/models/monster.dart b/server/lib/core/models/monster.dart index 77312cf..7e1232e 100644 --- a/server/lib/core/models/monster.dart +++ b/server/lib/core/models/monster.dart @@ -98,7 +98,7 @@ class MonsterModel { final levels = (data['levels'] as List<Object?>) .cast<Map<String, dynamic>>(); - List<MonsterLevelModel> monsterLevelDataList = []; + final List<MonsterLevelModel> monsterLevelDataList = []; for (final item in levels) { monsterLevelDataList.add(MonsterLevelModel.fromJson(item)); } diff --git a/server/lib/core/models/monster_ability.dart b/server/lib/core/models/monster_ability.dart index 3a90a52..f13ee3e 100644 --- a/server/lib/core/models/monster_ability.dart +++ b/server/lib/core/models/monster_ability.dart @@ -17,25 +17,25 @@ class MonsterAbilityDeckModel { as List< dynamic >; // ignore: avoid-dynamic, complex JSON cards array requires mutable dynamic list - List<MonsterAbilityCardModel> cards = []; + final List<MonsterAbilityCardModel> cards = []; for (final card in dynamicCards) { String title = name; if (card[0] is String) { title = card[0] as String; card.removeAt(0); } - int nr = card[0] as int; + final int nr = card[0] as int; ///duplication check if (cards.any((element) => element.nr == nr)) { print("duplicate monster ability card nr: $nr for $name"); } - bool shuffle = card[1] as bool; - int initiative = card[2] as int; - List<GraphicPositional> graphicPositionals = []; + final bool shuffle = card[1] as bool; + final int initiative = card[2] as int; + final List<GraphicPositional> graphicPositionals = []; if (card[3] is List) { //handle the graphic extras - List<dynamic> list = + final List<dynamic> list = card[3]; // ignore: avoid-dynamic, graphic extras are a dynamic JSON array for (final item in list) { @@ -47,7 +47,7 @@ class MonsterAbilityDeckModel { if (item.containsKey('scale')) { scale = item['scale']; } - GraphicPositional pos = GraphicPositional( + final GraphicPositional pos = GraphicPositional( item["gfx"], item["x"], item["y"], @@ -59,7 +59,7 @@ class MonsterAbilityDeckModel { card.removeAt(_kGraphicsIndex); } - List<String> lines = []; + final List<String> lines = []; for (int i = _kGraphicsIndex; i < card.length; i++) { lines.add(card[i] as String); } diff --git a/server/lib/core/models/room.dart b/server/lib/core/models/room.dart index 903dc47..036a385 100644 --- a/server/lib/core/models/room.dart +++ b/server/lib/core/models/room.dart @@ -6,11 +6,11 @@ class RoomMonsterData { const RoomMonsterData(this.name, this.normal, this.elite); factory RoomMonsterData.fromJson(Map<String, dynamic> data, String key) { - String name = key; - List<int> normal = data.containsKey('normal') + final String name = key; + final List<int> normal = data.containsKey('normal') ? data['normal'].cast<int>() : [0, 0, 0]; - List<int> elite = data.containsKey('elite') + final List<int> elite = data.containsKey('elite') ? data['elite'].cast<int>() : [0, 0, 0]; @@ -24,8 +24,8 @@ class RoomModel { const RoomModel(this.name, this.monsterData); factory RoomModel.fromJson(Map<String, dynamic> data) { - String name = data.keys.first; - List<RoomMonsterData> monsterList = []; + final String name = data.keys.first; + final List<RoomMonsterData> monsterList = []; data[name].forEach((key, value) { monsterList.add(RoomMonsterData.fromJson(value, key)); }); @@ -40,7 +40,7 @@ class RoomsModel { const RoomsModel(this.scenarioName, this.roomData); factory RoomsModel.fromJson(List<Object?> sectionData, String scenarioName) { - List<RoomModel> roomList = []; + final List<RoomModel> roomList = []; for (final value in sectionData) { roomList.add(RoomModel.fromJson(value as Map<String, dynamic>)); } @@ -54,7 +54,7 @@ class EditionRoomsModel { const EditionRoomsModel(this.roomData); factory EditionRoomsModel.fromJson(Map<String, dynamic> data) { - List<RoomsModel> roomList = []; + final List<RoomsModel> roomList = []; for (final entry in data.entries) { roomList.add(RoomsModel.fromJson(entry.value, entry.key)); } diff --git a/server/lib/core/models/scenario.dart b/server/lib/core/models/scenario.dart index 18cd709..0e3d97e 100644 --- a/server/lib/core/models/scenario.dart +++ b/server/lib/core/models/scenario.dart @@ -164,14 +164,14 @@ class ScenarioModel { Map<String, dynamic> data, RoomsModel? rooms, ) { - List<String> monsterList = []; + final List<String> monsterList = []; if (data.containsKey('monsters')) { final monsters = (data['monsters'] as List<Object?>).cast<String>(); for (final monster in monsters) { monsterList.add(monster); } } - List<SpecialRule> rulesList = []; + final List<SpecialRule> rulesList = []; if (data.containsKey('special')) { final specialRules = (data['special'] as List<Object?>) .cast<Map<String, dynamic>>(); @@ -188,10 +188,10 @@ class ScenarioModel { initMessage = data['initialMessage']; } - List<ScenarioModel> sectionList = []; + final List<ScenarioModel> sectionList = []; if (rooms != null) { - List names = []; + final List names = []; for (final u in rooms.roomData) { if (names.contains(u.name)) { print("duplicate ${u.name} in ${rooms.scenarioName}"); @@ -218,14 +218,14 @@ class ScenarioModel { } else { //it might be a bit silly that room data and section data is separate //merge if has already - int splitIndex = 0; + final int splitIndex = 0; //would be nice to know which is solo scenario - ScenarioModel? section = sectionList.firstWhereOrNull( + final ScenarioModel? section = sectionList.firstWhereOrNull( (element) => element.name == key.split(" ")[splitIndex], ); if (section != null) { //merge - ScenarioModel model = ScenarioModel.sectionFromJson( + final ScenarioModel model = ScenarioModel.sectionFromJson( key, sections[key], rooms, @@ -261,14 +261,14 @@ class ScenarioModel { Map<String, dynamic> data, RoomsModel? rooms, ) { - List<String> monsterList = []; + final List<String> monsterList = []; if (data.containsKey('monsters')) { final monsters = (data['monsters'] as List<Object?>).cast<String>(); for (final monster in monsters) { monsterList.add(monster); } } - List<SpecialRule> rulesList = []; + final List<SpecialRule> rulesList = []; if (data.containsKey('special')) { final specialRules = (data['special'] as List<Object?>) .cast<Map<String, dynamic>>(); @@ -282,7 +282,7 @@ class ScenarioModel { } //find right room - List<RoomMonsterData>? standees = rooms?.roomData + final List<RoomMonsterData>? standees = rooms?.roomData .firstWhereOrNull( (element) => element.name == diff --git a/server/lib/core/models/summon_model.dart b/server/lib/core/models/summon_model.dart index 802f3f8..4beb176 100644 --- a/server/lib/core/models/summon_model.dart +++ b/server/lib/core/models/summon_model.dart @@ -21,7 +21,7 @@ class SummonModel { ); factory SummonModel.fromJson(Map<String, dynamic> data, String key) { - String name = key; + final String name = key; StatValue health = const IntStatValue(2); //default to 2 not to die if (data.containsKey('health')) { health = StatValue.fromJson(data['health']); diff --git a/server/lib/core/settings.dart b/server/lib/core/settings.dart index 3f25afe..31d3e79 100644 --- a/server/lib/core/settings.dart +++ b/server/lib/core/settings.dart @@ -52,7 +52,7 @@ class Settings { /// Loads the named save into the game state (an undoable command). void loadSave(String saveName, {GameState? gameState}) { - String? save = saves[saveName]; + final String? save = saves[saveName]; if (save != null) { final gs = gameState ?? getIt<GameState>(); gs.action(LoadSaveCommand(saveName, save, gameState: gs)); @@ -72,7 +72,7 @@ class Settings { /// Loads the named character save (an undoable command). void loadCharacterSave(String saveId, {GameState? gameState}) { - String? save = characterSaves[saveId]; + final String? save = characterSaves[saveId]; if (save != null) { final gs = gameState ?? getIt<GameState>(); final name = saveId.split('\n').first; diff --git a/server/lib/core/stat_calculator.dart b/server/lib/core/stat_calculator.dart index 2ffb297..7027644 100644 --- a/server/lib/core/stat_calculator.dart +++ b/server/lib/core/stat_calculator.dart @@ -26,7 +26,7 @@ class StatCalculator { if (C < minNrCharacters) { C = minNrCharacters; } - int L = gs.level; + final int L = gs.level; String formula = str.replaceAll("C", C.toString()); formula = formula.replaceAll("L", L.toString()); return eval(formula); @@ -66,7 +66,7 @@ class Parser { int? parse() { try { nextChar(); - int? result = parseCondition(); + final int? result = parseCondition(); if (pos < str.length) { // ignore: avoid_print print("Unexpected: $ch"); @@ -148,7 +148,7 @@ class Parser { if (eat('-')) return -parseFactor()!; // unary minus int? result; - int startPos = pos; + final int startPos = pos; int asciiValue = ch.codeUnits.first; if (eat('(')) { // parentheses diff --git a/server/lib/core/state/game_save_state.dart b/server/lib/core/state/game_save_state.dart index 331b3a8..57ddf30 100644 --- a/server/lib/core/state/game_save_state.dart +++ b/server/lib/core/state/game_save_state.dart @@ -27,7 +27,7 @@ class GameSaveState { } if (data.containsKey('scenarioSectionsAdded')) { - List<Object?> scenarioSectionsAdded = + final List<Object?> scenarioSectionsAdded = data['scenarioSectionsAdded'] as List<Object?>; gameState._scenarioSectionsAdded.clear(); for (final item in scenarioSectionsAdded) { @@ -78,7 +78,7 @@ class GameSaveState { //main list — update existing objects in-place final list = data['currentList'] as List; - List<ListItemData> newList = []; + final List<ListItemData> newList = []; for (Map<String, dynamic> item in list) { if (item["noteRow"] == true) { final String itemId = item["id"] as String; @@ -133,10 +133,10 @@ class GameSaveState { // Prototype has the full initialized card set; used only for nr lookups. final proto = MonsterAbilityState(deckName); - List<MonsterAbilityCardModel> newDrawList = []; - List drawPile = item["drawPile"] as List; + final List<MonsterAbilityCardModel> newDrawList = []; + final List drawPile = item["drawPile"] as List; for (final cardItem in drawPile) { - int nr = cardItem["nr"]; + final int nr = cardItem["nr"]; for (final card in proto._drawPile.getList()) { if (card.nr == nr) { newDrawList.add(card); @@ -144,9 +144,9 @@ class GameSaveState { } } } - List<MonsterAbilityCardModel> newDiscardList = []; + final List<MonsterAbilityCardModel> newDiscardList = []; for (final cardItem in item["discardPile"] as List) { - int nr = cardItem["nr"]; + final int nr = cardItem["nr"]; for (final card in proto._drawPile.getList()) { if (card.nr == nr) { newDiscardList.add(card); @@ -192,7 +192,7 @@ class GameSaveState { } //////elements - Map elementData = data['elementState']; + final Map elementData = data['elementState']; for (final element in Elements.values) { final raw = elementData[element.index.toString()] as int?; final idx = @@ -218,7 +218,7 @@ class GameSaveState { void loadFromDisk(GameState gameState) { //have to call after init or element state overridden - String? data = getIt<SaveStore>().read(); + final String? data = getIt<SaveStore>().read(); if (data != null) { _savedState = data; load(gameState); diff --git a/server/lib/core/state/game_state.dart b/server/lib/core/state/game_state.dart index 23666fe..fc2521e 100644 --- a/server/lib/core/state/game_state.dart +++ b/server/lib/core/state/game_state.dart @@ -257,13 +257,13 @@ class GameState { String toString() => json.encode(toJson()); void save() { - GameSaveState state = GameSaveState(); + final GameSaveState state = GameSaveState(); state.saveToDisk(this); addSaveState(state); } void load() { - GameSaveState state = GameSaveState(); + final GameSaveState state = GameSaveState(); state.loadFromDisk(this); addSaveState( state, @@ -271,7 +271,7 @@ class GameState { } void loadFromData(String data) { - GameSaveState state = GameSaveState(); + final GameSaveState state = GameSaveState(); state.loadFromData(data, this); } diff --git a/server/lib/core/state/loot_deck_state.dart b/server/lib/core/state/loot_deck_state.dart index ccd1003..790e161 100644 --- a/server/lib/core/state/loot_deck_state.dart +++ b/server/lib/core/state/loot_deck_state.dart @@ -48,7 +48,7 @@ class LootCard { if (enhanced > 0) { value += enhanced; } - int characters = GameMethods.getCurrentCharacterAmount(); + final int characters = GameMethods.getCurrentCharacterAmount(); if (characters >= _kHighCharCount) { return value; } @@ -200,14 +200,14 @@ class LootDeck { )..owner = owner; } - List<LootCard> newDrawList = []; - List drawPile = lootDeckData["drawPile"] as List; + final List<LootCard> newDrawList = []; + final List drawPile = lootDeckData["drawPile"] as List; int id = 0; for (final item in drawPile) { if (item.containsKey('id')) id = item["id"] as int; newDrawList.add(cardFromJson(item as Map, id)); } - List<LootCard> newDiscardList = []; + final List<LootCard> newDiscardList = []; for (final item in lootDeckData["discardPile"] as List) { if (item.containsKey('id')) id = item["id"] as int; newDiscardList.add(cardFromJson(item as Map, id)); @@ -244,7 +244,7 @@ class LootDeck { } void _setDeck(LootDeckModel model) { - List<LootCard> cards = []; + final List<LootCard> cards = []; if (_hasCard1419) { _addOtherType(_kSpecialCard1419, cards, "special 1419"); @@ -434,7 +434,7 @@ class LootDeck { } List<LootCard> _getAvailableCards(List<LootCard> pool) { - List<LootCard> list = []; + final List<LootCard> list = []; for (final item in pool) { if (!_drawPile.getList().any((element) => element.id == item.id)) { list.add(item); @@ -525,8 +525,8 @@ class LootDeck { _initPools(); final gs = gameState ?? getIt<GameState>(); final gd = gameData ?? getIt<GameData>(); - String scenario = gs.scenario; - LootDeckModel? lootDeckModel = + final String scenario = gs.scenario; + final LootDeckModel? lootDeckModel = gd.modelData[gs.currentCampaign]?.scenarios[scenario]?.lootDeck; if (lootDeckModel != null) { _setDeck(lootDeckModel); @@ -535,7 +535,7 @@ class LootDeck { void _shuffle() { while (_discardPile.isNotEmpty) { - LootCard card = _discardPile.pop(); + final LootCard card = _discardPile.pop(); _drawPile.push(card); } _drawPile.shuffle(); @@ -543,7 +543,7 @@ class LootDeck { void draw(_StateModifier _, {GameState? gameState}) { //put top of draw pile on discard pile - LootCard card = _drawPile.pop(); + final LootCard card = _drawPile.pop(); //mark owner final gs = gameState ?? getIt<GameState>(); diff --git a/server/lib/core/state/modifier_deck.dart b/server/lib/core/state/modifier_deck.dart index b7c00f1..d50131f 100644 --- a/server/lib/core/state/modifier_deck.dart +++ b/server/lib/core/state/modifier_deck.dart @@ -100,7 +100,7 @@ class ModifierDeck { _needsShuffle = false; for (final item in modifierDeckData["drawPile"] as List) { - String gfx = item["gfx"]; + final String gfx = item["gfx"]; if (gfx == "curse" || gfx.contains("empower") || gfx.contains("enfeeble") || @@ -109,7 +109,7 @@ class ModifierDeck { } } for (final item in modifierDeckData["discardPile"] as List) { - String gfx = item["gfx"]; + final String gfx = item["gfx"]; if (_isMultiplyType(gfx)) { _needsShuffle = true; } @@ -527,7 +527,7 @@ class ModifierDeck { } //put top of draw pile on discard pile if (_drawPile.isNotEmpty) { - ModifierCard card = _drawPile.pop(); + final ModifierCard card = _drawPile.pop(); if (card.type == CardType.multiply) { _needsShuffle = true; } @@ -540,7 +540,7 @@ class ModifierDeck { } void reorderCards(_StateModifier s, int newIndex, int oldIndex) { - List<ModifierCard> list = List.of(_drawPile.getList()); + final List<ModifierCard> list = List.of(_drawPile.getList()); final item = list.removeAt(oldIndex); list.insert(newIndex, item); _drawPile.setList(list); @@ -588,7 +588,7 @@ class ModifierDeck { Map<String, dynamic> modifierDeckData, String deckId, ) { - List<ModifierCard> newList = []; + final List<ModifierCard> newList = []; for (final item in modifierDeckData[deckId] as List) { String gfx = item["gfx"]; gfx = gfx.replaceAll("-allies", ""); @@ -614,7 +614,7 @@ class ModifierDeck { } void _initDeck() { - List<ModifierCard> cards = []; + final List<ModifierCard> cards = []; cards.add(ModifierCard(CardType.add, "minus2")); cards.add(ModifierCard(CardType.add, "plus2")); cards.add(ModifierCard(CardType.multiply, "doubleAttack")); @@ -688,7 +688,7 @@ class ModifierDeck { } } } else { - int toRemove = count - notifierValue; + final int toRemove = count - notifierValue; for (int i = 0; i < toRemove; i++) { _drawPile.removeFirstWhere((card) => card.gfx == gfx); } @@ -700,7 +700,7 @@ class ModifierDeck { void _shuffle() { while (_discardPile.isNotEmpty) { - ModifierCard card = _discardPile.pop(); + final ModifierCard card = _discardPile.pop(); //remove curse and bless if (card.type != CardType.remove) { _drawPile.push(card); @@ -714,7 +714,7 @@ class ModifierDeck { void _shuffleOnlyBelowRevealed() { final revealCount = _revealedCount; - List<ModifierCard> revealed = []; + final List<ModifierCard> revealed = []; for (int i = 0; i < _revealedCount; i++) { revealed.insert(0, _drawPile.pop()); } @@ -728,7 +728,7 @@ class ModifierDeck { void _shuffleDrawPileRespectCassandra() { if (_cassandraSpecial) { //dont shuffle the revealed cards - List<ModifierCard> revealed = []; + final List<ModifierCard> revealed = []; for (int i = 0; i < _revealedCount; i++) { revealed.insert(0, _drawPile.pop()); } diff --git a/server/lib/core/state/monster.dart b/server/lib/core/state/monster.dart index 6ed3f67..c936907 100644 --- a/server/lib/core/state/monster.dart +++ b/server/lib/core/state/monster.dart @@ -73,7 +73,7 @@ class Monster extends ListItemData { _isActive = json['isActive']; } - List<Object?> instanceList = json["monsterInstances"] as List<Object?>; + final List<Object?> instanceList = json["monsterInstances"] as List<Object?>; _monsterInstances.clear(); for (Map<String, dynamic> item diff --git a/server/lib/core/state/monster_ability_state.dart b/server/lib/core/state/monster_ability_state.dart index 161a063..f1d4403 100644 --- a/server/lib/core/state/monster_ability_state.dart +++ b/server/lib/core/state/monster_ability_state.dart @@ -31,7 +31,7 @@ class MonsterAbilityState { MonsterAbilityState(this.name, {GameData? gameData}) { final gd = gameData ?? getIt<GameData>(); - List<MonsterAbilityDeckModel> monsters = []; + final List<MonsterAbilityDeckModel> monsters = []; for (String key in gd.modelData.keys) { monsters.addAll(gd.modelData[key]?.monsterAbilities ?? []); } diff --git a/server/lib/core/state/monster_instance.dart b/server/lib/core/state/monster_instance.dart index a3fde0c..f4c3c99 100644 --- a/server/lib/core/state/monster_instance.dart +++ b/server/lib/core/state/monster_instance.dart @@ -81,7 +81,7 @@ class MonsterInstance extends FigureState { newHealthValue = levels[levelIndex].normal?.health ?? newHealthValue; } } - int? value = StatCalculator.calculateFormula(newHealthValue); + final int? value = StatCalculator.calculateFormula(newHealthValue); if (value != null) { _maxHealth = value; } else { @@ -178,7 +178,7 @@ class MonsterInstance extends FigureState { } if (json.containsKey("conditionsAddedThisTurn")) { - List<Object?> condis2 = json["conditionsAddedThisTurn"] as List<Object?>; + final List<Object?> condis2 = json["conditionsAddedThisTurn"] as List<Object?>; for (int item in condis2.cast<int>()) { if (item >= 0 && item < Condition.values.length) { _conditionsAddedThisTurn.add(Condition.values[item]); @@ -186,7 +186,7 @@ class MonsterInstance extends FigureState { } } if (json.containsKey("conditionsAddedPreviousTurn")) { - List<Object?> condis3 = + final List<Object?> condis3 = json["conditionsAddedPreviousTurn"] as List<Object?>; for (int item in condis3.cast<int>()) { if (item >= 0 && item < Condition.values.length) { diff --git a/server/lib/core/state/sanctuary_deck.dart b/server/lib/core/state/sanctuary_deck.dart index 8858fea..0221403 100644 --- a/server/lib/core/state/sanctuary_deck.dart +++ b/server/lib/core/state/sanctuary_deck.dart @@ -16,14 +16,14 @@ class SanctuaryDeck { SanctuaryDeck.fromJson(Map<String, dynamic> modifierDeckData) { _initDeck(); - List<ModifierCard> newMultList = []; - List<ModifierCard> newFlipList = []; + final List<ModifierCard> newMultList = []; + final List<ModifierCard> newFlipList = []; for (final item in modifierDeckData["multPile"] as List) { - String gfx = item["gfx"]; + final String gfx = item["gfx"]; newMultList.add(ModifierCard(CardType.remove, gfx)); } for (final item in modifierDeckData["flipPile"] as List) { - String gfx = item["gfx"]; + final String gfx = item["gfx"]; newFlipList.add(ModifierCard(CardType.remove, gfx)); } _multPile.setList(newMultList); @@ -67,8 +67,8 @@ class SanctuaryDeck { void _initDeck() { _multPile.clear(); _flipPile.clear(); - List<ModifierCard> flipCards = []; - List<ModifierCard> multCards = []; + final List<ModifierCard> flipCards = []; + final List<ModifierCard> multCards = []; final prefix = "sanctuary/"; for (int i = 1; i < _kCardTypeCount; i++) { //2 of each of 4 different cards diff --git a/server/test/command/add_character_command_test.dart b/server/test/command/add_character_command_test.dart index 4fe9f1c..0795c3c 100644 --- a/server/test/command/add_character_command_test.dart +++ b/server/test/command/add_character_command_test.dart @@ -8,8 +8,8 @@ import 'package:x_haven_server/core/state/game_state.dart'; import 'test_helpers.dart'; void _tests() { - String oldState = gameState.toString(); - AddCharacterCommand command = AddCharacterCommand( + final String oldState = gameState.toString(); + final AddCharacterCommand command = AddCharacterCommand( "Hatchet", "Jaws of the Lion", "Arnold", @@ -29,7 +29,7 @@ void _tests() { "Hatchet", ); expect(gameState.currentList.length, 1); - Character brute = GameMethods.getCurrentCharacters().first; + final Character brute = GameMethods.getCurrentCharacters().first; expect(brute.characterState.display, "Arnold"); expect(brute.characterState.level, 9); expect(gameState.unlockedClasses.first, "Hatchet"); diff --git a/server/test/command/amd_remove_minus_1_command_test.dart b/server/test/command/amd_remove_minus_1_command_test.dart index 715dc1d..0d3c950 100644 --- a/server/test/command/amd_remove_minus_1_command_test.dart +++ b/server/test/command/amd_remove_minus_1_command_test.dart @@ -38,7 +38,7 @@ void main() { test('should remove a minus one card from a character deck', () { // Arrange final modifierDeck = character.characterState.modifierDeck; - int initialCount = _getMinusOnes(modifierDeck); + final int initialCount = _getMinusOnes(modifierDeck); expect(initialCount, 5); final command = AMDRemoveMinus1Command( @@ -61,7 +61,7 @@ void main() { character.id, gameState: getIt<GameState>(), ).execute(); // Add one first - int initialCount = _getMinusOnes(modifierDeck); + final int initialCount = _getMinusOnes(modifierDeck); expect(initialCount, 6); final command = AMDRemoveMinus1Command( @@ -84,7 +84,7 @@ void main() { character.id, gameState: getIt<GameState>(), ).execute(); // Add one first - int initialCount = _getMinusOnes(modifierDeck); + final int initialCount = _getMinusOnes(modifierDeck); expect(initialCount, 6); final command = AMDRemoveMinus1Command( diff --git a/server/test/command/test_helpers.dart b/server/test/command/test_helpers.dart index 67e6f16..3480d58 100644 --- a/server/test/command/test_helpers.dart +++ b/server/test/command/test_helpers.dart @@ -25,11 +25,11 @@ Future<void> setUpGame() async { } void checkSaveState() { - String state = gameState.toString(); - int nrStates = gameState.gameSaveStates.length; + final String state = gameState.toString(); + final int nrStates = gameState.gameSaveStates.length; gameState.save(); gameState.load(); - String newState = gameState.toString(); + final String newState = gameState.toString(); assert( gameState.gameSaveStates.length == nrStates + 2, ); //for some reason a null state is added on load. @@ -41,7 +41,7 @@ void checkNoSideEffects(List<String> changedFields, String oldState) { json.decode(oldState), json.decode(gameState.toString()), ); - DiffNode diff = differ.diff(); + final DiffNode diff = differ.diff(); diff.forEach((s, dn) { print("for each"); diff --git a/server/test/resource/game_methods_test.dart b/server/test/resource/game_methods_test.dart index f960ca9..dfa60fe 100644 --- a/server/test/resource/game_methods_test.dart +++ b/server/test/resource/game_methods_test.dart @@ -32,7 +32,7 @@ void main() async { test('should return 2 + game level when level is 4', () { // Act: Call the method we are testing. SetLevelCommand(4, null).execute(); - String oldState = gameState.toString(); + final String oldState = gameState.toString(); final result = GameMethods.getTrapValue(); // Assert: Check if the result is what we expect. @@ -42,7 +42,7 @@ void main() async { test('should return 2 when game level is 0', () { SetLevelCommand(0, null).execute(); - String oldState = gameState.toString(); + final String oldState = gameState.toString(); // Act final result = GameMethods.getTrapValue(); @@ -53,7 +53,7 @@ void main() async { test('should return 9 when game level is 7', () { SetLevelCommand(7, null).execute(); - String oldState = gameState.toString(); + final String oldState = gameState.toString(); // Act final result = GameMethods.getTrapValue(); @@ -291,7 +291,7 @@ void main() async { 35, gameState: getIt<GameState>(), ).execute(); - String oldState = gameState.toString(); + final String oldState = gameState.toString(); final character = getIt<GameState>().currentList.first as Character; expect(GameMethods.getInitiative(character), 35); checkNoSideEffects([], oldState); @@ -316,7 +316,7 @@ void main() async { test('should return the correct character', () { getIt<GameState>().clearList(); AddCharacterCommand('Blinkblade', 'Frosthaven', "", 1).execute(); - String oldState = gameState.toString(); + final String oldState = gameState.toString(); final character = GameMethods.getCharacterByName('Blinkblade'); expect(character, isNotNull); expect(character!.id, 'Blinkblade'); @@ -326,7 +326,7 @@ void main() async { test('should return null if character does not exist', () { getIt<GameState>().clearList(); AddCharacterCommand('Blinkblade', 'Frosthaven', "", 1).execute(); - String oldState = gameState.toString(); + final String oldState = gameState.toString(); final character = GameMethods.getCharacterByName( 'NonExistentCharacter', ); @@ -340,7 +340,7 @@ void main() async { getIt<GameState>().clearList(); AddCharacterCommand('Blinkblade', 'Frosthaven', "", 1).execute(); AddCharacterCommand('Banner Spear', 'Frosthaven', "", 1).execute(); - String oldState = gameState.toString(); + final String oldState = gameState.toString(); final characters = GameMethods.getCurrentCharacters(); expect(characters.length, 2); expect(characters[1].id, 'Blinkblade'); @@ -350,7 +350,7 @@ void main() async { test('should return an empty list if no characters', () { getIt<GameState>().clearList(); - String oldState = gameState.toString(); + final String oldState = gameState.toString(); final characters = GameMethods.getCurrentCharacters(); expect(characters, isEmpty); checkNoSideEffects([], oldState); @@ -372,7 +372,7 @@ void main() async { 'Blinkblade', gameState: getIt<GameState>(), ).execute(); // It's now Banner Spear's turn - String oldState = gameState.toString(); + final String oldState = gameState.toString(); final character = GameMethods.getCurrentCharacter(); expect(character, isNotNull); expect(character!.id, 'Banner Spear'); @@ -391,7 +391,7 @@ void main() async { getIt<GameState>().currentList.first.id, gameState: getIt<GameState>(), ).execute(); // It's now a monster's turn - String oldState = gameState.toString(); + final String oldState = gameState.toString(); final character = GameMethods.getCurrentCharacter(); expect(character, isNull); checkNoSideEffects([], oldState); @@ -400,14 +400,14 @@ void main() async { group('getModifierDeck', () { test('should return the monster modifier deck', () { - String oldState = gameState.toString(); + final String oldState = gameState.toString(); final deck = GameMethods.getModifierDeck('', getIt<GameState>()); expect(deck, equals(getIt<GameState>().modifierDeck)); checkNoSideEffects([], oldState); }); test('should return the allies modifier deck', () { - String oldState = gameState.toString(); + final String oldState = gameState.toString(); final deck = GameMethods.getModifierDeck('allies', getIt<GameState>()); expect(deck, equals(getIt<GameState>().modifierDeckAllies)); checkNoSideEffects([], oldState); @@ -421,7 +421,7 @@ void main() async { 'Blinkblade', 1, ).execute(); - String oldState = gameState.toString(); + final String oldState = gameState.toString(); final deck = GameMethods.getModifierDeck( 'Blinkblade', getIt<GameState>(), @@ -441,7 +441,7 @@ void main() async { 'Blinkblade', 1, ).execute(); - String oldState = gameState.toString(); + final String oldState = gameState.toString(); final character = getIt<GameState>().currentList.first as Character; expect(GameMethods.canAddPerk(character, 0), isTrue); checkNoSideEffects([], oldState); @@ -457,7 +457,7 @@ void main() async { ).execute(); final character = getIt<GameState>().currentList.first as Character; AddPerkCommand(character.id, 0).execute(); - String oldState = gameState.toString(); + final String oldState = gameState.toString(); expect(GameMethods.canAddPerk(character, 0), isFalse); checkNoSideEffects([], oldState); }); @@ -474,7 +474,7 @@ void main() async { ).execute(); final character = getIt<GameState>().currentList.first as Character; AddPerkCommand(character.id, 0).execute(); - String oldState = gameState.toString(); + final String oldState = gameState.toString(); expect(GameMethods.canRemovePerk(character, 0), isTrue); checkNoSideEffects([], oldState); }); @@ -490,7 +490,7 @@ void main() async { final character = getIt<GameState>().currentList.first as Character; AddPerkCommand(character.id, 12).execute(); AddPerkCommand(character.id, 13).execute(); - String oldState = gameState.toString(); + final String oldState = gameState.toString(); expect(GameMethods.canRemovePerk(character, 5), isFalse); checkNoSideEffects([], oldState); }); @@ -498,7 +498,7 @@ void main() async { group('perkGfxIdToCardId', () { test('should return the original gfx id if it is not a perk', () { - String oldState = gameState.toString(); + final String oldState = gameState.toString(); final id = GameMethods.perkGfxIdToCardId( 'test', PerkModel("", const [], const []), @@ -509,7 +509,7 @@ void main() async { }); test('should return the correct card id for a perk', () { - String oldState = gameState.toString(); + final String oldState = gameState.toString(); final perk = PerkModel("", const [], const ['perks/test']); final id = GameMethods.perkGfxIdToCardId('perks/test', perk, 0); expect(id, 'P0'); @@ -517,7 +517,7 @@ void main() async { }); test('should return the correct card id for a perk with two images', () { - String oldState = gameState.toString(); + final String oldState = gameState.toString(); final perk = PerkModel("", const [], const [ 'perks/test', 'perks/test2', @@ -533,14 +533,14 @@ void main() async { getIt<GameState>().clearList(); AddCharacterCommand('Blinkblade', 'Frosthaven', "", 1).execute(); AddCharacterCommand('Banner Spear', 'Frosthaven', "", 1).execute(); - String oldState = gameState.toString(); + final String oldState = gameState.toString(); expect(GameMethods.getCurrentCharacterAmount(), 2); checkNoSideEffects([], oldState); }); test('should return 0 if no characters', () { getIt<GameState>().clearList(); - String oldState = gameState.toString(); + final String oldState = gameState.toString(); expect(GameMethods.getCurrentCharacterAmount(), 0); checkNoSideEffects([], oldState); }); @@ -555,7 +555,7 @@ void main() async { false, gameState: getIt<GameState>(), ).execute(); - String oldState = gameState.toString(); + final String oldState = gameState.toString(); final monsters = GameMethods.getCurrentMonsters(); expect(monsters.length, 3); expect(monsters[0].id, 'Zealot'); @@ -566,7 +566,7 @@ void main() async { test('should return an empty list if no monsters', () { getIt<GameState>().clearList(); - String oldState = gameState.toString(); + final String oldState = gameState.toString(); final monsters = GameMethods.getCurrentMonsters(); expect(monsters, isEmpty); checkNoSideEffects([], oldState); @@ -596,7 +596,7 @@ void main() async { false, gameState: getIt<GameState>(), ).execute(); - String oldState = gameState.toString(); + final String oldState = gameState.toString(); final monster = getIt<GameState>().currentList.first as Monster; final standee = GameMethods.getRandomStandee(monster); expect(standee, isNot(0)); @@ -609,7 +609,7 @@ void main() async { test('should return a character', () { getIt<GameState>().clearList(); AddCharacterCommand('Blinkblade', 'Frosthaven', "", 1).execute(); - String oldState = gameState.toString(); + final String oldState = gameState.toString(); final figure = GameMethods.getFigure(null, 'Blinkblade'); expect(figure, isNotNull); expect(figure, isA<CharacterState>()); @@ -632,7 +632,7 @@ void main() async { false, gameState: getIt<GameState>(), ).execute(); - String oldState = gameState.toString(); + final String oldState = gameState.toString(); final figure = GameMethods.getFigure( monster.id, monster.monsterInstances.first.getId(), @@ -661,7 +661,7 @@ void main() async { false, gameState: getIt<GameState>(), ).execute(); - String oldState = gameState.toString(); + final String oldState = gameState.toString(); final id = GameMethods.getFigureIdFromNr(monster.id, 1); expect(id, isNotNull); expect(id, isNotEmpty); @@ -672,7 +672,7 @@ void main() async { group('isObjectiveOrEscort', () { test('should return true for Objective', () { final cmd = AddCharacterCommand("Objective", "na", "whatever", 1); - String oldState = gameState.toString(); + final String oldState = gameState.toString(); expect( GameMethods.isObjectiveOrEscort(cmd.character!.characterClass), isTrue, @@ -682,7 +682,7 @@ void main() async { test('should return true for Escort', () { final cmd = AddCharacterCommand("Escort", "na", "whatever", 1); - String oldState = gameState.toString(); + final String oldState = gameState.toString(); expect( GameMethods.isObjectiveOrEscort(cmd.character!.characterClass), isTrue, @@ -697,7 +697,7 @@ void main() async { "whatever", 1, ); - String oldState = gameState.toString(); + final String oldState = gameState.toString(); expect( GameMethods.isObjectiveOrEscort(cmd.character!.characterClass), isFalse, @@ -708,7 +708,7 @@ void main() async { group('shouldShowAlliesDeck', () { test('should return true if showAllyDeck setting is true', () { - String oldState = gameState.toString(); + final String oldState = gameState.toString(); getIt<Settings>().showAmdDeck = true; ShowAllyDeckCommand().execute(); expect(GameMethods.shouldShowAlliesDeck(), isTrue); @@ -716,7 +716,7 @@ void main() async { }); test('should return false if showAmdDeck setting is false', () { - String oldState = gameState.toString(); + final String oldState = gameState.toString(); getIt<Settings>().showAmdDeck = false; expect(GameMethods.shouldShowAlliesDeck(), isFalse); checkNoSideEffects([], oldState); @@ -737,7 +737,7 @@ void main() async { true, gameState: getIt<GameState>(), ).execute(); - String oldState = gameState.toString(); + final String oldState = gameState.toString(); expect(GameMethods.shouldShowAlliesDeck(), isTrue); checkNoSideEffects([], oldState); }); @@ -745,7 +745,7 @@ void main() async { group('canExpire', () { test('should return true for conditions that expire', () { - String oldState = gameState.toString(); + final String oldState = gameState.toString(); expect(GameMethods.canExpire(Condition.strengthen), isTrue); expect(GameMethods.canExpire(Condition.muddle), isTrue); expect(GameMethods.canExpire(Condition.invisible), isTrue); @@ -758,7 +758,7 @@ void main() async { }); test('should return false for conditions that do not expire', () { - String oldState = gameState.toString(); + final String oldState = gameState.toString(); expect(GameMethods.canExpire(Condition.bane), isFalse); expect(GameMethods.canExpire(Condition.poison), isFalse); expect(GameMethods.canExpire(Condition.wound), isFalse); @@ -771,13 +771,13 @@ void main() async { group('isFrosthavenStyledEdition', () { test('should return true for Frosthaven', () { - String oldState = gameState.toString(); + final String oldState = gameState.toString(); expect(GameMethods.isFrosthavenStyledEdition('Frosthaven'), isTrue); checkNoSideEffects([], oldState); }); test('should return true for Buttons and Bugs', () { - String oldState = gameState.toString(); + final String oldState = gameState.toString(); expect( GameMethods.isFrosthavenStyledEdition('Buttons and Bugs'), isTrue, @@ -786,7 +786,7 @@ void main() async { }); test('should return true for Gloomhaven 2nd Edition', () { - String oldState = gameState.toString(); + final String oldState = gameState.toString(); expect( GameMethods.isFrosthavenStyledEdition('Gloomhaven 2nd Edition'), isTrue, @@ -795,7 +795,7 @@ void main() async { }); test('should return true for Mercenary Packs', () { - String oldState = gameState.toString(); + final String oldState = gameState.toString(); expect( GameMethods.isFrosthavenStyledEdition('Mercenary Packs'), isTrue, @@ -804,7 +804,7 @@ void main() async { }); test('should return false for Gloomhaven', () { - String oldState = gameState.toString(); + final String oldState = gameState.toString(); expect(GameMethods.isFrosthavenStyledEdition('Gloomhaven'), isFalse); checkNoSideEffects([], oldState); }); @@ -813,7 +813,7 @@ void main() async { group('isFrosthavenStyle', () { test('should return true for Frosthaven monster', () { final monster = Monster('Ancient Artillery (FH)', 1, false); - String oldState = gameState.toString(); + final String oldState = gameState.toString(); expect(GameMethods.isFrosthavenStyle(monster.type), isTrue); checkNoSideEffects([], oldState); }); @@ -825,7 +825,7 @@ void main() async { false, gameState: getIt<GameState>(), ).execute(); // Adds monsters - String oldState = gameState.toString(); + final String oldState = gameState.toString(); final monster = Monster('Zealot', 1, false); getIt<Settings>().style = Style.original; expect(GameMethods.isFrosthavenStyle(monster.type), isFalse); @@ -833,7 +833,7 @@ void main() async { }); test('should return true if style is set to Frosthaven', () { - String oldState = gameState.toString(); + final String oldState = gameState.toString(); getIt<Settings>().style = Style.frosthaven; expect(GameMethods.isFrosthavenStyle(null), isTrue); checkNoSideEffects([], oldState); @@ -842,25 +842,25 @@ void main() async { group('isCustomCampaign', () { test('should return true for Crimson Scales', () { - String oldState = gameState.toString(); + final String oldState = gameState.toString(); expect(GameMethods.isCustomCampaign('Crimson Scales'), isTrue); checkNoSideEffects([], oldState); }); test('should return true for Trail of Ashes', () { - String oldState = gameState.toString(); + final String oldState = gameState.toString(); expect(GameMethods.isCustomCampaign('Trail of Ashes'), isTrue); checkNoSideEffects([], oldState); }); test('should return true for CCUG', () { - String oldState = gameState.toString(); + final String oldState = gameState.toString(); expect(GameMethods.isCustomCampaign('CCUG'), isTrue); checkNoSideEffects([], oldState); }); test('should return false for Frosthaven', () { - String oldState = gameState.toString(); + final String oldState = gameState.toString(); expect(GameMethods.isCustomCampaign('Frosthaven'), isFalse); checkNoSideEffects([], oldState); }); @@ -868,7 +868,7 @@ void main() async { group('findNrFromScenarioName', () { test('should return the scenario number from the name', () { - String oldState = gameState.toString(); + final String oldState = gameState.toString(); expect(GameMethods.findNrFromScenarioName('#1 '), 1); expect( GameMethods.findNrFromScenarioName('#10.0 A Sticky Situation'), @@ -879,7 +879,7 @@ void main() async { }); test('should return null if no number is found', () { - String oldState = gameState.toString(); + final String oldState = gameState.toString(); expect(GameMethods.findNrFromScenarioName('Some Scenario'), isNull); checkNoSideEffects([], oldState); }); @@ -888,14 +888,14 @@ void main() async { group('isOgGloomEdition', () { test('should return true for Gloomhaven', () { SetCampaignCommand('Gloomhaven').execute(); - String oldState = gameState.toString(); + final String oldState = gameState.toString(); expect(GameMethods.isOgGloomEdition(), isTrue); checkNoSideEffects([], oldState); }); test('should return false for Frosthaven', () { SetCampaignCommand('Frosthaven').execute(); - String oldState = gameState.toString(); + final String oldState = gameState.toString(); expect(GameMethods.isOgGloomEdition(), isFalse); checkNoSideEffects([], oldState); }); @@ -910,7 +910,7 @@ void main() async { false, gameState: getIt<GameState>(), ).execute(); - String oldState = gameState.toString(); + final String oldState = gameState.toString(); //DrawLootCardCommand(gameState: getIt<GameState>()).execute(); expect(GameMethods.hasLootDeck(), isTrue); checkNoSideEffects([], oldState); @@ -924,13 +924,13 @@ void main() async { false, gameState: getIt<GameState>(), ).execute(); - String oldState = gameState.toString(); + final String oldState = gameState.toString(); expect(GameMethods.hasLootDeck(), isFalse); checkNoSideEffects([], oldState); }); test('should return false if hideLootDeck setting is true', () { - String oldState = gameState.toString(); + final String oldState = gameState.toString(); getIt<Settings>().hideLootDeck = true; expect(GameMethods.hasLootDeck(), isFalse); checkNoSideEffects([], oldState); @@ -939,7 +939,7 @@ void main() async { group('getFactionCards', () { test('should return the correct cards for Demons', () { - String oldState = gameState.toString(); + final String oldState = gameState.toString(); final cards = GameMethods.getFactionCards('Demons'); expect(cards.length, 4); expect(cards[0].gfx, 'Demons-perks/plus1any'); @@ -947,7 +947,7 @@ void main() async { }); test('should return the correct cards for Merchant-Guild', () { - String oldState = gameState.toString(); + final String oldState = gameState.toString(); final cards = GameMethods.getFactionCards('Merchant-Guild'); expect(cards.length, 4); expect(cards[0].gfx, 'Merchant-Guild-perks/plus1curse'); @@ -955,7 +955,7 @@ void main() async { }); test('should return the correct cards for Military', () { - String oldState = gameState.toString(); + final String oldState = gameState.toString(); final cards = GameMethods.getFactionCards('Military'); expect(cards.length, 4); expect(cards[0].gfx, 'Military-perks/plus1strengthenally'); @@ -969,7 +969,7 @@ void main() async { AddCharacterCommand('Blinkblade', 'Frosthaven', "", 1).execute(); final character = getIt<GameState>().currentList.first as Character; AddPerkCommand(character.id, 3).execute(); // Adds a +1 card - String oldState = gameState.toString(); + final String oldState = gameState.toString(); expect(GameMethods.isCardInAnyCharacterDeck('P3'), isTrue); checkNoSideEffects([], oldState); }); @@ -977,7 +977,7 @@ void main() async { test('should return false if card is not in any character deck', () { getIt<GameState>().clearList(); AddCharacterCommand('Blinkblade', 'Frosthaven', "", 1).execute(); - String oldState = gameState.toString(); + final String oldState = gameState.toString(); expect(GameMethods.isCardInAnyCharacterDeck('P3'), isFalse); checkNoSideEffects([], oldState); }); @@ -1000,7 +1000,7 @@ void main() async { false, gameState: getIt<GameState>(), ).execute(); - String oldState = gameState.toString(); + final String oldState = gameState.toString(); final monster = getIt<GameState>().currentList.first as Monster; final instance = monster.monsterInstances.first; expect(GameMethods.hasRetaliate(monster, instance), isTrue); @@ -1023,7 +1023,7 @@ void main() async { false, gameState: getIt<GameState>(), ).execute(); - String oldState = gameState.toString(); + final String oldState = gameState.toString(); final monster = getIt<GameState>().currentList.first as Monster; final instance = monster.monsterInstances.first; expect(GameMethods.hasRetaliate(monster, instance), isFalse); @@ -1048,7 +1048,7 @@ void main() async { false, gameState: getIt<GameState>(), ).execute(); - String oldState = gameState.toString(); + final String oldState = gameState.toString(); final monster = getIt<GameState>().currentList.first as Monster; final instance = monster.monsterInstances.first; expect(GameMethods.hasShield(monster, instance), isTrue); @@ -1071,7 +1071,7 @@ void main() async { false, gameState: getIt<GameState>(), ).execute(); - String oldState = gameState.toString(); + final String oldState = gameState.toString(); final monster = getIt<GameState>().currentList.first as Monster; final instance = monster.monsterInstances.first; expect(GameMethods.hasShield(monster, instance), isFalse); @@ -1114,7 +1114,7 @@ void main() async { final monster = getIt<GameState>().currentList.first as Monster; // Monster is inactive by default (isActive = false until ability drawn) expect(monster.isActive, isFalse); - String oldState = gameState.toString(); + final String oldState = gameState.toString(); expect(GameMethods.getInitiative(monster), 99); checkNoSideEffects([], oldState); }); @@ -1122,7 +1122,7 @@ void main() async { group('summonDoesNotDie', () { test('Glacial Torrent Glacier does not die', () { - String oldState = gameState.toString(); + final String oldState = gameState.toString(); expect( GameMethods.summonDoesNotDie('Glacial Torrent', 'Glacier'), isTrue, @@ -1131,13 +1131,13 @@ void main() async { }); test('D.O.M.E. Barrier does not die', () { - String oldState = gameState.toString(); + final String oldState = gameState.toString(); expect(GameMethods.summonDoesNotDie('D.O.M.E.', 'Barrier'), isTrue); checkNoSideEffects([], oldState); }); test('arbitrary owner and id returns false', () { - String oldState = gameState.toString(); + final String oldState = gameState.toString(); expect( GameMethods.summonDoesNotDie('Blinkblade', 'Jade Falcon'), isFalse, @@ -1174,7 +1174,7 @@ void main() async { final summon = character.characterState.summonList.first; final figureId = summon.getId(); - String oldState = gameState.toString(); + final String oldState = gameState.toString(); final figure = GameMethods.getFigure('Blinkblade', figureId); expect(figure, isNotNull); expect(figure, isA<MonsterInstance>()); @@ -1186,7 +1186,7 @@ void main() async { test('Solo with Frosthaven scenario number is frosthaven styled', () { // Directly set the scenario string to avoid SetScenarioCommand's loot-deck lookup gameState.scenario = '#1 A Town Aflame'; - String oldState = gameState.toString(); + final String oldState = gameState.toString(); expect(GameMethods.isFrosthavenStyledEdition('Solo'), isTrue); checkNoSideEffects(['scenario'], oldState); }); @@ -1195,7 +1195,7 @@ void main() async { 'Solo with #19 scenario is NOT frosthaven styled (Forgotten Circles)', () { gameState.scenario = '#19 Forgotten Circles'; - String oldState = gameState.toString(); + final String oldState = gameState.toString(); expect(GameMethods.isFrosthavenStyledEdition('Solo'), isFalse); checkNoSideEffects(['scenario'], oldState); }, @@ -1205,7 +1205,7 @@ void main() async { 'Solo with scenario not in 1-100 range is not frosthaven styled', () { gameState.scenario = '#200 Some Scenario'; - String oldState = gameState.toString(); + final String oldState = gameState.toString(); expect(GameMethods.isFrosthavenStyledEdition('Solo'), isFalse); checkNoSideEffects(['scenario'], oldState); }, @@ -1256,7 +1256,7 @@ void main() async { false, gameState: getIt<GameState>(), ).execute(); - String oldState = gameState.toString(); + final String oldState = gameState.toString(); final next = GameMethods.getNextAvailableBnBStandee(monster); // Standee 1 is taken; next available should be 2 expect(next, 2); @@ -1282,7 +1282,7 @@ void main() async { gameState: getIt<GameState>(), ).execute(); } - String oldState = gameState.toString(); + final String oldState = gameState.toString(); final next = GameMethods.getNextAvailableBnBStandee(monster); expect(next, 0); checkNoSideEffects([], oldState); |
