mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-13 17:28:57 +07:00
Special construction set by the user (Gold, Science etc) are not auto-changed when a better alternative exists
This commit is contained in:
@ -360,7 +360,7 @@ class NextTurnAutomation{
|
||||
for (i in 0..city.population.population)
|
||||
city.population.autoAssignPopulation()
|
||||
|
||||
Automation().chooseNextConstruction(city.cityConstructions)
|
||||
city.cityConstructions.chooseNextConstruction()
|
||||
if (city.health < city.getMaxHealth())
|
||||
Automation().trainMilitaryUnit(city) // override previous decision if city is under attack
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ class CityConstructions {
|
||||
var builtBuildings = ArrayList<String>()
|
||||
val inProgressConstructions = HashMap<String, Int>()
|
||||
var currentConstruction: String = "Monument" // default starting building!
|
||||
var currentConstructionIsUserSet = false
|
||||
|
||||
//region pure functions
|
||||
fun clone(): CityConstructions {
|
||||
@ -172,7 +173,7 @@ class CityConstructions {
|
||||
if (!construction.isBuildable(this)) {
|
||||
// We can't build this building anymore! (Wonder has been built / resource is gone / etc.)
|
||||
cityInfo.civInfo.addNotification("[${cityInfo.name}] cannot continue work on [$saveCurrentConstruction]", cityInfo.location, Color.BROWN)
|
||||
chooseNextConstruction()
|
||||
cancelCurrentConstruction()
|
||||
} else
|
||||
currentConstruction = saveCurrentConstruction
|
||||
}
|
||||
@ -192,8 +193,7 @@ class CityConstructions {
|
||||
} else
|
||||
cityInfo.civInfo.addNotification("[$currentConstruction] has been built in [" + cityInfo.name + "]", cityInfo.location, Color.BROWN)
|
||||
|
||||
currentConstruction = ""
|
||||
chooseNextConstruction()
|
||||
cancelCurrentConstruction()
|
||||
}
|
||||
|
||||
fun addBuilding(buildingName:String){
|
||||
@ -211,10 +211,8 @@ class CityConstructions {
|
||||
fun purchaseBuilding(buildingName: String) {
|
||||
cityInfo.civInfo.gold -= getConstruction(buildingName).getGoldCost(cityInfo.civInfo)
|
||||
getConstruction(buildingName).postBuildEvent(this)
|
||||
if (currentConstruction == buildingName) {
|
||||
currentConstruction = ""
|
||||
chooseNextConstruction()
|
||||
}
|
||||
if (currentConstruction == buildingName)
|
||||
cancelCurrentConstruction()
|
||||
cityInfo.cityStats.update()
|
||||
}
|
||||
|
||||
@ -228,13 +226,18 @@ class CityConstructions {
|
||||
if (buildableCultureBuildings.isEmpty()) return
|
||||
val cultureBuildingToBuild = buildableCultureBuildings.minBy { it.cost }!!.name
|
||||
addBuilding(cultureBuildingToBuild)
|
||||
if (currentConstruction == cultureBuildingToBuild) {
|
||||
currentConstruction=""
|
||||
chooseNextConstruction()
|
||||
}
|
||||
if (currentConstruction == cultureBuildingToBuild)
|
||||
cancelCurrentConstruction()
|
||||
}
|
||||
|
||||
fun cancelCurrentConstruction(){
|
||||
currentConstructionIsUserSet=false
|
||||
currentConstruction=""
|
||||
chooseNextConstruction()
|
||||
}
|
||||
|
||||
fun chooseNextConstruction() {
|
||||
if(currentConstructionIsUserSet) return
|
||||
Automation().chooseNextConstruction(this)
|
||||
}
|
||||
//endregion
|
||||
|
@ -38,6 +38,7 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
|
||||
pickProductionButton.onClick {
|
||||
lastConstruction = cityScreen.city.cityConstructions.currentConstruction
|
||||
cityScreen.city.cityConstructions.currentConstruction = construction
|
||||
cityScreen.city.cityConstructions.currentConstructionIsUserSet=true
|
||||
cityScreen.city.cityStats.update()
|
||||
cityScreen.update()
|
||||
}
|
||||
|
Reference in New Issue
Block a user