mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-20 20:59:18 +07:00
Patch: Fix automation breaking on unknown units with no improvement placements (#11877)
This commit is contained in:
@ -198,9 +198,10 @@ object SpecificUnitAutomation {
|
|||||||
/** @return whether there was any progress in placing the improvement. A return value of `false`
|
/** @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. */
|
* can be interpreted as: the unit doesn't know where to place the improvement or is stuck. */
|
||||||
fun automateImprovementPlacer(unit: MapUnit) : Boolean {
|
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]
|
val improvement = unit.civ.gameInfo.ruleset.tileImprovements[improvementName]
|
||||||
?: return false
|
?: return false
|
||||||
val relatedStat = improvement.maxByOrNull { it.value }?.key ?: Stat.Culture
|
val relatedStat = improvement.maxByOrNull { it.value }?.key ?: Stat.Culture
|
||||||
|
Reference in New Issue
Block a user