From 936a32300ba22a3632ea9c5d671d736caf6ba9cd Mon Sep 17 00:00:00 2001 From: SimonCeder <63475501+SimonCeder@users.noreply.github.com> Date: Sat, 4 Dec 2021 22:25:43 +0100 Subject: [PATCH] counteroffer fixes (#5749) --- .../com/unciv/logic/automation/NextTurnAutomation.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/src/com/unciv/logic/automation/NextTurnAutomation.kt b/core/src/com/unciv/logic/automation/NextTurnAutomation.kt index 7ad7f2fefb..e1b0cbc369 100644 --- a/core/src/com/unciv/logic/automation/NextTurnAutomation.kt +++ b/core/src/com/unciv/logic/automation/NextTurnAutomation.kt @@ -90,17 +90,12 @@ object NextTurnAutomation { tradeLogic.acceptTrade() otherCiv.addNotification("[${civInfo.civName}] has accepted your trade request", NotificationIcon.Trade, civInfo.civName) } else { - tradeRequest.decline(civInfo) - /* Currently disabled until we solve the problems in https://github.com/yairm210/Unciv/issues/5728 - val counteroffer = getCounteroffer(civInfo, tradeRequest) if (counteroffer != null) { otherCiv.addNotification("[${civInfo.civName}] has made a counteroffer to your trade request", NotificationIcon.Trade, civInfo.civName) otherCiv.tradeRequests.add(counteroffer) } else - otherCiv.addNotification("[${civInfo.civName}] has denied your trade request", NotificationIcon.Trade, civInfo.civName) - - */ + tradeRequest.decline(civInfo) } } civInfo.tradeRequests.clear() @@ -111,6 +106,9 @@ object NextTurnAutomation { * guaranteed to find the best or closest one. */ private fun getCounteroffer(civInfo: CivilizationInfo, tradeRequest: TradeRequest): TradeRequest? { val otherCiv = civInfo.gameInfo.getCivilization(tradeRequest.requestingCiv) + // AIs counteroffering each other is problematic as they tend to ping-pong back and forth forever + if (otherCiv.playerType == PlayerType.AI) + return null val evaluation = TradeEvaluation() var delta = evaluation.getTradeAcceptability(tradeRequest.trade, civInfo, otherCiv) if (delta < 0) delta = (delta * 1.1f).toInt() // They seem very interested in this deal, let's push it a bit. @@ -128,6 +126,8 @@ object NextTurnAutomation { continue // Don't want to counteroffer straight gold for gold, that's silly if (offer.amount == 0) continue // For example resources gained by trade or CS + if (offer.type == TradeType.City) + continue // Players generally don't want to give up their cities, and they might misclick val value = evaluation.evaluateBuyCost(offer, civInfo, otherCiv) if (value > 0) potentialAsks[offer] = value