mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-11 00:08:58 +07:00
invokeUnitAction will take the first *actionable* action, instead of the first one that exists, which may not be actionable
This commit is contained in:
@ -23,9 +23,10 @@ object UnitActions {
|
|||||||
|
|
||||||
/** Returns whether the action was invoked */
|
/** Returns whether the action was invoked */
|
||||||
fun invokeUnitAction(unit: MapUnit, unitActionType: UnitActionType): Boolean {
|
fun invokeUnitAction(unit: MapUnit, unitActionType: UnitActionType): Boolean {
|
||||||
val unitAction = actionTypeToFunctions[unitActionType]?.invoke(unit, unit.getTile())?.firstOrNull()
|
val unitAction = if (unitActionType in actionTypeToFunctions) actionTypeToFunctions[unitActionType]!!.invoke(unit, unit.getTile())
|
||||||
?: getNormalActions(unit).firstOrNull { it.type == unitActionType }
|
.firstOrNull{ it.action != null }
|
||||||
?: getAdditionalActions(unit).firstOrNull { it.type == unitActionType }
|
else getNormalActions(unit).firstOrNull { it.type == unitActionType && it.action != null }
|
||||||
|
?: getAdditionalActions(unit).firstOrNull { it.type == unitActionType && it.action != null }
|
||||||
val internalAction = unitAction?.action ?: return false
|
val internalAction = unitAction?.action ?: return false
|
||||||
internalAction.invoke()
|
internalAction.invoke()
|
||||||
return true
|
return true
|
||||||
|
@ -1158,14 +1158,14 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl
|
|||||||
|
|
||||||
Uniques that can be added to units, unit types, or promotions
|
Uniques that can be added to units, unit types, or promotions
|
||||||
|
|
||||||
|
??? example "May create improvements on water resources"
|
||||||
|
Applicable to: Unit
|
||||||
|
|
||||||
??? example "Can build [improvementFilter/terrainFilter] improvements on tiles"
|
??? example "Can build [improvementFilter/terrainFilter] improvements on tiles"
|
||||||
Example: "Can build [All Road] improvements on tiles"
|
Example: "Can build [All Road] improvements on tiles"
|
||||||
|
|
||||||
Applicable to: Unit
|
Applicable to: Unit
|
||||||
|
|
||||||
??? example "May create improvements on water resources"
|
|
||||||
Applicable to: Unit
|
|
||||||
|
|
||||||
??? example "Can be added to [comment] in the Capital"
|
??? example "Can be added to [comment] in the Capital"
|
||||||
Example: "Can be added to [comment] in the Capital"
|
Example: "Can be added to [comment] in the Capital"
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user