From 73424466d466c4edd7fd4661e96959764e0f3b74 Mon Sep 17 00:00:00 2001 From: yairm210 Date: Sun, 15 Dec 2024 11:33:23 +0200 Subject: [PATCH] Resolved #12640 - "Tile provides yield without assigned population", "Adjacent enemy units ending their turn take [49] damage" accept tile/civ conditionals --- core/src/com/unciv/logic/city/CityStats.kt | 4 ++-- core/src/com/unciv/logic/map/mapunit/UnitTurnManager.kt | 2 +- core/src/com/unciv/logic/map/tile/Tile.kt | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/src/com/unciv/logic/city/CityStats.kt b/core/src/com/unciv/logic/city/CityStats.kt index 4a0c251876..96159b84f9 100644 --- a/core/src/com/unciv/logic/city/CityStats.kt +++ b/core/src/com/unciv/logic/city/CityStats.kt @@ -351,8 +351,8 @@ class CityStats(val city: City) { city.location == it.position || city.isWorked(it) || it.owningCity == city && (it.getUnpillagedTileImprovement() - ?.hasUnique(UniqueType.TileProvidesYieldWithoutPopulation) == true - || it.terrainHasUnique(UniqueType.TileProvidesYieldWithoutPopulation)) + ?.hasUnique(UniqueType.TileProvidesYieldWithoutPopulation, it.stateThisTile) == true + || it.terrainHasUnique(UniqueType.TileProvidesYieldWithoutPopulation, it.stateThisTile)) } for (tile in workedTiles) { if (tile.isBlockaded() && city.isWorked(tile)) { diff --git a/core/src/com/unciv/logic/map/mapunit/UnitTurnManager.kt b/core/src/com/unciv/logic/map/mapunit/UnitTurnManager.kt index 70a0d1117a..edc3672aa2 100644 --- a/core/src/com/unciv/logic/map/mapunit/UnitTurnManager.kt +++ b/core/src/com/unciv/logic/map/mapunit/UnitTurnManager.kt @@ -88,7 +88,7 @@ class UnitTurnManager(val unit: MapUnit) { && it.getUnpillagedImprovement() != null && unit.civ.isAtWarWith(it.getOwner()!!) }.map { tile -> - tile to tile.getTileImprovement()!!.getMatchingUniques(UniqueType.DamagesAdjacentEnemyUnits) + tile to tile.getTileImprovement()!!.getMatchingUniques(UniqueType.DamagesAdjacentEnemyUnits, tile.stateThisTile) .sumOf { it.params[0].toInt() } }.maxByOrNull { it.second } ?: return diff --git a/core/src/com/unciv/logic/map/tile/Tile.kt b/core/src/com/unciv/logic/map/tile/Tile.kt index 83499737fd..c5a717c75a 100644 --- a/core/src/com/unciv/logic/map/tile/Tile.kt +++ b/core/src/com/unciv/logic/map/tile/Tile.kt @@ -370,7 +370,7 @@ class Tile : IsPartOfGameInfoSerialization, Json.Serializable { fun isRoughTerrain() = allTerrains.any { it.isRough() } @Transient - private var stateThisTile: StateForConditionals = StateForConditionals.EmptyState + internal var stateThisTile: StateForConditionals = StateForConditionals.EmptyState /** Checks whether any of the TERRAINS of this tile has a certain unique */ fun terrainHasUnique(uniqueType: UniqueType, state: StateForConditionals = stateThisTile) = terrainUniqueMap.getMatchingUniques(uniqueType, state).any() @@ -430,7 +430,7 @@ class Tile : IsPartOfGameInfoSerialization, Json.Serializable { if (getCity() == null) return false return isCityCenter() || isWorked() - || getUnpillagedTileImprovement()?.hasUnique(UniqueType.TileProvidesYieldWithoutPopulation) == true + || getUnpillagedTileImprovement()?.hasUnique(UniqueType.TileProvidesYieldWithoutPopulation, stateThisTile) == true || terrainHasUnique(UniqueType.TileProvidesYieldWithoutPopulation) }