From b012fd0df8f65be0611687b155d3d5afa25296c5 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Sat, 9 May 2020 22:01:15 +0300 Subject: [PATCH] Fixed "isWorked" not registering for tiles worked not by the owning city --- build.gradle | 4 ++-- .../com/unciv/logic/automation/WorkerAutomation.kt | 6 +++--- core/src/com/unciv/logic/map/TileInfo.kt | 12 ++++++++---- core/src/com/unciv/ui/cityscreen/CityTileGroup.kt | 4 ++-- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/build.gradle b/build.gradle index c00eb636df..2068d19bd4 100644 --- a/build.gradle +++ b/build.gradle @@ -33,8 +33,8 @@ allprojects { version = '1.0.1' ext { appName = "Unciv" - appCodeNumber = 425 - appVersion = "3.8.7" + appCodeNumber = 426 + appVersion = "3.8.7-patch1" gdxVersion = '1.9.10' roboVMVersion = '2.3.1' diff --git a/core/src/com/unciv/logic/automation/WorkerAutomation.kt b/core/src/com/unciv/logic/automation/WorkerAutomation.kt index 368d1df3f3..b2623f9309 100644 --- a/core/src/com/unciv/logic/automation/WorkerAutomation.kt +++ b/core/src/com/unciv/logic/automation/WorkerAutomation.kt @@ -162,15 +162,15 @@ class WorkerAutomation(val unit: MapUnit) { fun getPriority(tileInfo: TileInfo, civInfo: CivilizationInfo): Int { var priority = 0 - if (tileInfo.getOwner() == civInfo){ + if (tileInfo.getOwner() == civInfo) { priority += 2 if (tileInfo.isWorked()) priority += 3 } // 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 - if (priority!=0 && tileInfo.hasViewableResource(civInfo)) priority += 1 + if (priority != 0 && tileInfo.hasViewableResource(civInfo)) priority += 1 return priority } diff --git a/core/src/com/unciv/logic/map/TileInfo.kt b/core/src/com/unciv/logic/map/TileInfo.kt index 7edd990ad6..342064937e 100644 --- a/core/src/com/unciv/logic/map/TileInfo.kt +++ b/core/src/com/unciv/logic/map/TileInfo.kt @@ -147,15 +147,19 @@ open class TileInfo { fun getTerrainFeature(): Terrain? = 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 { - val city = getCity() - return city!=null && city.workedTiles.contains(position) + return getWorkingCity() != null } fun isLocked(): Boolean{ - val city = getCity() - return city!=null && city.lockedTiles.contains(position) + val workingCity = getWorkingCity() + return workingCity!=null && workingCity.lockedTiles.contains(position) } fun getTileStats(observingCiv: CivilizationInfo): Stats = getTileStats(getCity(), observingCiv) diff --git a/core/src/com/unciv/ui/cityscreen/CityTileGroup.kt b/core/src/com/unciv/ui/cityscreen/CityTileGroup.kt index 7a7aa9a974..a253dfd4e5 100644 --- a/core/src/com/unciv/ui/cityscreen/CityTileGroup.kt +++ b/core/src/com/unciv/ui/cityscreen/CityTileGroup.kt @@ -25,7 +25,7 @@ class CityTileGroup(private val city: CityInfo, tileInfo: TileInfo, tileSetStrin } 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... 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) resourceImage?.setColor(1f, 1f, 1f, 0.5f) cityImage?.setColor(1f, 1f, 1f, 0.5f)