Pre-release
AdventureJS Docs Downloads
Score: 0 Moves: 0
// $has.js
(function () {
  /* global adventurejs A */
  var p = adventurejs.Asset.prototype;

  /**
   * <strong>has</strong> is an alias to asset.isWithin()
   * that reverses the direct and indirect objects, to test
   * whether that asset is in this asset.
   * <pre class="display"><code class="language-javascript">if( MyGame.$('crown').$has('jewel') ){ // do stuff }
   * </code></pre>
   * @memberOf adventurejs.Asset
   * @method adventurejs.Asset#has
   * @param {Object} asset
   */
  p.has = p.$has = function Asset_$has(asset) {
    if ("string" === typeof asset) asset = this.game.getAsset(asset);
    if (!asset || !asset.id || !asset.hasClass("Tangible")) return false;
    return asset.isWithin(this);
  };
})();