From 5ee3df96c8ff1d825aa21e61c2156efbb5172dd6 Mon Sep 17 00:00:00 2001 From: Gualdimar Date: Thu, 16 Mar 2023 14:30:12 +0200 Subject: [PATCH] Trade ending notification (#8925) * Notification of the end of a trade in 3 and 1 turns * Notification about the loss of an alliance is not shown if the city state is captured. * Shortened --- android/assets/jsons/translations/template.properties | 2 ++ .../logic/civilization/diplomacy/CityStateFunctions.kt | 2 +- .../logic/civilization/diplomacy/DiplomacyManager.kt | 8 ++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/android/assets/jsons/translations/template.properties b/android/assets/jsons/translations/template.properties index 95eaa425c3..21de6cb3e5 100644 --- a/android/assets/jsons/translations/template.properties +++ b/android/assets/jsons/translations/template.properties @@ -894,6 +894,8 @@ You and [name] are no longer allies! = [civName] has denied your trade request = [tradeOffer] from [otherCivName] has ended = [tradeOffer] to [otherCivName] has ended = +[tradeOffer] from [otherCivName] will end in [amount] turns = +[tradeOffer] from [otherCivName] will end next turn = One of our trades with [nation] has ended = One of our trades with [nation] has been cut short = [nation] agreed to stop settling cities near us! = diff --git a/core/src/com/unciv/logic/civilization/diplomacy/CityStateFunctions.kt b/core/src/com/unciv/logic/civilization/diplomacy/CityStateFunctions.kt index 9f56ade8eb..4405452b28 100644 --- a/core/src/com/unciv/logic/civilization/diplomacy/CityStateFunctions.kt +++ b/core/src/com/unciv/logic/civilization/diplomacy/CityStateFunctions.kt @@ -263,7 +263,7 @@ class CityStateFunctions(val civInfo: Civilization) { } } } - if (oldAllyName != null) { + if (oldAllyName != null && civInfo.isAlive()) { val oldAllyCiv = civInfo.gameInfo.getCivilization(oldAllyName) val text = "We have lost alliance with [${civInfo.civName}]." if (capitalLocation != null) oldAllyCiv.addNotification(text, capitalLocation, diff --git a/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt b/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt index 705e2ef528..e3cd79926d 100644 --- a/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt +++ b/core/src/com/unciv/logic/civilization/diplomacy/DiplomacyManager.kt @@ -573,6 +573,14 @@ class DiplomacyManager() : IsPartOfGameInfoSerialization { civInfo.cache.updateCivResources() } } + + for (offer in trade.theirOffers.filter { it.duration <= 3 }) + { + if (offer.duration == 3) + civInfo.addNotification("[${offer.name}] from [$otherCivName] will end in [3] turns", NotificationCategory.Trade, otherCivName, NotificationIcon.Trade) + else if (offer.duration == 1) + civInfo.addNotification("[${offer.name}] from [$otherCivName] will end next turn", NotificationCategory.Trade, otherCivName, NotificationIcon.Trade) + } } }