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

  /**
   * @ajspath adventurejs.Atom.Asset.Matter.Tangible.Thing.Container.LiquidContainer.Drainable.Sink
   * @augments adventurejs.Drainable
   * @class adventurejs.Sink
   * @ajsconstruct MyGame.createAsset({ "class":"Sink", "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 For bathrooms and kitchens.
   * @ajsdemo PlumbingDemo, BasicSink, IntegratedSink, BasicBathtub, IntegratedBathtub, Scorecard
   * @tutorial Substances_Vessels
   * @tutorial Tangibles_Components
   * @tutorial Tangibles_Collections
   * @classdesc
   * <p>
   * <strong>Sink</strong> is a subclass of
   * {@link adventurejs.Drainable|Drainable}.
   * A Sink 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 method that only pertains to a few
   * {@link adventurejs.Asset|Asset} classes, which have been
   * pre-configured with methods for interacting with certain
   * other classes.
   * To learn more, see <a href="/doc/Tangibles_Components.html">Components</a>.
   * </p>
   * @ajsexamples
   * <p>
   * Here is an example of a basic Sink.
   * </p>
   * <pre class="display"><code class="language-javascript">MyGame.createAsset({
   *   class: "Sink",
   *   name: "pedestal sink",
   *   place: { in: "Bathroom" },
   *   description: `A simple porcelain pedestal sink.
   *   There doesn't appear to be anything important
   *   about it. The sink appears to be
   *   { pedestal sink [is] on [or] off }. `,
   * });
   * </code></pre>
   * <p>
   * Notice how these examples use AdventureJS
   * custom templates such as
   * <code>{ sink 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 an Sink 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: "Sink",
   *   name: "sink",
   *   place: { in: "Room of Rest" },
   *   descriptions: {
   *     look: function()
   *     {
   *       return `A pedestal sink with porcelain handles
   *       and a stainless steel faucet. Its drain appears to
   *       be { sink drain [is] open [or] closed }. `;
   *     },
   *   },
   *   in: {
   *     vessel: {
   *       drain_id: "sink drain",
   *     }
   *   },
   *   components: [
   *     "hot water handle",
   *     "cold water handle",
   *     "faucet",
   *     "drain",
   *     "plug"
   *   ],
   * });
   * MyGame.createAsset({
   *   class: "Drain", // see {@link adventurejs.Drain|Drain} class
   *   name: "sink drain",
   *   synonyms: "sink drain",
   *   is: { open: true, },
   *   dov: { open: true, close: true, },
   *   descriptions: {
   *     look: function()
   *     {
   *       return `A dark drain. Currently
   *       { sink drain [is] open [or] closed }. `
   *     },
   *   },
   * });
   * MyGame.createAsset({
   *   class: "Faucet", // see {@link adventurejs.Faucet|Faucet} class
   *   name: "faucet",
   *   descriptions: { look: "The sink 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", "sink handle" ],
   *   adjectives: [ "hot water", "sink", "porcelain" ],
   *   descriptions: { look: "The sink's hot water handle. ", },
   *   set_substance_id: "hot water",
   *   set_substance_temperature: 70
   * });
   * MyGame.createAsset({
   *   class: "Handle",
   *   name: "cold water handle",
   *   descriptions: { look: "The sink'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",
   *   name: "sink handles",
   *   synonyms: [ "porcelain handles" ],
   *   place: { attached: "sink" },
   *   collection: [ "hot water handle", "cold water handle"],
   *   is: { listed: false },
   *   descriptions: { look: "Two porcelain sink handles, hot and cold. ", },
   * });
   * MyGame.createAsset({
   *   class: "Plug",
   *   name: "sink plug",
   *   synonyms: "plug",
   *   place: { in: "sink" },
   *   descriptions: { look: "A sink drain plug. ", },
   * });
   * </code></pre>
   **/
  class Sink extends adventurejs.Drainable {
    constructor(name, game_name) {
      super(name, game_name);
      this.class = "Sink";

      this.noun = "sink";
      this.plural = "sinks";
      this.singlePluralPairs = [["sink", "sinks"]];
      this.default_aspect = "in";

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

      this.aspects.in.set({
        contents_limits: {
          height: 2,
          width: 2,
          depth: 2,
          count: 5,
          weight: 10,
        },
        list_contents_in_examine: true,
        list_contents_in_room: true,
        nest: { can: { enter: false } },
      });

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