From 8b5c35890457c27ea68f278cb7f10511bf547a82 Mon Sep 17 00:00:00 2001 From: MioBestWaifu <117694699+MioBestWaifu@users.noreply.github.com> Date: Wed, 13 Dec 2023 17:36:02 -0300 Subject: [PATCH] Update TradeEvaluation.kt (#10713) --- core/src/com/unciv/logic/trade/TradeEvaluation.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/src/com/unciv/logic/trade/TradeEvaluation.kt b/core/src/com/unciv/logic/trade/TradeEvaluation.kt index b15094edd8..140bdc1794 100644 --- a/core/src/com/unciv/logic/trade/TradeEvaluation.kt +++ b/core/src/com/unciv/logic/trade/TradeEvaluation.kt @@ -338,7 +338,10 @@ class TradeEvaluation { val percentageAdvantage = absoluteAdvantage / theirCombatStrength.toFloat() // We don't add the same constraint here. We should not make peace easily if we're // heavily advantaged. - return (absoluteAdvantage * percentageAdvantage).toInt() * 10 + val totalAdvantage = (absoluteAdvantage * percentageAdvantage).toInt() * 10 + if(totalAdvantage < 0) //May be a negative number if strength disparity is such that it leads to integer overflow + return 10000 //in that rare case, the AI would accept peace against a defeated foe. + return totalAdvantage } else { // This results in huge values for large power imbalances. However, we should not give // up everything just because there is a big power imbalance. There's a better chance to