public/js-roguelike-skeleton/src/mixins/action-interface.js
function(action, target, settings){
            if(!this.performableActions){
                return false;
            }
            var handler = this.performableActions[action];
            if(!handler){
                return false;
            }

            settings = settings || {};
            // the functions are in this order because `this.canPerformActionOnTarget` will check `this.canPerformAction`
            // unless flaged to be skipped.
            if(!settings.skipCanPerformActionOnTarget && !this.canPerformActionOnTarget(action, target, settings)){
                return false;
            } else if(!settings.skipCanPerformAction && !this.canPerformAction(action, settings)){
                return false;
            }

            var result;
            if(handler.performAction === true){
                result = {};
            } else {
                result = handler.performAction.call(this, target, settings);
            }

            if(result === false){
                return false;
            }
            settings.result = result;
            var outcome = target.resolveAction(action, this, settings);
            if(outcome && handler.afterPerformActionSuccess){
                handler.afterPerformActionSuccess.call(this, target, settings);
            } else if(!outcome && handler.afterPerformActionFailure){
                handler.afterPerformActionFailure.call(this, target, settings);
            }
            return outcome;
        }
function(action, target, settings){
            if(!this.performableActions){
                return false;
            }
            var handler = this.performableActions[action];
            if(!handler){
                return false;
            }

            settings = settings || {};
            // the functions are in this order because `this.canPerformActionOnTarget` will check `this.canPerformAction`
            // unless flaged to be skipped.
            if(!settings.skipCanPerformActionOnTarget && !this.canPerformActionOnTarget(action, target, settings)){
                return false;
            } else if(!settings.skipCanPerformAction && !this.canPerformAction(action, settings)){
                return false;
            }

            var result;
            if(handler.performAction === true){
                result = {};
            } else {
                result = handler.performAction.call(this, target, settings);
            }

            if(result === false){
                return false;
            }
            settings.result = result;
            var outcome = target.resolveAction(action, this, settings);
            if(outcome && handler.afterPerformActionSuccess){
                handler.afterPerformActionSuccess.call(this, target, settings);
            } else if(!outcome && handler.afterPerformActionFailure){
                handler.afterPerformActionFailure.call(this, target, settings);
            }
            return outcome;
        }
function ( action , target , settings ) { if ( ! this . performableActions ) { return false ; } var handler = this . performableActions [ action ] ; if ( ! handler ) { return false ; } settings = settings || { } ; // the functions are in this order because `this.canPerformActionOnTarget` will check `this.canPerformAction` // unless flaged to be skipped. if ( ! settings . skipCanPerformActionOnTarget && ! this . canPerformActionOnTarget ( action , target , settings ) ) { return false ; } else if ( ! settings . skipCanPerformAction && ! this . canPerformAction ( action , settings ) ) { return false ; } var result ; if ( handler . performAction === true ) { result = { } ; } else { result = handler . performAction . call ( this , target , settings ) ; } if ( result === false ) { return false ; } settings . result = result ; var outcome = target . resolveAction ( action , this , settings ) ; if ( outcome && handler . afterPerformActionSuccess ) { handler . afterPerformActionSuccess . call ( this , target , settings ) ; } else if ( ! outcome && handler . afterPerformActionFailure ) { handler . afterPerformActionFailure . call ( this , target , settings ) ; } return outcome ; }
Performs an action on target with given settings.
@method performAction
@param {String} action - The action to perform.
@param {Object} target - The target object to perform the action on.
@param {Object} [settings] - Settings for the action.
@param {Object} [settings.skipCanPerformAction] - If true skips checking that `this.canPerformAction(action, settings) == true`
@param {Object} [settings.skipCanPerformActionOnTarget] - If true skips checking that `this.skipCanPerformActionOnTarget(action, target, settings) == true`
@return {Boolean} `true` if the action has been successfully completed.
Performs an action on target with given settings .