From e6a95452b4ef7e33b81df72deb2bbf73da791418 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Wed, 18 Jul 2018 17:58:38 +0300 Subject: [PATCH] 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 --- core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt index abb70cea67..83b61d978a 100644 --- a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt +++ b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt @@ -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)",