Pre-release
Adventure.js Docs Downloads
Score: 0 Moves: 0
// Window.js
(function () {
  /*global adventurejs A*/
  "use strict";

  /**
   * @ajspath adventurejs.Atom.Asset.Matter.Tangible.Thing.Aperture.Window
   * @augments adventurejs.Aperture
   * @class adventurejs.Window
   * @ajsconstruct MyGame.createAsset({ "class":"Window", "name":"foo", [...] })
   * @ajsconstructedby adventurejs.Game#createAsset
   * @ajsnavheading DoorExitClasses
   * @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 You make a better door than a window.
   * @tutorial CreateExit
   * @classdesc
   * <p>
   * <strong>Window</strong> is a subclass of
   * {@link adventurejs.Aperture|Aperture}. Windows can be
   * opened and closed, and locked and unlocked without a key.
   * Windows are singular, meaning they only exist in one Room.
   * To allow two-way travel between Windows, you must have two
   * Windows, each with its <a href="#linked_asset">linked_asset</a>
   * property set to the other Window. To make a window that
   * locks from the inside but not the outside, set
   * <code class="property">dov.unlock.with_nothing</code>
   * to <code class="property">false</code>.
   * Following is an example
   * with two Windows + Exits, with a lock on the inside.
   * </p>
   * <h3 class="example">Example:</h3>
   * <pre class="display"><code class="language-javascript">MyGame.createAsset({
   *   class:"Exit",
   *   direction:"south",
   *   place:{ in: "Schoolroom" },
   *   destination:"Play yard",
   *   aperture:"inside window"
   * });
   * MyGame.createAsset({
   *   class:"Window",
   *   name:"inside window",
   *   direction:"south",
   *   place:{ in: "Schoolroom" },
   *   linked_asset:"outside window",
   *   dov: {
   *     unlock: { with_nothing:true, },
   *     lock: { with_nothing:true, },
   *   },
   * });
   * MyGame.createAsset({
   *   class:"Exit",
   *   direction:"north",
   *   place:{ in: "Play yard" },
   *   destination:"Schoolroom",
   *   aperture:"outside window"
   * });
   * MyGame.createAsset({
   *   class:"Window",
   *   name:"outside window",
   *   place:{ in: "Play yard" },
   *   direction:"north",
   *   linked_asset:"inside window",
   *   dov: {
   *     unlock: { with_nothing:true, },
   *     lock: { with_nothing:true, },
   *   },
   * });
   * </code></pre>
   **/
  class Window extends adventurejs.Aperture {
    constructor(name, game_name) {
      super(name, game_name);
      this.class = "Window";

      this.noun = "window";
      this.plural = "windows";
      this.singlePluralPairs = [["window", "windows"]];
      //this.adjectives = "";

      this.is.aperture = true;
      this.is.listed_in_room = false;

      // this.setDOVs([
      //   'lock','unlock'
      // ]);
      this.setDOV({ open: { with_nothing: true } });
      this.setDOV({ close: { with_nothing: true } });
      this.setDOV({ lock: { with_nothing: true } });
      this.setDOV({ unlock: { with_nothing: true } });

      this.exit = "";

      this.is.lookthroughable = true;
      this.aspects.through = new adventurejs.Aspect(
        "through",
        this.game_name
      ).set({
        parent_id: this.id,
      });
    }
  }
  adventurejs.Window = Window;
})();