Skip to content

Commit

Permalink
Patch: Fix automation breaking on unknown units with no improvement p…
Browse files Browse the repository at this point in the history
…lacements (#11877)
  • Loading branch information
yairm210 authored Jun 28, 2024
1 parent 6315984 commit d6940af
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d6940af

Please sign in to comment.