From 7ee14396b1f1f96ed0472b5949ce82a7f9313276 Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Mon, 23 Nov 2026 15:38:13 +0100 Subject: 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. --- server/lib/core/game_methods.dart | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'server/lib/core/game_methods.dart') 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(); - int level = gs.level; + final int level = gs.level; if (level == _kCoinMaxLevel) { return _kCoinMaxValue; } @@ -162,7 +162,7 @@ class GameMethods { } static List getCurrentCharactersForState(GameState state) { - List characters = []; + final List characters = []; for (ListItemData data in state.currentList) { if (data is Character && !GameMethods.isObjectiveOrEscort(data.characterClass)) { @@ -291,7 +291,7 @@ class GameMethods { } static List getCurrentMonsters({GameState? gameState}) { - List monsters = []; + final List monsters = []; final gs = gameState ?? getIt(); 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(); - 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 available = []; + final List 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(); - 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 getFactionCards(String faction) { - List retVal = []; + final List retVal = []; if (faction == "Demons") { retVal.add(ModifierCard(CardType.add, "Demons-perks/plus1any")); retVal.add( -- cgit v1.3.1