mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-05 21:11:35 +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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unit.promotions.canBePromoted() &&
|
while (unit.promotions.canBePromoted() &&
|
||||||
// Restrict Human automated units from promotions via setting
|
// Restrict Human automated units from promotions via setting
|
||||||
(UncivGame.Current.settings.automatedUnitsChoosePromotions || unit.civ.isAI())) {
|
(UncivGame.Current.settings.automatedUnitsChoosePromotions || unit.civ.isAI())) {
|
||||||
val availablePromotions = unit.promotions.getAvailablePromotions()
|
val availablePromotions = unit.promotions.getAvailablePromotions()
|
||||||
.filterNot { it.hasUnique(UniqueType.SkipPromotion) }
|
.filterNot { it.hasUnique(UniqueType.SkipPromotion) }
|
||||||
if (availablePromotions.any())
|
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
|
//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){
|
fun addPromotion(promotionName: String, isFree: Boolean = false){
|
||||||
|
val ruleset = unit.civ.gameInfo.ruleset
|
||||||
|
val promotion = ruleset.unitPromotions[promotionName]!!
|
||||||
|
|
||||||
if (!isFree) {
|
if (!isFree) {
|
||||||
XP -= xpForNextPromotion()
|
if (!promotion.hasUnique(UniqueType.FreePromotion)) {
|
||||||
numberOfPromotions++
|
XP -= xpForNextPromotion()
|
||||||
|
numberOfPromotions++
|
||||||
|
}
|
||||||
|
|
||||||
for (unique in unit.getTriggeredUniques(UniqueType.TriggerUponPromotion))
|
for (unique in unit.getTriggeredUniques(UniqueType.TriggerUponPromotion))
|
||||||
UniqueTriggerActivation.triggerUnitwideUnique(unique, unit)
|
UniqueTriggerActivation.triggerUnitwideUnique(unique, unit)
|
||||||
}
|
}
|
||||||
|
|
||||||
val ruleset = unit.civ.gameInfo.ruleset
|
|
||||||
val promotion = ruleset.unitPromotions[promotionName]!!
|
|
||||||
|
|
||||||
if (!promotion.hasUnique(UniqueType.SkipPromotion))
|
if (!promotion.hasUnique(UniqueType.SkipPromotion))
|
||||||
promotions.add(promotionName)
|
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),
|
OneTimeUnitSpecialUpgrade("This Unit upgrades for free including special upgrades", UniqueTarget.UnitTriggerable),
|
||||||
OneTimeUnitGainPromotion("This Unit gains the [promotion] promotion", UniqueTarget.UnitTriggerable), // Not used in Vanilla
|
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),
|
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
|
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
|
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