mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-10 23:37:31 +07:00
Resolved #4629 - atomic bomb interception works as intended
This commit is contained in:
parent
b62c56d175
commit
775f42aa0d
@ -44,7 +44,7 @@ object Battle {
|
||||
val attackedTile = defender.getTile()
|
||||
|
||||
if (attacker is MapUnitCombatant && attacker.getUnitType().isAirUnit()) {
|
||||
tryInterceptAirAttack(attacker, defender)
|
||||
tryInterceptAirAttack(attacker, attackedTile, defender.getCivInfo())
|
||||
if (attacker.isDefeated()) return
|
||||
}
|
||||
|
||||
@ -505,10 +505,10 @@ object Battle {
|
||||
}
|
||||
|
||||
// Declare war on all potentially hit units. They'll try to intercept the nuke before it drops
|
||||
for (hitUnit in hitTiles.map { it.getUnits() }.flatten()) {
|
||||
tryDeclareWar(hitUnit.civInfo)
|
||||
for(civWhoseUnitWasAttacked in hitTiles.flatMap { it.getUnits() }.map { it.civInfo }.distinct()) {
|
||||
tryDeclareWar(civWhoseUnitWasAttacked)
|
||||
if (attacker.getUnitType().isAirUnit() && !attacker.isDefeated()) {
|
||||
tryInterceptAirAttack(attacker, MapUnitCombatant(hitUnit))
|
||||
tryInterceptAirAttack(attacker, targetTile, civWhoseUnitWasAttacked)
|
||||
}
|
||||
}
|
||||
if (attacker.isDefeated()) return
|
||||
@ -668,10 +668,9 @@ object Battle {
|
||||
}
|
||||
}
|
||||
|
||||
private fun tryInterceptAirAttack(attacker: MapUnitCombatant, defender: ICombatant) {
|
||||
private fun tryInterceptAirAttack(attacker: MapUnitCombatant, attackedTile:TileInfo, interceptingCiv:CivilizationInfo) {
|
||||
if (attacker.unit.hasUnique("Cannot be intercepted")) return
|
||||
val attackedTile = defender.getTile()
|
||||
for (interceptor in defender.getCivInfo().getCivUnits().filter { it.canIntercept(attackedTile) }) {
|
||||
for (interceptor in interceptingCiv.getCivUnits().filter { it.canIntercept(attackedTile) }) {
|
||||
if (Random().nextFloat() > 100f / interceptor.interceptChance()) continue
|
||||
|
||||
var damage = BattleDamage.calculateDamageToDefender(MapUnitCombatant(interceptor), null, attacker)
|
||||
@ -692,14 +691,14 @@ object Battle {
|
||||
attacker.getCivInfo()
|
||||
.addNotification("Our [$attackerName] was destroyed by an intercepting [$interceptorName]",
|
||||
interceptor.currentTile.position, attackerName, NotificationIcon.War, interceptorName)
|
||||
defender.getCivInfo()
|
||||
interceptingCiv
|
||||
.addNotification("Our [$interceptorName] intercepted and destroyed an enemy [$attackerName]",
|
||||
locations, interceptorName, NotificationIcon.War, attackerName)
|
||||
} else {
|
||||
attacker.getCivInfo()
|
||||
.addNotification("Our [$attackerName] was attacked by an intercepting [$interceptorName]",
|
||||
interceptor.currentTile.position, attackerName, NotificationIcon.War, interceptorName)
|
||||
defender.getCivInfo()
|
||||
interceptingCiv
|
||||
.addNotification("Our [$interceptorName] intercepted and attacked an enemy [$attackerName]",
|
||||
locations, interceptorName, NotificationIcon.War, attackerName)
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ class CityInfo {
|
||||
if (startingEra in ruleset.eras) {
|
||||
for (building in ruleset.eras[startingEra]!!.settlerBuildings) {
|
||||
if (ruleset.buildings[building]!!.isBuildable(cityConstructions)) {
|
||||
cityConstructions.addBuilding(civInfo.getEquivalentBuilding(building).name)
|
||||
try cityConstructions.addBuilding(civInfo.getEquivalentBuilding(building).name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user