Add the remove unit promotion unique (#10759)

* Added the remove unit promotion unique

* Moved two lines of code inside if
This commit is contained in:
PLynx 2023-12-17 21:03:52 +01:00 committed by GitHub
parent 3fd9bc2df3
commit cde26d325e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 0 deletions

View File

@ -91,6 +91,17 @@ class UnitPromotions : IsPartOfGameInfoSerialization {
unit.updateVisibleTiles() // some promotions/uniques give the unit bonus sight
}
fun removePromotion(promotionName: String) {
val ruleset = unit.civ.gameInfo.ruleset
val promotion = ruleset.unitPromotions[promotionName]!!
if (getPromotions().contains(promotion)) {
promotions.remove(promotionName)
unit.updateUniques()
unit.updateVisibleTiles()
}
}
private fun doDirectPromotionEffects(promotion: Promotion) {
for (unique in promotion.uniqueObjects)
if (unique.conditionalsApply(StateForConditionals(civInfo = unit.civ, unit = unit))

View File

@ -809,6 +809,14 @@ object UniqueTriggerActivation {
unit.civ.addNotification(notification, unit.getTile().position, NotificationCategory.Units, unit.name)
return true
}
UniqueType.OneTimeUnitRemovePromotion -> {
val promotion = unit.civ.gameInfo.ruleset.unitPromotions.keys
.firstOrNull { it == unique.params[0]}
?: return false
unit.promotions.removePromotion(promotion)
return true
}
else -> return triggerCivwideUnique(unique, civInfo = unit.civ, tile=unit.currentTile, triggerNotificationText = triggerNotificationText)
}
}

View File

@ -734,6 +734,7 @@ enum class UniqueType(
OneTimeUnitUpgrade("This Unit upgrades for free", UniqueTarget.UnitTriggerable), // Not used in Vanilla
OneTimeUnitSpecialUpgrade("This Unit upgrades for free including special upgrades", UniqueTarget.UnitTriggerable),
OneTimeUnitGainPromotion("This Unit gains the [promotion] promotion", UniqueTarget.UnitTriggerable), // Not used in Vanilla
OneTimeUnitRemovePromotion("This Unit loses the [promotion] promotion", UniqueTarget.UnitTriggerable),
SkipPromotion("Doing so will consume this opportunity to choose a Promotion", UniqueTarget.Promotion),
FreePromotion("This Promotion is free", UniqueTarget.Promotion),

View File

@ -185,6 +185,11 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl
Applicable to: UnitTriggerable
??? example "This Unit loses the [promotion] promotion"
Example: "This Unit loses the [Shock I] promotion"
Applicable to: UnitTriggerable
## Global uniques
!!! note ""