diff --git a/core/src/com/unciv/logic/city/CityStats.kt b/core/src/com/unciv/logic/city/CityStats.kt index 9364fb0f..b4e9f6aa 100644 --- a/core/src/com/unciv/logic/city/CityStats.kt +++ b/core/src/com/unciv/logic/city/CityStats.kt @@ -362,9 +362,11 @@ class CityStats { } fun isConnectedToCapital(roadType: RoadStatus): Boolean { - if (cityInfo.civInfo.cities.count() < 2) return false// first city! + if (cityInfo.civInfo.cities .count() < 2) return false// first city! - return cityInfo.isConnectedToCapital { it.contains(roadType.name) || it.contains("Harbor") } + // Railroad, or harbor from railroad + if (roadType == RoadStatus.Railroad) return cityInfo.isConnectedToCapital { it.any { it.contains("Railroad") } } + else return cityInfo.isConnectedToCapital() } //endregion diff --git a/core/src/com/unciv/logic/civilization/CapitalConnectionsFinder.kt b/core/src/com/unciv/logic/civilization/CapitalConnectionsFinder.kt index f1c351d6..3b58b995 100644 --- a/core/src/com/unciv/logic/civilization/CapitalConnectionsFinder.kt +++ b/core/src/com/unciv/logic/civilization/CapitalConnectionsFinder.kt @@ -19,7 +19,8 @@ class CapitalConnectionsFinder(private val civInfo: CivilizationInfo) { private val road = RoadStatus.Road.name private val railroad = RoadStatus.Railroad.name - private val harbor = "Harbor" + private val harborFromRoad = "Harbor-Road" + private val harborFromRailroad = "Harbor-Railroad" init { citiesReachedToMediums[civInfo.getCapital()] = hashSetOf("Start") @@ -36,8 +37,10 @@ class CapitalConnectionsFinder(private val civInfo: CivilizationInfo) { if (cityToConnectFrom.containsHarbor()) { checkHarbor(cityToConnectFrom) } - if (railroadIsResearched) { - checkRailroad(cityToConnectFrom) + if (railroadIsResearched){ + val mediumsReached= citiesReachedToMediums[cityToConnectFrom]!! + if(mediumsReached.contains("Start") || mediumsReached.contains(railroad) || mediumsReached.contains(harborFromRailroad)) + checkRailroad(cityToConnectFrom) // This is only relevant for city connection if there is an unbreaking line from the capital } if (theWheelIsResearched) { checkRoad(cityToConnectFrom) @@ -61,21 +64,22 @@ class CapitalConnectionsFinder(private val civInfo: CivilizationInfo) { check( cityToConnectFrom, transportType = railroad, - tileFilter = { tile -> tile.hasRailroad() || tile.isCityCenter() } + tileFilter = { tile -> tile.roadStatus == RoadStatus.Railroad || tile.isCityCenter() } ) } private fun checkHarbor(cityToConnectFrom: CityInfo) { check( cityToConnectFrom, - transportType = harbor, + transportType = if(cityToConnectFrom.wasPreviouslyReached("Railroad",null)) harborFromRailroad else harborFromRoad, + overridingTransportType = harborFromRailroad, tileFilter = { tile -> tile.isWater || tile.isCityCenter() }, cityFilter = { city -> city.containsHarbor() } ) } private fun CityInfo.containsHarbor() = - this.cityConstructions.containsBuildingOrEquivalent(harbor) + this.cityConstructions.containsBuildingOrEquivalent("Harbor") private fun check(cityToConnectFrom: CityInfo, transportType: String, diff --git a/core/src/com/unciv/logic/map/TileInfo.kt b/core/src/com/unciv/logic/map/TileInfo.kt index f9eeea8a..05450de7 100644 --- a/core/src/com/unciv/logic/map/TileInfo.kt +++ b/core/src/com/unciv/logic/map/TileInfo.kt @@ -447,8 +447,6 @@ open class TileInfo { fun hasConnection(civInfo: CivilizationInfo) = roadStatus != RoadStatus.None || forestOrJungleAreRoads(civInfo) - fun hasRailroad() = - roadStatus == RoadStatus.Railroad private fun forestOrJungleAreRoads(civInfo: CivilizationInfo) = civInfo.nation.forestsAndJunglesAreRoads