mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-22 22:00:24 +07:00
Declaring war now cancels all prior trade agreements
This commit is contained in:
@ -136,6 +136,21 @@ class DiplomacyManager() {
|
||||
fun declareWar(){
|
||||
diplomaticStatus = DiplomaticStatus.War
|
||||
val otherCiv = otherCiv()
|
||||
val otherCivDiplomacy = otherCiv.getDiplomacyManager(civInfo)
|
||||
|
||||
// Cancel all trades.
|
||||
for(trade in trades)
|
||||
for(offer in trade.theirOffers.filter { it.duration>0 })
|
||||
civInfo.addNotification("["+offer.name+"] from [$otherCivName] has ended",null, Color.GOLD)
|
||||
trades.clear()
|
||||
updateHasOpenBorders()
|
||||
|
||||
for(trade in otherCivDiplomacy.trades)
|
||||
for(offer in trade.theirOffers.filter { it.duration>0 })
|
||||
otherCiv.addNotification("["+offer.name+"] from [$otherCivName] has ended",null, Color.GOLD)
|
||||
otherCivDiplomacy.trades.clear()
|
||||
otherCivDiplomacy.updateHasOpenBorders()
|
||||
|
||||
|
||||
otherCiv.getDiplomacyManager(civInfo).diplomaticStatus = DiplomaticStatus.War
|
||||
otherCiv.addNotification("[${civInfo.civName}] has declared war on us!",null, Color.RED)
|
||||
|
@ -2,7 +2,8 @@ package com.unciv.logic.trade
|
||||
|
||||
import com.unciv.models.gamebasics.tr
|
||||
|
||||
data class TradeOffer(var name:String, var type: TradeType, var duration:Int, var amount:Int=1) {
|
||||
data class TradeOffer(var name:String, var type: TradeType,
|
||||
/** 0 for offers that are immediate (e.g. gold transfer) */ var duration:Int, var amount:Int=1) {
|
||||
|
||||
constructor() : this("", TradeType.Gold,0,0) // so that the json deserializer can work
|
||||
|
||||
@ -16,7 +17,7 @@ data class TradeOffer(var name:String, var type: TradeType, var duration:Int, va
|
||||
fun getOfferText(): String {
|
||||
var offerText = name.tr()
|
||||
if (type !in tradesToNotHaveNumbers) offerText += " (" + amount + ")"
|
||||
if (duration > 1) offerText += "\n" + duration + " {turns}".tr()
|
||||
if (duration > 0) offerText += "\n" + duration + " {turns}".tr()
|
||||
return offerText
|
||||
}
|
||||
|
||||
|
@ -112,8 +112,7 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
|
||||
table.add(civ.civName.toLabel().setFontColor(civ.getNation().getSecondaryColor())).row()
|
||||
table.addSeparator()
|
||||
for(offer in offersList){
|
||||
var offerText = offer.amount.toString()+" "+offer.name.tr()
|
||||
if(offer.duration>0)offerText += " ("+offer.duration+" {turns})".tr()
|
||||
val offerText = offer.getOfferText()
|
||||
table.add(offerText.toLabel().setFontColor(civ.getNation().getSecondaryColor())).row()
|
||||
}
|
||||
for(i in 1..numberOfOtherSidesOffers - offersList.size)
|
||||
|
Reference in New Issue
Block a user