Dealt with some game assumptions about what exists, which may not be true in mods
This commit is contained in:
parent
67ce953c62
commit
9ca7e7ac5b
3 changed files with 8 additions and 6 deletions
|
@ -27,8 +27,9 @@ class ConstructionAutomation(val cityConstructions: CityConstructions){
|
||||||
val militaryUnits = civUnits.filter { !it.type.isCivilian()}.count()
|
val militaryUnits = civUnits.filter { !it.type.isCivilian()}.count()
|
||||||
val workers = civUnits.filter { it.hasUnique(Constants.workerUnique) }.count().toFloat()
|
val workers = civUnits.filter { it.hasUnique(Constants.workerUnique) }.count().toFloat()
|
||||||
val cities = civInfo.cities.size
|
val cities = civInfo.cities.size
|
||||||
val canBuildWorkboat = cityInfo.cityConstructions.getConstructableUnits().map { it.name }.contains("Work Boats")
|
val canBuildWorkboat = cityInfo.cityConstructions.getConstructableUnits()
|
||||||
&& !cityInfo.getTiles().any { it.civilianUnit?.name == "Work Boats" }
|
.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
|
val needWorkboat = canBuildWorkboat
|
||||||
&& cityInfo.getTiles().any { it.isWater && it.hasViewableResource(civInfo) && it.improvement == null }
|
&& cityInfo.getTiles().any { it.isWater && it.hasViewableResource(civInfo) && it.improvement == null }
|
||||||
|
|
||||||
|
|
|
@ -211,7 +211,7 @@ class WorkerAutomation(val unit: MapUnit) {
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
if (improvementString == null) return 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 {
|
private fun isImprovementOnFeatureAllowed(tile: TileInfo, civInfo: CivilizationInfo): Boolean {
|
||||||
// Old hardcoded logic amounts to:
|
// Old hardcoded logic amounts to:
|
||||||
|
|
|
@ -323,10 +323,11 @@ class TechManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getBestRoadAvailable(): RoadStatus {
|
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 railroadImprovement = RoadStatus.Railroad.improvement(getRuleset())
|
||||||
val canBuildRailroad = isResearched(techEnablingRailroad)
|
val canBuildRailroad = railroadImprovement!=null && isResearched(railroadImprovement.techRequired!!)
|
||||||
|
|
||||||
return if (canBuildRailroad) RoadStatus.Railroad else RoadStatus.Road
|
return if (canBuildRailroad) RoadStatus.Railroad else RoadStatus.Road
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue