Pre-release
AdventureJS Docs Downloads
Score: 0 Moves: 0
// setAspectContentsKnown.js
(function () {
  /*global adventurejs A*/
  var p = adventurejs.Tangible.prototype;
  /**
   * When player knows an asset, call this function to
   * make its contents known. Generally, contents of
   * behind/in/on/under are listed automatically and known,
   * whereas attachments may go unlisted in room descriptions.
   * This function is chiefly for setting is.known
   * for attachments, but can be applied to any aspects.
   * @memberOf adventurejs.Tangible
   * @method adventurejs.Tangible#setAspectContentsKnown
   */
  p.setAspectContentsKnown = function Tangible_setAspectContentsKnown(
    aspect,
    value
  ) {
    //console.warn(this.id, "setAspectContentsKnown", aspect, value);
    if ("undefined" === typeof value) return false;
    if (!this.hasAspectAt(aspect)) {
      this.game.log(
        "L1459",
        "warn",
        "high",
        "setAspectContentsKnown.js > Bad request",
        "Tangible"
      );
      return false;
    }
    const subject = this.game.getSubject();
    var contents = this.aspects[aspect].contents;
    for (var i = 0; i < contents.length; i++) {
      var object = this.game.getAsset(contents[i]);
      subject.know(object);
    }
    return;
  };
})();