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

  /**
   * @ajspath adventurejs.Atom.Asset.Matter.Substance.Liquid
   * @augments adventurejs.Substance
   * @class adventurejs.Liquid
   * @ajsconstruct MyGame.createAsset({ "class":"Liquid", "name":"foo", [...] })
   * @ajsconstructedby adventurejs.Game#createAsset
   * @ajsnavheading SubstanceClasses
   * @param {String} game_name Name of top level game instance that is scoped to window.
   * @param {String} name Instance name.
   * @summary Base class for liquids. Has properties of water.
   * @tutorial Substances_AboutSubstances
   * @classdesc
   * <p>
   * <strong>Liquid</strong> is a subclass of
   * {@link adventurejs.Substance|Substance} with liquid
   * (as opposed to solid or gaseous) properties. Liquid is
   * equivalent to water in its freezing temperature, boiling
   * temperature, and specific heat.
   * </p>
   * <h3 class="examples">Example:</h3>
   * <p>
   * Substances are different from
   * {@link adventurejs.Tangible|Tangibles} in that they're
   * semi-global, rather than singular. The class represents
   * all of its kind in a {@link adventurejs.Game|Game},
   * meaning, if you create an instance called "water", all
   * water in the Game is the same water, whether it's in a
   * lake or a drinking glass. As such, Liquid
   * has no temperature setting of its own. Instead, temperature
   * can be applied to a Liquid's container.
   * </p>
   * <pre class="display"><code class="language-javascript">MyGame.createAsset({
   *   class: "Liquid",
   *   name: "water",
   *   description: "It's water. ",
   * });
   * MyGame.createAsset({
   *   class: "Bowl",
   *   name: "bowl",
   *   place: { on: "counter" },
   *   description: "It's a bowl. ",
   *   in:
   *   {
   *     vessel: {
   *       volume: 350,
   *       substance_id: "water",
   *       temperature: 20,
   *     },
   *   },
   * });
   * </code></pre>
   * <p>
   * Liquids that you define can be mixed and turned into
   * other Liquids by setting the
   * <a class="code property" href="#mixwith">mixwith</a>
   * property, as shown in the example below.
   * </p>
   * <pre class="display"><code class="language-javascript">MyGame.createAsset({
   *   class: "Liquid",
   *   name: "water",
   *   description: "It's water. ",
   *   mixwith:
   *   {
   *     "milk": "watery milk",
   *     "ketchup": "ketchup water",
   *     "beer": "watered down beer",
   *   },
   * });
   * MyGame.createAsset({
   *   class: "Liquid",
   *   name: "milk",
   *   description: "It's milk. ",
   *   mixwith:
   *   {
   *     "water": "watery milk",
   *   },
   * });
   *
   * MyGame.createAsset({
   *   class: "Liquid",
   *   name: "watery milk",
   *   description: "It's watery milk. ",
   *   mixwith:
   *   {
   *     "milk": "watery milk",
   *     "water": "watery milk",
   *   },
   * });
   * </code></pre>
   **/
  class Liquid extends adventurejs.Substance {
    constructor(name, game_name) {
      super(name, game_name);
      this.class = "Liquid";

      this.noun = "Liquid";

      this.is.known = true;
      this.is.liquid = true;

      this.setDOVs(["drink", "pour", "take", "put", "give"]);
      this.setIOVs(["fill"]);

      this.freezing_temperature = 0; // water // TODO lookup table
      this.boiling_temperature = 100; // water // TODO lookup table
      this.specific_heat = 4.2; // water = 4.2Kj or 4200j // TODO lookup table
      this.state = this.game.settings.states.LIQUID;
    }
  }

  adventurejs.Liquid = Liquid;
})();