mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-05 21:11:35 +07:00
Adjacency function can receive civ, for foreign/resource filters
This commit is contained in:
parent
138d1c64a1
commit
74ca1d43e8
@ -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 -> {
|
||||
|
@ -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 ->
|
||||
|
@ -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 ->
|
||||
|
Loading…
Reference in New Issue
Block a user