mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-27 08:09:21 +07:00
Reassign population after selling a specialist-providing building
This commit is contained in:
@ -598,12 +598,13 @@ class CityInfo {
|
|||||||
|
|
||||||
fun getGoldForSellingBuilding(buildingName:String) = getRuleset().buildings[buildingName]!!.cost / 10
|
fun getGoldForSellingBuilding(buildingName:String) = getRuleset().buildings[buildingName]!!.cost / 10
|
||||||
|
|
||||||
fun sellBuilding(buildingName:String){
|
fun sellBuilding(buildingName:String) {
|
||||||
cityConstructions.builtBuildings.remove(buildingName)
|
|
||||||
cityConstructions.removeBuilding(buildingName)
|
cityConstructions.removeBuilding(buildingName)
|
||||||
civInfo.gold += getGoldForSellingBuilding(buildingName)
|
civInfo.gold += getGoldForSellingBuilding(buildingName)
|
||||||
hasSoldBuildingThisTurn=true
|
hasSoldBuildingThisTurn = true
|
||||||
|
|
||||||
|
population.unassignExtraPopulation() // If the building provided specialists, release them to other work
|
||||||
|
population.autoAssignPopulation()
|
||||||
cityStats.update()
|
cityStats.update()
|
||||||
civInfo.updateDetailedCivResources() // this building could be a resource-requiring one
|
civInfo.updateDetailedCivResources() // this building could be a resource-requiring one
|
||||||
}
|
}
|
||||||
|
@ -79,8 +79,7 @@ class PopulationManager {
|
|||||||
// if small city, favor production above all, ignore gold!
|
// if small city, favor production above all, ignore gold!
|
||||||
// if larger city, food should be worth less!
|
// if larger city, food should be worth less!
|
||||||
internal fun autoAssignPopulation(foodWeight: Float = 1f) {
|
internal fun autoAssignPopulation(foodWeight: Float = 1f) {
|
||||||
if (getFreePopulation() == 0) return
|
for (i in 1..getFreePopulation()) {
|
||||||
|
|
||||||
//evaluate tiles
|
//evaluate tiles
|
||||||
val bestTile: TileInfo? = cityInfo.getTiles()
|
val bestTile: TileInfo? = cityInfo.getTiles()
|
||||||
.filter { it.aerialDistanceTo(cityInfo.getCenterTile()) <= 3 }
|
.filter { it.aerialDistanceTo(cityInfo.getCenterTile()) <= 3 }
|
||||||
@ -107,6 +106,7 @@ class PopulationManager {
|
|||||||
cityInfo.workedTiles = cityInfo.workedTiles.withItem(bestTile.position)
|
cityInfo.workedTiles = cityInfo.workedTiles.withItem(bestTile.position)
|
||||||
} else if (bestJob != null) specialistAllocations.add(bestJob, 1)
|
} else if (bestJob != null) specialistAllocations.add(bestJob, 1)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun unassignExtraPopulation() {
|
fun unassignExtraPopulation() {
|
||||||
for (tile in cityInfo.workedTiles.map { cityInfo.tileMap[it] }) {
|
for (tile in cityInfo.workedTiles.map { cityInfo.tileMap[it] }) {
|
||||||
|
@ -74,9 +74,7 @@ class DiplomacyScreen(val viewingCiv:CivilizationInfo):CameraStageBaseScreen() {
|
|||||||
|
|
||||||
leftSideTable.add(civIndicator).row()
|
leftSideTable.add(civIndicator).row()
|
||||||
|
|
||||||
civIndicator.onClick {
|
civIndicator.onClick { updateRightSide(civ) }
|
||||||
updateRightSide(civ)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user