diff --git a/android/assets/jsons/translations/Ukrainian.properties b/android/assets/jsons/translations/Ukrainian.properties index 75cee65c09..cc7e4a49ff 100644 --- a/android/assets/jsons/translations/Ukrainian.properties +++ b/android/assets/jsons/translations/Ukrainian.properties @@ -1163,7 +1163,7 @@ Vote for World Leader = Вибір світового лідера # Capturing a city -What would you like to do with the city? = Що ви хочете зробити з цим містом? +What would you like to do with the city of [cityName]? = Що ви хочете зробити з містом [cityName]? Annex = Анексувати Annexed cities become part of your regular empire. = Анексовані міста стануть частиною вашої імперії. Their citizens generate 2x the unhappiness, unless you build a courthouse. = Їх громадяни породжують вдвійчі більше нещастя, якщо ви не побудуєте будинок суду. @@ -1180,6 +1180,7 @@ The population will gradually dwindle until the city is destroyed. = Насел Original capitals and holy cities cannot be razed. = Початкові столиці та святі міста не можуть бути зруйновані. Destroy = Знищити Destroying the city instantly razes the city to the ground. = Знищення міста миттєво зрівняє його з землею. +Keep it = Залишити собі Remove your troops in our border immediately! = Негайно приберіть свої війська від нашого кордону! Sorry. = Вибачте. Never! = Ніколи! diff --git a/android/assets/jsons/translations/template.properties b/android/assets/jsons/translations/template.properties index 64816c3f4b..908da1883f 100644 --- a/android/assets/jsons/translations/template.properties +++ b/android/assets/jsons/translations/template.properties @@ -1140,7 +1140,7 @@ Vote for World Leader = # Capturing a city -What would you like to do with the city? = +What would you like to do with the city of [cityName]? = Annex = Annexed cities become part of your regular empire. = Their citizens generate 2x the unhappiness, unless you build a courthouse. = @@ -1157,6 +1157,7 @@ The population will gradually dwindle until the city is destroyed. = Original capitals and holy cities cannot be razed. = Destroy = Destroying the city instantly razes the city to the ground. = +Keep it = Remove your troops in our border immediately! = Sorry. = Never! = diff --git a/core/src/com/unciv/logic/city/CityInfoConquestFunctions.kt b/core/src/com/unciv/logic/city/CityInfoConquestFunctions.kt index f0e5f1c9a7..1461cd0b0a 100644 --- a/core/src/com/unciv/logic/city/CityInfoConquestFunctions.kt +++ b/core/src/com/unciv/logic/city/CityInfoConquestFunctions.kt @@ -1,4 +1,4 @@ -package com.unciv.logic.city +package com.unciv.logic.city import com.unciv.Constants import com.unciv.UncivGame @@ -279,7 +279,7 @@ class CityInfoConquestFunctions(val city: CityInfo){ // Place palace for newCiv if this is the only city they have // This needs to happen _before_ free buildings are added, as somtimes these should // only be placed in the capital, and then there needs to be a capital. - if (newCivInfo.cities.count() == 1) { + if (newCivInfo.cities.size == 1) { newCivInfo.moveCapitalTo(this) } diff --git a/core/src/com/unciv/logic/civilization/PopupAlert.kt b/core/src/com/unciv/logic/civilization/PopupAlert.kt index 1f5d7abe4f..17a949267f 100644 --- a/core/src/com/unciv/logic/civilization/PopupAlert.kt +++ b/core/src/com/unciv/logic/civilization/PopupAlert.kt @@ -7,6 +7,7 @@ enum class AlertType { WarDeclaration, FirstContact, CityConquered, + CityTraded, BorderConflict, DemandToStopSettlingCitiesNear, CitySettledNearOtherCivDespiteOurPromise, diff --git a/core/src/com/unciv/logic/trade/TradeLogic.kt b/core/src/com/unciv/logic/trade/TradeLogic.kt index ffc52c950b..cd510d2748 100644 --- a/core/src/com/unciv/logic/trade/TradeLogic.kt +++ b/core/src/com/unciv/logic/trade/TradeLogic.kt @@ -1,7 +1,9 @@ package com.unciv.logic.trade import com.unciv.Constants +import com.unciv.logic.civilization.AlertType import com.unciv.logic.civilization.CivilizationInfo +import com.unciv.logic.civilization.PopupAlert import com.unciv.logic.civilization.diplomacy.DiplomacyFlags import com.unciv.models.ruleset.ModOptionsConstants import com.unciv.models.ruleset.tile.ResourceType @@ -102,6 +104,13 @@ class TradeLogic(val ourCivilization:CivilizationInfo, val otherCivilization: Ci } to.updateViewableTiles() from.updateViewableTiles() + + // suggest an option to liberate the city + if (to.isPlayerCivilization() + && city.foundingCiv != "" + && from.civName != city.foundingCiv // can't liberate if the city actually belongs to those guys + && to.civName != city.foundingCiv) // can't liberate if it's our city + to.popupAlerts.add(PopupAlert(AlertType.CityTraded, city.id)) } if (offer.type == TradeType.Treaty) { if (offer.name == Constants.peaceTreaty) to.getDiplomacyManager(from).makePeace() diff --git a/core/src/com/unciv/ui/worldscreen/AlertPopup.kt b/core/src/com/unciv/ui/worldscreen/AlertPopup.kt index ce3da2b6ab..0cb4435628 100644 --- a/core/src/com/unciv/ui/worldscreen/AlertPopup.kt +++ b/core/src/com/unciv/ui/worldscreen/AlertPopup.kt @@ -32,7 +32,8 @@ import java.util.* * @see AlertType */ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popup(worldScreen) { - fun getCloseButton(text: String, key: Char = Char.MIN_VALUE, action: (() -> Unit)? = null): TextButton { + + private fun getCloseButton(text: String, key: Char = Char.MIN_VALUE, action: (() -> Unit)? = null): TextButton { // Popup.addCloseButton is close but AlertPopup needs the flexibility to add these inside a wrapper val button = text.toTextButton() val buttonAction = { @@ -92,8 +93,7 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu } AlertType.CityConquered -> { val city = worldScreen.gameInfo.getCities().first { it.id == popupAlert.value } - addGoodSizedLabel("What would you like to do with the city?", Constants.headingFontSize) - .padBottom(20f).row() + addQuestionAboutTheCity(city.name) val conqueringCiv = worldScreen.gameInfo.currentPlayerCiv if (city.foundingCiv != "" @@ -139,6 +139,19 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu } } } + AlertType.CityTraded -> { + val city = worldScreen.gameInfo.getCities().first { it.id == popupAlert.value } + addQuestionAboutTheCity(city.name) + val conqueringCiv = worldScreen.gameInfo.currentPlayerCiv + + addLiberateOption(city.foundingCiv) { + city.liberateCity(conqueringCiv) + worldScreen.shouldUpdate = true + close() + } + addSeparator() + add(getCloseButton("Keep it")).row() + } AlertType.BorderConflict -> { val civInfo = worldScreen.gameInfo.getCivilization(popupAlert.value) addLeaderName(civInfo) @@ -342,6 +355,11 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu add(responseTable) } + private fun addQuestionAboutTheCity(cityName: String) { + addGoodSizedLabel("What would you like to do with the city of [$cityName]?", + Constants.headingFontSize).padBottom(20f).row() + } + private fun addDestroyOption(destroyAction: () -> Unit) { add("Destroy".toTextButton().onClick(function = destroyAction)).row() keyPressDispatcher['d'] = destroyAction