From d6940afe7945a3213c85bba0e3715e55df49becf Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Fri, 28 Jun 2024 14:48:03 +0300 Subject: [PATCH] Patch: Fix automation breaking on unknown units with no improvement placements (#11877) --- .../unciv/logic/automation/unit/SpecificUnitAutomation.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/src/com/unciv/logic/automation/unit/SpecificUnitAutomation.kt b/core/src/com/unciv/logic/automation/unit/SpecificUnitAutomation.kt index 821437445a708..7a1b4125fd28e 100644 --- a/core/src/com/unciv/logic/automation/unit/SpecificUnitAutomation.kt +++ b/core/src/com/unciv/logic/automation/unit/SpecificUnitAutomation.kt @@ -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