Fixed "isWorked" not registering for tiles worked not by the owning city

This commit is contained in:
Yair Morgenstern 2020-05-09 22:01:15 +03:00
parent 6a7773730b
commit b012fd0df8
4 changed files with 15 additions and 11 deletions

View File

@ -33,8 +33,8 @@ allprojects {
version = '1.0.1' version = '1.0.1'
ext { ext {
appName = "Unciv" appName = "Unciv"
appCodeNumber = 425 appCodeNumber = 426
appVersion = "3.8.7" appVersion = "3.8.7-patch1"
gdxVersion = '1.9.10' gdxVersion = '1.9.10'
roboVMVersion = '2.3.1' roboVMVersion = '2.3.1'

View File

@ -162,15 +162,15 @@ class WorkerAutomation(val unit: MapUnit) {
fun getPriority(tileInfo: TileInfo, civInfo: CivilizationInfo): Int { fun getPriority(tileInfo: TileInfo, civInfo: CivilizationInfo): Int {
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.isWorked()) 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 })
priority += 1 priority += 1
if (priority!=0 && tileInfo.hasViewableResource(civInfo)) priority += 1 if (priority != 0 && tileInfo.hasViewableResource(civInfo)) priority += 1
return priority return priority
} }

View File

@ -147,15 +147,19 @@ open class TileInfo {
fun getTerrainFeature(): Terrain? = fun getTerrainFeature(): Terrain? =
if (terrainFeature == null) null else ruleset.terrains[terrainFeature!!] if (terrainFeature == null) null else ruleset.terrains[terrainFeature!!]
fun getWorkingCity():CityInfo? {
val civInfo = getOwner()
if (civInfo == null) return null
return civInfo.cities.firstOrNull { it.workedTiles.contains(position) }
}
fun isWorked(): Boolean { fun isWorked(): Boolean {
val city = getCity() return getWorkingCity() != null
return city!=null && city.workedTiles.contains(position)
} }
fun isLocked(): Boolean{ fun isLocked(): Boolean{
val city = getCity() val workingCity = getWorkingCity()
return city!=null && city.lockedTiles.contains(position) return workingCity!=null && workingCity.lockedTiles.contains(position)
} }
fun getTileStats(observingCiv: CivilizationInfo): Stats = getTileStats(getCity(), observingCiv) fun getTileStats(observingCiv: CivilizationInfo): Stats = getTileStats(getCity(), observingCiv)

View File

@ -25,7 +25,7 @@ class CityTileGroup(private val city: CityInfo, tileInfo: TileInfo, tileSetStrin
} }
fun update() { fun update() {
super.update(city.civInfo,true) super.update(city.civInfo, true)
// this needs to happen on update, because we can buy tiles, which changes the definition of the bought tiles... // this needs to happen on update, because we can buy tiles, which changes the definition of the bought tiles...
when { when {
@ -56,7 +56,7 @@ class CityTileGroup(private val city: CityInfo, tileInfo: TileInfo, tileSetStrin
} }
} }
terrainFeatureLayerGroup.color.a=0.5f terrainFeatureLayerGroup.color.a = 0.5f
icons.improvementIcon?.setColor(1f, 1f, 1f, 0.5f) icons.improvementIcon?.setColor(1f, 1f, 1f, 0.5f)
resourceImage?.setColor(1f, 1f, 1f, 0.5f) resourceImage?.setColor(1f, 1f, 1f, 0.5f)
cityImage?.setColor(1f, 1f, 1f, 0.5f) cityImage?.setColor(1f, 1f, 1f, 0.5f)