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

  /**
   * @ajspath adventurejs.Atom.Asset.Matter.Tangible.Thing.WritingSurface.Paper
   * @augments adventurejs.WritingSurface
   * @class adventurejs.Paper
   * @ajsconstruct MyGame.createAsset({ "class":"Paper", "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 sheet of paper that can be typed on or written on.
   * @tutorial Tangibles_AboutTangibles
   * @ajsdemo WritingDemo, Office, Playroom, Classroom, Library, Scorecard
   * @ajscss Styles
   * @classdesc
   * <p>
   * <strong>Paper</strong> is a subclass of
   * {@link adventurejs.WritingSurface|WritingSurface} with
   * <code class="property">asset.dov.write.enabled</code> and its
   * <code class="property">asset.dov.erase.enabled</code> properties set to true.
   * To append strings written on it to its description, set
   * <code class="property">append_written_strings_to_description</code>
   * to true.
   * <code class="property">asset.dov.write.enabled</code> allows it to receive
   * strings using the
   * {@link adventurejs.Verb|Verb} {@link write}.
   * <code class="property">asset.dov.erase.enabled</code>
   * allows it to be erased.
   * <code class="property">asset.dov.type.enabled</code> allows it to receive
   * strings using the
   * {@link adventurejs.Verb|Verb} {@link type}, via
   * {@link adventurejs.Typewriter|Typewriter}.
   * To append strings typed on it to its description, set
   * <code class="property">append_typed_strings_to_description</code>
   * to true.
   * </p>
   * <pre class="display border outline">
   * <span class="ajs-player-input">&gt; write "cordon bleu" on blue sheet
   * You write "cordon bleu" on the blue sheet with the blue pencil.
   *
   * <span class="ajs-player-input">&gt; examine blue sheet
   * It's a blue sheet of paper. The phrase "cordon bleu" is written on it in blue pencil.
   * </pre>
   * <h3 class="examples">Example:</h3>
   * <pre class="display"><code class="language-javascript">MyGame.createAsset({
   *   class: "Paper",
   *   name: "blue sheet",
   *   descriptions: { look: "It's a blue sheet of paper. ", },
   *   place: { in: "middle drawer" },
   * });
   * MyGame.createAsset({
   *   class: "Paper",
   *   name: "goldenrod sheet",
   *   descriptions: { look: "It's a goldenrod sheet of paper. ", },
   *   place: { in: "bottom drawer" },
   * });
   * MyGame.createAsset({
   *   class: "Paper",
   *   name: "pink sheet",
   *   descriptions: { look: "It's a pink sheet of paper. ", },
   *   place: { in: "top drawer" },
   * });
   * MyGame.createAsset({
   *   class: "Typewriter",
   *   name: "typewriter",
   *   place: { on: "desk" },
   *   descriptions: { look: "It's a top of the line IBM Selectric typewriter. ", },
   *   dov: { take: false, },
   * });
   * </code></pre>
   **/
  class Paper extends adventurejs.WritingSurface {
    constructor(name, game_name) {
      super(name, game_name);
      this.class = "Paper";

      this.synonyms = ["paper"];

      this.setDOVs(["put", "get", "take", "give", "tear", "erase", "read"]);

      this.setIOV({
        type: { with_classes: ["Typewriter"], with_params: { target: true } },
      });
      this.setIOV({
        write: {
          with_classes: ["WritingImplement"],
          with_params: { target: true },
        },
      });
      this.setIOV({
        draw: {
          with_classes: ["WritingImplement"],
          with_params: { target: true },
        },
      });

      this.append_typed_strings_to_description = true;
    }
  }

  adventurejs.Paper = Paper;
})();