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 {
return when {
city.attackedThisTurn -> false
else -> {
val enemy = chooseBombardTarget(city)
if (enemy == null) return false
Battle.attack(CityCombatant(city), enemy)
true
}
}
if (!city.canBombard()) return false
val enemy = chooseBombardTarget(city)
if (enemy == null) return false
Battle.attack(CityCombatant(city), enemy)
return true
}
private fun chooseBombardTarget(city: CityInfo): ICombatant? {

View File

@ -157,7 +157,7 @@ class CityInfo {
return toReturn
}
fun canBombard() = !attackedThisTurn && !isInResistance()
fun getCenterTile(): TileInfo = centerTileInfo
fun getTiles(): Sequence<TileInfo> = tiles.asSequence().map { tileMap[it] }
fun getWorkableTiles() = tilesInRange.asSequence().filter { it.getOwner() == civInfo }
@ -242,7 +242,6 @@ class CityInfo {
}
fun isGrowing() = foodForNextTurn() > 0
fun isStarving() = foodForNextTurn() < 0
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 getGreatPersonMap(): StatMap {
fun getGreatPersonPointsForNextTurn(): StatMap {
val stats = StatMap()
for ((specialist, amount) in population.getNewSpecialists())
if (getRuleset().specialists.containsKey(specialist)) // To solve problems in total remake mods
@ -300,7 +299,7 @@ class CityInfo {
fun getGreatPersonPoints(): Stats {
val stats = Stats()
for (entry in getGreatPersonMap().values)
for (entry in getGreatPersonPointsForNextTurn().values)
stats.add(entry)
return stats
}
@ -437,8 +436,7 @@ class CityInfo {
}
/*
When someone settles a city within 6 tiles of another civ,
this makes the AI unhappy and it starts a rolling event.
When someone settles a city within 6 tiles of another civ, this makes the AI unhappy and it starts a rolling event.
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)
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
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.math.Vector2
import com.unciv.ui.cityscreen.CityScreen
import com.unciv.ui.pickerscreens.TechPickerScreen

View File

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

View File

@ -239,7 +239,7 @@ class CityInfoTable(private val cityScreen: CityScreen) : Table(CameraStageBaseS
}
private fun Table.addGreatPersonPointInfo(cityInfo: CityInfo) {
val greatPersonPoints = cityInfo.getGreatPersonMap()
val greatPersonPoints = cityInfo.getGreatPersonPointsForNextTurn()
val statToGreatPerson = GreatPersonManager().statToGreatPersonMapping
for (stat in Stat.values()) {
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) {
val unitsInTile = selectedTile!!.getUnits()
if (previousSelectedCity != null && !previousSelectedCity.attackedThisTurn
if (previousSelectedCity != null && previousSelectedCity.canBombard()
&& selectedTile!!.getTilesInDistance(2).contains(previousSelectedCity.getCenterTile())
&& unitsInTile.any()
&& 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>) {
if (city.attackedThisTurn) return
if (!city.canBombard()) return
val attackableTiles = UnitAutomation.getBombardTargets(city)
.filter { (UncivGame.Current.viewEntireMapForDebug || playerViewableTilePositions.contains(it.position)) }