From 5b5e4137db43df8d10ed2dc24bb0b2d404e89c77 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Mon, 20 Jun 2022 09:46:57 +0300 Subject: [PATCH] Resolved crash for stats not in statCostModifiers --- core/src/com/unciv/models/ruleset/Speed.kt | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/core/src/com/unciv/models/ruleset/Speed.kt b/core/src/com/unciv/models/ruleset/Speed.kt index 949e2a815a..1f3c5aaefa 100644 --- a/core/src/com/unciv/models/ruleset/Speed.kt +++ b/core/src/com/unciv/models/ruleset/Speed.kt @@ -32,14 +32,19 @@ class Speed : RulesetObject() { } val statCostModifiers: HashMap by lazy { - HashMap().apply { - this[Stat.Faith] = 1f; - this[Stat.Production] = productionCostModifier; - this[Stat.Gold] = goldCostModifier; - this[Stat.Science] = scienceCostModifier; - this[Stat.Faith] = faithCostModifier; - this[Stat.Happiness] = 1f; + val map = HashMap() + for (stat in Stat.values()) { + val modifier = when (stat) { + Stat.Production -> productionCostModifier + Stat.Gold -> goldCostModifier + Stat.Science -> scienceCostModifier + Stat.Faith -> faithCostModifier + else -> 1f + } + map[stat] = modifier } + + map } companion object {