Fixed a bug where one city challengers could capture enemy cities (#4431)

* Fixed a bug where one city challengres could capture enemy cities

* Actually, this is a cleaner implementation
This commit is contained in:
Xander Lenstra
2021-07-09 08:11:17 +02:00
committed by GitHub
parent 5e01ce82b2
commit ced85fafd1
2 changed files with 10 additions and 8 deletions

View File

@ -369,11 +369,6 @@ object Battle {
}
city.hasJustBeenConquered = true
if (attackerCiv.isBarbarian()) {
city.destroyCity()
return
}
for (unique in attackerCiv.getMatchingUniques("Upon capturing a city, receive [] times its [] production as [] immediately")) {
attackerCiv.addStat(
Stat.valueOf(unique.params[2]),
@ -381,6 +376,11 @@ object Battle {
)
}
if (attackerCiv.isBarbarian() || attackerCiv.isOneCityChallenger()) {
city.destroyCity(true)
return
}
if (attackerCiv.isPlayerCivilization()) {
attackerCiv.popupAlerts.add(PopupAlert(AlertType.CityConquered, city.id))
UncivGame.Current.settings.addCompletedTutorialTask("Conquer a city")

View File

@ -440,9 +440,11 @@ class CityInfo {
}
}
fun destroyCity() {
// Original capitals can't be destroyed
if (isOriginalCapital) return
fun destroyCity(overrideSafeties: Boolean = false) {
// Original capitals can't be destroyed.
// Unless they are captured by a one-city-challenger for some reason.
// This was tested in the original.
if (isOriginalCapital && !overrideSafeties) return
for (airUnit in getCenterTile().airUnits.toList()) airUnit.destroy() //Destroy planes stationed in city