mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-29 06:51:30 -04:00
More defensive coding of speedupWonderConstruction (#9671)
This commit is contained in:
parent
330fa6593b
commit
6a8f4914b8
@ -304,11 +304,8 @@ object SpecificUnitAutomation {
|
|||||||
}.mapNotNull { city ->
|
}.mapNotNull { city ->
|
||||||
val path = unit.movement.getShortestPath(city.getCenterTile())
|
val path = unit.movement.getShortestPath(city.getCenterTile())
|
||||||
if (path.any() && path.size <= 5) city to path.size else null
|
if (path.any() && path.size <= 5) city to path.size else null
|
||||||
}.minByOrNull { it.second }?.first
|
}.minByOrNull { it.second }
|
||||||
|
?.first ?: return false
|
||||||
if (nearbyCityWithAvailableWonders == null) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
if (unit.currentTile == nearbyCityWithAvailableWonders.getCenterTile()) {
|
if (unit.currentTile == nearbyCityWithAvailableWonders.getCenterTile()) {
|
||||||
val wonderToHurry =
|
val wonderToHurry =
|
||||||
@ -317,11 +314,12 @@ object SpecificUnitAutomation {
|
|||||||
0,
|
0,
|
||||||
wonderToHurry.name
|
wonderToHurry.name
|
||||||
)
|
)
|
||||||
UnitActions.getUnitActions(unit)
|
unit.showAdditionalActions = false // make sure getUnitActions doesn't skip the important ones
|
||||||
.first {
|
val unitAction = UnitActions.getUnitActions(unit).firstOrNull {
|
||||||
it.type == UnitActionType.HurryBuilding
|
it.type == UnitActionType.HurryBuilding || it.type == UnitActionType.HurryWonder
|
||||||
|| it.type == UnitActionType.HurryWonder }
|
} ?: return false
|
||||||
.action!!.invoke()
|
if (unitAction.action == null) return false
|
||||||
|
unitAction.action.invoke()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user