From e9d36ea0ce02c890fb87fb5ac636400d87fdf750 Mon Sep 17 00:00:00 2001 From: Xander Lenstra <71121390+xlenstra@users.noreply.github.com> Date: Sun, 24 Oct 2021 19:44:54 +0200 Subject: [PATCH] Fixed a bug where AI would not found religions (#5544) --- .../unciv/logic/automation/SpecificUnitAutomation.kt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/core/src/com/unciv/logic/automation/SpecificUnitAutomation.kt b/core/src/com/unciv/logic/automation/SpecificUnitAutomation.kt index 9b793549ef..8a0e3e4376 100644 --- a/core/src/com/unciv/logic/automation/SpecificUnitAutomation.kt +++ b/core/src/com/unciv/logic/automation/SpecificUnitAutomation.kt @@ -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())