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

  /**
   * @ajspath AdventureJS.Atom.Asset.Matter.Tangible.Thing.WritingImplement
   * @augments AdventureJS.Assets.Thing
   * @class AdventureJS.Assets.WritingImplement
   * @ajsconstruct MyGame.createAsset({ "class":"WritingImplement", "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 Generic base class for pens, pencils and the like.
   * @tutorial Tangibles_AboutTangibles
   * @ajsdemo WritingDemo, Office, Playroom, Classroom, Library, Scorecard
   * @ajscss Styles
   * @ajstangiblecontainer attached
   * @classdesc
   * <p>
   * <strong>WritingImplement</strong> is a subclass of
   * {@link AdventureJS.Assets.Thing|Thing}, and is chiefly notable
   * in that its <code class="property">iov.write</code>
   * property is set to true, which allows a player to write
   * on other assets such as {@link AdventureJS.Assets.Paper|Paper}.
   * </p>
   * <p>
   * WritingImplement has an
   * <code class="property">attached</code>
   * {@link AdventureJS.AssetHelpers.Aspect|Aspect}
   * which allows one thing to be attached to it.
   * No particular things are specified. See
   * {@link AdventureJS.Assets.Pen|Pen} and
   * {@link AdventureJS.Assets.Pencil|Pencil}
   * for examples of WritingImplements
   * that specify a certain class which
   * may be attached.
   * To learn more about limiting what may be attached, see
   * <a href="/doc/Tangibles_Aspects.html">How to Use Aspects</a>.
   * </p>
   * <h3 class="examples">Example:</h3>
   * <pre class="display"><code class="language-javascript">MyGame.createAsset({
   *   class: "WritingImplement",
   *   name: "purple crayon",
   *   article: "a",
   *   place: { in: "crayon box" },
   *   descriptions: { look: "This purple crayon looks like it could be used to draw anything. ", },
   * });
   * </code></pre>
   **/
  class WritingImplement extends AdventureJS.Assets.Thing {
    constructor(name, game_name, context_id = "", id = "") {
      super(name, game_name, context_id, id);
      this.class = "WritingImplement";
      this.group = ["writing implements"];

      this.setIOV({
        write: { with_classes: ["Paper"], with_params: { tool: true } },
      });

      // @TODO what about "write with pen" ?

      this.setIOV({
        draw: { with_classes: ["Paper"], with_params: { tool: true } },
      });

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

      this.on_tie_to_this_take_this = true;
      this.on_tie_to_drag_behind_rope = true;

      /**
       * String representing a color. Intended for things like
       * colored pens.
       * @var {String} AdventureJS.Assets.WritingImplement#color
       * @default ""
       */
      // this.appearance.color = "";
      this.color = "";

      /**
       * Indicates whether strings written with this implement
       * can be erased.
       * @var {Boolean} AdventureJS.Assets.WritingImplement#is!erasable
       * @default false
       */
      this.is.erasable = false;
    }
  }
  AdventureJS.Assets.WritingImplement = WritingImplement;
})();