diff --git a/core/src/com/unciv/logic/automation/ConstructionAutomation.kt b/core/src/com/unciv/logic/automation/ConstructionAutomation.kt index ce6c7a61cf..9d12eb064a 100644 --- a/core/src/com/unciv/logic/automation/ConstructionAutomation.kt +++ b/core/src/com/unciv/logic/automation/ConstructionAutomation.kt @@ -46,7 +46,8 @@ class ConstructionAutomation(val cityConstructions: CityConstructions){ fun chooseNextConstruction() { if (!UncivGame.Current.settings.autoAssignCityProduction - && civInfo.playerType== PlayerType.Human && !cityInfo.isPuppet) + && civInfo.playerType == PlayerType.Human && !cityInfo.isPuppet + ) return if (cityConstructions.getCurrentConstruction() !is PerpetualConstruction) return // don't want to be stuck on these forever @@ -61,33 +62,37 @@ class ConstructionAutomation(val cityConstructions: CityConstructions){ addSpaceshipPartChoice() addOtherBuildingChoice() - if(!cityInfo.isPuppet) { + if (!cityInfo.isPuppet) { addWondersChoice() addWorkerChoice() addWorkBoatChoice() addMilitaryUnitChoice() } - + val production = cityInfo.cityStats.currentCityStats.production - val theChosenOne: String - if (relativeCostEffectiveness.isEmpty()) { // choose one of the special constructions instead - // add science! - if (PerpetualConstruction.science.isBuildable(cityConstructions) && !allTechsAreResearched) - theChosenOne = "Science" - else if (PerpetualConstruction.gold.isBuildable(cityConstructions)) - theChosenOne = "Gold" - else theChosenOne = "Nothing" - } else if (relativeCostEffectiveness.any { it.remainingWork < production * 30 }) { - relativeCostEffectiveness.removeAll { it.remainingWork >= production * 30 } - theChosenOne = relativeCostEffectiveness.minByOrNull { it.remainingWork / it.choiceModifier }!!.choice - } - // it's possible that this is a new city and EVERYTHING is way expensive - ignore modifiers, go for the cheapest. - // Nobody can plan 30 turns ahead, I don't care how cost-efficient you are. - else theChosenOne = relativeCostEffectiveness.minByOrNull { it.remainingWork }!!.choice + val chosenConstruction: String = + if (relativeCostEffectiveness.isEmpty()) { // choose one of the special constructions instead + // add science! + when { + PerpetualConstruction.science.isBuildable(cityConstructions) && !allTechsAreResearched -> PerpetualConstruction.science.name + PerpetualConstruction.gold.isBuildable(cityConstructions) -> PerpetualConstruction.gold.name + else -> PerpetualConstruction.idle.name + } + } else if (relativeCostEffectiveness.any { it.remainingWork < production * 30 }) { + relativeCostEffectiveness.removeAll { it.remainingWork >= production * 30 } + relativeCostEffectiveness.minByOrNull { it.remainingWork / it.choiceModifier }!!.choice + } + // it's possible that this is a new city and EVERYTHING is way expensive - ignore modifiers, go for the cheapest. + // Nobody can plan 30 turns ahead, I don't care how cost-efficient you are. + else relativeCostEffectiveness.minByOrNull { it.remainingWork }!!.choice - civInfo.addNotification("Work has started on [$theChosenOne]", CityAction(cityInfo.location), NotificationIcon.Construction) - cityConstructions.currentConstructionFromQueue = theChosenOne + civInfo.addNotification( + "Work has started on [$chosenConstruction]", + CityAction(cityInfo.location), + NotificationIcon.Construction + ) + cityConstructions.currentConstructionFromQueue = chosenConstruction } private fun addMilitaryUnitChoice() { diff --git a/core/src/com/unciv/logic/map/MapUnit.kt b/core/src/com/unciv/logic/map/MapUnit.kt index 2aa356211c..9aaee55661 100644 --- a/core/src/com/unciv/logic/map/MapUnit.kt +++ b/core/src/com/unciv/logic/map/MapUnit.kt @@ -936,12 +936,12 @@ class MapUnit { fun isTransportTypeOf(mapUnit: MapUnit): Boolean { // Currently, only missiles and airplanes can be carried if (!mapUnit.baseUnit.movesLikeAirUnits()) return false - return getMatchingUniques("Can carry [] [] units").any { mapUnit.matchesFilter(it.params[1]) } + return getMatchingUniques(UniqueType.CarryAirUnits).any { mapUnit.matchesFilter(it.params[1]) } } private fun carryCapacity(unit: MapUnit): Int { - return (getMatchingUniques("Can carry [] [] units") - + getMatchingUniques("Can carry [] extra [] units")) + return (getMatchingUniques(UniqueType.CarryAirUnits) + + getMatchingUniques(UniqueType.CarryExtraAirUnits)) .filter { unit.matchesFilter(it.params[1]) } .sumOf { it.params[0].toInt() } } diff --git a/core/src/com/unciv/models/ruleset/unique/UniqueType.kt b/core/src/com/unciv/models/ruleset/unique/UniqueType.kt index 7a73f8bb8b..18ff35a32a 100644 --- a/core/src/com/unciv/models/ruleset/unique/UniqueType.kt +++ b/core/src/com/unciv/models/ruleset/unique/UniqueType.kt @@ -183,6 +183,10 @@ enum class UniqueType(val text:String, vararg targets: UniqueTarget) { SpreadReligionStrengthUnits("[amount]% Spread Religion Strength for [mapUnitFilter] units", UniqueTarget.Global), + CarryAirUnits("Can carry [amount] [mapUnitFilter] units", UniqueTarget.Unit), + CarryExtraAirUnits("Can carry [amount] extra [mapUnitFilter] units", UniqueTarget.Unit), + CannotBeCarriedBy("Cannot be carried by [mapUnitFilter] units", UniqueTarget.Unit), + // The following block gets cached in MapUnit for faster getMovementCostBetweenAdjacentTiles DoubleMovementOnTerrain("Double movement in [terrainFilter]", UniqueTarget.Unit), @Deprecated("As of 3.17.1", ReplaceWith("Double movement in [terrainFilter]"), DeprecationLevel.WARNING)