Cities in resistance cannot bombard, as per Civ V - #663

This commit is contained in:
Yair Morgenstern 2021-06-08 21:59:23 +03:00
parent 7cad6dcfe5
commit 8441ab9e56
6 changed files with 13 additions and 20 deletions

View File

@ -377,15 +377,11 @@ object UnitAutomation {
} }
fun tryBombardEnemy(city: CityInfo): Boolean { fun tryBombardEnemy(city: CityInfo): Boolean {
return when { if (!city.canBombard()) return false
city.attackedThisTurn -> false val enemy = chooseBombardTarget(city)
else -> { if (enemy == null) return false
val enemy = chooseBombardTarget(city) Battle.attack(CityCombatant(city), enemy)
if (enemy == null) return false return true
Battle.attack(CityCombatant(city), enemy)
true
}
}
} }
private fun chooseBombardTarget(city: CityInfo): ICombatant? { private fun chooseBombardTarget(city: CityInfo): ICombatant? {

View File

@ -157,7 +157,7 @@ class CityInfo {
return toReturn return toReturn
} }
fun canBombard() = !attackedThisTurn && !isInResistance()
fun getCenterTile(): TileInfo = centerTileInfo fun getCenterTile(): TileInfo = centerTileInfo
fun getTiles(): Sequence<TileInfo> = tiles.asSequence().map { tileMap[it] } fun getTiles(): Sequence<TileInfo> = tiles.asSequence().map { tileMap[it] }
fun getWorkableTiles() = tilesInRange.asSequence().filter { it.getOwner() == civInfo } fun getWorkableTiles() = tilesInRange.asSequence().filter { it.getOwner() == civInfo }
@ -242,7 +242,6 @@ class CityInfo {
} }
fun isGrowing() = foodForNextTurn() > 0 fun isGrowing() = foodForNextTurn() > 0
fun isStarving() = foodForNextTurn() < 0 fun isStarving() = foodForNextTurn() < 0
private fun foodForNextTurn() = cityStats.currentCityStats.food.roundToInt() private fun foodForNextTurn() = cityStats.currentCityStats.food.roundToInt()
@ -265,7 +264,7 @@ class CityInfo {
fun containsBuildingUnique(unique: String) = cityConstructions.getBuiltBuildings().any { it.uniques.contains(unique) } fun containsBuildingUnique(unique: String) = cityConstructions.getBuiltBuildings().any { it.uniques.contains(unique) }
fun getGreatPersonMap(): StatMap { fun getGreatPersonPointsForNextTurn(): StatMap {
val stats = StatMap() val stats = StatMap()
for ((specialist, amount) in population.getNewSpecialists()) for ((specialist, amount) in population.getNewSpecialists())
if (getRuleset().specialists.containsKey(specialist)) // To solve problems in total remake mods if (getRuleset().specialists.containsKey(specialist)) // To solve problems in total remake mods
@ -300,7 +299,7 @@ class CityInfo {
fun getGreatPersonPoints(): Stats { fun getGreatPersonPoints(): Stats {
val stats = Stats() val stats = Stats()
for (entry in getGreatPersonMap().values) for (entry in getGreatPersonPointsForNextTurn().values)
stats.add(entry) stats.add(entry)
return stats return stats
} }
@ -437,8 +436,7 @@ class CityInfo {
} }
/* /*
When someone settles a city within 6 tiles of another civ, When someone settles a city within 6 tiles of another civ, this makes the AI unhappy and it starts a rolling event.
this makes the AI unhappy and it starts a rolling event.
The SettledCitiesNearUs flag gets added to the AI so it knows this happened, The SettledCitiesNearUs flag gets added to the AI so it knows this happened,
and on its turn it asks the player to stop (with a DemandToStopSettlingCitiesNear alert type) and on its turn it asks the player to stop (with a DemandToStopSettlingCitiesNear alert type)
If the player says "whatever, I'm not promising to stop", they get a -10 modifier which gradually disappears in 40 turns If the player says "whatever, I'm not promising to stop", they get a -10 modifier which gradually disappears in 40 turns

View File

@ -1,6 +1,5 @@
package com.unciv.logic.civilization package com.unciv.logic.civilization
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.math.Vector2 import com.badlogic.gdx.math.Vector2
import com.unciv.ui.cityscreen.CityScreen import com.unciv.ui.cityscreen.CityScreen
import com.unciv.ui.pickerscreens.TechPickerScreen import com.unciv.ui.pickerscreens.TechPickerScreen

View File

@ -394,7 +394,7 @@ open class TileInfo {
|| baseTerrainObject.uniques.contains(filter) || baseTerrainObject.uniques.contains(filter)
|| improvement == filter || improvement == filter
|| resource == filter || resource == filter
|| (resource != null && getTileResource().resourceType.name + " resource" == filter) || resource != null && getTileResource().resourceType.name + " resource" == filter
|| filter == "Water" && isWater || filter == "Water" && isWater
|| filter == "Land" && isLand || filter == "Land" && isLand
|| filter == "Coastal" && isCoastalTile() || filter == "Coastal" && isCoastalTile()

View File

@ -239,7 +239,7 @@ class CityInfoTable(private val cityScreen: CityScreen) : Table(CameraStageBaseS
} }
private fun Table.addGreatPersonPointInfo(cityInfo: CityInfo) { private fun Table.addGreatPersonPointInfo(cityInfo: CityInfo) {
val greatPersonPoints = cityInfo.getGreatPersonMap() val greatPersonPoints = cityInfo.getGreatPersonPointsForNextTurn()
val statToGreatPerson = GreatPersonManager().statToGreatPersonMapping val statToGreatPerson = GreatPersonManager().statToGreatPersonMapping
for (stat in Stat.values()) { for (stat in Stat.values()) {
if (!statToGreatPerson.containsKey(stat)) continue if (!statToGreatPerson.containsKey(stat)) continue

View File

@ -166,7 +166,7 @@ class WorldMapHolder(internal val worldScreen: WorldScreen, internal val tileMap
if (newSelectedUnit == null || newSelectedUnit.type == UnitType.Civilian) { if (newSelectedUnit == null || newSelectedUnit.type == UnitType.Civilian) {
val unitsInTile = selectedTile!!.getUnits() val unitsInTile = selectedTile!!.getUnits()
if (previousSelectedCity != null && !previousSelectedCity.attackedThisTurn if (previousSelectedCity != null && previousSelectedCity.canBombard()
&& selectedTile!!.getTilesInDistance(2).contains(previousSelectedCity.getCenterTile()) && selectedTile!!.getTilesInDistance(2).contains(previousSelectedCity.getCenterTile())
&& unitsInTile.any() && unitsInTile.any()
&& unitsInTile.first().civInfo.isAtWarWith(worldScreen.viewingCiv)) { && unitsInTile.first().civInfo.isAtWarWith(worldScreen.viewingCiv)) {
@ -548,7 +548,7 @@ class WorldMapHolder(internal val worldScreen: WorldScreen, internal val tileMap
} }
private fun updateTilegroupsForSelectedCity(city: CityInfo, playerViewableTilePositions: HashSet<Vector2>) { private fun updateTilegroupsForSelectedCity(city: CityInfo, playerViewableTilePositions: HashSet<Vector2>) {
if (city.attackedThisTurn) return if (!city.canBombard()) return
val attackableTiles = UnitAutomation.getBombardTargets(city) val attackableTiles = UnitAutomation.getBombardTargets(city)
.filter { (UncivGame.Current.viewEntireMapForDebug || playerViewableTilePositions.contains(it.position)) } .filter { (UncivGame.Current.viewEntireMapForDebug || playerViewableTilePositions.contains(it.position)) }