mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-26 05:14:32 -04:00
Fixed unassigning extra specialists, and activate that at the end of each turn
This commit is contained in:
parent
3f97daf1da
commit
1564502fc2
@ -332,12 +332,12 @@ class CityInfo {
|
|||||||
expansion.nextTurn(stats.culture)
|
expansion.nextTurn(stats.culture)
|
||||||
if (isBeingRazed) {
|
if (isBeingRazed) {
|
||||||
population.population--
|
population.population--
|
||||||
if (population.population <= 0) { // there are strange cases where we geet to -1
|
if (population.population <= 0) { // there are strange cases where we get to -1
|
||||||
civInfo.addNotification("[$name] has been razed to the ground!", location, Color.RED)
|
civInfo.addNotification("[$name] has been razed to the ground!", location, Color.RED)
|
||||||
destroyCity()
|
destroyCity()
|
||||||
} else {//if not razed yet:
|
} else { //if not razed yet:
|
||||||
if (population.foodStored >= population.getFoodToNextPopulation()) {//if surplus in the granary...
|
if (population.foodStored >= population.getFoodToNextPopulation()) { //if surplus in the granary...
|
||||||
population.foodStored = population.getFoodToNextPopulation() - 1//...reduce below the new growth treshold
|
population.foodStored = population.getFoodToNextPopulation() - 1 //...reduce below the new growth threshold
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else population.nextTurn(foodForNextTurn())
|
} else population.nextTurn(foodForNextTurn())
|
||||||
|
@ -116,6 +116,13 @@ class PopulationManager {
|
|||||||
cityInfo.workedTiles = cityInfo.workedTiles.withoutItem(tile.position)
|
cityInfo.workedTiles = cityInfo.workedTiles.withoutItem(tile.position)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// unassign specialists that cannot be (e.g. the city was captured and one of the specialist buildings was destroyed)
|
||||||
|
val maxSpecialists = getMaxSpecialists().toHashMap()
|
||||||
|
val specialistsHashmap = specialists.toHashMap()
|
||||||
|
for(entry in maxSpecialists)
|
||||||
|
if(specialistsHashmap[entry.key]!! > entry.value)
|
||||||
|
specialists.add(entry.key,maxSpecialists[entry.key]!! - specialistsHashmap[entry.key]!!)
|
||||||
|
|
||||||
while (getFreePopulation()<0) {
|
while (getFreePopulation()<0) {
|
||||||
//evaluate tiles
|
//evaluate tiles
|
||||||
val worstWorkedTile: TileInfo? = if(cityInfo.workedTiles.isEmpty()) null
|
val worstWorkedTile: TileInfo? = if(cityInfo.workedTiles.isEmpty()) null
|
||||||
@ -148,12 +155,6 @@ class PopulationManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// unassign specialists that cannot be (e.g. the city was captured and one of the specialist buildings was destroyed)
|
|
||||||
val maxSpecialists = getMaxSpecialists().toHashMap()
|
|
||||||
val specialistsHashmap = specialists.toHashMap()
|
|
||||||
for(entry in maxSpecialists)
|
|
||||||
if(specialistsHashmap[entry.key]!! > entry.value)
|
|
||||||
specialists.add(entry.key,specialistsHashmap[entry.key]!! - maxSpecialists[entry.key]!!)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getMaxSpecialists(): Stats {
|
fun getMaxSpecialists(): Stats {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user