Pre-release
AdventureJS Docs Downloads
Score: 0 Moves: 0
// $getKey.js
(function () {
  /*global adventurejs A*/
  var p = adventurejs.Character.prototype;
  /**
   * Returns one key that player is carrying, if any,
   * to unlock the specified asset.
   * @memberOf adventurejs.Character
   * @method adventurejs.Character#$getKey
   * @param {Object|String} direct_object An asset or asset ID to unlock.
   * @returns {Object|null} A Key asset, if player has any.
   */
  p.$getKey = function Character_getKey(direct_object) {
    let keys = this.findNestedIndirectObjects("unlock", direct_object);
    return keys[0] || null;
  };
})();