From fbb516f90f1917c33e3bffc4e452f4b34192b3fd Mon Sep 17 00:00:00 2001 From: SeventhM <127357473+SeventhM@users.noreply.github.com> Date: Sun, 10 Sep 2023 23:29:06 -0700 Subject: [PATCH] Fix AI getting stuck when it can't promote with enough xp (#10089) * Fix AI getting stuck when it can't promote with enough xp * Reverse the check for promotions * Forgot to remove extra break --- .../src/com/unciv/logic/automation/unit/UnitAutomation.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/src/com/unciv/logic/automation/unit/UnitAutomation.kt b/core/src/com/unciv/logic/automation/unit/UnitAutomation.kt index 8b3d5659fa..a438d1a3ee 100644 --- a/core/src/com/unciv/logic/automation/unit/UnitAutomation.kt +++ b/core/src/com/unciv/logic/automation/unit/UnitAutomation.kt @@ -164,10 +164,10 @@ object UnitAutomation { (UncivGame.Current.settings.automatedUnitsChoosePromotions || unit.civ.isAI())) { val availablePromotions = unit.promotions.getAvailablePromotions() .filterNot { it.hasUnique(UniqueType.SkipPromotion) } - if (availablePromotions.any()) - unit.promotions.addPromotion( - availablePromotions.filter { it.hasUnique(UniqueType.FreePromotion) }.toList().randomOrNull()?.name - ?: availablePromotions.toList().random().name) + if (availablePromotions.none()) break + unit.promotions.addPromotion( + availablePromotions.filter { it.hasUnique(UniqueType.FreePromotion) }.toList().randomOrNull()?.name + ?: availablePromotions.toList().random().name) } //This allows for military units with certain civilian abilities to behave as civilians in peace and soldiers in war