mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-21 05:09:25 +07:00
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:
@ -59,7 +59,12 @@ class UnitActions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(unit.getBaseUnit().upgradesTo!=null && tile.getOwner()==unit.civInfo) {
|
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)) {
|
if (upgradedUnit.isBuildable(unit.civInfo)) {
|
||||||
val goldCostOfUpgrade = (upgradedUnit.cost - unit.getBaseUnit().cost) * 2 + 10
|
val goldCostOfUpgrade = (upgradedUnit.cost - unit.getBaseUnit().cost) * 2 + 10
|
||||||
actionList += UnitAction("Upgrade to [${upgradedUnit.name}] ([$goldCostOfUpgrade] gold)",
|
actionList += UnitAction("Upgrade to [${upgradedUnit.name}] ([$goldCostOfUpgrade] gold)",
|
||||||
|
Reference in New Issue
Block a user