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

  /**
   * @ajspath adventurejs.Atom.Asset.Matter.Tangible.Thing.Plug
   * @augments adventurejs.Thing
   * @class adventurejs.Plug
   * @ajsconstruct MyGame.createAsset({ "class":"Plug", "name":"foo", [...] })
   * @ajsconstructedby adventurejs.Game#createAsset
   * @ajsnavheading BathroomClasses
   * @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.
   * @ajspartof Drain, Sink
   * @summary Used to plug drains.
   * @classdesc
   * <p>
   * <strong>Plug</strong> is a subclass of
   * {@link adventurejs.Thing|Thing} but in fact any
   * {@link adventurejs.Tangible|Tangible}
   * {@link adventurejs.Asset|Asset}
   * can be used as a plug by including the ID
   * of assets it can plug in its
   * <code>asset.iov.plug.with_assets</code>.
   * A corresponding
   * <code>asset.dov.plug.with_assets</code>.
   * value is set to specify assets that can be used to plug
   * {@link adventurejs.Drain|Drains}.
   * When setting up paired assets, it's only necessary to set one
   * or the other of these properties as the pairing will be applied
   * to both assets during game initialization.
   * </p>
   * <h3 class="examples">Example:</h3>
   * <p>
   * The following example shows a plug and its corresponding drain.
   * </p>
   * <pre class="display"><code class="language-javascript">MyGame.createAsset({
   *   class: "Plug",
   *   name: "sink plug",
   *   synonyms: "plug",
   *   iov: { plug: { with_assets: { 'sink drain' }, }, },
   *   place: { in: "sink drain" },
   *   descriptions: { look: "A sink drain plug. ", },
   * });
   *
   * MyGame.createAsset({
   *   class: "Drain",
   *   name: "sink drain",
   *   is: { closed: true },
   *   dov: { plug: { with_assets: { 'sink plug' }, }, },
   *   descriptions: {
   *     look: function()
   *     {
   *       return "A dark drain. Currently
   *       $( sink drain is| open or| closed ). "
   *     },
   *   },
   * });
   * </code></pre>
   *
   * <p>
   * Some classes contain more advanced methods for linking
   * specific related asset classes. For instance, the
   * {@link adventurejs.Sink|Sinks} class has a
   * <a class="code" href="/doc/adventurejs.Tangible.html#property_parts">parts</a>
   * property that allows for easy linking of drain and plug assets.
   * </p>
   * <pre class="display"><code class="language-javascript">MyGame.createAsset({
   *   class: "Sink",
   *   name: "sink",
   *   place: { in: "Utility Room" },
   *   descriptions: {
   *     look: function()
   *     {
   *       return "A grubby utility sink with a stained drain that is currently $( sink drain is| open or| closed ). ";
   *       // see <a href="/doc/Scripting_CustomTemplates.html">Custom Templates</a> to learn about $( sink drain is| open or| closed )
   *     },
   *   },
   *   parts: [
   *     // see <a href="/doc/Tangibles_LinkedAssets.html">Linked Assets</a> to learn about parts
   *     "sink drain",
   *     "sink plug"
   *   ],
   * });
   * </code></pre>
   * <p>
   * <a class="code" href="/doc/adventurejs.Tangible.html#property_parts">parts</a>
   * allows an author to easily link certain types of class instances.
   * As shown here, the class for {@link adventurejs.Sink|Sinks}
   * contains a method for linking sinks with their constituent parts
   * including drains and faucets.
   * See
   * <a href="/doc/Tangibles_LinkedAssets.html">Linked Assets</a>
   * to learn about parts.
   * <br><br>
   * The Sink and Drain descriptions include this String Substitution:
   * $( sink drain is| open or| closed )
   * which will substitute the word "open" or
   * "closed" depending on the Drain's state. See
   * <a href="/doc/Scripting_CustomTemplates.html">Custom Templates</a>
   * to learn more.
   * </p>
   **/
  class Plug extends adventurejs.Thing {
    constructor(name, game_name) {
      super(name, game_name);
      this.class = "Plug";

      this.singlePluralPairs = [["plug", "plugs"]];

      this.descriptions.look = "It's a plug.";

      this.is.listed_in_parent = true;

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

      this.setIOV("plug", {
        with_params: {
          take_breaks_connections: true,
        },
      });

      this.dimensions.width = 0.1;
      this.dimensions.height = 0.1;
    }
  }
  adventurejs.Plug = Plug;
})();