From cc8a0ab9eba0bb5fdf0c518f441a840a0d5f8122 Mon Sep 17 00:00:00 2001 From: SeventhM <127357473+SeventhM@users.noreply.github.com> Date: Wed, 24 Jan 2024 23:05:08 -0800 Subject: [PATCH] Fix build errors (#11000) * Fix build errors * [+30%]% * Apparently I need to specify cities or units * Screw it, add "vs [combatantFilter]" * Accidental listing twice * case --- android/assets/jsons/Civ V - Gods & Kings/Nations.json | 2 +- android/assets/jsons/Civ V - Vanilla/Nations.json | 2 +- core/src/com/unciv/logic/battle/BattleDamage.kt | 6 ------ .../src/com/unciv/models/ruleset/tile/TileImprovement.kt | 3 +-- core/src/com/unciv/models/ruleset/unique/Unique.kt | 2 +- .../unciv/models/ruleset/unique/UniqueParameterType.kt | 9 ++++++--- core/src/com/unciv/models/ruleset/unique/UniqueType.kt | 3 ++- 7 files changed, 12 insertions(+), 15 deletions(-) diff --git a/android/assets/jsons/Civ V - Gods & Kings/Nations.json b/android/assets/jsons/Civ V - Gods & Kings/Nations.json index da8cb9d49e..2ed5eb5cb8 100644 --- a/android/assets/jsons/Civ V - Gods & Kings/Nations.json +++ b/android/assets/jsons/Civ V - Gods & Kings/Nations.json @@ -653,7 +653,7 @@ "innerColor": [255,120,0], "favoredReligion": "Tengriism", "uniqueName": "Mongol Terror", - "uniques": ["+30% Strength when fighting City-State units and cities", "[+1] Movement "], + "uniques": ["[+30]% Strength ", "[+1] Movement "], "cities": ["Karakorum","Beshbalik","Turfan","Hsia","Old Sarai","New Sarai","Tabriz","Tiflis","Otrar","Sanchu","Kazan", "Almarikh","Ulaanbaatar","Hovd","Darhan","Dalandzadgad","Mandalgovi","Choybalsan","Erdenet","Tsetserieg", "Baruun-Urt","Ereen","Batshireet","Choyr","Ulaangom","Tosontsengel","Altay","Uliastay","Bayanhongor", diff --git a/android/assets/jsons/Civ V - Vanilla/Nations.json b/android/assets/jsons/Civ V - Vanilla/Nations.json index 898f2390d4..0d51ede51a 100644 --- a/android/assets/jsons/Civ V - Vanilla/Nations.json +++ b/android/assets/jsons/Civ V - Vanilla/Nations.json @@ -607,7 +607,7 @@ "outerColor": [81,0,9], "innerColor": [255,120,0], "uniqueName": "Mongol Terror", - "uniques": ["+30% Strength when fighting City-State units and cities", "[+1] Movement "], + "uniques": ["[+30]% Strength ", "[+1] Movement "], "cities": ["Karakorum","Beshbalik","Turfan","Hsia","Old Sarai","New Sarai","Tabriz","Tiflis","Otrar","Sanchu","Kazan", "Almarikh","Ulaanbaatar","Hovd","Darhan","Dalandzadgad","Mandalgovi","Choybalsan","Erdenet","Tsetserieg", "Baruun-Urt","Ereen","Batshireet","Choyr","Ulaangom","Tosontsengel","Altay","Uliastay","Bayanhongor", diff --git a/core/src/com/unciv/logic/battle/BattleDamage.kt b/core/src/com/unciv/logic/battle/BattleDamage.kt index 7e36530da1..839366925c 100644 --- a/core/src/com/unciv/logic/battle/BattleDamage.kt +++ b/core/src/com/unciv/logic/battle/BattleDamage.kt @@ -109,12 +109,6 @@ object BattleDamage { if (strengthMalus != null) { modifiers.add("Adjacent enemy units", strengthMalus.params[0].toInt()) } - - // e.g., Mongolia - https://civilization.fandom.com/wiki/Mongolian_(Civ5) - if (enemy.getCivInfo().isCityState() - && civInfo.hasUnique(UniqueType.StrengthBonusVsCityStates) - ) - modifiers["vs [City-States]"] = 30 } private fun addResourceLackingMalus(combatant: MapUnitCombatant, modifiers: Counter) { diff --git a/core/src/com/unciv/models/ruleset/tile/TileImprovement.kt b/core/src/com/unciv/models/ruleset/tile/TileImprovement.kt index 2302851ddc..7288918a7d 100644 --- a/core/src/com/unciv/models/ruleset/tile/TileImprovement.kt +++ b/core/src/com/unciv/models/ruleset/tile/TileImprovement.kt @@ -34,8 +34,7 @@ class TileImprovement : RulesetStatsObject() { fun getTurnsToBuild(civInfo: Civilization, unit: MapUnit): Int { val state = StateForConditionals(civInfo, unit = unit) - val buildSpeedUniques = unit.getMatchingUniques(UniqueType.TileImprovementTime, state, checkCivInfoUniques = true) + - unit.getMatchingUniques(UniqueType.SpecificImprovementTime, state, checkCivInfoUniques = true) + val buildSpeedUniques = unit.getMatchingUniques(UniqueType.SpecificImprovementTime, state, checkCivInfoUniques = true) .filter { matchesFilter(it.params[1]) } return buildSpeedUniques .fold(turnsToBuild.toFloat() * civInfo.gameInfo.speed.improvementBuildLengthModifier) { calculatedTurnsToBuild, unique -> diff --git a/core/src/com/unciv/models/ruleset/unique/Unique.kt b/core/src/com/unciv/models/ruleset/unique/Unique.kt index d6ac81209d..e0dfad21e7 100644 --- a/core/src/com/unciv/models/ruleset/unique/Unique.kt +++ b/core/src/com/unciv/models/ruleset/unique/Unique.kt @@ -300,7 +300,7 @@ class Unique(val text: String, val sourceObjectType: UniqueTarget? = null, val s checkOnCity { getCenterTile().militaryUnit?.canGarrison() == true } UniqueType.ConditionalVsCity -> state.theirCombatant?.matchesFilter("City") == true - UniqueType.ConditionalVsUnits -> state.theirCombatant?.matchesFilter(condition.params[0]) == true + UniqueType.ConditionalVsUnits, UniqueType.ConditionalVsCombatant -> 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 9894baf39f..02588fc827 100644 --- a/core/src/com/unciv/models/ruleset/unique/UniqueParameterType.kt +++ b/core/src/com/unciv/models/ruleset/unique/UniqueParameterType.kt @@ -83,9 +83,12 @@ enum class UniqueParameterType( /** 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? { - if (parameterText == "City") return null // City also recognizes "All" but that's covered by BaseUnitFilter too - return MapUnitFilter.getErrorSeverity(parameterText, ruleset) + UniqueType.UniqueParameterErrorSeverity? = getErrorSeverityForFilter(parameterText, ruleset) + + override fun isKnownValue(parameterText: String, ruleset: Ruleset): Boolean { + if (parameterText == "City") return true // MapUnitFilter covers CivFilter + if (MapUnitFilter.isKnownValue(parameterText, ruleset)) return true + return false } }, diff --git a/core/src/com/unciv/models/ruleset/unique/UniqueType.kt b/core/src/com/unciv/models/ruleset/unique/UniqueType.kt index d1908cc766..224e2c5729 100644 --- a/core/src/com/unciv/models/ruleset/unique/UniqueType.kt +++ b/core/src/com/unciv/models/ruleset/unique/UniqueType.kt @@ -344,7 +344,7 @@ enum class UniqueType( Strength("[relativeAmount]% Strength", UniqueTarget.Unit, UniqueTarget.Global), StrengthNearCapital("[relativeAmount]% Strength decreasing with distance from the capital", UniqueTarget.Unit, UniqueTarget.Global), FlankAttackBonus("[relativeAmount]% to Flank Attack bonuses", UniqueTarget.Unit, UniqueTarget.Global), - @Deprecated("as of 4.9.0",ReplaceWith("[+30%]% Strength "), DeprecationLevel.ERROR) + @Deprecated("as of 4.9.0",ReplaceWith("[+30]% Strength "), DeprecationLevel.ERROR) StrengthBonusVsCityStates("+30% Strength when fighting City-State units and cities", UniqueTarget.Global), StrengthForAdjacentEnemies("[relativeAmount]% Strength for enemy [combatantFilter] units in adjacent [tileFilter] tiles", UniqueTarget.Unit), StrengthWhenStacked("[relativeAmount]% Strength when stacked with [mapUnitFilter]", UniqueTarget.Unit), // candidate for conditional! @@ -664,6 +664,7 @@ enum class UniqueType( ConditionalUnitWithoutPromotion("for units without [promotion]", UniqueTarget.Conditional), ConditionalVsCity("vs cities", UniqueTarget.Conditional), ConditionalVsUnits("vs [mapUnitFilter] units", UniqueTarget.Conditional), + ConditionalVsCombatant("vs [combatantFilter]", UniqueTarget.Conditional), ConditionalVsLargerCiv("when fighting units from a Civilization with more Cities than you", UniqueTarget.Conditional), ConditionalAttacking("when attacking", UniqueTarget.Conditional), ConditionalDefending("when defending", UniqueTarget.Conditional),