Fix Ensure Minimum Stats (#9408)

This commit is contained in:
SomeTroglodyte 2023-05-20 23:13:50 +02:00 committed by GitHub
parent 728afab1db
commit ec4586af6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 */