Pre-release
Adventure.js Docs Downloads
Score: 0 Moves: 0
// getCustomSuccessMessage.js

(function () {
  /*global adventurejs A*/
  "use strict";

  var p = adventurejs.Game.prototype;

  /**
   * Check to see if an Asset has a custom success message for the specified verb.
   * @method adventurejs.Game#getCustomSuccessMessage
   * @memberOf adventurejs.Game
   * @param {Object} asset A game asset.
   * @param {String} verbName A verb name.
   * @returns {Boolean}
   */
  p.getCustomSuccessMessage = function Game_getCustomSuccessMessage(
    asset,
    verbName
  ) {
    if (!asset) return false;
    if ("string" !== typeof verbName) return false;
    if (asset.verb_success_hooks && asset.verb_success_hooks[verbName]) {
      var msg = A.getSAF.call(this.game, asset.verb_success_hooks[verbName]);
      if ("string" === typeof msg) {
        return msg;
      }
    }
    return false;
  };
})();