diff --git a/buildSrc/src/main/kotlin/BuildConfig.kt b/buildSrc/src/main/kotlin/BuildConfig.kt index 1850fd43e2..6da6358c97 100644 --- a/buildSrc/src/main/kotlin/BuildConfig.kt +++ b/buildSrc/src/main/kotlin/BuildConfig.kt @@ -4,7 +4,7 @@ object BuildConfig { const val kotlinVersion = "1.5.30" const val appName = "Unciv" const val appCodeNumber = 644 - const val appVersion = "3.17.15" + const val appVersion = "3.18.0" const val gdxVersion = "1.10.0" const val roboVMVersion = "2.3.1" diff --git a/core/src/com/unciv/logic/battle/Battle.kt b/core/src/com/unciv/logic/battle/Battle.kt index 51e17bd34b..bc5b6c6282 100644 --- a/core/src/com/unciv/logic/battle/Battle.kt +++ b/core/src/com/unciv/logic/battle/Battle.kt @@ -517,6 +517,7 @@ object Battle { capturedUnit.capturedBy(attacker.getCivInfo()) attacker.getCivInfo().popupAlerts.add(PopupAlert(AlertType.RecapturedCivilian, capturedUnitTile.position.toString())) } + // Captured settlers are converted to workers unless captured by barbarians (so they can be returned later). capturedUnit.hasUnique("Founds a new city") && !attacker.getCivInfo().isBarbarian() -> { capturedUnit.destroy() @@ -525,9 +526,7 @@ object Battle { capturedUnit.civInfo = attacker.getCivInfo() attacker.getCivInfo().placeUnitNearTile(capturedUnitTile.position, Constants.worker) } - else -> { - capturedUnit.capturedBy(attacker.getCivInfo()) - } + else -> capturedUnit.capturedBy(attacker.getCivInfo()) } if (checkDefeat) diff --git a/core/src/com/unciv/logic/map/MapUnit.kt b/core/src/com/unciv/logic/map/MapUnit.kt index d1d82c9860..6bcf1d2b57 100644 --- a/core/src/com/unciv/logic/map/MapUnit.kt +++ b/core/src/com/unciv/logic/map/MapUnit.kt @@ -6,6 +6,7 @@ import com.unciv.UncivGame import com.unciv.logic.automation.UnitAutomation import com.unciv.logic.automation.WorkerAutomation import com.unciv.logic.city.CityInfo +import com.unciv.logic.city.RejectionReason import com.unciv.logic.civilization.CivilizationInfo import com.unciv.logic.civilization.LocationAction import com.unciv.logic.civilization.NotificationIcon @@ -470,18 +471,23 @@ class MapUnit { * Used for upgrading units via ancient ruins. */ fun canUpgrade(unitToUpgradeTo: BaseUnit = getUnitToUpgradeTo(), ignoreRequired: Boolean = false): Boolean { - // We need to remove the unit from the civ for this check, - // because if the unit requires, say, horses, and so does its upgrade, - // and the civ currently has 0 horses, - // if we don't remove the unit before the check it's return false! - if (name == unitToUpgradeTo.name) return false - civInfo.removeUnit(this) - val canUpgrade = - if (ignoreRequired) unitToUpgradeTo.isBuildableIgnoringTechs(civInfo) - else unitToUpgradeTo.isBuildable(civInfo) - civInfo.addUnit(this) - return canUpgrade + val rejectionReasons = unitToUpgradeTo.getRejectionReasons(civInfo) + if (rejectionReasons.isEmpty()) return true + + if (rejectionReasons.size == 1 && rejectionReasons.contains(RejectionReason.ConsumesResources)) { + // We need to remove the unit from the civ for this check, + // because if the unit requires, say, horses, and so does its upgrade, + // and the civ currently has 0 horses, we need to see if the upgrade will be buildable + // WHEN THE CURRENT UNIT IS NOT HERE + civInfo.removeUnit(this) + val canUpgrade = + if (ignoreRequired) unitToUpgradeTo.isBuildableIgnoringTechs(civInfo) + else unitToUpgradeTo.isBuildable(civInfo) + civInfo.addUnit(this) + return canUpgrade + } + return false } fun getCostOfUpgrade(): Int {