If a unit's upgrade is obsolete, then we try to upgrade to the next non-obsolete unit in line in the upgrade succession tree

This commit is contained in:
Yair Morgenstern
2018-07-18 17:58:38 +03:00
parent a86460b345
commit e6a95452b4

View File

@ -59,7 +59,12 @@ class UnitActions {
}
if(unit.getBaseUnit().upgradesTo!=null && tile.getOwner()==unit.civInfo) {
val upgradedUnit = GameBasics.Units[unit.getBaseUnit().upgradesTo!!]!!
var upgradedUnit = GameBasics.Units[unit.getBaseUnit().upgradesTo!!]!!
// Go up the upgrade tree until you find the first one which isn't obsolete
while (upgradedUnit.obsoleteTech!=null && unit.civInfo.tech.isResearched(upgradedUnit.obsoleteTech!!))
upgradedUnit = GameBasics.Units[upgradedUnit.upgradesTo!!]!!
if (upgradedUnit.isBuildable(unit.civInfo)) {
val goldCostOfUpgrade = (upgradedUnit.cost - unit.getBaseUnit().cost) * 2 + 10
actionList += UnitAction("Upgrade to [${upgradedUnit.name}] ([$goldCostOfUpgrade] gold)",