mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-24 18:06:04 +07:00
Update unit uniques when entering moving to new tiles
This commit is contained in:
parent
aa49e47ca0
commit
154c083d3f
@ -164,7 +164,7 @@ object BattleDamage {
|
||||
val modifiers = Counter<String>()
|
||||
|
||||
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())
|
||||
}
|
||||
}
|
||||
|
@ -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<Unique>()
|
||||
|
||||
@Transient
|
||||
private var tempUniquesMap = UniqueMap()
|
||||
|
||||
fun getUniques(): ArrayList<Unique> = tempUniques
|
||||
fun getUniques(): Sequence<Unique> = 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)
|
||||
}
|
||||
|
@ -558,6 +558,8 @@ class UnitMovementAlgorithms(val unit: MapUnit) {
|
||||
if (needToFindNewRoute && unit.currentTile != origin) {
|
||||
moveToTile(destination, considerZoneOfControl)
|
||||
}
|
||||
|
||||
unit.updateUniques(unit.currentTile.ruleset)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -207,7 +207,6 @@ object UniqueTriggerActivation {
|
||||
}
|
||||
|
||||
OneTimeGainPopulation -> {
|
||||
val citiesWithPopulationChanged: MutableList<Vector2> = 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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user