The original capital can not be razed (#2412)

* Civ is not defeated while at least 1 settler is alive

* The original capital cannot be razed

* Revert "Civ is not defeated while at least 1 settler is alive"

Defeat condition is: no cities remained
This commit is contained in:
Jack Rainy 2020-04-16 10:33:58 +03:00 committed by GitHub
parent 68af30acf0
commit 2594777b52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 6 deletions

View file

@ -56,6 +56,10 @@ class CityInfo {
var attackedThisTurn = false
var hasSoldBuildingThisTurn = false
var isPuppet = false
/** The very first found city is the _original_ capital,
* while the _current_ capital can be any other city after the original one is captured.
* It is important to distinct them since the original cannot be razed and defines the Domination Victory. */
var isOriginalCapital = false
constructor() // for json parsing, we need to have a default constructor
constructor(civInfo: CivilizationInfo, cityLocation: Vector2) { // new city!
@ -76,6 +80,7 @@ class CityInfo {
name = cityNamePrefix + cityName
isOriginalCapital = civInfo.citiesCreated == 0
civInfo.citiesCreated++
civInfo.cities = civInfo.cities.toMutableList().apply { add(this@CityInfo) }
@ -125,6 +130,7 @@ class CityInfo {
toReturn.foundingCiv = foundingCiv
toReturn.turnAcquired = turnAcquired
toReturn.isPuppet = isPuppet
toReturn.isOriginalCapital = isOriginalCapital
return toReturn
}
@ -139,7 +145,7 @@ class CityInfo {
val mediumTypes = civInfo.citiesConnectedToCapitalToMediums[this] ?: return false
return connectionTypePredicate(mediumTypes)
}
fun isInResistance() = resistanceCounter>0
fun isInResistance() = resistanceCounter > 0
fun getRuleset() = civInfo.gameInfo.ruleSet

View file

@ -262,8 +262,8 @@ class CivilizationInfo {
override fun toString(): String {return civName} // for debug
/** Returns true if the civ was fully initialized and has no cities or settlers remaining */
fun isDefeated()= cities.isEmpty()
/** Returns true if the civ was fully initialized and has no cities remaining */
fun isDefeated()= cities.isEmpty() // No cities
&& exploredTiles.isNotEmpty() // Dirty hack: exploredTiles are empty only before starting units are placed
&& !isBarbarian() // Barbarians can be never defeated
&& (citiesCreated > 0 || !getCivUnits().any { it.name == Constants.settler })

View file

@ -125,7 +125,9 @@ class CityScreen(internal val city: CityInfo): CameraStageBaseScreen() {
val razeCityButton = "Raze city".toTextButton()
razeCityButton.labelCell.pad(10f)
razeCityButton.onClick { city.isBeingRazed=true; update() }
if(!UncivGame.Current.worldScreen.isPlayersTurn) razeCityButton.disable()
if(!UncivGame.Current.worldScreen.isPlayersTurn || city.isOriginalCapital)
razeCityButton.disable()
razeCityButtonHolder.add(razeCityButton).colspan(cityPickerTable.columns)
} else {
val stopRazingCityButton = "Stop razing city".toTextButton()

View file

@ -99,13 +99,15 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu
addSeparator()
add("Raze".toTextButton().onClick {
add("Raze".toTextButton().apply {
if (city.isOriginalCapital) disable()
else onClick {
city.puppetCity(conqueringCiv)
city.annexCity()
city.isBeingRazed = true
worldScreen.shouldUpdate=true
close()
}).row()
}}).row()
addGoodSizedLabel("Razing the city annexes it, and starts razing the city to the ground.").row()
addGoodSizedLabel("The population will gradually dwindle until the city is destroyed.").row()
} else {