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) { fun foundReligion(unit: MapUnit) {
val cityToFoundReligionAt = unit.civInfo.cities.firstOrNull { val cityToFoundReligionAt =
!it.isHolyCity() if (unit.getTile().isCityCenter() && !unit.getTile().owningCity!!.isHolyCity()) unit.getTile().owningCity
&& unit.movement.canMoveTo(it.getCenterTile()) else unit.civInfo.cities.firstOrNull {
&& unit.movement.canReach(it.getCenterTile()) !it.isHolyCity()
} && unit.movement.canMoveTo(it.getCenterTile())
&& unit.movement.canReach(it.getCenterTile())
}
if (cityToFoundReligionAt == null) return if (cityToFoundReligionAt == null) return
if (unit.getTile() != cityToFoundReligionAt.getCenterTile()) { if (unit.getTile() != cityToFoundReligionAt.getCenterTile()) {
unit.movement.headTowards(cityToFoundReligionAt.getCenterTile()) unit.movement.headTowards(cityToFoundReligionAt.getCenterTile())