From b5a4591955d976fdcf2c68873a7a18669dd70d79 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Thu, 23 Jul 2020 14:24:50 +0300 Subject: [PATCH] Resovled #2852 - can no longer make peace with a city state while at war with its ally --- .../com/unciv/logic/civilization/CivilizationInfo.kt | 6 ++---- core/src/com/unciv/ui/trade/DiplomacyScreen.kt | 11 ++++++----- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt index 00c6f8091c..04dbb60519 100644 --- a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt +++ b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt @@ -65,7 +65,7 @@ class CivilizationInfo { var diplomacy = HashMap() var notifications = ArrayList() val popupAlerts = ArrayList() - var allyCivName = "" + private var allyCivName = "" var naturalWonders = ArrayList() //** for trades here, ourOffers is the current civ's offers, and theirOffers is what the requesting civ offers */ @@ -549,9 +549,7 @@ class CivilizationInfo { addNotification("[${otherCiv.civName}] gave us a [${militaryUnit.name}] as gift near [${city.name}]!", null, Color.GREEN) } - fun getAllyCiv(): String { - return allyCivName - } + fun getAllyCiv() = allyCivName fun updateAllyCivForCityState() { var newAllyName = "" diff --git a/core/src/com/unciv/ui/trade/DiplomacyScreen.kt b/core/src/com/unciv/ui/trade/DiplomacyScreen.kt index 9f8be3d21f..4f8ab6e2a8 100644 --- a/core/src/com/unciv/ui/trade/DiplomacyScreen.kt +++ b/core/src/com/unciv/ui/trade/DiplomacyScreen.kt @@ -96,8 +96,7 @@ class DiplomacyScreen(val viewingCiv:CivilizationInfo):CameraStageBaseScreen() { diplomacyTable.add(("Type: ".tr() + otherCiv.getCityStateType().toString().tr()).toLabel()).row() otherCiv.updateAllyCivForCityState() val ally = otherCiv.getAllyCiv() - if (ally != "") - { + if (ally != "") { val allyString = "{Ally: }{$ally} {Influence: }".tr() + otherCiv.getDiplomacyManager(ally).influence.toString() diplomacyTable.add(allyString.toLabel()).row() @@ -120,7 +119,7 @@ class DiplomacyScreen(val viewingCiv:CivilizationInfo):CameraStageBaseScreen() { CityStateType.Militaristic -> "Provides land units every 20 turns at 30 Influence".tr() } - val friendBonusLabelColor:Color + val friendBonusLabelColor: Color if (otherCivDiplomacyManager.relationshipLevel() >= RelationshipLevel.Friend) { friendBonusLabelColor = Color.GREEN // RelationshipChange = Ally -> Friend or Friend -> Favorable @@ -160,10 +159,12 @@ class DiplomacyScreen(val viewingCiv:CivilizationInfo):CameraStageBaseScreen() { }, this).open() } diplomacyTable.add(peaceButton).row() - if(isNotPlayersTurn()) peaceButton.disable() + val cityStatesAlly = otherCiv.getAllyCiv() + val atWarWithItsAlly = viewingCiv.getKnownCivs().any { it.civName == cityStatesAlly && it.isAtWarWith(viewingCiv) } + if (isNotPlayersTurn() || atWarWithItsAlly) peaceButton.disable() } else { val declareWarButton = getDeclareWarButton(diplomacyManager, otherCiv) - if(isNotPlayersTurn()) declareWarButton.disable() + if (isNotPlayersTurn()) declareWarButton.disable() diplomacyTable.add(declareWarButton).row() }