Added trigger conditional for constructing building

This commit is contained in:
Yair Morgenstern 2023-01-16 22:51:37 +02:00
parent 7c52e25a1d
commit 1c64844c1e
3 changed files with 8 additions and 1 deletions

View File

@ -563,7 +563,7 @@ object Battle {
for (unique in attackerCiv.getTriggeredUniques(UniqueType.TriggerUponConqueringCity,
StateForConditionals(attackerCiv, city, attacker.unit, attackedTile = city.getCenterTile() )
))
UniqueTriggerActivation.triggerCivwideUnique(unique, attackerCiv)
UniqueTriggerActivation.triggerCivwideUnique(unique, attackerCiv, city)
}
fun getMapCombatantOfTile(tile: TileInfo): ICombatant? {

View File

@ -16,6 +16,7 @@ import com.unciv.models.ruleset.Ruleset
import com.unciv.models.ruleset.unique.LocalUniqueCache
import com.unciv.models.ruleset.unique.StateForConditionals
import com.unciv.models.ruleset.unique.UniqueMap
import com.unciv.models.ruleset.unique.UniqueTriggerActivation
import com.unciv.models.ruleset.unique.UniqueType
import com.unciv.models.ruleset.unit.BaseUnit
import com.unciv.models.stats.Stat
@ -440,6 +441,11 @@ class CityConstructions : IsPartOfGameInfoSerialization {
NotificationCategory.General, NotificationIcon.Construction, buildingIcon)
}
}
if (construction is Building)
for (unique in cityInfo.civInfo.getTriggeredUniques(UniqueType.TriggerUponConstructingBuilding, StateForConditionals(cityInfo.civInfo, cityInfo)))
if (unique.conditionals.any {it.type == UniqueType.TriggerUponConstructingBuilding && construction.matchesFilter(it.params[0])})
UniqueTriggerActivation.triggerCivwideUnique(unique, cityInfo.civInfo, cityInfo)
}
fun addBuilding(buildingName: String) {

View File

@ -705,6 +705,7 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
TriggerUponDeclaringWar("upon declaring war", UniqueTarget.TriggerCondition),
TriggerUponEnteringGoldenAge("upon entering a Golden Age", UniqueTarget.TriggerCondition),
TriggerUponConqueringCity("upon conquering a city", UniqueTarget.TriggerCondition),
TriggerUponConstructingBuilding("upon constructing [buildingFilter]", UniqueTarget.TriggerCondition),
//endregion