mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-28 06:16:37 -04:00
Worker automation uses more resource.
This commit is contained in:
parent
48efb4dcd2
commit
922a29e60f
@ -30,7 +30,7 @@ class WorkerAutomation(val unit: MapUnit) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (tile.improvementInProgress == null && tile.isLand()) {
|
if (tile.improvementInProgress == null && tile.isLand()) {
|
||||||
val improvement = chooseImprovement(tile)
|
val improvement = chooseImprovement(tile, unit.civInfo)
|
||||||
if (tile.canBuildImprovement(improvement, unit.civInfo)) {
|
if (tile.canBuildImprovement(improvement, unit.civInfo)) {
|
||||||
// What if we're stuck on this tile but can't build there?
|
// What if we're stuck on this tile but can't build there?
|
||||||
tile.startWorkingOnImprovement(improvement, unit.civInfo)
|
tile.startWorkingOnImprovement(improvement, unit.civInfo)
|
||||||
@ -98,10 +98,10 @@ class WorkerAutomation(val unit: MapUnit) {
|
|||||||
val workableTiles = currentTile.getTilesInDistance(4)
|
val workableTiles = currentTile.getTilesInDistance(4)
|
||||||
.filter {
|
.filter {
|
||||||
(it.civilianUnit== null || it == currentTile)
|
(it.civilianUnit== null || it == currentTile)
|
||||||
&& it.improvement == null
|
&& (it.improvement == null || (it.hasViewableResource(unit.civInfo) && it.getTileResource().improvement != it.improvement))
|
||||||
&& it.isLand()
|
&& it.isLand()
|
||||||
&& !it.getBaseTerrain().impassable
|
&& !it.getBaseTerrain().impassable
|
||||||
&& it.canBuildImprovement(chooseImprovement(it), unit.civInfo)
|
&& it.canBuildImprovement(chooseImprovement(it, unit.civInfo), unit.civInfo)
|
||||||
&& {val city=it.getCity(); city==null || it.getCity()?.civInfo == unit.civInfo}() // don't work tiles belonging to another civ
|
&& {val city=it.getCity(); city==null || it.getCity()?.civInfo == unit.civInfo}() // don't work tiles belonging to another civ
|
||||||
}.sortedByDescending { getPriority(it, unit.civInfo) }.toMutableList()
|
}.sortedByDescending { getPriority(it, unit.civInfo) }.toMutableList()
|
||||||
|
|
||||||
@ -131,14 +131,21 @@ class WorkerAutomation(val unit: MapUnit) {
|
|||||||
return priority
|
return priority
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun chooseImprovement(tile: TileInfo): TileImprovement {
|
private fun chooseImprovement(tile: TileInfo, civInfo: CivilizationInfo): TileImprovement {
|
||||||
|
val improvementStringForResource : String ?= when {
|
||||||
|
tile.resource == null || !tile.hasViewableResource(civInfo) -> null
|
||||||
|
tile.terrainFeature == "Marsh" -> "Remove Marsh"
|
||||||
|
tile.terrainFeature == "Jungle" -> "Remove Jungle"
|
||||||
|
tile.terrainFeature == "Forest" && tile.getTileResource().improvement!="Camp" -> "Remove Forest"
|
||||||
|
else -> tile.getTileResource().improvement
|
||||||
|
}
|
||||||
|
|
||||||
val improvementString = when {
|
val improvementString = when {
|
||||||
tile.improvementInProgress != null -> tile.improvementInProgress
|
tile.improvementInProgress != null -> tile.improvementInProgress
|
||||||
|
improvementStringForResource != null -> improvementStringForResource
|
||||||
tile.terrainFeature == "Jungle" -> "Trading post"
|
tile.terrainFeature == "Jungle" -> "Trading post"
|
||||||
tile.terrainFeature == "Marsh" -> "Remove Marsh"
|
tile.terrainFeature == "Marsh" -> "Remove Marsh"
|
||||||
tile.terrainFeature == "Forest" &&
|
tile.terrainFeature == "Forest" -> "Lumber mill"
|
||||||
(tile.resource == null || tile.getTileResource().improvement!="Camp") -> "Lumber mill"
|
|
||||||
tile.resource != null -> tile.getTileResource().improvement
|
|
||||||
tile.baseTerrain == "Hill" -> "Mine"
|
tile.baseTerrain == "Hill" -> "Mine"
|
||||||
tile.baseTerrain in listOf("Grassland","Desert","Plains") -> "Farm"
|
tile.baseTerrain in listOf("Grassland","Desert","Plains") -> "Farm"
|
||||||
tile.baseTerrain == "Tundra" -> "Trading post"
|
tile.baseTerrain == "Tundra" -> "Trading post"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user