mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 22:06:05 -04:00
Reassign population after selling a specialist-providing building
This commit is contained in:
parent
d3ba68f7d3
commit
4578994adf
@ -599,11 +599,12 @@ class CityInfo {
|
||||
fun getGoldForSellingBuilding(buildingName:String) = getRuleset().buildings[buildingName]!!.cost / 10
|
||||
|
||||
fun sellBuilding(buildingName:String) {
|
||||
cityConstructions.builtBuildings.remove(buildingName)
|
||||
cityConstructions.removeBuilding(buildingName)
|
||||
civInfo.gold += getGoldForSellingBuilding(buildingName)
|
||||
hasSoldBuildingThisTurn = true
|
||||
|
||||
population.unassignExtraPopulation() // If the building provided specialists, release them to other work
|
||||
population.autoAssignPopulation()
|
||||
cityStats.update()
|
||||
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 larger city, food should be worth less!
|
||||
internal fun autoAssignPopulation(foodWeight: Float = 1f) {
|
||||
if (getFreePopulation() == 0) return
|
||||
|
||||
for (i in 1..getFreePopulation()) {
|
||||
//evaluate tiles
|
||||
val bestTile: TileInfo? = cityInfo.getTiles()
|
||||
.filter { it.aerialDistanceTo(cityInfo.getCenterTile()) <= 3 }
|
||||
@ -107,6 +106,7 @@ class PopulationManager {
|
||||
cityInfo.workedTiles = cityInfo.workedTiles.withItem(bestTile.position)
|
||||
} else if (bestJob != null) specialistAllocations.add(bestJob, 1)
|
||||
}
|
||||
}
|
||||
|
||||
fun unassignExtraPopulation() {
|
||||
for (tile in cityInfo.workedTiles.map { cityInfo.tileMap[it] }) {
|
||||
|
@ -74,9 +74,7 @@ class DiplomacyScreen(val viewingCiv:CivilizationInfo):CameraStageBaseScreen() {
|
||||
|
||||
leftSideTable.add(civIndicator).row()
|
||||
|
||||
civIndicator.onClick {
|
||||
updateRightSide(civ)
|
||||
}
|
||||
civIndicator.onClick { updateRightSide(civ) }
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user