mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-29 23:10:39 -04:00
doCitadelDamage minor optimization (#5565)
This commit is contained in:
parent
693cf97849
commit
eaa765a619
@ -1013,20 +1013,19 @@ class MapUnit {
|
|||||||
|
|
||||||
private fun doCitadelDamage() {
|
private fun doCitadelDamage() {
|
||||||
// Check for Citadel damage - note: 'Damage does not stack with other Citadels'
|
// Check for Citadel damage - note: 'Damage does not stack with other Citadels'
|
||||||
val citadelTile = currentTile.neighbors
|
val (citadelTile, damage) = currentTile.neighbors
|
||||||
.filter {
|
.filter {
|
||||||
it.getOwner() != null
|
it.getOwner() != null
|
||||||
&& it.improvement != null
|
&& it.improvement != null
|
||||||
&& civInfo.isAtWarWith(it.getOwner()!!)
|
&& civInfo.isAtWarWith(it.getOwner()!!)
|
||||||
&& it.getTileImprovement()!!.hasUnique(UniqueType.DamagesAdjacentEnemyUnits)
|
}.map { tile ->
|
||||||
}.maxByOrNull { tile ->
|
tile to tile.getTileImprovement()!!
|
||||||
tile.getTileImprovement()!!
|
|
||||||
.getMatchingUniques(UniqueType.DamagesAdjacentEnemyUnits)
|
.getMatchingUniques(UniqueType.DamagesAdjacentEnemyUnits)
|
||||||
.sumOf { it.params[0].toInt() }
|
.sumOf { it.params[0].toInt() }
|
||||||
}
|
}.maxByOrNull { it.second }
|
||||||
|
?: return
|
||||||
if (citadelTile != null) {
|
if (damage == 0) return
|
||||||
health -= citadelTile.getTileImprovement()!!.getMatchingUniques(UniqueType.DamagesAdjacentEnemyUnits).sumOf { it.params[0].toInt() }
|
health -= damage
|
||||||
val locations = LocationAction(listOf(citadelTile.position, currentTile.position))
|
val locations = LocationAction(listOf(citadelTile.position, currentTile.position))
|
||||||
if (health <= 0) {
|
if (health <= 0) {
|
||||||
civInfo.addNotification(
|
civInfo.addNotification(
|
||||||
@ -1046,7 +1045,6 @@ class MapUnit {
|
|||||||
NotificationIcon.Citadel, NotificationIcon.War, name
|
NotificationIcon.Citadel, NotificationIcon.War, name
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fun matchesFilter(filter: String): Boolean {
|
fun matchesFilter(filter: String): Boolean {
|
||||||
if (filter.contains('{')) // multiple types at once - AND logic. Looks like:"{Military} {Land}"
|
if (filter.contains('{')) // multiple types at once - AND logic. Looks like:"{Military} {Land}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user