mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-22 05:41:11 +07:00
Resolved #2638 - Auto-assign of population no longer "double books" tiles
This commit is contained in:
@ -74,22 +74,22 @@ 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
|
if (getFreePopulation() == 0) return
|
||||||
|
|
||||||
//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 }
|
||||||
.filterNot { cityInfo.workedTiles.contains(it.position) || cityInfo.location==it.position}
|
.filterNot { it.isWorked() || cityInfo.location == it.position }
|
||||||
.maxBy { Automation.rankTileForCityWork(it,cityInfo, foodWeight) }
|
.maxBy { Automation.rankTileForCityWork(it, cityInfo, foodWeight) }
|
||||||
val valueBestTile = if(bestTile==null) 0f
|
val valueBestTile = if (bestTile == null) 0f
|
||||||
else Automation.rankTileForCityWork(bestTile, cityInfo, foodWeight)
|
else Automation.rankTileForCityWork(bestTile, cityInfo, foodWeight)
|
||||||
|
|
||||||
//evaluate specialists
|
//evaluate specialists
|
||||||
val maxSpecialistsMap = getMaxSpecialists().toHashMap()
|
val maxSpecialistsMap = getMaxSpecialists().toHashMap()
|
||||||
val policies = cityInfo.civInfo.policies.adoptedPolicies
|
val policies = cityInfo.civInfo.policies.adoptedPolicies
|
||||||
val bestJob: Stat? = specialists.toHashMap()
|
val bestJob: Stat? = specialists.toHashMap()
|
||||||
.filter {maxSpecialistsMap.containsKey(it.key) && it.value < maxSpecialistsMap[it.key]!!}
|
.filter { maxSpecialistsMap.containsKey(it.key) && it.value < maxSpecialistsMap[it.key]!! }
|
||||||
.map {it.key}
|
.map { it.key }
|
||||||
.maxBy { Automation.rankSpecialist(cityInfo.cityStats.getStatsOfSpecialist(it, policies), cityInfo) }
|
.maxBy { Automation.rankSpecialist(cityInfo.cityStats.getStatsOfSpecialist(it, policies), cityInfo) }
|
||||||
var valueBestSpecialist = 0f
|
var valueBestSpecialist = 0f
|
||||||
if (bestJob != null) {
|
if (bestJob != null) {
|
||||||
@ -110,7 +110,7 @@ class PopulationManager {
|
|||||||
|
|
||||||
fun unassignExtraPopulation() {
|
fun unassignExtraPopulation() {
|
||||||
for(tile in cityInfo.workedTiles.map { cityInfo.tileMap[it] }) {
|
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)
|
cityInfo.workedTiles = cityInfo.workedTiles.withoutItem(tile.position)
|
||||||
if (tile.aerialDistanceTo(cityInfo.getCenterTile()) > 3)
|
if (tile.aerialDistanceTo(cityInfo.getCenterTile()) > 3)
|
||||||
cityInfo.workedTiles = cityInfo.workedTiles.withoutItem(tile.position)
|
cityInfo.workedTiles = cityInfo.workedTiles.withoutItem(tile.position)
|
||||||
|
@ -56,7 +56,8 @@ class Technology {
|
|||||||
lineList += " * " + wonder.name.tr() + " (" + wonder.getShortDescription(ruleset) + ")"
|
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()
|
if (revealedResource != null) lineList += "Reveals [$revealedResource] on the map".tr()
|
||||||
|
|
||||||
val tileImprovements = ruleset.tileImprovements.values.filter { it.techRequired == name }
|
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 }
|
if(city.civInfo.cities.filterNot { it==city }
|
||||||
.any { it.workedTiles.contains(selectedTile.position) }) {
|
.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)){
|
if(city.workedTiles.contains(selectedTile.position)){
|
||||||
|
@ -39,8 +39,7 @@ class CityTileGroup(private val city: CityInfo, tileInfo: TileInfo, tileSetStrin
|
|||||||
baseLayerGroup.color.a = 0.5f
|
baseLayerGroup.color.a = 0.5f
|
||||||
}
|
}
|
||||||
|
|
||||||
city.civInfo.cities.filterNot { it == city } // worked by another city
|
tileInfo.isWorked() && tileInfo.getWorkingCity()!=city -> {
|
||||||
.any { it.workedTiles.contains(tileInfo.position) } -> {
|
|
||||||
// Don't fade out, but don't add a population icon either.
|
// Don't fade out, but don't add a population icon either.
|
||||||
baseLayerGroup.color.a = 0.5f
|
baseLayerGroup.color.a = 0.5f
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user