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/methods/monster_methods.dart | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'server/lib/core/methods/monster_methods.dart') 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(); - Map monsters = {}; + final Map monsters = {}; final modelData = gd.modelData; for (String key in modelData.keys) { monsters.addAll(modelData[key]?.monsters ?? {}); @@ -43,8 +43,8 @@ class MonsterMethods { List items, { GameState? gameState, }) { - List deckIds = []; - List newList = []; + final List deckIds = []; + final List newList = []; final gs = gameState ?? getIt(); for (final item in gs.currentList) { if (item is Monster) { @@ -235,7 +235,7 @@ class MonsterMethods { GameState? gameState, }) { int levelAdjust = 0; - Set alliedMonsters = {}; + final Set 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(); //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(); 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 normals = []; - List elites = []; + final List normals = []; + final List 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( -- cgit v1.3.1