From 0e87be84875172ac142ea7c1dc953861a010b1dd Mon Sep 17 00:00:00 2001 From: WhoIsJohannes <126110113+WhoIsJohannes@users.noreply.github.com> Date: Tue, 4 Apr 2023 22:40:36 +0200 Subject: [PATCH] Prevent offering zero gold. (#9119) This happened to me in a game, unfortunately I don't have the save since it's one round ago in a multiplayer game, but I'm pretty sure this is the part of the code causing the problem. --- .../automation/civilization/NextTurnAutomation.kt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/core/src/com/unciv/logic/automation/civilization/NextTurnAutomation.kt b/core/src/com/unciv/logic/automation/civilization/NextTurnAutomation.kt index 0b9f7af6d7..72185c08c1 100644 --- a/core/src/com/unciv/logic/automation/civilization/NextTurnAutomation.kt +++ b/core/src/com/unciv/logic/automation/civilization/NextTurnAutomation.kt @@ -235,7 +235,16 @@ object NextTurnAutomation { val valueOfOne = evaluation.evaluateSellCost(TradeOffer(ourGold.name, ourGold.type, 1, ourGold.duration), civInfo, otherCiv) val amountToGive = min(deltaInOurFavor / valueOfOne, ourGold.amount) deltaInOurFavor -= amountToGive * valueOfOne - counterofferGifts.add(TradeOffer(ourGold.name, ourGold.type, amountToGive, ourGold.duration)) + if (amountToGive > 0) { + counterofferGifts.add( + TradeOffer( + ourGold.name, + ourGold.type, + amountToGive, + ourGold.duration + ) + ) + } } } }