From ec4586af6cc6c398f9491bb35b92666d312fcae0 Mon Sep 17 00:00:00 2001 From: SomeTroglodyte <63000004+SomeTroglodyte@users.noreply.github.com> Date: Sat, 20 May 2023 23:13:50 +0200 Subject: [PATCH] Fix Ensure Minimum Stats (#9408) --- core/src/com/unciv/logic/map/tile/TileStatFunctions.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/src/com/unciv/logic/map/tile/TileStatFunctions.kt b/core/src/com/unciv/logic/map/tile/TileStatFunctions.kt index 0c4108af77..215fbf4669 100644 --- a/core/src/com/unciv/logic/map/tile/TileStatFunctions.kt +++ b/core/src/com/unciv/logic/map/tile/TileStatFunctions.kt @@ -84,8 +84,11 @@ class TileStatFunctions(val tile: Tile) { /** Ensures each stat is >= [other].stat - modifies in place */ private fun Stats.coerceAtLeast(other: Stats) { - for ((stat, value) in other) + // Note: Not `for ((stat, value) in other)` - that would skip zero values + for (stat in Stat.values()) { + val value = other[stat] if (this[stat] < value) this[stat] = value + } } /** Gets basic stats to start off [getTileStats] or [getTileStartYield], independently mutable result */