mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 22:06:05 -04:00
Fixed sqrt of negative number (#5193)
This commit is contained in:
parent
70c3b4bd65
commit
03a7288656
@ -29,6 +29,7 @@ import com.unciv.ui.victoryscreen.RankingType
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.collections.ArrayList
|
import kotlin.collections.ArrayList
|
||||||
import kotlin.collections.HashMap
|
import kotlin.collections.HashMap
|
||||||
|
import kotlin.math.max
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
import kotlin.math.sqrt
|
import kotlin.math.sqrt
|
||||||
@ -524,9 +525,8 @@ class CivilizationInfo {
|
|||||||
else
|
else
|
||||||
unit.getForceEvaluation()
|
unit.getForceEvaluation()
|
||||||
}
|
}
|
||||||
val goldBonus = sqrt(gold.toFloat()).toPercent() // 2f if gold == 10000
|
val goldBonus = sqrt(max(0f, gold.toFloat())).toPercent() // 2f if gold == 10000
|
||||||
sum = (sum * min(goldBonus, 2f)).toInt() // 2f is max bonus
|
sum = (sum * min(goldBonus, 2f)).toInt() // 2f is max bonus
|
||||||
|
|
||||||
return sum
|
return sum
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user