API Docs for:
Show:

PerformableActionInterface Class

Surface API to handle PerformableAction implementations. This allows a source object and target object to have separate action resolution logic without directly referencing eachother. See also ResolvableActionInterface, ResolvableAction

Methods

canPerformAction

(
  • action
  • [settings]
)
Boolean

Checks if source can perform an action with given settings. (source is this) Functionality separated to avoid checking multiple targets when source cannot perform action regardless of target.

Parameters:

  • action String
    • The action to check.
  • [settings] Object optional
    • Settings for the action.

Returns:

Boolean:

true if the action can be performed.

canPerformActionOnTarget

(
  • action
  • target
  • [settings]
)
Boolean

Checks if source can perform an action on target with given settings.

Parameters:

  • action String
    • The action to check.
  • target Object
    • The target object to check against.
  • [settings] Object optional
    • Settings for the action.
    • [skipCanPerformAction] Object optional
      • If true skips checking that this.canPerformAction(action, settings) == true

Returns:

Boolean:

true if the action can be performed on target.

getTargetsForAction

(
  • action
  • [settings]
)
Array

Returns a list of valid targets to perform an action on.

Parameters:

  • action String
    • The action to get targets for.
  • [settings] Object optional
    • Settings for the action.

Returns:

Array:

Array of valid targets.

performAction

(
  • action
  • target
  • [settings]
)
Boolean

Performs an action on target with given settings.

Parameters:

  • action String
    • The action to perform.
  • target Object
    • The target object to perform the action on.
  • [settings] Object optional
    • Settings for the action.
    • [skipCanPerformAction] Object optional
      • If true skips checking that this.canPerformAction(action, settings) == true
    • [skipCanPerformActionOnTarget] Object optional
      • If true skips checking that this.skipCanPerformActionOnTarget(action, target, settings) == true

Returns:

Boolean:

true if the action has been successfully completed.

setPerformableAction

(
  • action
  • implementation
)

Sets a performable action implementation on object.

Parameters:

  • action String
    • The action name.
  • implementation PerformableAction
    • Object to set as the action implementation. or a string to lookup an implementation RL.PerformableActions[implementation].