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

  /**
   * @ajspath adventurejs.Atom.Asset.Matter.Tangible.Thing.WritingImplement.Pencil
   * @augments adventurejs.WritingImplement
   * @class adventurejs.Pencil
   * @ajsconstruct MyGame.createAsset({ "class":"Pencil", "name":"foo", [...] })
   * @ajsconstructedby adventurejs.Game#createAsset
   * @ajsnavheading WritingClasses
   * @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.
   * @summary A writing implement.
   * @classdesc
   * <p>
   * <strong>Pencil</strong> is a subclass of
   * {@link adventurejs.WritingImplement|WritingImplement}.
   * Pens and other WritingImplements have their
   * <code class="property">iov.write.enabled</code>
   * property set to true, which allows a player to write on things
   * with <code class="property">asset.dov.write.enabled</code>
   * set to true, such as {@link adventurejs.Paper|Paper}.
   * </p>
   * <p>
   * All that distinguishes Pen from other WritingImplements
   * is that its
   * <code class="property">attached</code>
   * {@link adventurejs.Aspect|Aspect}
   * allows an instance of class
   * {@link adventurejs.Eraser|Eraser} to be attached.
   * </p>
   * <h3 class="examples">Example:</h3>
   * <pre class="display"><code class="language-javascript">MyGame.createAsset({
   *   class: "Pencil",
   *   name: "chewed pencil",
   *   article: "a",
   *   place: { on: "table" },
   *   descriptions: { look: "It's a #2 pencil with teeth marks and a worn out eraser. ", },
   * });
   * MyGame.createAsset({
   *   class: "Eraser",
   *   name: "frog eraser",
   *   article: "the",
   *   place: { on: "table" },
   *   descriptions: { look: "It's an eraser in the shape of a frog. ", },
   * });
   * MyGame.createAsset({
   *   class: "Paper",
   *   name: "construction paper",
   *   descriptions: { look: "It's a pink sheet of construction paper. ", },
   *   adjectives: ["pink"]
   *   place: { in: "bottom drawer" },
   * });
   * </code></pre>
   * <p>
   * The above example uses
   * <code class="property">with_classes</code>
   * to limit what a
   * player can put in without having to write custom
   * failure code for every object. To learn more, see
   * <a href="/doc/Tangibles_Aspects.html">How to Use Aspects</a>.
   * </p>
   **/
  class Pencil extends adventurejs.WritingImplement {
    constructor(name, game_name) {
      super(name, game_name);
      this.class = "Pencil";

      this.noun = "pencil";
      this.plural = "pencils";
      this.singlePluralPairs = [["pencil", "pencils"]];
      this.group = ["writing implements"];

      this.aspects.attached = new adventurejs.Aspect(
        "attached",
        this.game_name
      ).set({
        parent_id: this.id,
        list_in_room: false,
        list_in_examine: true,
        maxcount: 1, // presumably a cap
        with_classes: ["Eraser"],
      });
    }
  }
  adventurejs.Pencil = Pencil;
})();