AI can no longer raze capital cities

This commit is contained in:
Yair Morgenstern 2020-11-02 20:21:44 +02:00
parent 77af9ba80c
commit 87b0af6c1c
2 changed files with 13 additions and 14 deletions

View File

@ -122,9 +122,7 @@ object Battle {
} }
for (unique in bonusUniques) { for (unique in bonusUniques) {
if (!defeatedUnit.matchesCategory(unique.params[1])) { if (!defeatedUnit.matchesCategory(unique.params[1])) continue
continue
}
val yieldPercent = unique.params[0].toFloat() / 100 val yieldPercent = unique.params[0].toFloat() / 100
val defeatedUnitYieldSourceType = unique.params[2] val defeatedUnitYieldSourceType = unique.params[2]
@ -303,13 +301,13 @@ object Battle {
attackerCiv.addNotification("We have conquered the city of [${city.name}]!", city.location, Color.RED) attackerCiv.addNotification("We have conquered the city of [${city.name}]!", city.location, Color.RED)
city.getCenterTile().apply { city.getCenterTile().apply {
if(militaryUnit!=null) militaryUnit!!.destroy() if (militaryUnit != null) militaryUnit!!.destroy()
if(civilianUnit!=null) captureCivilianUnit(attacker, MapUnitCombatant(civilianUnit!!)) if (civilianUnit != null) captureCivilianUnit(attacker, MapUnitCombatant(civilianUnit!!))
for(airUnit in airUnits.toList()) airUnit.destroy() for (airUnit in airUnits.toList()) airUnit.destroy()
} }
city.hasJustBeenConquered = true city.hasJustBeenConquered = true
if (!attackerCiv.isMajorCiv()){ if (!attackerCiv.isMajorCiv()) {
city.destroyCity() city.destroyCity()
return return
} }
@ -317,10 +315,9 @@ object Battle {
if (attackerCiv.isPlayerCivilization()) { if (attackerCiv.isPlayerCivilization()) {
attackerCiv.popupAlerts.add(PopupAlert(AlertType.CityConquered, city.id)) attackerCiv.popupAlerts.add(PopupAlert(AlertType.CityConquered, city.id))
UncivGame.Current.settings.addCompletedTutorialTask("Conquer a city") UncivGame.Current.settings.addCompletedTutorialTask("Conquer a city")
} } else {
else {
city.puppetCity(attackerCiv) city.puppetCity(attackerCiv)
if (city.population.population < 4) { if (city.population.population < 4 && !city.isOriginalCapital) {
city.annexCity() city.annexCity()
city.isBeingRazed = true city.isBeingRazed = true
} }
@ -328,9 +325,9 @@ object Battle {
} }
fun getMapCombatantOfTile(tile:TileInfo): ICombatant? { fun getMapCombatantOfTile(tile:TileInfo): ICombatant? {
if(tile.isCityCenter()) return CityCombatant(tile.getCity()!!) if (tile.isCityCenter()) return CityCombatant(tile.getCity()!!)
if(tile.militaryUnit!=null) return MapUnitCombatant(tile.militaryUnit!!) if (tile.militaryUnit != null) return MapUnitCombatant(tile.militaryUnit!!)
if(tile.civilianUnit!=null) return MapUnitCombatant(tile.civilianUnit!!) if (tile.civilianUnit != null) return MapUnitCombatant(tile.civilianUnit!!)
return null return null
} }

View File

@ -125,8 +125,10 @@ internal object DesktopLauncher {
* this causes a delay, leading to horrible lag if there are enough switches. * this causes a delay, leading to horrible lag if there are enough switches.
* The cost of this specific solution is that the entire game.png needs be be kept in-memory constantly. * The cost of this specific solution is that the entire game.png needs be be kept in-memory constantly.
* It's currently only 1.5MB so it should be okay, but it' an important point to remember for the future. * It's currently only 1.5MB so it should be okay, but it' an important point to remember for the future.
* Sidenode: Modded tilesets don't have this problem, since all the images are included in the mod's single PNG. * Sidenote: Modded tilesets don't have this problem, since all the images are included in the mod's single PNG.
* Probably. Unless they have some truly huge images. * Probably. Unless they have some truly huge images.
* Sidenote 2: Okay entire so custom tilesets do have this problem because they can get so big that what accommodates
* the regular tileset (4096) doesn't suit them. Looking at you 5hex.
*/ */
settings.maxWidth = 4096 settings.maxWidth = 4096
settings.maxHeight = 4096 settings.maxHeight = 4096