mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-27 08:09:21 +07:00
Resolved #2175 - Can no queue multiple perpetual builds
This commit is contained in:
@ -4,7 +4,7 @@ import com.badlogic.gdx.graphics.Color
|
|||||||
import com.unciv.Constants
|
import com.unciv.Constants
|
||||||
import com.unciv.UncivGame
|
import com.unciv.UncivGame
|
||||||
import com.unciv.logic.city.CityConstructions
|
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.CityAction
|
||||||
import com.unciv.logic.civilization.PlayerType
|
import com.unciv.logic.civilization.PlayerType
|
||||||
import com.unciv.models.ruleset.Building
|
import com.unciv.models.ruleset.Building
|
||||||
@ -50,7 +50,7 @@ class ConstructionAutomation(val cityConstructions: CityConstructions){
|
|||||||
if (!UncivGame.Current.settings.autoAssignCityProduction
|
if (!UncivGame.Current.settings.autoAssignCityProduction
|
||||||
&& civInfo.playerType== PlayerType.Human && !cityInfo.isPuppet)
|
&& civInfo.playerType== PlayerType.Human && !cityInfo.isPuppet)
|
||||||
return
|
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()
|
addFoodBuildingChoice()
|
||||||
addProductionBuildingChoice()
|
addProductionBuildingChoice()
|
||||||
@ -75,9 +75,9 @@ class ConstructionAutomation(val cityConstructions: CityConstructions){
|
|||||||
val theChosenOne: String
|
val theChosenOne: String
|
||||||
if (relativeCostEffectiveness.isEmpty()) { // choose one of the special constructions instead
|
if (relativeCostEffectiveness.isEmpty()) { // choose one of the special constructions instead
|
||||||
// add science!
|
// add science!
|
||||||
if (SpecialConstruction.science.isBuildable(cityConstructions))
|
if (PerpetualConstruction.science.isBuildable(cityConstructions))
|
||||||
theChosenOne = "Science"
|
theChosenOne = "Science"
|
||||||
else if (SpecialConstruction.gold.isBuildable(cityConstructions))
|
else if (PerpetualConstruction.gold.isBuildable(cityConstructions))
|
||||||
theChosenOne = "Gold"
|
theChosenOne = "Gold"
|
||||||
else theChosenOne = "Nothing"
|
else theChosenOne = "Nothing"
|
||||||
} else if (relativeCostEffectiveness.any { it.remainingWork < production * 30 }) {
|
} else if (relativeCostEffectiveness.any { it.remainingWork < production * 30 }) {
|
||||||
|
@ -92,7 +92,7 @@ class CityConstructions {
|
|||||||
val currentConstructionSnapshot = currentConstruction // See below
|
val currentConstructionSnapshot = currentConstruction // See below
|
||||||
var result = currentConstructionSnapshot.tr()
|
var result = currentConstructionSnapshot.tr()
|
||||||
if (currentConstructionSnapshot != "") {
|
if (currentConstructionSnapshot != "") {
|
||||||
val construction = SpecialConstruction.specialConstructionsMap[currentConstructionSnapshot]
|
val construction = PerpetualConstruction.perpetualConstructionsMap[currentConstructionSnapshot]
|
||||||
if (construction == null) {
|
if (construction == null) {
|
||||||
val turnsLeft = turnsToConstruction(currentConstructionSnapshot)
|
val turnsLeft = turnsToConstruction(currentConstructionSnapshot)
|
||||||
result += ("\r\n" + "Cost".tr() + " " + getConstruction(currentConstruction).getProductionCost(cityInfo.civInfo).toString()).tr()
|
result += ("\r\n" + "Cost".tr() + " " + getConstruction(currentConstruction).getProductionCost(cityInfo.civInfo).toString()).tr()
|
||||||
@ -110,7 +110,7 @@ class CityConstructions {
|
|||||||
val currentConstructionSnapshot = currentConstruction
|
val currentConstructionSnapshot = currentConstruction
|
||||||
var result = currentConstructionSnapshot.tr()
|
var result = currentConstructionSnapshot.tr()
|
||||||
if (currentConstructionSnapshot!=""
|
if (currentConstructionSnapshot!=""
|
||||||
&& !SpecialConstruction.specialConstructionsMap.containsKey(currentConstructionSnapshot)) {
|
&& !PerpetualConstruction.perpetualConstructionsMap.containsKey(currentConstructionSnapshot)) {
|
||||||
val turnsLeft = turnsToConstruction(currentConstructionSnapshot)
|
val turnsLeft = turnsToConstruction(currentConstructionSnapshot)
|
||||||
result += ConstructionInfoTable.turnOrTurns(turnsLeft)
|
result += ConstructionInfoTable.turnOrTurns(turnsLeft)
|
||||||
}
|
}
|
||||||
@ -152,7 +152,7 @@ class CityConstructions {
|
|||||||
gameBasics.units.containsKey(constructionName) -> return gameBasics.units[constructionName]!!
|
gameBasics.units.containsKey(constructionName) -> return gameBasics.units[constructionName]!!
|
||||||
constructionName=="" -> return getConstruction("Nothing")
|
constructionName=="" -> return getConstruction("Nothing")
|
||||||
else -> {
|
else -> {
|
||||||
val special = SpecialConstruction.specialConstructionsMap[constructionName]
|
val special = PerpetualConstruction.perpetualConstructionsMap[constructionName]
|
||||||
if(special!=null) return special
|
if(special!=null) return special
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -174,7 +174,7 @@ class CityConstructions {
|
|||||||
fun getRemainingWork(constructionName: String, useStoredProduction: Boolean = true): Int {
|
fun getRemainingWork(constructionName: String, useStoredProduction: Boolean = true): Int {
|
||||||
val constr = getConstruction(constructionName)
|
val constr = getConstruction(constructionName)
|
||||||
return when {
|
return when {
|
||||||
constr is SpecialConstruction -> 0
|
constr is PerpetualConstruction -> 0
|
||||||
useStoredProduction -> constr.getProductionCost(cityInfo.civInfo) - getWorkDone(constructionName)
|
useStoredProduction -> constr.getProductionCost(cityInfo.civInfo) - getWorkDone(constructionName)
|
||||||
else -> constr.getProductionCost(cityInfo.civInfo)
|
else -> constr.getProductionCost(cityInfo.civInfo)
|
||||||
}
|
}
|
||||||
@ -222,7 +222,7 @@ class CityConstructions {
|
|||||||
stopUnbuildableConstruction()
|
stopUnbuildableConstruction()
|
||||||
|
|
||||||
val construction = getConstruction(currentConstruction)
|
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 {
|
else {
|
||||||
val productionCost = construction.getProductionCost(cityInfo.civInfo)
|
val productionCost = construction.getProductionCost(cityInfo.civInfo)
|
||||||
if (inProgressConstructions.containsKey(currentConstruction)
|
if (inProgressConstructions.containsKey(currentConstruction)
|
||||||
@ -237,7 +237,7 @@ class CityConstructions {
|
|||||||
stopUnbuildableConstruction()
|
stopUnbuildableConstruction()
|
||||||
validateConstructionQueue()
|
validateConstructionQueue()
|
||||||
|
|
||||||
if(getConstruction(currentConstruction) !is SpecialConstruction)
|
if(getConstruction(currentConstruction) !is PerpetualConstruction)
|
||||||
addProductionPoints(cityStats.production.roundToInt())
|
addProductionPoints(cityStats.production.roundToInt())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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 {
|
override fun shouldBeDisplayed(construction: CityConstructions): Boolean {
|
||||||
return isBuildable(construction)
|
return isBuildable(construction)
|
||||||
}
|
}
|
||||||
@ -25,23 +25,23 @@ open class SpecialConstruction(override var name: String, val description: Strin
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val CONVERSION_RATE: Int = 4
|
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 {
|
override fun isBuildable(construction: CityConstructions): Boolean {
|
||||||
return construction.cityInfo.civInfo.tech.getTechUniques().contains("Enables conversion of city production to science")
|
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 {
|
override fun isBuildable(construction: CityConstructions): Boolean {
|
||||||
return construction.cityInfo.civInfo.tech.getTechUniques().contains("Enables conversion of city production to gold")
|
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 isBuildable(construction: CityConstructions): Boolean = true
|
||||||
|
|
||||||
override fun getProductionTooltip(cityInfo: CityInfo): String = ""
|
override fun getProductionTooltip(cityInfo: CityInfo): String = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
val specialConstructionsMap: Map<String, SpecialConstruction>
|
val perpetualConstructionsMap: Map<String, PerpetualConstruction>
|
||||||
= mapOf(science.name to science, gold.name to gold, idle.name to idle)
|
= mapOf(science.name to science, gold.name to gold, idle.name to idle)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table
|
|||||||
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane
|
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane
|
||||||
import com.unciv.logic.city.CityInfo
|
import com.unciv.logic.city.CityInfo
|
||||||
import com.unciv.logic.city.IConstruction
|
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.ui.utils.ImageGetter
|
||||||
import com.unciv.models.ruleset.Building
|
import com.unciv.models.ruleset.Building
|
||||||
import com.unciv.models.ruleset.unit.BaseUnit
|
import com.unciv.models.ruleset.unit.BaseUnit
|
||||||
@ -48,7 +48,7 @@ class ConstructionInfoTable(val city: CityInfo): Table() {
|
|||||||
|
|
||||||
|
|
||||||
var buildingText = construction.name.tr()
|
var buildingText = construction.name.tr()
|
||||||
val specialConstruction = SpecialConstruction.specialConstructionsMap[construction.name]
|
val specialConstruction = PerpetualConstruction.perpetualConstructionsMap[construction.name]
|
||||||
if (specialConstruction == null) {
|
if (specialConstruction == null) {
|
||||||
val turnsToComplete = cityConstructions.turnsToConstruction(construction.name)
|
val turnsToComplete = cityConstructions.turnsToConstruction(construction.name)
|
||||||
buildingText += ("\r\n" + "Cost".tr() + " " + construction.getProductionCost(city.civInfo).toString()).tr()
|
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)
|
description = construction.getDescription(true)
|
||||||
else if (construction is Building)
|
else if (construction is Building)
|
||||||
description = construction.getDescription(true, city.civInfo, city.civInfo.gameInfo.ruleSet)
|
description = construction.getDescription(true, city.civInfo, city.civInfo.gameInfo.ruleSet)
|
||||||
else if(construction is SpecialConstruction)
|
else if(construction is PerpetualConstruction)
|
||||||
description = construction.description.tr()
|
description = construction.description.tr()
|
||||||
else description="" // Should never happen
|
else description="" // Should never happen
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import com.badlogic.gdx.utils.Align
|
|||||||
import com.unciv.UncivGame
|
import com.unciv.UncivGame
|
||||||
import com.unciv.logic.city.CityInfo
|
import com.unciv.logic.city.CityInfo
|
||||||
import com.unciv.logic.city.IConstruction
|
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.UncivSound
|
||||||
import com.unciv.models.stats.Stat
|
import com.unciv.models.stats.Stat
|
||||||
import com.unciv.models.translations.tr
|
import com.unciv.models.translations.tr
|
||||||
@ -150,7 +150,7 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
|
|||||||
else buildableBuildings += productionTextButton
|
else buildableBuildings += productionTextButton
|
||||||
}
|
}
|
||||||
|
|
||||||
for (specialConstruction in SpecialConstruction.specialConstructionsMap.values
|
for (specialConstruction in PerpetualConstruction.perpetualConstructionsMap.values
|
||||||
.filter { it.shouldBeDisplayed(cityConstructions) }) {
|
.filter { it.shouldBeDisplayed(cityConstructions) }) {
|
||||||
specialConstructions += getProductionButton(specialConstruction.name,
|
specialConstructions += getProductionButton(specialConstruction.name,
|
||||||
"Produce [${specialConstruction.name}]".tr()
|
"Produce [${specialConstruction.name}]".tr()
|
||||||
@ -253,6 +253,7 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
|
|||||||
|| cityConstructions.isQueueFull()
|
|| cityConstructions.isQueueFull()
|
||||||
|| !cityConstructions.getConstruction(construction.name).isBuildable(cityConstructions)
|
|| !cityConstructions.getConstruction(construction.name).isBuildable(cityConstructions)
|
||||||
|| !UncivGame.Current.worldScreen.isPlayersTurn
|
|| !UncivGame.Current.worldScreen.isPlayersTurn
|
||||||
|
|| construction is PerpetualConstruction && cityConstructions.isBeingConstructedOrEnqueued(construction.name)
|
||||||
|| city.isPuppet) {
|
|| city.isPuppet) {
|
||||||
button.disable()
|
button.disable()
|
||||||
} else {
|
} else {
|
||||||
|
@ -12,7 +12,7 @@ import com.badlogic.gdx.utils.Align
|
|||||||
import com.unciv.UncivGame
|
import com.unciv.UncivGame
|
||||||
import com.unciv.logic.city.CityConstructions
|
import com.unciv.logic.city.CityConstructions
|
||||||
import com.unciv.logic.city.CityInfo
|
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.cityscreen.CityScreen
|
||||||
import com.unciv.ui.trade.DiplomacyScreen
|
import com.unciv.ui.trade.DiplomacyScreen
|
||||||
import com.unciv.ui.utils.*
|
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 secondaryColor = cityConstructions.cityInfo.civInfo.nation.getInnerColor()
|
||||||
val cityCurrentConstruction = cityConstructions.getCurrentConstruction()
|
val cityCurrentConstruction = cityConstructions.getCurrentConstruction()
|
||||||
if(cityCurrentConstruction !is SpecialConstruction) {
|
if(cityCurrentConstruction !is PerpetualConstruction) {
|
||||||
val turnsToConstruction = cityConstructions.turnsToConstruction(cityCurrentConstruction.name)
|
val turnsToConstruction = cityConstructions.turnsToConstruction(cityCurrentConstruction.name)
|
||||||
val label = turnsToConstruction.toString().toLabel(secondaryColor,14)
|
val label = turnsToConstruction.toString().toLabel(secondaryColor,14)
|
||||||
label.pack()
|
label.pack()
|
||||||
|
Reference in New Issue
Block a user