mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-23 14:19:15 +07:00
Resolved #586 - units now upgrade to the most recent upgrade, not to the next possible one
This commit is contained in:
@ -214,12 +214,12 @@ class MapUnit {
|
||||
}
|
||||
|
||||
fun getUnitToUpgradeTo(): BaseUnit {
|
||||
var upgradedUnit = baseUnit().getUpgradeUnit(civInfo)
|
||||
var unit = baseUnit()
|
||||
|
||||
// Go up the upgrade tree until you find the first one which isn't obsolete
|
||||
while (upgradedUnit.obsoleteTech!=null && civInfo.tech.isResearched(upgradedUnit.obsoleteTech!!))
|
||||
upgradedUnit = upgradedUnit.getUpgradeUnit(civInfo)
|
||||
return upgradedUnit
|
||||
// Go up the upgrade tree until you find the last one which is buildable
|
||||
while (unit.upgradesTo!=null && civInfo.tech.isResearched(unit.getDirectUpgradeUnit(civInfo).requiredTech!!))
|
||||
unit = unit.getDirectUpgradeUnit(civInfo)
|
||||
return unit
|
||||
}
|
||||
|
||||
fun canUpgrade(): Boolean {
|
||||
|
@ -138,7 +138,7 @@ class BaseUnit : INamed, IConstruction, ICivilopedia {
|
||||
unit.promotions.addPromotion("Drill I", isFree = true)
|
||||
}
|
||||
|
||||
fun getUpgradeUnit(civInfo: CivilizationInfo):BaseUnit{
|
||||
fun getDirectUpgradeUnit(civInfo: CivilizationInfo):BaseUnit{
|
||||
val uniqueUnitReplacesUpgrade: BaseUnit? = GameBasics.Units.values
|
||||
.firstOrNull{it.uniqueTo==civInfo.civName && it.replaces == upgradesTo}
|
||||
if(uniqueUnitReplacesUpgrade!=null) return uniqueUnitReplacesUpgrade
|
||||
|
Reference in New Issue
Block a user