diff --git a/core/src/com/unciv/logic/map/tile/Tile.kt b/core/src/com/unciv/logic/map/tile/Tile.kt index cc048147e5..48bc973fb6 100644 --- a/core/src/com/unciv/logic/map/tile/Tile.kt +++ b/core/src/com/unciv/logic/map/tile/Tile.kt @@ -467,11 +467,11 @@ open class Tile : IsPartOfGameInfoSerialization { } // This should be the only adjacency function - fun isAdjacentTo(terrainFilter:String): Boolean { + fun isAdjacentTo(terrainFilter:String, observingCiv: Civilization?=null): Boolean { // Rivers are odd, as they aren't technically part of any specific tile but still count towards adjacency if (terrainFilter == Constants.river) return isAdjacentToRiver() if (terrainFilter == Constants.freshWater && isAdjacentToRiver()) return true - return (neighbors + this).any { neighbor -> neighbor.matchesFilter(terrainFilter) } + return (neighbors + this).any { neighbor -> neighbor.matchesFilter(terrainFilter, observingCiv) } } /** Implements [UniqueParameterType.TileFilter][com.unciv.models.ruleset.unique.UniqueParameterType.TileFilter] */ @@ -514,7 +514,7 @@ open class Tile : IsPartOfGameInfoSerialization { "Water resource" -> isWater && observingCiv != null && hasViewableResource(observingCiv) "Natural Wonder" -> naturalWonder != null "Featureless" -> terrainFeatures.isEmpty() - Constants.freshWaterFilter -> isAdjacentTo(Constants.freshWater) + Constants.freshWaterFilter -> isAdjacentTo(Constants.freshWater, observingCiv) in terrainFeatures -> true else -> { diff --git a/core/src/com/unciv/models/ruleset/Building.kt b/core/src/com/unciv/models/ruleset/Building.kt index 77b097cfa1..84aa64c4af 100644 --- a/core/src/com/unciv/models/ruleset/Building.kt +++ b/core/src/com/unciv/models/ruleset/Building.kt @@ -7,9 +7,9 @@ import com.unciv.logic.civilization.Civilization import com.unciv.models.Counter import com.unciv.models.ruleset.tile.ResourceType import com.unciv.models.ruleset.tile.TileImprovement -import com.unciv.models.ruleset.unique.Unique import com.unciv.models.ruleset.unique.LocalUniqueCache import com.unciv.models.ruleset.unique.StateForConditionals +import com.unciv.models.ruleset.unique.Unique import com.unciv.models.ruleset.unique.UniqueParameterType import com.unciv.models.ruleset.unique.UniqueTarget import com.unciv.models.ruleset.unique.UniqueType @@ -271,7 +271,7 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction { yield(RejectionReasonType.MustNotBeOnTile.toInstance(unique.text)) UniqueType.MustBeNextTo -> - if (!cityCenter.isAdjacentTo(unique.params[0])) + if (!cityCenter.isAdjacentTo(unique.params[0], civ)) yield(RejectionReasonType.MustBeNextToTile.toInstance(unique.text)) UniqueType.MustNotBeNextTo -> diff --git a/core/src/com/unciv/models/ruleset/unique/Unique.kt b/core/src/com/unciv/models/ruleset/unique/Unique.kt index ed78c0ed2e..d6ac81209d 100644 --- a/core/src/com/unciv/models/ruleset/unique/Unique.kt +++ b/core/src/com/unciv/models/ruleset/unique/Unique.kt @@ -318,8 +318,8 @@ class Unique(val text: String, val sourceObjectType: UniqueTarget? = null, val s relevantTile?.matchesFilter(condition.params[0], state.civInfo) == true UniqueType.ConditionalInTilesNot -> relevantTile?.matchesFilter(condition.params[0], state.civInfo) == false - UniqueType.ConditionalAdjacentTo -> relevantTile?.isAdjacentTo(condition.params[0]) == true - UniqueType.ConditionalNotAdjacentTo -> relevantTile?.isAdjacentTo(condition.params[0]) == false + UniqueType.ConditionalAdjacentTo -> relevantTile?.isAdjacentTo(condition.params[0], state.civInfo) == true + UniqueType.ConditionalNotAdjacentTo -> relevantTile?.isAdjacentTo(condition.params[0], state.civInfo) == false UniqueType.ConditionalFightingInTiles -> state.attackedTile?.matchesFilter(condition.params[0], state.civInfo) == true UniqueType.ConditionalInTilesAnd ->