diff --git a/android/assets/jsons/translations/template.properties b/android/assets/jsons/translations/template.properties index 24af28d408..f0c860cf92 100644 --- a/android/assets/jsons/translations/template.properties +++ b/android/assets/jsons/translations/template.properties @@ -767,6 +767,7 @@ Auto-assign city production = Auto-build roads = Automated workers replace improvements = Automated units move on turn start = +Automated units can upgrade = Order trade offers by amount = Ask for confirmation when pressing next turn = Notifications log max turns = diff --git a/core/src/com/unciv/logic/automation/unit/UnitAutomation.kt b/core/src/com/unciv/logic/automation/unit/UnitAutomation.kt index d738181ac4..c4740b3da4 100644 --- a/core/src/com/unciv/logic/automation/unit/UnitAutomation.kt +++ b/core/src/com/unciv/logic/automation/unit/UnitAutomation.kt @@ -1,6 +1,7 @@ package com.unciv.logic.automation.unit import com.unciv.Constants +import com.unciv.UncivGame import com.unciv.logic.automation.Automation import com.unciv.logic.automation.civilization.NextTurnAutomation import com.unciv.logic.battle.Battle @@ -17,6 +18,7 @@ import com.unciv.logic.civilization.managers.ReligionState import com.unciv.logic.map.mapunit.MapUnit import com.unciv.logic.map.tile.Tile import com.unciv.models.UnitActionType +import com.unciv.models.metadata.GameSettings import com.unciv.models.ruleset.unique.UniqueType import com.unciv.ui.screens.worldscreen.unit.actions.UnitActions import com.unciv.ui.screens.worldscreen.unit.actions.UnitActionsPillage @@ -128,6 +130,8 @@ object UnitAutomation { } internal fun tryUpgradeUnit(unit: MapUnit): Boolean { + val isHuman = unit.civ.isHuman() + if (!UncivGame.Current.settings.automatedUnitsCanUpgrade && isHuman) return false if (unit.baseUnit.upgradesTo == null) return false val upgradedUnit = unit.upgrade.getUnitToUpgradeTo() if (!upgradedUnit.isBuildable(unit.civ)) return false // for resource reasons, usually diff --git a/core/src/com/unciv/models/metadata/GameSettings.kt b/core/src/com/unciv/models/metadata/GameSettings.kt index cbb0434864..28008f3299 100644 --- a/core/src/com/unciv/models/metadata/GameSettings.kt +++ b/core/src/com/unciv/models/metadata/GameSettings.kt @@ -71,6 +71,7 @@ class GameSettings { var autoBuildingRoads: Boolean = true var automatedWorkersReplaceImprovements = true var automatedUnitsMoveOnTurnStart: Boolean = false + var automatedUnitsCanUpgrade: Boolean = true var showMinimap: Boolean = true var minimapSize: Int = 6 // default corresponds to 15% screen space diff --git a/core/src/com/unciv/ui/popups/options/GameplayTab.kt b/core/src/com/unciv/ui/popups/options/GameplayTab.kt index f38665e786..6c24c53212 100644 --- a/core/src/com/unciv/ui/popups/options/GameplayTab.kt +++ b/core/src/com/unciv/ui/popups/options/GameplayTab.kt @@ -42,6 +42,11 @@ fun gameplayTab( "Automated units move on turn start", settings.automatedUnitsMoveOnTurnStart, true ) { settings.automatedUnitsMoveOnTurnStart = it } + optionsPopup.addCheckbox( + this, + "Automated units can upgrade", + settings.automatedUnitsCanUpgrade, true + ) { settings.automatedUnitsCanUpgrade = it } optionsPopup.addCheckbox(this, "Order trade offers by amount", settings.orderTradeOffersByAmount) { settings.orderTradeOffersByAmount = it } optionsPopup.addCheckbox(this, "Ask for confirmation when pressing next turn", settings.confirmNextTurn) { settings.confirmNextTurn = it }