diff --git a/core/src/com/unciv/logic/automation/ConstructionAutomation.kt b/core/src/com/unciv/logic/automation/ConstructionAutomation.kt index ed36675f..60896456 100644 --- a/core/src/com/unciv/logic/automation/ConstructionAutomation.kt +++ b/core/src/com/unciv/logic/automation/ConstructionAutomation.kt @@ -27,8 +27,9 @@ class ConstructionAutomation(val cityConstructions: CityConstructions){ val militaryUnits = civUnits.filter { !it.type.isCivilian()}.count() val workers = civUnits.filter { it.hasUnique(Constants.workerUnique) }.count().toFloat() val cities = civInfo.cities.size - val canBuildWorkboat = cityInfo.cityConstructions.getConstructableUnits().map { it.name }.contains("Work Boats") - && !cityInfo.getTiles().any { it.civilianUnit?.name == "Work Boats" } + val canBuildWorkboat = cityInfo.cityConstructions.getConstructableUnits() + .any { it.uniques.contains("May create improvements on water resources") } + && !cityInfo.getTiles().any { it.civilianUnit?.hasUnique("May create improvements on water resources")==true } val needWorkboat = canBuildWorkboat && cityInfo.getTiles().any { it.isWater && it.hasViewableResource(civInfo) && it.improvement == null } diff --git a/core/src/com/unciv/logic/automation/WorkerAutomation.kt b/core/src/com/unciv/logic/automation/WorkerAutomation.kt index ea78e45e..c42bf81c 100644 --- a/core/src/com/unciv/logic/automation/WorkerAutomation.kt +++ b/core/src/com/unciv/logic/automation/WorkerAutomation.kt @@ -211,7 +211,7 @@ class WorkerAutomation(val unit: MapUnit) { else -> null } if (improvementString == null) return null - return unit.civInfo.gameInfo.ruleSet.tileImprovements[improvementString]!! + return unit.civInfo.gameInfo.ruleSet.tileImprovements[improvementString] // For mods, the tile improvement may not exist, so don't assume. } private fun isImprovementOnFeatureAllowed(tile: TileInfo, civInfo: CivilizationInfo): Boolean { // Old hardcoded logic amounts to: diff --git a/core/src/com/unciv/logic/civilization/TechManager.kt b/core/src/com/unciv/logic/civilization/TechManager.kt index c2a2739c..c8a13d01 100644 --- a/core/src/com/unciv/logic/civilization/TechManager.kt +++ b/core/src/com/unciv/logic/civilization/TechManager.kt @@ -323,10 +323,11 @@ class TechManager { } fun getBestRoadAvailable(): RoadStatus { - if (!isResearched(RoadStatus.Road.improvement(getRuleset())!!.techRequired!!)) return RoadStatus.None + val roadImprovement = RoadStatus.Road.improvement(getRuleset()) // May not exist in mods + if (roadImprovement == null || !isResearched(roadImprovement.techRequired!!)) return RoadStatus.None - val techEnablingRailroad = RoadStatus.Railroad.improvement(getRuleset())!!.techRequired!! - val canBuildRailroad = isResearched(techEnablingRailroad) + val railroadImprovement = RoadStatus.Railroad.improvement(getRuleset()) + val canBuildRailroad = railroadImprovement!=null && isResearched(railroadImprovement.techRequired!!) return if (canBuildRailroad) RoadStatus.Railroad else RoadStatus.Road }