Solved edge case where automated prophet couldn't head towards the city

This commit is contained in:
yairm210 2021-10-19 21:25:43 +03:00
parent 55bed3bf30
commit c708ebd7f0

View File

@ -378,14 +378,18 @@ object SpecificUnitAutomation {
}
fun foundReligion(unit: MapUnit) {
val cityToFoundReligionAt = unit.civInfo.cities.first { !it.isHolyCity() }
val cityToFoundReligionAt = unit.civInfo.cities.firstOrNull {
!it.isHolyCity()
&& unit.movement.canMoveTo(it.getCenterTile())
&& unit.movement.canReach(it.getCenterTile())
}
if (cityToFoundReligionAt == null) return
if (unit.getTile() != cityToFoundReligionAt.getCenterTile()) {
unit.movement.headTowards(cityToFoundReligionAt.getCenterTile())
return
return
}
UnitActions.getFoundReligionAction(unit)()
}
fun enhanceReligion(unit: MapUnit) {