mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-10 07:16:54 +07:00
Fixed bug with aircraft rejection reasons
This commit is contained in:
parent
18be173ab8
commit
34664e6071
@ -414,22 +414,19 @@ object SpecificUnitAutomation {
|
||||
|
||||
private fun tryMoveToCitiesToAerialAttackFrom(pathsToCities: HashMap<TileInfo, ArrayList<TileInfo>>, airUnit: MapUnit) {
|
||||
val citiesThatCanAttackFrom = pathsToCities.keys
|
||||
.filter {
|
||||
destinationCity -> destinationCity != airUnit.currentTile
|
||||
&& destinationCity.getTilesInDistance(airUnit.getRange())
|
||||
.any { BattleHelper.containsAttackableEnemy(it, MapUnitCombatant(airUnit)) }
|
||||
}
|
||||
.filter { destinationCity ->
|
||||
destinationCity != airUnit.currentTile
|
||||
&& destinationCity.getTilesInDistance(airUnit.getRange())
|
||||
.any { BattleHelper.containsAttackableEnemy(it, MapUnitCombatant(airUnit)) }
|
||||
}
|
||||
if (citiesThatCanAttackFrom.isEmpty()) return
|
||||
|
||||
//todo: this logic looks similar to some parts of automateFighter, maybe pull out common code
|
||||
//todo: maybe group by size and choose highest priority within the same size turns
|
||||
val closestCityThatCanAttackFrom = citiesThatCanAttackFrom.minByOrNull { pathsToCities[it]!!.size }!!
|
||||
val closestCityThatCanAttackFrom =
|
||||
citiesThatCanAttackFrom.minByOrNull { pathsToCities[it]!!.size }!!
|
||||
val firstStepInPath = pathsToCities[closestCityThatCanAttackFrom]!!.first()
|
||||
try {
|
||||
airUnit.movement.moveToTile(firstStepInPath)
|
||||
}catch (ex:java.lang.Exception){
|
||||
println()
|
||||
}
|
||||
airUnit.movement.moveToTile(firstStepInPath)
|
||||
}
|
||||
|
||||
fun automateNukes(unit: MapUnit) {
|
||||
|
@ -229,6 +229,7 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction {
|
||||
val unit = MapUnit()
|
||||
unit.name = name
|
||||
unit.civInfo = civInfo
|
||||
unit.owner = civInfo.civName
|
||||
|
||||
// must be after setting name & civInfo because it sets the baseUnit according to the name
|
||||
// and the civInfo is required for using `hasUnique` when determining its movement options
|
||||
|
Loading…
Reference in New Issue
Block a user