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/state/loot_deck_state.dart | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'server/lib/core/state/loot_deck_state.dart') 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 newDrawList = []; - List drawPile = lootDeckData["drawPile"] as List; + final List 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 newDiscardList = []; + final List 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 cards = []; + final List cards = []; if (_hasCard1419) { _addOtherType(_kSpecialCard1419, cards, "special 1419"); @@ -434,7 +434,7 @@ class LootDeck { } List _getAvailableCards(List pool) { - List list = []; + final List 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(); final gd = gameData ?? getIt(); - 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(); -- cgit v1.3.1