Pre-release
AdventureJS Docs Downloads Bundler Devlog Score: 0 Moves: 0
// Enclosure.js
(function () {
  /* global AdventureJS A */

  /**
   * @ajspath AdventureJS.Atom.Asset.Tangible.Entity.Enclosure
   * @augments AdventureJS.Assets.Entity
   * @class AdventureJS.Assets.Enclosure
   * @ajsconstruct MyGame.createAsset({ "class": "Enclosure", "name": "foo", [...] })
   * @ajsconstructedby AdventureJS.Game#createAsset
   * @ajsnavheading EnclosureClasses
   * @param {String} game_name The name of the top level game object.
   * @param {String} name A name for the object, to be serialized and used as ID.
   * @summary A base class for all kinds of enclosures.
   * @tutorial Entities
   * @ajstangiblecontainer on
   * @classdesc
   * <p>
   * <strong>Enclosure</strong> is the ancestor class for
   * all types of enclosures including
   * {@link AdventureJS.Assets.Tent|Tent} and
   * {@link AdventureJS.Assets.Cubicle|Cubicle}.
   * </p>
   * <a option id="Examples"></a>
   * <h3 class="examples">Example:</h3>
   * <pre class="display"><code class="language-javascript">MyGame.createAsset({
   *   class: "Tent",
   *   name: "changing tent",
   *   place: { in: "Beach Area" },
   *   description: `
   *     Tent is perhaps too generous a term for this changing area,
   *     which is little more than a curtained cubicle rigged up on strings.
   *   `,
   *   adjectives: ["curtain", "curtains", "string", "strings", "cubicle", "changing area"],
   * });
   * </code></pre>
   **/
  class Enclosure extends AdventureJS.Assets.Entity {
    constructor(name, game_name, context_id = "", id = "") {
      super(name, game_name, context_id, id);
      this.class = "Enclosure";

      this.setDOVs([
        "get",
        "go",
        "lie",
        "sit",
        "stand",
        "kneel",
        "enter",
        "exit",
      ]);
      this.unsetDOVs(["take", "give", "put"]);
      this.setIOVs(["take", "put"]);

      this.default_aspect = "in";
      this.dimensions.height = 1;

      this.aspects.in = new AdventureJS.Helpers.Aspect(
        "in",
        this.game_name,
        this.id
      ).set({
        list_contents_in_room: true,
        list_contents_in_examine: true,
        know_contents_with_parent: true,
        see_contents_with_parent: true,
        capacity: {
          height: -1,
          width: -1,
          depth: -1,
          count: -1,
          weight: -1,
        },
        orientation: "horizontal",
      });

      this.aspects.in.nest = new AdventureJS.Helpers.Nest(
        "in",
        this.game_name,
        this.id
      ).set({
        posture: "stand",
        preposition: "in",
        can: {
          // locomotion
          bounce: true,
          climb: true,
          enter: true,
          exit: true,
          go: true,
          hop: true,
          jump: true,
          // posture
          kneel: true,
          lie: true,
          sit: true,
          stand: true,
        },
      });
    }
  }
  AdventureJS.Assets.Enclosure = Enclosure;
})();