From fe5a2acf04b4705f02fc650f54942aed0a2a43b2 Mon Sep 17 00:00:00 2001 From: czyh2022 <126690022+czyh2022@users.noreply.github.com> Date: Thu, 26 Dec 2024 02:37:23 +0800 Subject: [PATCH] Allow civs to trade with each other before settling their first cities (#12706) Co-authored-by: czyh2022 <2200013085@stu.pku.edu.cn> --- core/src/com/unciv/logic/trade/TradeEvaluation.kt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/core/src/com/unciv/logic/trade/TradeEvaluation.kt b/core/src/com/unciv/logic/trade/TradeEvaluation.kt index a883045276..5e030fb925 100644 --- a/core/src/com/unciv/logic/trade/TradeEvaluation.kt +++ b/core/src/com/unciv/logic/trade/TradeEvaluation.kt @@ -24,16 +24,22 @@ class TradeEvaluation { // Edge case time! Guess what happens if you offer a peace agreement to the AI for all their cities except for the capital, // and then capture their capital THAT SAME TURN? It can agree, leading to the civilization getting instantly destroyed! - if (trade.ourOffers.count { it.type == TradeOfferType.City } == offerer.cities.size - || trade.theirOffers.count { it.type == TradeOfferType.City } == tradePartner.cities.size) + // If a civ doen't has ever owned an original capital, which means it has not settle the first city yet, + // it shouldn't be forbidden to trade with other civs owing to cities.size == 0. + if ((offerer.hasEverOwnedOriginalCapital && trade.ourOffers.count { it.type == TradeOfferType.City } == offerer.cities.size) + || (tradePartner.hasEverOwnedOriginalCapital && trade.theirOffers.count { it.type == TradeOfferType.City } == tradePartner.cities.size)) { return false + } for (offer in trade.ourOffers) - if (!isOfferValid(offer, offerer, tradePartner)) + if (!isOfferValid(offer, offerer, tradePartner)) { return false + } + for (offer in trade.theirOffers) - if (!isOfferValid(offer, tradePartner, offerer)) + if (!isOfferValid(offer, tradePartner, offerer)) { return false + } return true }