can now raze non-original capitals at capture (#4903)

* can now raze non-original capitals at capture

* clearer code, equal for AI, get gold and reduce pop when liberating

* fix conflict??

* fix conflict????

* restore whitespace

* restore whitespace

Co-authored-by: Yair Morgenstern <yairm210@hotmail.com>
This commit is contained in:
SimonCeder 2021-08-22 08:12:29 +02:00 committed by GitHub
parent f6a3808fe0
commit 33cba2eea9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 4 deletions

View File

@ -429,7 +429,7 @@ object Battle {
UncivGame.Current.settings.addCompletedTutorialTask("Conquer a city")
} else {
city.puppetCity(attackerCiv)
if (city.population.population < 4 && city.canBeDestroyed()) {
if (city.population.population < 4 && city.canBeDestroyed(justCaptured = true)) {
city.annexCity()
city.isBeingRazed = true
}

View File

@ -663,8 +663,8 @@ class CityInfo {
return religion.religionThisIsTheHolyCityOf != null
}
fun canBeDestroyed(): Boolean {
return !isOriginalCapital && !isCapital() && !isHolyCity()
fun canBeDestroyed(justCaptured: Boolean = false): Boolean {
return !isOriginalCapital && !isHolyCity() && (!isCapital() || justCaptured)
}

View File

@ -100,6 +100,7 @@ class CityInfoConquestFunctions(val city: CityInfo){
}
fun liberateCity(conqueringCiv: CivilizationInfo) {
val goldPlundered = getGoldForCapturingCity(conqueringCiv)
city.apply {
if (foundingCiv == "") { // this should never happen but just in case...
puppetCity(conqueringCiv)
@ -107,6 +108,9 @@ class CityInfoConquestFunctions(val city: CityInfo){
return
}
conqueringCiv.addGold(goldPlundered)
conqueringCiv.addNotification("Received [$goldPlundered] Gold for capturing [$name]", getCenterTile().position, NotificationIcon.Gold)
val oldCiv = civInfo
val foundingCiv = civInfo.gameInfo.civilizations.first { it.civName == foundingCiv }
@ -120,6 +124,7 @@ class CityInfoConquestFunctions(val city: CityInfo){
Battle.destroyIfDefeated(oldCiv, conqueringCiv)
health = getMaxHealth() / 2 // I think that cities recover to half health when conquered?
if (population.population > 1) population.addPopulation(-1 - population.population / 4) // so from 2-4 population, remove 1, from 5-8, remove 2, etc.
reassignPopulation()
if (foundingCiv.cities.size == 1) cityConstructions.addBuilding(capitalCityIndicator()) // Resurrection!

View File

@ -142,7 +142,7 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu
close()
}
add("Raze".toTextButton().apply {
if (!city.canBeDestroyed()) disable()
if (!city.canBeDestroyed(justCaptured = true)) disable()
else {
onClick(function = razeAction)
keyPressDispatcher['r'] = razeAction