mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-04 07:17:50 +07:00
Conditional triggers now work with timed uniques
This commit is contained in:
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -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`.
|
||||
|
Reference in New Issue
Block a user