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

  /**
   * @ajspath adventurejs.Atom.Asset.Matter.Tangible.Thing.Container.SurfaceContainer
   * @augments adventurejs.Container
   * @class adventurejs.SurfaceContainer
   * @ajsconstruct MyGame.createAsset({ "class":"SurfaceContainer", "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.
   * @ajstangiblecontainer on
   * @summary A simple base class with a surface.
   * @classdesc <strong>SurfaceContainer</strong> is a simple
   * child class of {@link adventurejs.Container|Container},
   * with only one additional property, which is that you can put other
   * things on it. In practice, any {@link adventurejs.Tangible|Tangible}
   * {@link adventurejs.Asset|Asset} can be made into a surface
   * simply by giving it a
   * {@link adventurejs.Aspect|Aspect}.
   **/
  class SurfaceContainer extends adventurejs.Container {
    constructor(name, game_name) {
      super(name, game_name);
      this.class = "SurfaceContainer";

      this.default_aspect = "on";

      this.aspects.on = new adventurejs.Aspect("on", this.game_name).set({
        parent_id: this.id,
        list_in_room: true,
        list_in_examine: true,
        maxheight: 6,
        maxwidth: 6,
        maxdepth: 6,
        maxcount: 10,
        maxsize: 20,
        maxweight: 100,
        player: { can: { enter: true, stand: true, exit: false } },
      });
    }
  }

  adventurejs.SurfaceContainer = SurfaceContainer;
})();