diff --git a/core/src/com/unciv/logic/automation/unit/UnitAutomation.kt b/core/src/com/unciv/logic/automation/unit/UnitAutomation.kt index 08e7e41a78..8b3d5659fa 100644 --- a/core/src/com/unciv/logic/automation/unit/UnitAutomation.kt +++ b/core/src/com/unciv/logic/automation/unit/UnitAutomation.kt @@ -159,13 +159,15 @@ object UnitAutomation { return } - if (unit.promotions.canBePromoted() && + while (unit.promotions.canBePromoted() && // Restrict Human automated units from promotions via setting (UncivGame.Current.settings.automatedUnitsChoosePromotions || unit.civ.isAI())) { val availablePromotions = unit.promotions.getAvailablePromotions() .filterNot { it.hasUnique(UniqueType.SkipPromotion) } if (availablePromotions.any()) - unit.promotions.addPromotion(availablePromotions.toList().random().name) + 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 diff --git a/core/src/com/unciv/logic/map/mapunit/UnitPromotions.kt b/core/src/com/unciv/logic/map/mapunit/UnitPromotions.kt index 6f2185136d..0924376a45 100644 --- a/core/src/com/unciv/logic/map/mapunit/UnitPromotions.kt +++ b/core/src/com/unciv/logic/map/mapunit/UnitPromotions.kt @@ -63,17 +63,19 @@ class UnitPromotions : IsPartOfGameInfoSerialization { } fun addPromotion(promotionName: String, isFree: Boolean = false){ + val ruleset = unit.civ.gameInfo.ruleset + val promotion = ruleset.unitPromotions[promotionName]!! + if (!isFree) { - XP -= xpForNextPromotion() - numberOfPromotions++ + if (!promotion.hasUnique(UniqueType.FreePromotion)) { + XP -= xpForNextPromotion() + numberOfPromotions++ + } for (unique in unit.getTriggeredUniques(UniqueType.TriggerUponPromotion)) UniqueTriggerActivation.triggerUnitwideUnique(unique, unit) } - val ruleset = unit.civ.gameInfo.ruleset - val promotion = ruleset.unitPromotions[promotionName]!! - if (!promotion.hasUnique(UniqueType.SkipPromotion)) promotions.add(promotionName) diff --git a/core/src/com/unciv/models/ruleset/unique/UniqueType.kt b/core/src/com/unciv/models/ruleset/unique/UniqueType.kt index 95264f57cc..0806a22673 100644 --- a/core/src/com/unciv/models/ruleset/unique/UniqueType.kt +++ b/core/src/com/unciv/models/ruleset/unique/UniqueType.kt @@ -713,6 +713,7 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags: OneTimeUnitSpecialUpgrade("This Unit upgrades for free including special upgrades", UniqueTarget.UnitTriggerable), OneTimeUnitGainPromotion("This Unit gains the [promotion] promotion", UniqueTarget.UnitTriggerable), // Not used in Vanilla SkipPromotion("Doing so will consume this opportunity to choose a Promotion", UniqueTarget.Promotion), + FreePromotion("This Promotion is free", UniqueTarget.Promotion), UnitsGainPromotion("[mapUnitFilter] units gain the [promotion] promotion", UniqueTarget.Triggerable), // Not used in Vanilla FreeStatBuildings("Provides the cheapest [stat] building in your first [amount] cities for free", UniqueTarget.Triggerable), // used in Policy