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

  /**
   * @ajspath adventurejs.Atom.Asset.Matter.Tangible.Thing.Container.LiquidContainer.Drainable.Bathtub
   * @augments adventurejs.Drainable
   * @class adventurejs.Bathtub
   * @ajsconstruct MyGame.createAsset({ "class":"Bathtub", "name":"foo", [...] })
   * @ajsconstructedby adventurejs.Game#createAsset
   * @ajsnavheading PlumbingClasses
   * @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.
   * @ajscomponents Faucet, FaucetHandle, Drain, Plug
   * @summary Rub a dub dub.
   * @ajsdemo PlumbingDemo, BasicSink, IntegratedSink, BasicBathtub, IntegratedBathtub, Scorecard
   * @tutorial Substances_Vessels
   * @tutorial Tangibles_Components
   * @tutorial Tangibles_Collections
   * @classdesc
   * <p>
   * <strong>Bathtub</strong> is a subclass of
   * {@link adventurejs.Drainable|Drainable}.
   * A Bathtub can be linked with a
   * {@link adventurejs.Faucet|Faucet} and
   * {@link adventurejs.FaucetHandle|Handles} and a
   * {@link adventurejs.Drain|Drain} and
   * {@link adventurejs.Plug|Plug}
   * through the use of the
   * <code class="property">{@link adventurejs.Tangible#components|components}</code>
   * property.
   * </p>
   * <p>
   * Note that <code class="property">components</code>
   * is a special convenience property that only pertains to some
   * {@link adventurejs.Asset|Asset} classes with inherent code
   * for linking certain other Asset classes.
   * To learn more, see <a href="/doc/Tangibles_Components.html">Components</a>.
   * </p>
   * @ajsexamples
   * <p>
   * Here is an example of a basic Bathtub.
   * </p>
   * <pre class="display"><code class="language-javascript">MyGame.createAsset({
   *   class: "Bathtub",
   *   name: "clawfoot bathtub",
   *   place: { in: "Bathroom" },
   *   description: `A simple porcelain bathtub.
   *   There doesn't appear to be anything important
   *   about it. The bathtub appears to be
   *   { clawfoot bathtub [is] on [or] off }. `,
   * });
   * </code></pre>
   * <p>
   * Notice how these examples use AdventureJS
   * custom templates such as
   * <code>{ bathtub drain [is] open [or] closed }</code>
   * to create dynamic descriptions. Custom templates look
   * similar to, but are distinct from,
   * <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals" class="external">Javascript
   * template literals</a>. To learn more, see
   * <a href="/doc/Scripting_CustomTemplates.html">Custom Templates</a>.
   * </p>
   * <p>
   * Here is an example of a Bathtub with integrated components:
   * {@link adventurejs.Faucet|Faucet},
   * {@link adventurejs.FaucetHandle|Handles},
   * {@link adventurejs.Drain|Drain} and
   * {@link adventurejs.Plug|Plug}.
   * </p>
   * <pre class="display"><code class="language-javascript">MyGame.createAsset({
   *   class: "Bathtub",
   *   name: "bathtub",
   *   place: { in: "Spa" },
   *   descriptions: {
   *     look: function()
   *     {
   *       return `A clawfoot tub with porcelain handles
   *       and a stainless steel faucet. Its drain appears to
   *       be { bathtub drain [is] open [or] closed }. `;
   *     },
   *   },
   *   in: {
   *     vessel: {
   *       drain_id: "bathtub drain",
   *     }
   *   },
   *   components: [
   *     "hot water handle",
   *     "cold water handle",
   *     "faucet",
   *     "drain",
   *     "plug"
   *   ],
   * });
   * MyGame.createAsset({
   *   class: "Drain", // see {@link adventurejs.Drain|Drain} class
   *   name: "bathtub drain",
   *   synonyms: "bathtub drain",
   *   is: { open: true, },
   *   dov: { open: true, close: true, },
   *   descriptions: {
   *     look: function()
   *     {
   *       return "A dark drain. Currently
   *       { bathtub drain [is] open [or] closed }. "
   *     },
   *   },
   * });
   * MyGame.createAsset({
   *   class: "Faucet", // see {@link adventurejs.Faucet|Faucet} class
   *   name: "faucet",
   *   descriptions: { look: "The bathtub faucet. ", },
   *   substance_id: "water",
   *   max_volume_of_flow_per_turn: 1000,
   * });
   * MyGame.createAsset({
   *   class: "FaucetHandle", // see {@link adventurejs.FaucetHandle|FaucetHandle} class
   *   name: "hot water handle",
   *   synonyms: [ "handle", "bathtub handle" ],
   *   adjectives: [ "hot water", "bathtub", "porcelain" ],
   *   descriptions: { look: "The bathtub's hot water handle. ", },
   *   set_substance_id: "hot water",
   *   set_substance_temperature: 70
   * });
   * MyGame.createAsset({
   *   class: "FaucetHandle", // see {@link adventurejs.FaucetHandle|FaucetHandle} class
   *   name: "cold water handle",
   *   descriptions: { look: "The bathtub's cold water handle. ", },
   *   set_substance_id: "cold water",
   *   set_substance_temperature: 20
   * });
   * // since the hot and cold handles are distinct objects,
   * // this Collection provides a way to give a useful response
   * // should a player input "examine handles"
   * MyGame.createAsset({
   *   class: "Collection", // see {@link adventurejs.Collection|Collection} class
   *   name: "bathtub handles",
   *   synonyms: [ "porcelain handles" ],
   *   place: { attached: "bathtub" },
   *   collection: [ "hot water handle", "cold water handle"],
   *   is: { listed: false },
   *   descriptions: { look: "Two porcelain bathtub handles, hot and cold. ", },
   * });
   * MyGame.createAsset({
   *   class: "Plug",
   *   name: "bathtub plug",
   *   synonyms: "plug",
   *   place: { in: "bathtub" },
   *   descriptions: { look: "A bathtub drain plug. ", },
   * });
   * </code></pre>
   **/
  class Bathtub extends adventurejs.Drainable {
    constructor(name, game_name) {
      super(name, game_name);
      this.class = "Bathtub";

      this.noun = "bathtub";
      this.plural = "bathtubs";
      this.synonyms = ["tub"];
      this.singlePluralPairs = [["bathtub", "bathtubs"]];
      this.default_aspect = "in";

      this.setDOVs(["turnOn", "turnOff", "plug", "get"]);
      this.setDOV({ unplug: { with_nothing: true } });
      this.setIOVs(["put", "take"]);

      this.aspects.in.set({
        list_contents_in_examine: true,
        list_contents_in_room: false,
        contents_limits: {
          height: 2,
          width: 6,
          depth: 2,
          count: 10,
          weight: 100,
        },

        nest: {
          posture: "sit",
          preposition: "in",
          can: {
            enter: true,
            exit: true,
            hide: true,
            kneel: true,
            lie: true,
            sit: true,
            stand: true,
          },
        },
      });

      this.aspects.in.vessel.set({ maxvolume: "200L" });
    }
  }
  adventurejs.Bathtub = Bathtub;
})();