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

  /**
   * @ajspath adventurejs.Atom.Asset.Matter.Tangible.Scenery
   * @augments adventurejs.Tangible
   * @class adventurejs.Scenery
   * @ajsconstruct MyGame.createAsset({ "class":"Scenery", "name":"foo", [...] })
   * @ajsconstructedby adventurejs.Game#createAsset
   * @ajsnavheading MiscAssetClasses
   * @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 Stop and smell the roses.
   * @tutorial NextSteps_GlobalScenery
   * @classdesc
   * <p>
   * <strong>Scenery</strong> is a subclass of
   * {@link adventurejs.Tangible|Tangible}
   * that is used to create simple, minimally
   * interactive objects that the player can
   * only sense but not manipulate.
   * Imagine an outdoor {@link adventurejs.Room|Room}
   * with sun and sky and distant mountains.
   * Use Scenery {@link adventurejs.Asset|Assets}
   * to provide responses to player input like
   * <code class="property">examine sky</code>
   * without coding complex objects.
   * </p>
   * <p>Before creating new Scenery, take note that
   * {@link adventurejs.Game|Game} predefines a group
   * of global Scenery Assets that includes sun, sky,
   * moon, stars and a few others; walls for each
   * direction; and fake
   * {@link adventurejs.Exit|Exits} to provide messages
   * when players try to travel in directions that
   * have no actual Exits. To learn more about
   * predefined Scenery, see the
   * {@link adventurejs.Zone|Zone} page or
   * <a href="/doc/NextSteps_GlobalScenery.html">Global Scenery</a>.
   * </p>
   * <h3 class="examples">Example:</h3>
   * <p>
   * There are two ways to construct new Scenery Assets.
   * First, there is the standard
   * {@link adventurejs.Asset#createAsset|createAsset} method.
   * Scenery can be made either local or global. To make
   * Scenery local, set its
   * <code class="property">location</code> property or
   * <code class="property">thing_this_is_in</code>
   * property (they're equivalent) to the Room it should
   * appear in. To make it global, set its
   * <code class="property">is.global</code>
   * property to true. Global Scenery can be seen in any
   * Room for which it is enabled.
   * </p>
   * <pre class="display"><code class="language-javascript">MyGame.createAsset({
   *   class: "Scenery",
   *   name: "fireflies",
   *   descriptions: { look: "Fireflies! They blink cheerfully against the dusky evening. ", },
   *   is: { global: true }, // for global availability use this
   *   is: { known: true }, // necessary if setting global
   *   //place: { in: "Dusky Woods" }, // for single location use this
   * });
   * </code></pre>
   * <p>
   * The shortcut method is to add Scenery to a Room's
   * <code class="property">room_scenery</code> property.
   * If the Scenery is to be global, it can be added to
   * multiple Rooms this way. The Scenery only needs to
   * be defined one time, using
   * <code class="property">create:true</code>.
   * Other Rooms can simply have the Scenery's
   * <code class="property">enabled</code>
   * property set to true. Other rooms can also be set
   * to show a different description for the Scenery.
   * </p>
   * <pre class="display"><code class="language-javascript">MyGame.createAsset({
   *   class: "Room",
   *   name: "Deep Forest",
   *   room_scenery: {
   *     fireflies: {
   * <span class="new">      create: true, // only set this once</span>
   *       is: { global: true }, // available in any Room
   *       enabled: true, // per room
   *       descriptions: { look: "Fireflies!", }, // global unless specified elsewhere
   *     },
   *   },
   * }
   *
   * MyGame.createAsset({
   *   class: "Room",
   *   name: "Deeper Forest",
   *   room_scenery: {
   *     fireflies: {
   *       enabled: true, // uses same description as above
   *     },
   *   },
   * }
   *
   * MyGame.createAsset({
   *   class: "Room",
   *   name: "Deepest Forest",
   *   room_scenery: {
   *     fireflies: {
   *       enabled: true,
   *       descriptions: { look: "Thick as a field of stars.", }, // uses unique description
   *     },
   *   },
   * }
   * </code></pre>
   * <p>
   * To learn more about working with Scenery, see the
   * {@link adventurejs.Zone|Zone} page or
   * <a href="/doc/NextSteps_GlobalScenery.html">Global Scenery</a>.
   * </p>
   **/
  class Scenery extends adventurejs.Tangible {
    constructor(name, game_name) {
      super(name, game_name);
      this.class = "Scenery";

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

      // unset VerbSubscriptions inherited from Matter
      this.unsetDOVs([
        "touch",
        "kick",
        "push",
        "shake",
        "move",
        "pull",
        "hit",
        "throw",
      ]);
    }
  }
  adventurejs.Scenery = Scenery;
})();