diff --git a/core/src/com/unciv/logic/battle/BattleDamage.kt b/core/src/com/unciv/logic/battle/BattleDamage.kt index 711d9ddecd..932b1a47a0 100644 --- a/core/src/com/unciv/logic/battle/BattleDamage.kt +++ b/core/src/com/unciv/logic/battle/BattleDamage.kt @@ -164,7 +164,7 @@ object BattleDamage { val modifiers = Counter() if (attacker is MapUnitCombatant) { - for (unique in attacker.unit.getUniques().filter{it.isOfType(UniqueType.StrengthWhenAirsweep)}) { + for (unique in attacker.unit.getMatchingUniques(UniqueType.StrengthWhenAirsweep)) { modifiers.add(getModifierStringFromUnique(unique), unique.params[0].toInt()) } } diff --git a/core/src/com/unciv/logic/map/MapUnit.kt b/core/src/com/unciv/logic/map/MapUnit.kt index 21b11db542..f7cee8fe3d 100644 --- a/core/src/com/unciv/logic/map/MapUnit.kt +++ b/core/src/com/unciv/logic/map/MapUnit.kt @@ -258,16 +258,10 @@ class MapUnit : IsPartOfGameInfoSerialization { fun getTile(): TileInfo = currentTile - - // This SHOULD NOT be a HashSet, because if it is, then e.g. promotions with the same uniques - // (e.g. barrage I, barrage II) will not get counted twice! - @Transient - private var tempUniques = ArrayList() - @Transient private var tempUniquesMap = UniqueMap() - fun getUniques(): ArrayList = tempUniques + fun getUniques(): Sequence = tempUniquesMap.values.asSequence().flatten() fun getMatchingUniques( uniqueType: UniqueType, @@ -299,7 +293,6 @@ class MapUnit : IsPartOfGameInfoSerialization { uniques.addAll(promotion.uniqueObjects) } - tempUniques = uniques tempUniquesMap = UniqueMap().apply { addUniques(uniques) } diff --git a/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt b/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt index c578dee6e4..a22191beb1 100644 --- a/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt +++ b/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt @@ -558,6 +558,8 @@ class UnitMovementAlgorithms(val unit: MapUnit) { if (needToFindNewRoute && unit.currentTile != origin) { moveToTile(destination, considerZoneOfControl) } + + unit.updateUniques(unit.currentTile.ruleset) } /** diff --git a/core/src/com/unciv/models/ruleset/unique/UniqueTriggerActivation.kt b/core/src/com/unciv/models/ruleset/unique/UniqueTriggerActivation.kt index a58bee59ad..f27f4dbb3c 100644 --- a/core/src/com/unciv/models/ruleset/unique/UniqueTriggerActivation.kt +++ b/core/src/com/unciv/models/ruleset/unique/UniqueTriggerActivation.kt @@ -207,7 +207,6 @@ object UniqueTriggerActivation { } OneTimeGainPopulation -> { - val citiesWithPopulationChanged: MutableList = mutableListOf() val applicableCities = when (unique.params[1]) { "in this city" -> sequenceOf(cityInfo!!) "in other cities" -> civInfo.cities.asSequence().filter { it != cityInfo } @@ -222,7 +221,7 @@ object UniqueTriggerActivation { LocationAction(applicableCities.map { it.location }), NotificationIcon.Population ) - return citiesWithPopulationChanged.isNotEmpty() + return applicableCities.any() } OneTimeGainPopulationRandomCity -> { if (civInfo.cities.isEmpty()) return false @@ -288,8 +287,8 @@ object UniqueTriggerActivation { if (notification != null) { civInfo.addNotification( notification, - NotificationIcon.War - ) // I'm open for better icons + NotificationIcon.Construction + ) } return true }