From a47864ecac5cee42d655bf8219f917241a66f318 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Sun, 26 Feb 2023 21:52:18 +0200 Subject: [PATCH] Special type for unit triggerables --- .../com/unciv/models/ruleset/unique/UniqueType.kt | 12 +++++++----- .../src/com/unciv/app/desktop/UniqueDocsWriter.kt | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/core/src/com/unciv/models/ruleset/unique/UniqueType.kt b/core/src/com/unciv/models/ruleset/unique/UniqueType.kt index 7cabea0ac5..8cb7252af8 100644 --- a/core/src/com/unciv/models/ruleset/unique/UniqueType.kt +++ b/core/src/com/unciv/models/ruleset/unique/UniqueType.kt @@ -11,6 +11,8 @@ enum class UniqueTarget(val inheritsFrom: UniqueTarget? = null) { /** Only includes uniques that have immediate effects, caused by UniqueTriggerActivation */ Triggerable, + UnitTriggerable(Triggerable), + /** Buildings, units, nations, policies, religions, techs etc. * Basically anything caught by CivInfo.getMatchingUniques. */ Global(Triggerable), @@ -34,7 +36,7 @@ enum class UniqueTarget(val inheritsFrom: UniqueTarget? = null) { // they're all just Unit uniques in different places. // So there should be no uniqueType that has a Promotion or UnitType target. // Except meta-level uniques, such as 'incompatible with [promotion]', of course - Unit, + Unit(UnitTriggerable), UnitType(Unit), Promotion(Unit), @@ -689,11 +691,11 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags: OneTimeGlobalAlert("Triggers the following global alert: [comment]", UniqueTarget.Policy), // used in Policy OneTimeGlobalSpiesWhenEnteringEra("Every major Civilization gains a spy once a civilization enters this era", UniqueTarget.Era), - OneTimeUnitHeal("Heal this unit by [amount] HP", UniqueTarget.Unit), - OneTimeUnitGainXP("This Unit gains [amount] XP", UniqueTarget.Ruins, UniqueTarget.Unit), - OneTimeUnitUpgrade("This Unit upgrades for free", UniqueTarget.Global, UniqueTarget.Unit), // Not used in Vanilla + OneTimeUnitHeal("Heal this unit by [amount] HP", UniqueTarget.UnitTriggerable), + OneTimeUnitGainXP("This Unit gains [amount] XP", UniqueTarget.Ruins, UniqueTarget.UnitTriggerable), + OneTimeUnitUpgrade("This Unit upgrades for free", UniqueTarget.Global, UniqueTarget.UnitTriggerable), // Not used in Vanilla OneTimeUnitSpecialUpgrade("This Unit upgrades for free including special upgrades", UniqueTarget.Ruins), - OneTimeUnitGainPromotion("This Unit gains the [promotion] promotion", UniqueTarget.Triggerable, UniqueTarget.Unit), // Not used in Vanilla + OneTimeUnitGainPromotion("This Unit gains the [promotion] promotion", UniqueTarget.UnitTriggerable), // Not used in Vanilla SkipPromotion("Doing so will consume this opportunity to choose a Promotion", UniqueTarget.Promotion), UnitsGainPromotion("[mapUnitFilter] units gain the [promotion] promotion", UniqueTarget.Triggerable), // Not used in Vanilla diff --git a/desktop/src/com/unciv/app/desktop/UniqueDocsWriter.kt b/desktop/src/com/unciv/app/desktop/UniqueDocsWriter.kt index a6b25cc879..11715080dc 100644 --- a/desktop/src/com/unciv/app/desktop/UniqueDocsWriter.kt +++ b/desktop/src/com/unciv/app/desktop/UniqueDocsWriter.kt @@ -39,7 +39,7 @@ class UniqueDocsWriter { // The UniqueType are shown in enum order within their group, and groups are ordered // by their UniqueTarget.ordinal as well - source code order. val targetTypesToUniques: Map> = - if(showUniqueOnOneTarget) + if (showUniqueOnOneTarget) UniqueType.values().asSequence() .groupBy { it.targetTypes.minOrNull()!! } .toSortedMap()