mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-07 14:02:48 +07:00
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:
parent
3fd9bc2df3
commit
cde26d325e
@ -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))
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -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),
|
||||
|
||||
|
@ -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 ""
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user