mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 22:06:05 -04:00
Resolved #586 - units now upgrade to the most recent upgrade, not to the next possible one
This commit is contained in:
parent
f1f3753231
commit
c33b0a67fe
@ -214,12 +214,12 @@ class MapUnit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getUnitToUpgradeTo(): BaseUnit {
|
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
|
// Go up the upgrade tree until you find the last one which is buildable
|
||||||
while (upgradedUnit.obsoleteTech!=null && civInfo.tech.isResearched(upgradedUnit.obsoleteTech!!))
|
while (unit.upgradesTo!=null && civInfo.tech.isResearched(unit.getDirectUpgradeUnit(civInfo).requiredTech!!))
|
||||||
upgradedUnit = upgradedUnit.getUpgradeUnit(civInfo)
|
unit = unit.getDirectUpgradeUnit(civInfo)
|
||||||
return upgradedUnit
|
return unit
|
||||||
}
|
}
|
||||||
|
|
||||||
fun canUpgrade(): Boolean {
|
fun canUpgrade(): Boolean {
|
||||||
|
@ -138,7 +138,7 @@ class BaseUnit : INamed, IConstruction, ICivilopedia {
|
|||||||
unit.promotions.addPromotion("Drill I", isFree = true)
|
unit.promotions.addPromotion("Drill I", isFree = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getUpgradeUnit(civInfo: CivilizationInfo):BaseUnit{
|
fun getDirectUpgradeUnit(civInfo: CivilizationInfo):BaseUnit{
|
||||||
val uniqueUnitReplacesUpgrade: BaseUnit? = GameBasics.Units.values
|
val uniqueUnitReplacesUpgrade: BaseUnit? = GameBasics.Units.values
|
||||||
.firstOrNull{it.uniqueTo==civInfo.civName && it.replaces == upgradesTo}
|
.firstOrNull{it.uniqueTo==civInfo.civName && it.replaces == upgradesTo}
|
||||||
if(uniqueUnitReplacesUpgrade!=null) return uniqueUnitReplacesUpgrade
|
if(uniqueUnitReplacesUpgrade!=null) return uniqueUnitReplacesUpgrade
|
||||||
|
Loading…
x
Reference in New Issue
Block a user