Pre-release
Adventure.js Docs Downloads
Score: 0 Moves: 0
// areAnscestorsKnown.js
(function() {
	/*global adventurejs A*/ 
  "use strict";
  var p = adventurejs.Tangible.prototype;	
  /**
   * Checks to see if this asset and its containing parent(s)
   * are known to player. Takes into account nesting doll 
   * situations and looks all the way up the chain.
   * Useful for determining whether a player can "see"
   * a nested object.
   * @memberOf adventurejs.Tangible
	 * @method adventurejs.Tangible#areAnscestorsKnown
   * @returns {Boolean}
   */
   p.areAnscestorsKnown = function Tangible_AreThisAndAnscestorsKnown() 
   {
     var player_knows_parent = true;
     var parent = this.getPlaceAsset();

     if( parent
     && "undefined" !== typeof parent.is.known
     && "undefined" !== typeof parent.areAnscestorsKnown ) 
     {
      player_knows_parent = parent.areAnscestorsKnown();
     }
     if (this.is.known && player_knows_parent) 
     {
       return true;
     }
     else 
     {
       return false;
     }
   }
 }());