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/lib/core/methods/monster_methods.dart | |
| 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/lib/core/methods/monster_methods.dart')
| -rw-r--r-- | server/lib/core/methods/monster_methods.dart | 24 |
1 files changed, 12 insertions, 12 deletions
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( |
