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

  /**
   * @ajspath adventurejs.Atom.Asset.Matter.Tangible.Thing.Vehicle
   * @augments adventurejs.Thing
   * @class adventurejs.Vehicle
   * @classdesc Explanation of the class.
   * @ajsconstruct MyGame.createAsset({ "class":"Vehicle", "name":"foo", [...] })
   * @ajsconstructedby adventurejs.Game#createAsset
   * @ajsnavheading VehicleClasses
   * @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 Base class for things like bicycles and skateboards.
   * @tutorial Tangibles_Vehicles
   * @ajstangiblecontainer on
   * @classdesc
   * <p>
   * <strong>Vehicle</strong> is the ancestor class for
   * things like {@link adventurejs.Bicycle|Bicycle} and
   * {@link adventurejs.Skateboard|Skateboard}.
   *
   * Vehicles are unique among other Asset classes in that
   * {@link adventurejs.Character|Characters} may carry them,
   * while also being nested in/on them.
   * Nesting is a special kind of parent/child relationship that
   * is only used for Characters.
   * This feature is a function of
   * {@link adventurejs.Tangible|Tangible}'s
   * <code>asset.dov.ride</code>.
   * To learn more, see
   * <a href="/doc/Tangibles_Vehicles.html">Simple Vehicles</a>.
   * </p>
   * <h3 class="examples">Example:</h3>
   * <pre class="display"><code class="language-javascript">MyGame.createAsset({
   *   class: "Vehicle",
   *   name: "pogo stick",
   *   place: { in: "Toy Closet" },
   *   descriptions: { look: "It's a pogo stick. ", },
   * });
   * </code></pre>
   **/
  class Vehicle extends adventurejs.Thing {
    constructor(name, game_name) {
      super(name, game_name);
      this.class = "Vehicle";

      this.setDOVs(["ride", "get", "take", "give", "put"]);
      this.setIOVs(["tie"]);

      this.on_tie_to_this_take_this = false;
      this.on_tie_to_drag_behind_rope = true;

      this.aspects.on = new adventurejs.Aspect("on", this.game_name).set({
        parent_id: this.id,
        list_in_room: false,
        list_in_examine: true,
        contents_limits: {
          count: 1, // presumably a cap
        },
        with_classes: ["Character"],
        player: {
          can: {
            enter: true,
            sit: true,
            exit: true,
            ride: true,
          },
          posture: "sit",
        },
      });
      this.default_aspect = "on";
    }
  }

  adventurejs.Vehicle = Vehicle;
})();