summaryrefslogtreecommitdiff
path: root/server/lib/core/methods/round_methods.dart
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@spawned.biz>2026-11-23 15:38:13 +0100
committerJoel Klinghed <the_jk@spawned.biz>2026-11-23 15:38:13 +0100
commit7ee14396b1f1f96ed0472b5949ce82a7f9313276 (patch)
treecddf00fe4049908155a15e813bb8d226ad710f81 /server/lib/core/methods/round_methods.dart
parent4a45fe143bd050d89183427443dedfd656f507bc (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/round_methods.dart')
-rw-r--r--server/lib/core/methods/round_methods.dart20
1 files changed, 10 insertions, 10 deletions
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<GameState>();
final gd = gameData ?? getIt<GameData>();
- List<SpecialRule>? rules =
+ final List<SpecialRule>? 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) {