Fixed bug where cities would not "recognize" tiles on the first turn

This commit is contained in:
Yair Morgenstern 2018-05-06 10:52:29 +03:00
parent f0cf29e6b9
commit 75f4301004
2 changed files with 4 additions and 5 deletions

View File

@ -33,14 +33,14 @@ class CityInfo {
fun getCenterTile(): TileInfo = tileMap[location]
fun getTiles(): List<TileInfo> = tiles.map { tileMap[it] }
fun getTilesInRange(): List<TileInfo> = getCenterTile().getTilesInDistance( 3).filter { civInfo == it.getOwner() }
fun getTilesInRange(): List<TileInfo> = getCenterTile().getTilesInDistance( 3)
// Remove resources required by buildings
fun getCityResources(): Counter<TileResource> {
val cityResources = Counter<TileResource>()
for (tileInfo in getTilesInRange().filter { it.resource != null }) {
for (tileInfo in getTiles().filter { it.resource != null }) {
val resource = tileInfo.tileResource
if (resource.improvement == tileInfo.improvement || tileInfo.isCityCenter())
cityResources.add(resource, 1)
@ -77,7 +77,6 @@ class CityInfo {
constructor(civInfo: CivilizationInfo, cityLocation: Vector2) {
this.civInfo = civInfo
setTransients()
@ -94,7 +93,6 @@ class CityInfo {
expansion.reset()
val tile = getCenterTile()
tile.roadStatus = RoadStatus.Railroad
if (listOf("Forest", "Jungle", "Marsh").contains(tile.terrainFeature))

View File

@ -151,9 +151,10 @@ class Building : NamedStats(), IConstruction, ICivilopedia {
if (requiredNearbyImprovedResources != null) {
val containsResourceWithImprovement = construction.cityInfo.getTilesInRange()
.any {
it.resource != null
it.resource != null
&& requiredNearbyImprovedResources!!.contains(it.resource!!)
&& it.tileResource.improvement == it.improvement
&& it.getOwner() == civInfo
}
if (!containsResourceWithImprovement) return false
}