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.
This commit is contained in:
WhoIsJohannes 2023-04-04 22:40:36 +02:00 committed by GitHub
parent 735a0f6f40
commit 0e87be8487
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
)
)
}
}
}
}