diff --git a/core/src/com/unciv/logic/battle/AirInterception.kt b/core/src/com/unciv/logic/battle/AirInterception.kt index c982cf0442..c366e8aef1 100644 --- a/core/src/com/unciv/logic/battle/AirInterception.kt +++ b/core/src/com/unciv/logic/battle/AirInterception.kt @@ -161,7 +161,7 @@ object AirInterception { // Can't intercept if we have a unique preventing it val conditionalState = StateForConditionals(interceptingCiv, ourCombatant = MapUnitCombatant(unit), theirCombatant = attacker, combatAction = CombatAction.Intercept, attackedTile = attackedTile) unit.getMatchingUniques(UniqueType.CannotInterceptUnits, conditionalState) - .none { attacker.matchesCategory(it.params[0]) } + .none { attacker.matchesFilter(it.params[0]) } // Defender can't intercept either && unit != (defender as? MapUnitCombatant)?.unit } diff --git a/core/src/com/unciv/logic/battle/Battle.kt b/core/src/com/unciv/logic/battle/Battle.kt index 77586b34e5..9b58f47ca4 100644 --- a/core/src/com/unciv/logic/battle/Battle.kt +++ b/core/src/com/unciv/logic/battle/Battle.kt @@ -215,7 +215,7 @@ object Battle { val bonusUniques = getKillUnitPlunderUniques(civUnit, defeatedUnit) for (unique in bonusUniques) { - if (!defeatedUnit.matchesCategory(unique.params[1])) continue + if (!defeatedUnit.matchesFilter(unique.params[1])) continue val yieldPercent = unique.params[0].toFloat() / 100 val defeatedUnitYieldSourceType = unique.params[2] @@ -331,7 +331,7 @@ object Battle { val plunderedGoods = Stats() for (unique in plunderingUnit.unit.getMatchingUniques(UniqueType.DamageUnitsPlunder, checkCivInfoUniques = true)) { - if (plunderedUnit.matchesCategory(unique.params[1])) { + if (plunderedUnit.matchesFilter(unique.params[1])) { val percentage = unique.params[0].toFloat() plunderedGoods.add(Stat.valueOf(unique.params[2]), percentage / 100f * damageDealt) } @@ -483,7 +483,7 @@ object Battle { if (!otherIsBarbarian && civ.isMajorCiv()) { // Can't get great generals from Barbarians var greatGeneralUnits = civ.gameInfo.ruleset.greatGeneralUnits - .filter { it.hasUnique(UniqueType.GreatPersonFromCombat, stateForConditionals) && + .filter { it.hasUnique(UniqueType.GreatPersonFromCombat, stateForConditionals) && // Check if the unit is allowed for the Civ, ignoring build constrants it.getRejectionReasons(civ).none { reason -> !reason.isConstructionRejection() && @@ -491,7 +491,7 @@ object Battle { !reason.techPolicyEraWonderRequirements() } }.asSequence() // For compatibility with older rulesets - if (civ.gameInfo.ruleset.greatGeneralUnits.isEmpty() && + if (civ.gameInfo.ruleset.greatGeneralUnits.isEmpty() && civ.gameInfo.ruleset.units["Great General"] != null) greatGeneralUnits += civ.gameInfo.ruleset.units["Great General"]!! diff --git a/core/src/com/unciv/logic/battle/BattleDamage.kt b/core/src/com/unciv/logic/battle/BattleDamage.kt index af65bc147a..7e36530da1 100644 --- a/core/src/com/unciv/logic/battle/BattleDamage.kt +++ b/core/src/com/unciv/logic/battle/BattleDamage.kt @@ -104,7 +104,7 @@ object BattleDamage { // e.g., Maori Warrior - https://civilization.fandom.com/wiki/Maori_Warrior_(Civ5) val strengthMalus = adjacentUnits.filter { it.civ.isAtWarWith(combatant.getCivInfo()) } .flatMap { it.getMatchingUniques(UniqueType.StrengthForAdjacentEnemies) } - .filter { combatant.matchesCategory(it.params[1]) && combatant.getTile().matchesFilter(it.params[2]) } + .filter { combatant.matchesFilter(it.params[1]) && combatant.getTile().matchesFilter(it.params[2]) } .maxByOrNull { it.params[0] } if (strengthMalus != null) { modifiers.add("Adjacent enemy units", strengthMalus.params[0].toInt()) diff --git a/core/src/com/unciv/logic/battle/BattleUnitCapture.kt b/core/src/com/unciv/logic/battle/BattleUnitCapture.kt index 8ddea77535..dcc3b691a0 100644 --- a/core/src/com/unciv/logic/battle/BattleUnitCapture.kt +++ b/core/src/com/unciv/logic/battle/BattleUnitCapture.kt @@ -45,7 +45,7 @@ object BattleUnitCapture { private fun unitCapturedPrizeShipsUnique(attacker: MapUnitCombatant, defender: MapUnitCombatant): Boolean { if (attacker.unit.getMatchingUniques(UniqueType.KillUnitCapture) - .none { defender.matchesCategory(it.params[0]) } + .none { defender.matchesFilter(it.params[0]) } ) return false val captureChance = min( diff --git a/core/src/com/unciv/logic/battle/CityCombatant.kt b/core/src/com/unciv/logic/battle/CityCombatant.kt index cc7706eaa3..a50c35484b 100644 --- a/core/src/com/unciv/logic/battle/CityCombatant.kt +++ b/core/src/com/unciv/logic/battle/CityCombatant.kt @@ -23,7 +23,7 @@ class CityCombatant(val city: City) : ICombatant { override fun isDefeated(): Boolean = city.health == 1 override fun isInvisible(to: Civilization): Boolean = false override fun canAttack(): Boolean = city.canBombard() - override fun matchesCategory(category: String) = category == "City" || category == "All" + override fun matchesFilter(filter: String) = filter == "City" || filter == "All" override fun getAttackSound() = UncivSound.Bombard override fun takeDamage(damage: Int) { diff --git a/core/src/com/unciv/logic/battle/ICombatant.kt b/core/src/com/unciv/logic/battle/ICombatant.kt index 1d45790013..1bc3b315f0 100644 --- a/core/src/com/unciv/logic/battle/ICombatant.kt +++ b/core/src/com/unciv/logic/battle/ICombatant.kt @@ -19,7 +19,7 @@ interface ICombatant { fun isInvisible(to: Civilization): Boolean fun canAttack(): Boolean /** Implements [UniqueParameterType.CombatantFilter][com.unciv.models.ruleset.unique.UniqueParameterType.CombatantFilter] */ - fun matchesCategory(category: String): Boolean + fun matchesFilter(filter: String): Boolean fun getAttackSound(): UncivSound fun isMelee(): Boolean = !isRanged() diff --git a/core/src/com/unciv/logic/battle/MapUnitCombatant.kt b/core/src/com/unciv/logic/battle/MapUnitCombatant.kt index e1958f66d3..6daa487cc1 100644 --- a/core/src/com/unciv/logic/battle/MapUnitCombatant.kt +++ b/core/src/com/unciv/logic/battle/MapUnitCombatant.kt @@ -18,7 +18,7 @@ class MapUnitCombatant(val unit: MapUnit) : ICombatant { override fun isDefeated(): Boolean = unit.health <= 0 override fun isInvisible(to: Civilization): Boolean = unit.isInvisible(to) override fun canAttack(): Boolean = unit.canAttack() - override fun matchesCategory(category: String) = unit.matchesFilter(category) + override fun matchesFilter(filter: String) = unit.matchesFilter(filter) override fun getAttackSound() = unit.baseUnit.attackSound.let { if (it == null) UncivSound.Click else UncivSound(it) } diff --git a/core/src/com/unciv/logic/battle/TargetHelper.kt b/core/src/com/unciv/logic/battle/TargetHelper.kt index 689e000bb3..f60f8d7e70 100644 --- a/core/src/com/unciv/logic/battle/TargetHelper.kt +++ b/core/src/com/unciv/logic/battle/TargetHelper.kt @@ -107,7 +107,7 @@ object TargetHelper { if (combatant is MapUnitCombatant && combatant.unit.getMatchingUniques(UniqueType.CanOnlyAttackUnits).run { - any() && none { tileCombatant.matchesCategory(it.params[0]) } + any() && none { tileCombatant.matchesFilter(it.params[0]) } } ) return false diff --git a/core/src/com/unciv/models/ruleset/unique/Unique.kt b/core/src/com/unciv/models/ruleset/unique/Unique.kt index 6acd5bbc2c..a8576e40f7 100644 --- a/core/src/com/unciv/models/ruleset/unique/Unique.kt +++ b/core/src/com/unciv/models/ruleset/unique/Unique.kt @@ -299,8 +299,8 @@ class Unique(val text: String, val sourceObjectType: UniqueTarget? = null, val s UniqueType.ConditionalWhenGarrisoned -> checkOnCity { getCenterTile().militaryUnit?.canGarrison() == true } - UniqueType.ConditionalVsCity -> state.theirCombatant?.matchesCategory("City") == true - UniqueType.ConditionalVsUnits -> state.theirCombatant?.matchesCategory(condition.params[0]) == true + UniqueType.ConditionalVsCity -> state.theirCombatant?.matchesFilter("City") == true + UniqueType.ConditionalVsUnits -> state.theirCombatant?.matchesFilter(condition.params[0]) == true UniqueType.ConditionalOurUnit, UniqueType.ConditionalOurUnitOnUnit -> relevantUnit?.matchesFilter(condition.params[0]) == true UniqueType.ConditionalUnitWithPromotion -> relevantUnit?.promotions?.promotions?.contains(condition.params[0]) == true diff --git a/core/src/com/unciv/models/ruleset/unique/UniqueParameterType.kt b/core/src/com/unciv/models/ruleset/unique/UniqueParameterType.kt index 0f8a3edca1..9894baf39f 100644 --- a/core/src/com/unciv/models/ruleset/unique/UniqueParameterType.kt +++ b/core/src/com/unciv/models/ruleset/unique/UniqueParameterType.kt @@ -80,7 +80,7 @@ enum class UniqueParameterType( if (parameterText == "All") null else UniqueType.UniqueParameterErrorSeverity.RulesetInvariant }, - /** Implemented by [ICombatant.matchesCategory][com.unciv.logic.battle.ICombatant.matchesCategory] */ + /** Implemented by [ICombatant.matchesCategory][com.unciv.logic.battle.ICombatant.matchesFilter] */ CombatantFilter("combatantFilter", "City", "This indicates a combatant, which can either be a unit or a city (when bombarding). Must either be `City` or a `mapUnitFilter`") { override fun getErrorSeverity(parameterText: String, ruleset: Ruleset): UniqueType.UniqueParameterErrorSeverity? { @@ -309,7 +309,7 @@ enum class UniqueParameterType( TerrainFilter("terrainFilter", Constants.freshWaterFilter, null, "Terrain Filters") { private val knownValues = setOf( "All", "Terrain", - Constants.coastal, Constants.river, "Open terrain", "Rough terrain", "Water resource", + Constants.coastal, Constants.river, "Open terrain", "Rough terrain", "Water resource", "resource", "Foreign Land", "Foreign", "Friendly Land", "Friendly", "Enemy Land", "Enemy", "Featureless", Constants.freshWaterFilter, "non-fresh water", "Natural Wonder", "Impassable", "Land", "Water"