mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 13:55:54 -04:00
chore: Simplified interception notifications
This commit is contained in:
parent
f503737e15
commit
9e089bd91d
@ -53,18 +53,14 @@ object AirInterception {
|
|||||||
.shuffled() // randomize Civ
|
.shuffled() // randomize Civ
|
||||||
.sortedByDescending { it.interceptChance() }) {
|
.sortedByDescending { it.interceptChance() }) {
|
||||||
// No chance of Interceptor to miss (unlike regular Interception). Always want to deal damage
|
// No chance of Interceptor to miss (unlike regular Interception). Always want to deal damage
|
||||||
val interceptingCiv = interceptor.civ
|
|
||||||
val interceptorName = interceptor.name
|
|
||||||
// pairs of LocationAction for Notification
|
// pairs of LocationAction for Notification
|
||||||
val locations = LocationAction(
|
val locations = LocationAction(
|
||||||
interceptor.currentTile.position,
|
interceptor.currentTile.position,
|
||||||
attacker.unit.currentTile.position
|
attacker.unit.currentTile.position
|
||||||
)
|
)
|
||||||
val locationsInterceptorUnknown =
|
|
||||||
LocationAction(attackedTile.position, attacker.unit.currentTile.position)
|
|
||||||
|
|
||||||
interceptor.attacksThisTurn++ // even if you miss, you took the shot
|
interceptor.attacksThisTurn++ // even if you miss, you took the shot
|
||||||
if (!interceptor.baseUnit.isAirUnit()) {
|
if (!interceptor.baseUnit.isAirUnit()) {
|
||||||
|
val interceptorName = interceptor.name
|
||||||
// Deal no damage (moddable in future?) and no XP
|
// Deal no damage (moddable in future?) and no XP
|
||||||
val attackerText =
|
val attackerText =
|
||||||
"Our [$attackerName] ([-0] HP) was attacked by an intercepting [$interceptorName] ([-0] HP)"
|
"Our [$attackerName] ([-0] HP) was attacked by an intercepting [$interceptorName] ([-0] HP)"
|
||||||
@ -74,7 +70,7 @@ object AirInterception {
|
|||||||
attackerText, locations, NotificationCategory.War,
|
attackerText, locations, NotificationCategory.War,
|
||||||
attackerName, NotificationIcon.War, interceptorName
|
attackerName, NotificationIcon.War, interceptorName
|
||||||
)
|
)
|
||||||
interceptingCiv.addNotification(
|
interceptor.civ.addNotification(
|
||||||
interceptorText, locations, NotificationCategory.War,
|
interceptorText, locations, NotificationCategory.War,
|
||||||
interceptorName, NotificationIcon.War, attackerName
|
interceptorName, NotificationIcon.War, attackerName
|
||||||
)
|
)
|
||||||
@ -89,14 +85,14 @@ object AirInterception {
|
|||||||
Battle.addXp(MapUnitCombatant(interceptor), 5, attacker)
|
Battle.addXp(MapUnitCombatant(interceptor), 5, attacker)
|
||||||
Battle.addXp(attacker, 5, MapUnitCombatant(interceptor))
|
Battle.addXp(attacker, 5, MapUnitCombatant(interceptor))
|
||||||
|
|
||||||
addInterceptionNotifications(
|
val locationsInterceptorUnknown =
|
||||||
|
LocationAction(attackedTile.position, attacker.unit.currentTile.position)
|
||||||
|
|
||||||
|
addAirSweepInterceptionNotifications(
|
||||||
attacker,
|
attacker,
|
||||||
interceptor,
|
interceptor,
|
||||||
attackerName,
|
|
||||||
damageDealt,
|
damageDealt,
|
||||||
interceptorName,
|
|
||||||
locationsInterceptorUnknown,
|
locationsInterceptorUnknown,
|
||||||
interceptingCiv,
|
|
||||||
locations
|
locations
|
||||||
)
|
)
|
||||||
attacker.unit.action = null
|
attacker.unit.action = null
|
||||||
@ -109,16 +105,17 @@ object AirInterception {
|
|||||||
attacker.unit.action = null
|
attacker.unit.action = null
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addInterceptionNotifications(
|
// TODO: Check overlap with addInterceptionNotifications, and unify what we can
|
||||||
|
private fun addAirSweepInterceptionNotifications(
|
||||||
attacker: MapUnitCombatant,
|
attacker: MapUnitCombatant,
|
||||||
interceptor: MapUnit,
|
interceptor: MapUnit,
|
||||||
attackerName: String,
|
|
||||||
damageDealt: Battle.DamageDealt,
|
damageDealt: Battle.DamageDealt,
|
||||||
interceptorName: String,
|
|
||||||
locationsInterceptorUnknown: Sequence<LocationAction>,
|
locationsInterceptorUnknown: Sequence<LocationAction>,
|
||||||
interceptingCiv: Civilization,
|
|
||||||
locations: Sequence<LocationAction>
|
locations: Sequence<LocationAction>
|
||||||
) {
|
) {
|
||||||
|
val attackerName = attacker.getName()
|
||||||
|
val interceptorName = interceptor.name
|
||||||
|
|
||||||
val attackerText =
|
val attackerText =
|
||||||
if (attacker.isDefeated()) {
|
if (attacker.isDefeated()) {
|
||||||
if (interceptor.getTile() in attacker.getCivInfo().viewableTiles)
|
if (interceptor.getTile() in attacker.getCivInfo().viewableTiles)
|
||||||
@ -137,11 +134,11 @@ object AirInterception {
|
|||||||
if (attacker.isDefeated())
|
if (attacker.isDefeated())
|
||||||
"Our [$interceptorName] ([-${damageDealt.attackerDealt}] HP) intercepted and destroyed an enemy [$attackerName] ([-${damageDealt.defenderDealt}] HP)"
|
"Our [$interceptorName] ([-${damageDealt.attackerDealt}] HP) intercepted and destroyed an enemy [$attackerName] ([-${damageDealt.defenderDealt}] HP)"
|
||||||
else if (MapUnitCombatant(interceptor).isDefeated()) {
|
else if (MapUnitCombatant(interceptor).isDefeated()) {
|
||||||
if (attacker.getTile() in interceptingCiv.viewableTiles) "Our [$interceptorName] ([-${damageDealt.attackerDealt}] HP) intercepted and was destroyed by an enemy [$attackerName] ([-${damageDealt.defenderDealt}] HP)"
|
if (attacker.getTile() in interceptor.civ.viewableTiles) "Our [$interceptorName] ([-${damageDealt.attackerDealt}] HP) intercepted and was destroyed by an enemy [$attackerName] ([-${damageDealt.defenderDealt}] HP)"
|
||||||
else "Our [$interceptorName] ([-${damageDealt.attackerDealt}] HP) intercepted and was destroyed by an unknown enemy"
|
else "Our [$interceptorName] ([-${damageDealt.attackerDealt}] HP) intercepted and was destroyed by an unknown enemy"
|
||||||
} else "Our [$interceptorName] ([-${damageDealt.attackerDealt}] HP) intercepted and attacked an enemy [$attackerName] ([-${damageDealt.defenderDealt}] HP)"
|
} else "Our [$interceptorName] ([-${damageDealt.attackerDealt}] HP) intercepted and attacked an enemy [$attackerName] ([-${damageDealt.defenderDealt}] HP)"
|
||||||
|
|
||||||
interceptingCiv.addNotification(
|
interceptor.civ.addNotification(
|
||||||
interceptorText, locations, NotificationCategory.War,
|
interceptorText, locations, NotificationCategory.War,
|
||||||
interceptorName, NotificationIcon.War, attackerName
|
interceptorName, NotificationIcon.War, attackerName
|
||||||
)
|
)
|
||||||
@ -189,10 +186,20 @@ object AirInterception {
|
|||||||
if (damage > 0)
|
if (damage > 0)
|
||||||
Battle.addXp(MapUnitCombatant(interceptor), 2, attacker)
|
Battle.addXp(MapUnitCombatant(interceptor), 2, attacker)
|
||||||
|
|
||||||
|
addInterceptionNotifications(attacker, interceptor, damage)
|
||||||
|
|
||||||
|
return Battle.DamageDealt(0, damage)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun addInterceptionNotifications(
|
||||||
|
attacker: MapUnitCombatant,
|
||||||
|
interceptor: MapUnit,
|
||||||
|
damage: Int
|
||||||
|
) {
|
||||||
val attackerName = attacker.getName()
|
val attackerName = attacker.getName()
|
||||||
val interceptorName = interceptor.name
|
val interceptorName = interceptor.name
|
||||||
val locations = LocationAction(interceptor.currentTile.position, attacker.unit.currentTile.position)
|
|
||||||
|
|
||||||
|
val locations = LocationAction(interceptor.currentTile.position, attacker.unit.currentTile.position)
|
||||||
val attackerText = if (!attacker.isDefeated())
|
val attackerText = if (!attacker.isDefeated())
|
||||||
"Our [$attackerName] ([-$damage] HP) was attacked by an intercepting [$interceptorName] ([-0] HP)"
|
"Our [$attackerName] ([-$damage] HP) was attacked by an intercepting [$interceptorName] ([-0] HP)"
|
||||||
else if (interceptor.getTile() in attacker.getCivInfo().viewableTiles)
|
else if (interceptor.getTile() in attacker.getCivInfo().viewableTiles)
|
||||||
@ -207,10 +214,10 @@ object AirInterception {
|
|||||||
val interceptorText = if (attacker.isDefeated())
|
val interceptorText = if (attacker.isDefeated())
|
||||||
"Our [$interceptorName] ([-0] HP) intercepted and destroyed an enemy [$attackerName] ([-$damage] HP)"
|
"Our [$interceptorName] ([-0] HP) intercepted and destroyed an enemy [$attackerName] ([-$damage] HP)"
|
||||||
else "Our [$interceptorName] ([-0] HP) intercepted and attacked an enemy [$attackerName] ([-$damage] HP)"
|
else "Our [$interceptorName] ([-0] HP) intercepted and attacked an enemy [$attackerName] ([-$damage] HP)"
|
||||||
interceptingCiv.addNotification(interceptorText, locations, NotificationCategory.War,
|
interceptor.civ.addNotification(
|
||||||
interceptorName, NotificationIcon.War, attackerName)
|
interceptorText, locations, NotificationCategory.War,
|
||||||
|
interceptorName, NotificationIcon.War, attackerName
|
||||||
return Battle.DamageDealt(0, damage)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -301,8 +301,6 @@ object Nuke {
|
|||||||
targetedCity.population.addPopulation(-populationLoss)
|
targetedCity.population.addPopulation(-populationLoss)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private fun City.getAggregateModifier(uniqueType: UniqueType): Float {
|
private fun City.getAggregateModifier(uniqueType: UniqueType): Float {
|
||||||
var modifier = 1f
|
var modifier = 1f
|
||||||
for (unique in getMatchingUniques(uniqueType)) {
|
for (unique in getMatchingUniques(uniqueType)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user