Pre-release
AdventureJS Docs Downloads
Score: 0 Moves: 0
// areAnscestorsClosed.js
(function () {
  /* global adventurejs A */
  var p = adventurejs.Tangible.prototype;
  /**
   * Checks to see if this asset's containing parent(s) is closed.
   * Takes into account nesting doll
   * situations and looks all the way up the chain.
   * Useful for determining whether a player can interact
   * with a nested object.
   * @memberOf adventurejs.Tangible
   * @method adventurejs.Tangible#areAnscestorsClosed
   * @returns {Boolean}
   */
  p.areAnscestorsClosed = function Tangible_areAnscestorsClosed() {
    var parent = this.getPlaceAsset();
    var aspect = this.getPlaceAspect();
    var parentClosed = false;
    var anscestorsClosed = false;
    if (
      parent &&
      aspect.name === "in" &&
      parent.isDOV("open") &&
      parent.is.closed &&
      "undefined" !== typeof parent.areAnscestorsClosed
    ) {
      parentClosed = true;
      anscestorsClosed = parent.areAnscestorsClosed();
    }
    if (parentClosed || anscestorsClosed) {
      return true;
    }
    return false;
  };
})();