Conditional triggers now work with timed uniques

This commit is contained in:
Yair Morgenstern
2023-01-16 22:03:17 +02:00
parent 6d8ea49b23
commit f89c2330aa
2 changed files with 10 additions and 4 deletions

View File

@ -305,7 +305,8 @@ class UniqueMap: HashMap<String, ArrayList<Unique>>() {
/** Adds one [unique] unless it has a ConditionalTimedUnique conditional */
fun addUnique(unique: Unique) {
if (unique.conditionals.any { it.type == UniqueType.ConditionalTimedUnique }) return
if (unique.conditionals.any { it.type == UniqueType.ConditionalTimedUnique }
&& unique.conditionals.none { it.type!!.targetTypes.contains(UniqueTarget.TriggerCondition)}) return
if (!containsKey(unique.placeholderText)) this[unique.placeholderText] = ArrayList()
this[unique.placeholderText]!!.add(unique)
}
@ -326,9 +327,11 @@ class UniqueMap: HashMap<String, ArrayList<Unique>>() {
fun getAllUniques() = this.asSequence().flatMap { it.value.asSequence() }
fun getTriggeredUniques(trigger: UniqueType, stateForConditionals: StateForConditionals) =
getAllUniques().filter { it.conditionals.any { it.type == trigger } }
.filter { it.conditionalsApply(stateForConditionals) }
fun getTriggeredUniques(trigger: UniqueType, stateForConditionals: StateForConditionals): Sequence<Unique> {
val result = getAllUniques().filter { it.conditionals.any { it.type == trigger } }
.filter { it.conditionalsApply(stateForConditionals) }
return result
}
}

View File

@ -1883,6 +1883,9 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl
??? example "upon declaring war"
Applicable to: TriggerCondition
??? example "upon entering a Golden Age"
Applicable to: TriggerCondition
*[action]: An action that a unit can perform. Currently, there are only two actions part of this: 'Spread Religion' and 'Remove Foreign religions from your own cities'
*[amount]: This indicates a whole number, possibly with a + or - sign, such as `2`, `+13`, or `-3`.