Pre-release
Adventure.js Docs Downloads
Score: 0 Moves: 0
// get.js
(function () {
  /*global adventurejs A*/
  "use strict";
  var p = adventurejs.Tangible.prototype;
  /**
   * Utility function that provides an easy way for
   * authors to test for various conditions.
   * <ul>
   * <li>all - list things anywhere in this</li>
   * <li>behind - list things behind this</li>
   * <li>in - list things in this</li>
   * <li>on - list things on this</li>
   * <li>under - list things under this</li>
   * <li>attached - list things attached to this</li>
   * </ul>
   * @memberOf adventurejs.Tangible
   * @method adventurejs.Tangible#get
   * @param {String} property
   * @param {String} qualifier
   */
  p.get = p.$get = function Tangible_$get(property, qualifier) {
    if (
      this.game.dictionary.isPreposition(property) &&
      this.hasAspectAt(property)
    ) {
      // this returns a list of ids
      // what if author wants a nice formatted list?
      return this.aspects[property].contents;
    }

    switch (property) {
      // TODO
      // case "everythingInsideMeRecursively":
      // return;
      //break;

      case "all":
        var things = [];

        for (var aspect in this.aspects) {
          things.concat(this.aspects[aspect].contents);
        }

        return things;

      default:
        if ("undefined" === typeof this[property]) {
          console.warn(
            "Tangible.get() couldn't find a property called " +
              property +
              " on " +
              this.name +
              "."
          );
          return false;
        }

        return this[property];
    } // switch
  }; // adventurejs.Tangible.prototype.get
})();