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

  /**
   * @ajspath adventurejs.Atom.Asset.Matter.Tangible.Thing.Paper
   * @augments adventurejs.Thing
   * @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.Thing|Thing}.
   * To {@link write} on it, set
   * <code class="property">asset.dov.write.enabled</code> to true.
   * To {@link type} on it, set
   * <code class="property">asset.dov.type.enabled</code> to true
   * and put it in a {@link adventurejs.Typewriter|Typewriter}.
   * To append strings typed or written on it to its description, set
   * <code class="property">append_written_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. Written on the blue sheet is a phrase: "cordon bleu".
   * </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.Thing {
    constructor(name, game_name) {
      super(name, game_name);
      this.class = "Paper";

      this.synonyms = ["paper"];
      this.setDOVs([
        "put",
        "get",
        "take",
        "give",
        "tear",
        "erase",
        "read",
        // "write",
      ]);
      this.setIOV({ type: { with_params: { target: true } } });
      this.setIOV({ write: { with_params: { target: true } } });

      this.append_written_strings_to_description = true;
      this.append_typed_strings_to_description = true;
    }
  }

  adventurejs.Paper = Paper;
})();