diff --git a/core/src/com/unciv/models/ruleset/unique/UniqueType.kt b/core/src/com/unciv/models/ruleset/unique/UniqueType.kt index 7bd9861bf3..1a8a307359 100644 --- a/core/src/com/unciv/models/ruleset/unique/UniqueType.kt +++ b/core/src/com/unciv/models/ruleset/unique/UniqueType.kt @@ -516,6 +516,10 @@ enum class UniqueType( /** @see CostsResources */ UnitActionStockpileCost("costs [amount] [stockpiledResource]", UniqueTarget.UnitActionModifier, docDescription = "A positive Integer value will be subtracted from your stock. Do not confuse with \"Costs [amount] [stockpiledResource]\" (uppercase 'C') for Improvements, Buildings, and Units."), + UnitActionRemovingPromotion("removing the [promotion] promotion/status", UniqueTarget.UnitActionModifier, + docDescription = "Removes the promotion/status from the unit -" + + " this is not a cost, units will be able to activate the action even without the promotion/status. " + + "To limit, use conditional"), UnitActionOnce("once", UniqueTarget.UnitActionModifier), UnitActionLimitedTimes("[amount] times", UniqueTarget.UnitActionModifier), UnitActionExtraLimitedTimes("[amount] additional time(s)", UniqueTarget.UnitActionModifier), diff --git a/core/src/com/unciv/ui/screens/worldscreen/unit/actions/UnitActionModifiers.kt b/core/src/com/unciv/ui/screens/worldscreen/unit/actions/UnitActionModifiers.kt index 14f00b8e28..917a03a53c 100644 --- a/core/src/com/unciv/ui/screens/worldscreen/unit/actions/UnitActionModifiers.kt +++ b/core/src/com/unciv/ui/screens/worldscreen/unit/actions/UnitActionModifiers.kt @@ -7,6 +7,7 @@ import com.unciv.models.stats.Stat import com.unciv.models.stats.Stats import com.unciv.models.translations.removeConditionals import com.unciv.models.translations.tr +import com.unciv.ui.components.fonts.FontRulesetIcons import com.unciv.ui.components.fonts.Fonts import kotlin.math.ceil @@ -116,6 +117,16 @@ object UnitActionModifiers { if(unit.civ.getCivResourcesByName()[resourceName] != null) unit.civ.resourceStockpiles.add(resourceName, -amount) } + UniqueType.UnitActionRemovingPromotion -> { + val promotionName = conditional.params[0] + // if has a status, remove that instead - the promotion is 'safe' + val unitStatus = unit.statuses.firstOrNull { it.name == promotionName } + if (unitStatus != null) { + unit.statuses.remove(unitStatus) + } else { // check for real promotion + unit.promotions.removePromotion(promotionName) + } + } else -> continue } } @@ -176,6 +187,12 @@ object UnitActionModifiers { actionUnique, defaultAllMovement ).tr() + Fonts.movement + + for (removes in actionUnique.getModifiers(UniqueType.UnitActionRemovingPromotion)) { + val promotionName = removes.params[0] + val promotionChar = FontRulesetIcons.rulesetObjectNameToChar[promotionName] + if (promotionChar != null) effects += "-$promotionChar" + } return if (effects.isEmpty()) "" else "(${effects.joinToString { it.tr() }})"