Patch: Fix automation breaking on unknown units with no improvement placements (#11877)

This commit is contained in:
Yair Morgenstern
2024-06-28 14:48:03 +03:00
committed by GitHub
parent 6315984da7
commit d6940afe79

View File

@ -198,9 +198,10 @@ object SpecificUnitAutomation {
/** @return whether there was any progress in placing the improvement. A return value of `false`
* can be interpreted as: the unit doesn't know where to place the improvement or is stuck. */
fun automateImprovementPlacer(unit: MapUnit) : Boolean {
val improvementBuildingUniques = unit.getMatchingUniques(UniqueType.ConstructImprovementInstantly)
val improvementBuildingUnique = unit.getMatchingUniques(UniqueType.ConstructImprovementInstantly).firstOrNull()
?: return false
val improvementName = improvementBuildingUniques.first().params[0]
val improvementName = improvementBuildingUnique.params[0]
val improvement = unit.civ.gameInfo.ruleset.tileImprovements[improvementName]
?: return false
val relatedStat = improvement.maxByOrNull { it.value }?.key ?: Stat.Culture