mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-28 22:37:02 -04:00
Declaring war now cancels all prior trade agreements
This commit is contained in:
parent
8a600ea07d
commit
bda375f441
@ -136,6 +136,21 @@ class DiplomacyManager() {
|
|||||||
fun declareWar(){
|
fun declareWar(){
|
||||||
diplomaticStatus = DiplomaticStatus.War
|
diplomaticStatus = DiplomaticStatus.War
|
||||||
val otherCiv = otherCiv()
|
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.getDiplomacyManager(civInfo).diplomaticStatus = DiplomaticStatus.War
|
||||||
otherCiv.addNotification("[${civInfo.civName}] has declared war on us!",null, Color.RED)
|
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
|
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
|
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 {
|
fun getOfferText(): String {
|
||||||
var offerText = name.tr()
|
var offerText = name.tr()
|
||||||
if (type !in tradesToNotHaveNumbers) offerText += " (" + amount + ")"
|
if (type !in tradesToNotHaveNumbers) offerText += " (" + amount + ")"
|
||||||
if (duration > 1) offerText += "\n" + duration + " {turns}".tr()
|
if (duration > 0) offerText += "\n" + duration + " {turns}".tr()
|
||||||
return offerText
|
return offerText
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,8 +112,7 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
|
|||||||
table.add(civ.civName.toLabel().setFontColor(civ.getNation().getSecondaryColor())).row()
|
table.add(civ.civName.toLabel().setFontColor(civ.getNation().getSecondaryColor())).row()
|
||||||
table.addSeparator()
|
table.addSeparator()
|
||||||
for(offer in offersList){
|
for(offer in offersList){
|
||||||
var offerText = offer.amount.toString()+" "+offer.name.tr()
|
val offerText = offer.getOfferText()
|
||||||
if(offer.duration>0)offerText += " ("+offer.duration+" {turns})".tr()
|
|
||||||
table.add(offerText.toLabel().setFontColor(civ.getNation().getSecondaryColor())).row()
|
table.add(offerText.toLabel().setFontColor(civ.getNation().getSecondaryColor())).row()
|
||||||
}
|
}
|
||||||
for(i in 1..numberOfOtherSidesOffers - offersList.size)
|
for(i in 1..numberOfOtherSidesOffers - offersList.size)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user