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/round_methods.dart | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'server/lib/core/methods/round_methods.dart') 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(); final gd = gameData ?? getIt(); - List? rules = + final List? 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) { -- cgit v1.3.1