Resovled #2852 - can no longer make peace with a city state while at war with its ally

This commit is contained in:
Yair Morgenstern 2020-07-23 14:24:50 +03:00
parent 3f44e1c519
commit b5a4591955
2 changed files with 8 additions and 9 deletions

View File

@ -65,7 +65,7 @@ class CivilizationInfo {
var diplomacy = HashMap<String, DiplomacyManager>() var diplomacy = HashMap<String, DiplomacyManager>()
var notifications = ArrayList<Notification>() var notifications = ArrayList<Notification>()
val popupAlerts = ArrayList<PopupAlert>() val popupAlerts = ArrayList<PopupAlert>()
var allyCivName = "" private var allyCivName = ""
var naturalWonders = ArrayList<String>() var naturalWonders = ArrayList<String>()
//** for trades here, ourOffers is the current civ's offers, and theirOffers is what the requesting civ offers */ //** 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) addNotification("[${otherCiv.civName}] gave us a [${militaryUnit.name}] as gift near [${city.name}]!", null, Color.GREEN)
} }
fun getAllyCiv(): String { fun getAllyCiv() = allyCivName
return allyCivName
}
fun updateAllyCivForCityState() { fun updateAllyCivForCityState() {
var newAllyName = "" var newAllyName = ""

View File

@ -96,8 +96,7 @@ class DiplomacyScreen(val viewingCiv:CivilizationInfo):CameraStageBaseScreen() {
diplomacyTable.add(("Type: ".tr() + otherCiv.getCityStateType().toString().tr()).toLabel()).row() diplomacyTable.add(("Type: ".tr() + otherCiv.getCityStateType().toString().tr()).toLabel()).row()
otherCiv.updateAllyCivForCityState() otherCiv.updateAllyCivForCityState()
val ally = otherCiv.getAllyCiv() val ally = otherCiv.getAllyCiv()
if (ally != "") if (ally != "") {
{
val allyString = "{Ally: }{$ally} {Influence: }".tr() + val allyString = "{Ally: }{$ally} {Influence: }".tr() +
otherCiv.getDiplomacyManager(ally).influence.toString() otherCiv.getDiplomacyManager(ally).influence.toString()
diplomacyTable.add(allyString.toLabel()).row() 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() CityStateType.Militaristic -> "Provides land units every 20 turns at 30 Influence".tr()
} }
val friendBonusLabelColor:Color val friendBonusLabelColor: Color
if (otherCivDiplomacyManager.relationshipLevel() >= RelationshipLevel.Friend) { if (otherCivDiplomacyManager.relationshipLevel() >= RelationshipLevel.Friend) {
friendBonusLabelColor = Color.GREEN friendBonusLabelColor = Color.GREEN
// RelationshipChange = Ally -> Friend or Friend -> Favorable // RelationshipChange = Ally -> Friend or Friend -> Favorable
@ -160,10 +159,12 @@ class DiplomacyScreen(val viewingCiv:CivilizationInfo):CameraStageBaseScreen() {
}, this).open() }, this).open()
} }
diplomacyTable.add(peaceButton).row() 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 { } else {
val declareWarButton = getDeclareWarButton(diplomacyManager, otherCiv) val declareWarButton = getDeclareWarButton(diplomacyManager, otherCiv)
if(isNotPlayersTurn()) declareWarButton.disable() if (isNotPlayersTurn()) declareWarButton.disable()
diplomacyTable.add(declareWarButton).row() diplomacyTable.add(declareWarButton).row()
} }