mirror of
https://github.com/yairm210/Unciv.git
synced 2025-03-11 18:39:43 +07:00
Made it impossible to cut short peace treaties (#5450)
This commit is contained in:
parent
24d7a57c1f
commit
2bd8132b8d
@ -357,7 +357,6 @@ class DiplomacyManager() {
|
||||
|
||||
//region state-changing functions
|
||||
fun removeUntenableTrades() {
|
||||
|
||||
for (trade in trades.toList()) {
|
||||
|
||||
// Every cancelled trade can change this - if 1 resource is missing,
|
||||
@ -367,10 +366,18 @@ class DiplomacyManager() {
|
||||
|
||||
for (offer in trade.ourOffers) {
|
||||
if (offer.type in listOf(TradeType.Luxury_Resource, TradeType.Strategic_Resource)
|
||||
&& (offer.name in negativeCivResources || !civInfo.gameInfo.ruleSet.tileResources.containsKey(offer.name))) {
|
||||
&& (offer.name in negativeCivResources || !civInfo.gameInfo.ruleSet.tileResources.containsKey(offer.name))
|
||||
) {
|
||||
|
||||
trades.remove(trade)
|
||||
val otherCivTrades = otherCiv().getDiplomacyManager(civInfo).trades
|
||||
otherCivTrades.removeAll { it.equals(trade.reverse()) }
|
||||
|
||||
// Can't cut short peace treaties!
|
||||
if (trade.theirOffers.any { it.name == Constants.peaceTreaty }) {
|
||||
remakePeaceTreaty(trade.theirOffers.first { it.name == Constants.peaceTreaty }.duration)
|
||||
}
|
||||
|
||||
civInfo.addNotification("One of our trades with [$otherCivName] has been cut short", NotificationIcon.Trade, otherCivName)
|
||||
otherCiv().addNotification("One of our trades with [${civInfo.civName}] has been cut short", NotificationIcon.Trade, civInfo.civName)
|
||||
civInfo.updateDetailedCivResources()
|
||||
@ -379,6 +386,18 @@ class DiplomacyManager() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun remakePeaceTreaty(durationLeft: Int) {
|
||||
val treaty = Trade()
|
||||
treaty.ourOffers.add(
|
||||
TradeOffer(Constants.peaceTreaty, TradeType.Treaty, duration = durationLeft)
|
||||
)
|
||||
treaty.theirOffers.add(
|
||||
TradeOffer(Constants.peaceTreaty, TradeType.Treaty, duration = durationLeft)
|
||||
)
|
||||
trades.add(treaty)
|
||||
otherCiv().getDiplomacyManager(civInfo).trades.add(treaty)
|
||||
}
|
||||
|
||||
// for performance reasons we don't want to call this every time we want to see if a unit can move through a tile
|
||||
fun updateHasOpenBorders() {
|
||||
// City-states can enter ally's territory (the opposite is true anyway even without open borders)
|
||||
|
Loading…
Reference in New Issue
Block a user