Fixed a bug where AI would not found religions (#5544)

This commit is contained in:
Xander Lenstra 2021-10-24 19:44:54 +02:00 committed by GitHub
parent 074676c342
commit e9d36ea0ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -378,11 +378,13 @@ object SpecificUnitAutomation {
}
fun foundReligion(unit: MapUnit) {
val cityToFoundReligionAt = unit.civInfo.cities.firstOrNull {
!it.isHolyCity()
&& unit.movement.canMoveTo(it.getCenterTile())
&& unit.movement.canReach(it.getCenterTile())
}
val cityToFoundReligionAt =
if (unit.getTile().isCityCenter() && !unit.getTile().owningCity!!.isHolyCity()) unit.getTile().owningCity
else 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())