Pre-release
Adventure.js Docs Downloads
Score: 0 Moves: 0
// setAttachmentsKnown.js
(function () {
  /*global adventurejs A*/
  "use strict";
  var p = adventurejs.Tangible.prototype;
  /**
   * Attachments may go unlisted in room descriptions unlike other assets.
   * It's assumed that the author will include them in their
   * parent's description.
   * For example "The desk has a drawer" where drawer is an attachment.
   * When these assets go unlisted,
   * they miss being marked as seen / known like other assets.
   * This function explicitly sets
   * is.known / is.seen properties for attachments.
   * @memberOf adventurejs.Tangible
   * @method adventurejs.Tangible#setAttachmentsKnown
   */
  p.setAttachmentsKnown = function Tangible_setAttachmentsKnown() {
    //console.warn( this.name + " recognize attachments" );

    if (!this.hasAspectAt("attached")) {
      this.game.log(
        "warn",
        "high",
        "setAttachmentsKnown.js > Bad request",
        "Tangible"
      );
      return false;
    }
    var contents = this.aspects.attached.contents;
    for (var i = 0; i < contents.length; i++) {
      var object = this.game.getAsset(contents[i]);
      object.setKnown();
      object.setSeen();
    }
    return;
  };
})();