@Interdice even after all that there was still a bug - we didn't check if the tiles we were sending the missionary/inquisitor to was actually reachable :)

This commit is contained in:
yairm210 2021-12-16 22:54:46 +02:00
parent a7b880c033
commit 9d38ce75c4

View File

@ -300,7 +300,8 @@ object SpecificUnitAutomation {
val destination = cities.getTiles().asSequence()
.filterNot { unit.getTile().owningCity == it.owningCity } // to prevent the ai from moving around randomly
.filter { unit.movement.canMoveTo(it) }
.minByOrNull { it.aerialDistanceTo(unit.currentTile) }
.sortedBy { it.aerialDistanceTo(unit.currentTile) }
.firstOrNull { unit.movement.canReach(it) }
if (destination != null) {
@ -328,14 +329,16 @@ object SpecificUnitAutomation {
destination = cityToProtect.getCenterTile().neighbors.asSequence()
.filterNot { unit.getTile().owningCity == it.owningCity } // to prevent the ai from moving around randomly
.filter { unit.movement.canMoveTo(it) }
.minByOrNull { it.aerialDistanceTo(unit.currentTile) }
.sortedBy { it.aerialDistanceTo(unit.currentTile) }
.firstOrNull { unit.movement.canReach(it) }
}
if (destination == null) {
if (cityToConvert == null) return
destination = cityToConvert.getCenterTile().neighbors.asSequence()
.filterNot { unit.getTile().owningCity == it.owningCity } // to prevent the ai from moving around randomly
.filter { unit.movement.canMoveTo(it) }
.minByOrNull { it.aerialDistanceTo(unit.currentTile) }
.sortedBy { it.aerialDistanceTo(unit.currentTile) }
.firstOrNull { unit.movement.canReach(it) }
}
if (destination != null)
@ -346,7 +349,6 @@ object SpecificUnitAutomation {
doReligiousAction(unit, destination)
}
}
private fun isInquisitorInTheCity(city: CityInfo, unit: MapUnit): Boolean {