mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 13:55:54 -04:00
Added TileInfo.providsYield() - this will help us later
This commit is contained in:
parent
cdc7739784
commit
755586eecd
@ -169,7 +169,7 @@ class WorkerAutomation(val unit: MapUnit) {
|
|||||||
var priority = 0
|
var priority = 0
|
||||||
if (tileInfo.getOwner() == civInfo) {
|
if (tileInfo.getOwner() == civInfo) {
|
||||||
priority += 2
|
priority += 2
|
||||||
if (tileInfo.isWorked()) priority += 3
|
if (tileInfo.providesYield()) priority += 3
|
||||||
}
|
}
|
||||||
// give a minor priority to tiles that we could expand onto
|
// give a minor priority to tiles that we could expand onto
|
||||||
else if (tileInfo.getOwner() == null && tileInfo.neighbors.any { it.getOwner() == civInfo })
|
else if (tileInfo.getOwner() == null && tileInfo.neighbors.any { it.getOwner() == civInfo })
|
||||||
|
@ -4,7 +4,6 @@ import com.badlogic.gdx.graphics.Color
|
|||||||
import com.unciv.logic.automation.Automation
|
import com.unciv.logic.automation.Automation
|
||||||
import com.unciv.logic.map.TileInfo
|
import com.unciv.logic.map.TileInfo
|
||||||
import com.unciv.models.Counter
|
import com.unciv.models.Counter
|
||||||
import com.unciv.models.stats.Stats
|
|
||||||
import com.unciv.ui.utils.withItem
|
import com.unciv.ui.utils.withItem
|
||||||
import com.unciv.ui.utils.withoutItem
|
import com.unciv.ui.utils.withoutItem
|
||||||
import kotlin.math.floor
|
import kotlin.math.floor
|
||||||
@ -80,15 +79,15 @@ class PopulationManager {
|
|||||||
//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 { it.isWorked() || cityInfo.location == it.position }
|
.filterNot { it.providesYield() }
|
||||||
.maxBy { Automation.rankTileForCityWork(it, cityInfo, foodWeight) }
|
.maxByOrNull { 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)
|
||||||
|
|
||||||
val bestJob: String? = getMaxSpecialists()
|
val bestJob: String? = getMaxSpecialists()
|
||||||
.filter { specialistAllocations[it.key]!! < it.value }
|
.filter { specialistAllocations[it.key]!! < it.value }
|
||||||
.map { it.key }
|
.map { it.key }
|
||||||
.maxBy { Automation.rankSpecialist(getStatsOfSpecialist(it), cityInfo) }
|
.maxByOrNull { Automation.rankSpecialist(getStatsOfSpecialist(it), cityInfo) }
|
||||||
|
|
||||||
|
|
||||||
var valueBestSpecialist = 0f
|
var valueBestSpecialist = 0f
|
||||||
@ -127,7 +126,7 @@ class PopulationManager {
|
|||||||
else {
|
else {
|
||||||
cityInfo.workedTiles.asSequence()
|
cityInfo.workedTiles.asSequence()
|
||||||
.map { cityInfo.tileMap[it] }
|
.map { cityInfo.tileMap[it] }
|
||||||
.minBy {
|
.minByOrNull {
|
||||||
Automation.rankTileForCityWork(it, cityInfo)
|
Automation.rankTileForCityWork(it, cityInfo)
|
||||||
+(if (it.isLocked()) 10 else 0)
|
+(if (it.isLocked()) 10 else 0)
|
||||||
}!!
|
}!!
|
||||||
@ -137,7 +136,7 @@ class PopulationManager {
|
|||||||
|
|
||||||
//evaluate specialists
|
//evaluate specialists
|
||||||
val worstJob: String? = specialistAllocations.keys
|
val worstJob: String? = specialistAllocations.keys
|
||||||
.minBy { Automation.rankSpecialist(getStatsOfSpecialist(it), cityInfo) }
|
.minByOrNull { Automation.rankSpecialist(getStatsOfSpecialist(it), cityInfo) }
|
||||||
var valueWorstSpecialist = 0f
|
var valueWorstSpecialist = 0f
|
||||||
if (worstJob != null)
|
if (worstJob != null)
|
||||||
valueWorstSpecialist = Automation.rankSpecialist(getStatsOfSpecialist(worstJob), cityInfo)
|
valueWorstSpecialist = Automation.rankSpecialist(getStatsOfSpecialist(worstJob), cityInfo)
|
||||||
|
@ -21,8 +21,10 @@ class MapUnit {
|
|||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
lateinit var civInfo: CivilizationInfo
|
lateinit var civInfo: CivilizationInfo
|
||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
lateinit var baseUnit: BaseUnit
|
lateinit var baseUnit: BaseUnit
|
||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
internal lateinit var currentTile: TileInfo
|
internal lateinit var currentTile: TileInfo
|
||||||
|
|
||||||
@ -40,22 +42,31 @@ class MapUnit {
|
|||||||
// which in turn is a component of getShortestPath and canReach
|
// which in turn is a component of getShortestPath and canReach
|
||||||
@Transient
|
@Transient
|
||||||
var ignoresTerrainCost = false
|
var ignoresTerrainCost = false
|
||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
var allTilesCosts1 = false
|
var allTilesCosts1 = false
|
||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
var canPassThroughImpassableTiles = false
|
var canPassThroughImpassableTiles = false
|
||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
var roughTerrainPenalty = false
|
var roughTerrainPenalty = false
|
||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
var doubleMovementInCoast = false
|
var doubleMovementInCoast = false
|
||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
var doubleMovementInForestAndJungle = false
|
var doubleMovementInForestAndJungle = false
|
||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
var doubleMovementInSnowTundraAndHills = false
|
var doubleMovementInSnowTundraAndHills = false
|
||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
var canEnterIceTiles = false
|
var canEnterIceTiles = false
|
||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
var cannotEnterOceanTiles = false
|
var cannotEnterOceanTiles = false
|
||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
var cannotEnterOceanTilesUntilAstronomy = false
|
var cannotEnterOceanTilesUntilAstronomy = false
|
||||||
|
|
||||||
@ -75,12 +86,8 @@ class MapUnit {
|
|||||||
* Name which should be displayed in UI
|
* Name which should be displayed in UI
|
||||||
*/
|
*/
|
||||||
fun displayName(): String {
|
fun displayName(): String {
|
||||||
return if(instanceName == null) {
|
return if (instanceName == null) name
|
||||||
name
|
else "$instanceName ({$name})"
|
||||||
}
|
|
||||||
else {
|
|
||||||
"$instanceName ({$name})"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var currentMovement: Float = 0f
|
var currentMovement: Float = 0f
|
||||||
@ -362,7 +369,7 @@ class MapUnit {
|
|||||||
val destination = action!!.replace("moveTo ", "").split(",").dropLastWhile { it.isEmpty() }.toTypedArray()
|
val destination = action!!.replace("moveTo ", "").split(",").dropLastWhile { it.isEmpty() }.toTypedArray()
|
||||||
val destinationVector = Vector2(destination[0].toFloat(), destination[1].toFloat())
|
val destinationVector = Vector2(destination[0].toFloat(), destination[1].toFloat())
|
||||||
val destinationTile = currentTile.tileMap[destinationVector]
|
val destinationTile = currentTile.tileMap[destinationVector]
|
||||||
if (!movement.canReach(destinationTile)){ // That tile that we were moving towards is now unreachable -
|
if (!movement.canReach(destinationTile)) { // That tile that we were moving towards is now unreachable -
|
||||||
// for instance we headed towards an unknown tile and it's apparently unreachable
|
// for instance we headed towards an unknown tile and it's apparently unreachable
|
||||||
action = null
|
action = null
|
||||||
return
|
return
|
||||||
@ -419,7 +426,7 @@ class MapUnit {
|
|||||||
|
|
||||||
private fun tryProvideProductionToClosestCity() {
|
private fun tryProvideProductionToClosestCity() {
|
||||||
val tile = getTile()
|
val tile = getTile()
|
||||||
val closestCity = civInfo.cities.minBy { it.getCenterTile().aerialDistanceTo(tile) }
|
val closestCity = civInfo.cities.minByOrNull { it.getCenterTile().aerialDistanceTo(tile) }
|
||||||
if (closestCity == null) return
|
if (closestCity == null) return
|
||||||
val distance = closestCity.getCenterTile().aerialDistanceTo(tile)
|
val distance = closestCity.getCenterTile().aerialDistanceTo(tile)
|
||||||
var productionPointsToAdd = if (distance == 1) 20 else 20 - (distance - 2) * 5
|
var productionPointsToAdd = if (distance == 1) 20 else 20 - (distance - 2) * 5
|
||||||
@ -438,7 +445,7 @@ class MapUnit {
|
|||||||
|
|
||||||
if (hasUnique("+10 HP when healing")) amountToHealBy += 10
|
if (hasUnique("+10 HP when healing")) amountToHealBy += 10
|
||||||
val maxAdjacentHealingBonus = currentTile.getTilesInDistance(1)
|
val maxAdjacentHealingBonus = currentTile.getTilesInDistance(1)
|
||||||
.flatMap { it.getUnits().asSequence() }.map { it.adjacentHealingBonus() }.max()
|
.flatMap { it.getUnits().asSequence() }.map { it.adjacentHealingBonus() }.maxOrNull()
|
||||||
if (maxAdjacentHealingBonus != null)
|
if (maxAdjacentHealingBonus != null)
|
||||||
amountToHealBy += maxAdjacentHealingBonus
|
amountToHealBy += maxAdjacentHealingBonus
|
||||||
if (hasUnique("All healing effects doubled"))
|
if (hasUnique("All healing effects doubled"))
|
||||||
|
@ -219,6 +219,7 @@ open class TileInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun isWorked(): Boolean = getWorkingCity() != null
|
fun isWorked(): Boolean = getWorkingCity() != null
|
||||||
|
fun providesYield() = getCity() != null && (isCityCenter() || isWorked())
|
||||||
|
|
||||||
fun isLocked(): Boolean {
|
fun isLocked(): Boolean {
|
||||||
val workingCity = getWorkingCity()
|
val workingCity = getWorkingCity()
|
||||||
|
@ -203,7 +203,7 @@ class CityScreen(internal val city: CityInfo): CameraStageBaseScreen() {
|
|||||||
selectedTile = tileInfo
|
selectedTile = tileInfo
|
||||||
selectedConstruction = null
|
selectedConstruction = null
|
||||||
if (tileGroup.isWorkable && canChangeState) {
|
if (tileGroup.isWorkable && canChangeState) {
|
||||||
if (!tileInfo.isWorked() && city.population.getFreePopulation() > 0) {
|
if (!tileInfo.providesYield() && city.population.getFreePopulation() > 0) {
|
||||||
city.workedTiles.add(tileInfo.position)
|
city.workedTiles.add(tileInfo.position)
|
||||||
game.settings.addCompletedTutorialTask("Reassign worked tiles")
|
game.settings.addCompletedTutorialTask("Reassign worked tiles")
|
||||||
} else if (tileInfo.isWorked() && !tileInfo.isLocked())
|
} else if (tileInfo.isWorked() && !tileInfo.isLocked())
|
||||||
|
@ -74,11 +74,8 @@ class CityTileGroup(private val city: CityInfo, tileInfo: TileInfo, tileSetStrin
|
|||||||
yieldGroup.centerX(this)
|
yieldGroup.centerX(this)
|
||||||
yieldGroup.y = height * 0.25f - yieldGroup.height / 2
|
yieldGroup.y = height * 0.25f - yieldGroup.height / 2
|
||||||
|
|
||||||
if (tileInfo.isWorked()) {
|
if (tileInfo.providesYield()) yieldGroup.color = Color.WHITE
|
||||||
yieldGroup.color = Color.WHITE
|
else yieldGroup.color = Color.GRAY.cpy().apply { a = 0.5f }
|
||||||
} else if (!tileInfo.isCityCenter()) {
|
|
||||||
yieldGroup.color = Color.GRAY.cpy().apply { a = 0.5f }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updatePopulationIcon() {
|
private fun updatePopulationIcon() {
|
||||||
@ -88,8 +85,8 @@ class CityTileGroup(private val city: CityInfo, tileInfo: TileInfo, tileSetStrin
|
|||||||
populationIcon.setPosition(width / 2 - populationIcon.width / 2,
|
populationIcon.setPosition(width / 2 - populationIcon.width / 2,
|
||||||
height * 0.85f - populationIcon.height / 2)
|
height * 0.85f - populationIcon.height / 2)
|
||||||
|
|
||||||
if (tileInfo.isWorked()) populationIcon.color = Color.WHITE
|
if (tileInfo.providesYield()) populationIcon.color = Color.WHITE
|
||||||
else if (!tileInfo.isCityCenter()) populationIcon.color = Color.GRAY.cpy()
|
else populationIcon.color = Color.GRAY.cpy()
|
||||||
|
|
||||||
populationIcon.toFront()
|
populationIcon.toFront()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user