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