Fixed AI unit upgrading - can now 'skip' over intermediate units, the way the "promote unit" action works. #3115

This commit is contained in:
Yair Morgenstern 2020-09-10 19:51:14 +03:00
parent 10b0d498c6
commit 9ba9dd6fcf

View file

@ -73,11 +73,9 @@ object UnitAutomation {
}
internal fun tryUpgradeUnit(unit: MapUnit): Boolean {
val upgradesTo = unit.baseUnit().upgradesTo
if (upgradesTo == null) return false
val upgradedUnit = unit.civInfo.gameInfo.ruleSet.units.getValue(upgradesTo)
if (!upgradedUnit.isBuildable(unit.civInfo)) return false
if (unit.baseUnit.upgradesTo == null) return false
val upgradedUnit = unit.getUnitToUpgradeTo()
if (!upgradedUnit.isBuildable(unit.civInfo)) return false // for resource reasons, usually
val upgradeAction = UnitActions.getUpgradeAction(unit)
if (upgradeAction == null) return false