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
This commit is contained in:
SeventhM 2023-09-10 23:29:06 -07:00 committed by GitHub
parent 19f9cba058
commit fbb516f90f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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