Resolved #2638 - Auto-assign of population no longer "double books" tiles
This commit is contained in:
parent
0678e77487
commit
eb6a11cccb
4 changed files with 11 additions and 11 deletions
|
@ -74,22 +74,22 @@ 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
|
||||
if (getFreePopulation() == 0) return
|
||||
|
||||
//evaluate tiles
|
||||
val bestTile: TileInfo? = cityInfo.getTiles()
|
||||
.filter { it.aerialDistanceTo(cityInfo.getCenterTile()) <= 3 }
|
||||
.filterNot { cityInfo.workedTiles.contains(it.position) || cityInfo.location==it.position}
|
||||
.maxBy { Automation.rankTileForCityWork(it,cityInfo, foodWeight) }
|
||||
val valueBestTile = if(bestTile==null) 0f
|
||||
.filterNot { it.isWorked() || cityInfo.location == it.position }
|
||||
.maxBy { Automation.rankTileForCityWork(it, cityInfo, foodWeight) }
|
||||
val valueBestTile = if (bestTile == null) 0f
|
||||
else Automation.rankTileForCityWork(bestTile, cityInfo, foodWeight)
|
||||
|
||||
//evaluate specialists
|
||||
val maxSpecialistsMap = getMaxSpecialists().toHashMap()
|
||||
val policies = cityInfo.civInfo.policies.adoptedPolicies
|
||||
val bestJob: Stat? = specialists.toHashMap()
|
||||
.filter {maxSpecialistsMap.containsKey(it.key) && it.value < maxSpecialistsMap[it.key]!!}
|
||||
.map {it.key}
|
||||
.filter { maxSpecialistsMap.containsKey(it.key) && it.value < maxSpecialistsMap[it.key]!! }
|
||||
.map { it.key }
|
||||
.maxBy { Automation.rankSpecialist(cityInfo.cityStats.getStatsOfSpecialist(it, policies), cityInfo) }
|
||||
var valueBestSpecialist = 0f
|
||||
if (bestJob != null) {
|
||||
|
@ -110,7 +110,7 @@ class PopulationManager {
|
|||
|
||||
fun unassignExtraPopulation() {
|
||||
for(tile in cityInfo.workedTiles.map { cityInfo.tileMap[it] }) {
|
||||
if (tile.getOwner() != cityInfo.civInfo)
|
||||
if (tile.getOwner() != cityInfo.civInfo || tile.getWorkingCity() != cityInfo)
|
||||
cityInfo.workedTiles = cityInfo.workedTiles.withoutItem(tile.position)
|
||||
if (tile.aerialDistanceTo(cityInfo.getCenterTile()) > 3)
|
||||
cityInfo.workedTiles = cityInfo.workedTiles.withoutItem(tile.position)
|
||||
|
|
|
@ -56,7 +56,8 @@ class Technology {
|
|||
lineList += " * " + wonder.name.tr() + " (" + wonder.getShortDescription(ruleset) + ")"
|
||||
}
|
||||
|
||||
val revealedResource = ruleset.tileResources.values.filter { it.revealedBy == name }.map { it.name }.firstOrNull() // can only be one
|
||||
val revealedResource = ruleset.tileResources.values.filter { it.revealedBy == name }
|
||||
.map { it.name }.firstOrNull() // can only be one
|
||||
if (revealedResource != null) lineList += "Reveals [$revealedResource] on the map".tr()
|
||||
|
||||
val tileImprovements = ruleset.tileImprovements.values.filter { it.techRequired == name }
|
||||
|
|
|
@ -53,7 +53,7 @@ class CityScreenTileTable(val cityScreen: CityScreen): Table(){
|
|||
|
||||
if(city.civInfo.cities.filterNot { it==city }
|
||||
.any { it.workedTiles.contains(selectedTile.position) }) {
|
||||
innerTable.add("Worked by [${selectedTile.getCity()!!.name}]".toLabel()).row()
|
||||
innerTable.add("Worked by [${selectedTile.getWorkingCity()!!.name}]".toLabel()).row()
|
||||
}
|
||||
|
||||
if(city.workedTiles.contains(selectedTile.position)){
|
||||
|
|
|
@ -39,8 +39,7 @@ class CityTileGroup(private val city: CityInfo, tileInfo: TileInfo, tileSetStrin
|
|||
baseLayerGroup.color.a = 0.5f
|
||||
}
|
||||
|
||||
city.civInfo.cities.filterNot { it == city } // worked by another city
|
||||
.any { it.workedTiles.contains(tileInfo.position) } -> {
|
||||
tileInfo.isWorked() && tileInfo.getWorkingCity()!=city -> {
|
||||
// Don't fade out, but don't add a population icon either.
|
||||
baseLayerGroup.color.a = 0.5f
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue