diff --git a/core/src/com/unciv/logic/automation/ConstructionAutomation.kt b/core/src/com/unciv/logic/automation/ConstructionAutomation.kt index 68486903c8..23e2b65a68 100644 --- a/core/src/com/unciv/logic/automation/ConstructionAutomation.kt +++ b/core/src/com/unciv/logic/automation/ConstructionAutomation.kt @@ -4,7 +4,7 @@ import com.badlogic.gdx.graphics.Color import com.unciv.Constants import com.unciv.UncivGame import com.unciv.logic.city.CityConstructions -import com.unciv.logic.city.SpecialConstruction +import com.unciv.logic.city.PerpetualConstruction import com.unciv.logic.civilization.CityAction import com.unciv.logic.civilization.PlayerType import com.unciv.models.ruleset.Building @@ -50,7 +50,7 @@ class ConstructionAutomation(val cityConstructions: CityConstructions){ if (!UncivGame.Current.settings.autoAssignCityProduction && civInfo.playerType== PlayerType.Human && !cityInfo.isPuppet) return - if (cityConstructions.getCurrentConstruction() !is SpecialConstruction) return // don't want to be stuck on these forever + if (cityConstructions.getCurrentConstruction() !is PerpetualConstruction) return // don't want to be stuck on these forever addFoodBuildingChoice() addProductionBuildingChoice() @@ -75,9 +75,9 @@ class ConstructionAutomation(val cityConstructions: CityConstructions){ val theChosenOne: String if (relativeCostEffectiveness.isEmpty()) { // choose one of the special constructions instead // add science! - if (SpecialConstruction.science.isBuildable(cityConstructions)) + if (PerpetualConstruction.science.isBuildable(cityConstructions)) theChosenOne = "Science" - else if (SpecialConstruction.gold.isBuildable(cityConstructions)) + else if (PerpetualConstruction.gold.isBuildable(cityConstructions)) theChosenOne = "Gold" else theChosenOne = "Nothing" } else if (relativeCostEffectiveness.any { it.remainingWork < production * 30 }) { diff --git a/core/src/com/unciv/logic/city/CityConstructions.kt b/core/src/com/unciv/logic/city/CityConstructions.kt index fa0340350c..475a6b249e 100644 --- a/core/src/com/unciv/logic/city/CityConstructions.kt +++ b/core/src/com/unciv/logic/city/CityConstructions.kt @@ -92,7 +92,7 @@ class CityConstructions { val currentConstructionSnapshot = currentConstruction // See below var result = currentConstructionSnapshot.tr() if (currentConstructionSnapshot != "") { - val construction = SpecialConstruction.specialConstructionsMap[currentConstructionSnapshot] + val construction = PerpetualConstruction.perpetualConstructionsMap[currentConstructionSnapshot] if (construction == null) { val turnsLeft = turnsToConstruction(currentConstructionSnapshot) result += ("\r\n" + "Cost".tr() + " " + getConstruction(currentConstruction).getProductionCost(cityInfo.civInfo).toString()).tr() @@ -110,7 +110,7 @@ class CityConstructions { val currentConstructionSnapshot = currentConstruction var result = currentConstructionSnapshot.tr() if (currentConstructionSnapshot!="" - && !SpecialConstruction.specialConstructionsMap.containsKey(currentConstructionSnapshot)) { + && !PerpetualConstruction.perpetualConstructionsMap.containsKey(currentConstructionSnapshot)) { val turnsLeft = turnsToConstruction(currentConstructionSnapshot) result += ConstructionInfoTable.turnOrTurns(turnsLeft) } @@ -152,7 +152,7 @@ class CityConstructions { gameBasics.units.containsKey(constructionName) -> return gameBasics.units[constructionName]!! constructionName=="" -> return getConstruction("Nothing") else -> { - val special = SpecialConstruction.specialConstructionsMap[constructionName] + val special = PerpetualConstruction.perpetualConstructionsMap[constructionName] if(special!=null) return special } } @@ -174,7 +174,7 @@ class CityConstructions { fun getRemainingWork(constructionName: String, useStoredProduction: Boolean = true): Int { val constr = getConstruction(constructionName) return when { - constr is SpecialConstruction -> 0 + constr is PerpetualConstruction -> 0 useStoredProduction -> constr.getProductionCost(cityInfo.civInfo) - getWorkDone(constructionName) else -> constr.getProductionCost(cityInfo.civInfo) } @@ -222,7 +222,7 @@ class CityConstructions { stopUnbuildableConstruction() val construction = getConstruction(currentConstruction) - if(construction is SpecialConstruction) chooseNextConstruction() // check every turn if we could be doing something better, because this doesn't end by itself + if(construction is PerpetualConstruction) chooseNextConstruction() // check every turn if we could be doing something better, because this doesn't end by itself else { val productionCost = construction.getProductionCost(cityInfo.civInfo) if (inProgressConstructions.containsKey(currentConstruction) @@ -237,7 +237,7 @@ class CityConstructions { stopUnbuildableConstruction() validateConstructionQueue() - if(getConstruction(currentConstruction) !is SpecialConstruction) + if(getConstruction(currentConstruction) !is PerpetualConstruction) addProductionPoints(cityStats.production.roundToInt()) } diff --git a/core/src/com/unciv/logic/city/IConstruction.kt b/core/src/com/unciv/logic/city/IConstruction.kt index 391120fda0..e312174447 100644 --- a/core/src/com/unciv/logic/city/IConstruction.kt +++ b/core/src/com/unciv/logic/city/IConstruction.kt @@ -16,7 +16,7 @@ interface IConstruction : INamed { -open class SpecialConstruction(override var name: String, val description: String) : IConstruction{ +open class PerpetualConstruction(override var name: String, val description: String) : IConstruction{ override fun shouldBeDisplayed(construction: CityConstructions): Boolean { return isBuildable(construction) } @@ -25,23 +25,23 @@ open class SpecialConstruction(override var name: String, val description: Strin companion object { const val CONVERSION_RATE: Int = 4 - val science = object : SpecialConstruction("Science", "Convert production to science at a rate of $CONVERSION_RATE to 1") { + val science = object : PerpetualConstruction("Science", "Convert production to science at a rate of $CONVERSION_RATE to 1") { override fun isBuildable(construction: CityConstructions): Boolean { return construction.cityInfo.civInfo.tech.getTechUniques().contains("Enables conversion of city production to science") } } - val gold = object : SpecialConstruction("Gold", "Convert production to gold at a rate of $CONVERSION_RATE to 1") { + val gold = object : PerpetualConstruction("Gold", "Convert production to gold at a rate of $CONVERSION_RATE to 1") { override fun isBuildable(construction: CityConstructions): Boolean { return construction.cityInfo.civInfo.tech.getTechUniques().contains("Enables conversion of city production to gold") } } - val idle = object : SpecialConstruction("Nothing", "The city will not produce anything.") { + val idle = object : PerpetualConstruction("Nothing", "The city will not produce anything.") { override fun isBuildable(construction: CityConstructions): Boolean = true override fun getProductionTooltip(cityInfo: CityInfo): String = "" } - val specialConstructionsMap: Map + val perpetualConstructionsMap: Map = mapOf(science.name to science, gold.name to gold, idle.name to idle) } diff --git a/core/src/com/unciv/ui/cityscreen/ConstructionInfoTable.kt b/core/src/com/unciv/ui/cityscreen/ConstructionInfoTable.kt index b579bbab53..bb5ed25ba0 100644 --- a/core/src/com/unciv/ui/cityscreen/ConstructionInfoTable.kt +++ b/core/src/com/unciv/ui/cityscreen/ConstructionInfoTable.kt @@ -5,7 +5,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane import com.unciv.logic.city.CityInfo import com.unciv.logic.city.IConstruction -import com.unciv.logic.city.SpecialConstruction +import com.unciv.logic.city.PerpetualConstruction import com.unciv.ui.utils.ImageGetter import com.unciv.models.ruleset.Building import com.unciv.models.ruleset.unit.BaseUnit @@ -48,7 +48,7 @@ class ConstructionInfoTable(val city: CityInfo): Table() { var buildingText = construction.name.tr() - val specialConstruction = SpecialConstruction.specialConstructionsMap[construction.name] + val specialConstruction = PerpetualConstruction.perpetualConstructionsMap[construction.name] if (specialConstruction == null) { val turnsToComplete = cityConstructions.turnsToConstruction(construction.name) buildingText += ("\r\n" + "Cost".tr() + " " + construction.getProductionCost(city.civInfo).toString()).tr() @@ -65,7 +65,7 @@ class ConstructionInfoTable(val city: CityInfo): Table() { description = construction.getDescription(true) else if (construction is Building) description = construction.getDescription(true, city.civInfo, city.civInfo.gameInfo.ruleSet) - else if(construction is SpecialConstruction) + else if(construction is PerpetualConstruction) description = construction.description.tr() else description="" // Should never happen diff --git a/core/src/com/unciv/ui/cityscreen/ConstructionsTable.kt b/core/src/com/unciv/ui/cityscreen/ConstructionsTable.kt index 7117709706..f97b2e4002 100644 --- a/core/src/com/unciv/ui/cityscreen/ConstructionsTable.kt +++ b/core/src/com/unciv/ui/cityscreen/ConstructionsTable.kt @@ -9,7 +9,7 @@ import com.badlogic.gdx.utils.Align import com.unciv.UncivGame import com.unciv.logic.city.CityInfo import com.unciv.logic.city.IConstruction -import com.unciv.logic.city.SpecialConstruction +import com.unciv.logic.city.PerpetualConstruction import com.unciv.models.UncivSound import com.unciv.models.stats.Stat import com.unciv.models.translations.tr @@ -150,7 +150,7 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre else buildableBuildings += productionTextButton } - for (specialConstruction in SpecialConstruction.specialConstructionsMap.values + for (specialConstruction in PerpetualConstruction.perpetualConstructionsMap.values .filter { it.shouldBeDisplayed(cityConstructions) }) { specialConstructions += getProductionButton(specialConstruction.name, "Produce [${specialConstruction.name}]".tr() @@ -253,6 +253,7 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre || cityConstructions.isQueueFull() || !cityConstructions.getConstruction(construction.name).isBuildable(cityConstructions) || !UncivGame.Current.worldScreen.isPlayersTurn + || construction is PerpetualConstruction && cityConstructions.isBeingConstructedOrEnqueued(construction.name) || city.isPuppet) { button.disable() } else { diff --git a/core/src/com/unciv/ui/tilegroups/CityButton.kt b/core/src/com/unciv/ui/tilegroups/CityButton.kt index da8b4f0d07..ce43dc0ae7 100644 --- a/core/src/com/unciv/ui/tilegroups/CityButton.kt +++ b/core/src/com/unciv/ui/tilegroups/CityButton.kt @@ -12,7 +12,7 @@ import com.badlogic.gdx.utils.Align import com.unciv.UncivGame import com.unciv.logic.city.CityConstructions import com.unciv.logic.city.CityInfo -import com.unciv.logic.city.SpecialConstruction +import com.unciv.logic.city.PerpetualConstruction import com.unciv.ui.cityscreen.CityScreen import com.unciv.ui.trade.DiplomacyScreen import com.unciv.ui.utils.* @@ -259,7 +259,7 @@ class CityButton(val city: CityInfo, internal val tileGroup: WorldTileGroup, ski val secondaryColor = cityConstructions.cityInfo.civInfo.nation.getInnerColor() val cityCurrentConstruction = cityConstructions.getCurrentConstruction() - if(cityCurrentConstruction !is SpecialConstruction) { + if(cityCurrentConstruction !is PerpetualConstruction) { val turnsToConstruction = cityConstructions.turnsToConstruction(cityCurrentConstruction.name) val label = turnsToConstruction.toString().toLabel(secondaryColor,14) label.pack()