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

  /**
   * @ajspath adventurejs.Atom.Asset.Matter.Tangible.Thing.Container.LiquidContainer.DrinkingMug
   * @augments adventurejs.LiquidContainer
   * @class adventurejs.DrinkingMug
   * @ajsconstruct MyGame.createAsset({ "class":"DrinkingMug", "name":"foo", [...] })
   * @ajsconstructedby adventurejs.Game#createAsset
   * @ajsnavheading KitchenClasses
   * @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.
   * @ajssubstancecontainer in
   * @ajstangiblecontainer in
   * @ajstangiblecontainer attached
   * @summary A place for your coffee.
   * @classdesc
   * <p>
   * <strong>DrinkingMug</strong> is a subclass of
   * {@link adventurejs.LiquidContainer|LiquidContainer}.
   * Player can drink from it, pour from it, pour into it.
   * Authors can set a maximum volume / current volume
   * for DrinkingMug. DrinkingMug isn't very
   * different from
   * {@link adventurejs.DrinkingGlass|DrinkingGlass}
   * apart from it's opaque, and has a
   * {@link adventurejs.Aspect|Aspect}
   * that lets you optionally attach a handle to it.
   * </p>
   * <h3 class="examples">Example:</h3>
   * <pre class="display"><code class="language-javascript">MyGame.createAsset({
   *   class: "DrinkingMug",
   *   name: "ugly mug",
   *   descriptions: { look: "It's a stained porcelain mug with a chipped handle. ", },
   *   in: {
   *     vessel: {
   *       maxvolume: 500,
   *       volume: 250,
   *       substance_id: "coffee",
   *     },
   *   },
   * });
   * </code></pre>
   * <p>
   * Notice how the description of the mug refers to a handle.
   * In real life a mug would have a handle, and your player
   * might be prompted to input <code class="property">examine handle</code>.
   * Maybe that's more detail than you care about, or maybe
   * you like that sort of fiddly detail. It's your choice.
   * To give a mug a handle that players can refer to, but which
   * they can't necessarily  manipulate on its own, you can create
   * a unique {@link adventurejs.Asset|Asset}
   * and attach it to the DrinkingMug, as in the next example.
   * We haven't created a special mug handle class, so in this
   * example we're making an instance of the
   * {@link adventurejs.Thing|Thing} class, which is a low level
   * class used for most of the manipulatable objects
   * in the game world. Note the
   * <code class="property">thing_this_is_attached</code>
   * property.
   * </p>
   * <pre class="display"><code class="language-javascript">MyGame.createAsset({
   *   class: "Thing",
   *   name: "chipped handle",
   *   descriptions: { look: "The mug's handle is cracked but serviceable. ", },
   *   place: { attached: "ugly mug" },
   * });
   * </code></pre>
   **/
  class DrinkingMug extends adventurejs.LiquidContainer {
    constructor(name, game_name) {
      super(name, game_name);
      this.class = "DrinkingMug";

      this.descriptions.look = "It's a coffee mug.";
      this.noun = "mug";
      this.plural = "mugs";
      this.singlePluralPairs = [["mug", "mugs"]];
      this.adjectives = ["coffee"];

      this.setDOVs(["take", "give", "put"]);

      this.aspects.attached = new adventurejs.Aspect(
        "attached",
        this.game_name
      ).set({
        enabled: true,
        list_in_room: false,
        list_in_examine: false,
        player_can_add_assets_to_contents: false,
        player_can_remove_assets_from_contents: false,
      });

      // this.parts.handle = {
      //     adjectives: "",
      //     descriptions: { look: "There's nothing special about the mug's handle.", },
      //     nouns: "handle",
      // };

      this.aspects.in.vessel.maxvolume = 500;
    }
  }
  adventurejs.DrinkingMug = DrinkingMug;
})();