mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-03 21:40:31 +07:00
Add unique for a promotion to be free (#10015)
* Add unique for a promotion to be free * Have Ai prefer free promotions * Allow AI to get multiple promotions each step
This commit is contained in:
parent
087c2a0946
commit
d19281e0e6
@ -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
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user