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

  /**
   * @ajspath adventurejs.Atom.StateManager.Asset_Is
   * @augments adventurejs.StateManager
   * @class adventurejs.Asset_Is
   * @ajsnavheading StateClasses
   * @param {String} game_name Name of top level game instance that is scoped to window.
   * @param {String} name Instance name.
   * @summary A container for state variables.
   * @classdesc
   * <p>
   * <strong>Asset_Is</strong> is a state management class for all {@link adventurejs.Asset|Assets}.
   * used to store general state variables.
   **/

  class Asset_Is extends adventurejs.StateManager {
    constructor(name = "is", game_name, parent_id) {
      // Call the constructor of the parent class
      super(name, game_name, parent_id);

      this.class = "Asset_Is";

      /**
       * Used to track whether player knows about an asset.
       * @var {Boolean} adventurejs.Asset#is!known
       * @default false
       * @todo In games with multiple characters, any character the player takes
       * will share this knowledge. May want an option to set this per player character.
       */
      this._known = false;

      /**
       * Set to true when an object is removed from the game
       * by destruction.
       * @var {Boolean} adventurejs.Asset#is!destroyed
       * @default false
       */
      this.destroyed = false;

      /**
       * Set to true when an object is in the game.
       * @var {Boolean} adventurejs.Asset#is!extant
       * @default true
       */
      this.extant = true;

      /**
       * Set whether object is a collection of other object IDs.
       * @var {Boolean} adventurejs.Asset#is!collection
       * @default true
       */
      this.collection = false;

      /**
       * Used at runtime to keep track of asset's validation state.
       * @var {Boolean} adventurejs.Asset#is!validated
       * @default false
       */
      this.validated = false;

      /**
       * Used at runtime to keep track of asset's initialization state.
       * @var {Boolean} adventurejs.Asset#is!initialized
       * @default false
       */
      this.initialized = false;

      /**
       * Almost all assets are given a name which is then used to create
       * their id, with some exceptions.
       * For example, exit ids are generated by taking the name of the
       * exit's room + the exit's direction.
       * @var {Boolean} adventurejs.Asset#is!nameless
       * @default false
       */
      this.nameless = false;

      /**
       * Almost all tangible assets have a singular location.
       * Global assets are available in all locations
       * in order to catch player input.
       * @var {Boolean} adventurejs.Asset#is!global
       * @default false
       */
      this.global = false;

      /**
       * Abstractions are universally available and bypass reachability tests.
       * @var {Boolean} adventurejs.Asset#is!abstract
       * @default false
       */
      this.abstract = false;

      /**
       * Meant for use to distinguish some assets as being singular
       * in the game world.
       * @var {Boolean} adventurejs.Asset#is!singleton
       * @default false
       * @todo Have only applied this to several special global assets,
       * and have not implemented any code around it. Is it still useful?
       */
      this.singleton = false;

      return this;
    }

    get known() {
      return this._known;
    }
    set known(known) {
      this._known = known;
    }
  }
  adventurejs.Asset_Is = Asset_Is;
})();