Automated units will not autopromote by default (changeable by options setting)

This commit is contained in:
Yair Morgenstern 2023-08-29 14:48:58 +03:00
parent 4d068d7b20
commit 014dea246f
4 changed files with 14 additions and 7 deletions

View File

@ -770,6 +770,7 @@ Auto-build roads =
Automated workers replace improvements =
Automated units move on turn start =
Automated units can upgrade =
Automated units choose promotions =
Order trade offers by amount =
Ask for confirmation when pressing next turn =
Notifications log max turns =

View File

@ -18,7 +18,6 @@ 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
@ -160,7 +159,9 @@ object UnitAutomation {
return
}
if (unit.promotions.canBePromoted()) {
if (unit.promotions.canBePromoted() &&
// Restrict Human automated units from promotions via setting
(UncivGame.Current.settings.automatedUnitsChoosePromotions || unit.civ.isAI())) {
val availablePromotions = unit.promotions.getAvailablePromotions()
.filterNot { it.hasUnique(UniqueType.SkipPromotion) }
if (availablePromotions.any())
@ -383,7 +384,7 @@ object UnitAutomation {
unit.movement.headTowards(encampmentToHeadTowards)
return true
}
private fun tryHealUnit(unit: MapUnit): Boolean {
if (unit.baseUnit.isRanged() && unit.hasUnique(UniqueType.HealsEvenAfterAction))
return false // will heal anyway, and attacks don't hurt

View File

@ -71,7 +71,8 @@ class GameSettings {
var autoBuildingRoads: Boolean = true
var automatedWorkersReplaceImprovements = true
var automatedUnitsMoveOnTurnStart: Boolean = false
var automatedUnitsCanUpgrade: Boolean = true
var automatedUnitsCanUpgrade: Boolean = false
var automatedUnitsChoosePromotions: Boolean = false
var showMinimap: Boolean = true
var minimapSize: Int = 6 // default corresponds to 15% screen space

View File

@ -2,12 +2,11 @@ package com.unciv.ui.popups.options
import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.unciv.GUI
import com.unciv.UncivGame
import com.unciv.logic.civilization.PlayerType
import com.unciv.models.metadata.GameSettings
import com.unciv.ui.screens.basescreen.BaseScreen
import com.unciv.ui.components.UncivSlider
import com.unciv.ui.components.extensions.toLabel
import com.unciv.ui.screens.basescreen.BaseScreen
fun gameplayTab(
optionsPopup: OptionsPopup
@ -45,8 +44,13 @@ fun gameplayTab(
optionsPopup.addCheckbox(
this,
"Automated units can upgrade",
settings.automatedUnitsCanUpgrade, true
settings.automatedUnitsCanUpgrade, false
) { settings.automatedUnitsCanUpgrade = it }
optionsPopup.addCheckbox(
this,
"Automated units choose promotions",
settings.automatedUnitsChoosePromotions, false
) { settings.automatedUnitsChoosePromotions = 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 }