Fixed bug with aircraft rejection reasons

This commit is contained in:
Yair Morgenstern 2022-04-20 12:50:30 +03:00
parent 18be173ab8
commit 34664e6071
2 changed files with 9 additions and 11 deletions

View File

@ -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) {

View File

@ -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