Pre-release
AdventureJS Docs Downloads
Score: 0 Moves: 0
// hasContents.js
(function () {
  /* global adventurejs A */
  var p = adventurejs.Tangible.prototype;
  /**
   * Check whether this asset has any contents.
   * @memberOf adventurejs.Tangible
   * @method adventurejs.Tangible#hasContents
   * @param {String} preposition Optionally provide a preposition to specify an aspect.
   * @returns {Boolean}
   */
  p.hasContents = function Tangible_hasContents(preposition) {
    if (preposition) {
      let aspect = this.aspects[preposition];
      if (aspect.contents.length > 0) return true;
    } else {
      for (let item in this.aspects) {
        let aspect = this.aspects[item];
        if (aspect.contents.length > 0) return true;
      }
    }
    return false;
  };
})();