mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-24 03:53:12 -04:00
chore: Added unit.removeStatus helper function
This commit is contained in:
parent
ef53f35e0f
commit
7f45ccd7b7
@ -1041,6 +1041,13 @@ class MapUnit : IsPartOfGameInfoSerialization {
|
|||||||
statuses.add(status)
|
statuses.add(status)
|
||||||
updateUniques()
|
updateUniques()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun removeStatus(name:String){
|
||||||
|
val wereRemoved = statuses.removeAll { it.name == name }
|
||||||
|
if (wereRemoved){
|
||||||
|
updateUniques()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
fun isNuclearWeapon() = hasUnique(UniqueType.NuclearWeapon)
|
fun isNuclearWeapon() = hasUnique(UniqueType.NuclearWeapon)
|
||||||
|
@ -169,7 +169,7 @@ class UnitTurnManager(val unit: MapUnit) {
|
|||||||
|
|
||||||
for (status in unit.statuses.toList()){
|
for (status in unit.statuses.toList()){
|
||||||
status.turnsLeft--
|
status.turnsLeft--
|
||||||
if (status.turnsLeft <= 0) unit.statuses.remove(status)
|
if (status.turnsLeft <= 0) unit.removeStatus(status.name)
|
||||||
}
|
}
|
||||||
unit.updateUniques()
|
unit.updateUniques()
|
||||||
}
|
}
|
||||||
|
@ -985,9 +985,9 @@ object UniqueTriggerActivation {
|
|||||||
}
|
}
|
||||||
UniqueType.OneTimeUnitLoseStatus -> {
|
UniqueType.OneTimeUnitLoseStatus -> {
|
||||||
if (unit == null) return null
|
if (unit == null) return null
|
||||||
val unitStatus = unit.statuses.firstOrNull { it.name == unique.params[1] } ?: return null
|
if (unit.statuses.none { it.name == unique.params[1] }) return null
|
||||||
return {
|
return {
|
||||||
unit.statuses.remove(unitStatus)
|
unit.removeStatus(unique.params[1])
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,9 +120,9 @@ object UnitActionModifiers {
|
|||||||
UniqueType.UnitActionRemovingPromotion -> {
|
UniqueType.UnitActionRemovingPromotion -> {
|
||||||
val promotionName = conditional.params[0]
|
val promotionName = conditional.params[0]
|
||||||
// if has a status, remove that instead - the promotion is 'safe'
|
// if has a status, remove that instead - the promotion is 'safe'
|
||||||
val unitStatus = unit.statuses.firstOrNull { it.name == promotionName }
|
val unitStatus =
|
||||||
if (unitStatus != null) {
|
if (unit.statuses.any { it.name == promotionName }) {
|
||||||
unit.statuses.remove(unitStatus)
|
unit.removeStatus(promotionName)
|
||||||
} else { // check for real promotion
|
} else { // check for real promotion
|
||||||
unit.promotions.removePromotion(promotionName)
|
unit.promotions.removePromotion(promotionName)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user