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

  /**
   * @ajspath AdventureJS.Atom.Asset.Matter.Tangible.Thing.WritingSurface
   * @augments AdventureJS.Assets.Thing
   * @class AdventureJS.Assets.WritingSurface
   * @ajsconstruct MyGame.createAsset({ "class":"WritingSurface", "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 surface that can be written on and erased.
   * @tutorial Tangibles_AboutTangibles
   * @ajsdemo WritingDemo, Office, Playroom, Classroom, Library, Scorecard
   * @ajscss Styles
   * @classdesc
   * <p>
   * <strong>WritingSurface</strong> is a subclass of
   * {@link AdventureJS.Assets.Thing|Thing} with its
   * <code class="property">asset.dov.write.enabled</code> and
   * <code class="property">asset.dov.erase.enabled</code> properties set to true.
   * <code class="property">asset.dov.write.enabled</code> allows it to receive
   * strings using the
   * {@link AdventureJS.Dictionary.Verb|Verb} {@link write}.
   * <code class="property">asset.dov.erase.enabled</code>
   * allows it to be erased and
   * <code class="property">asset.dov.erase.with_nothing</code>
   * allows it to be erased without an eraser.
   * With WritingSurface's
   * <code class="property">append_written_strings_to_description</code>
   * property set to true, anything written
   * on it can be included in the WritingSurface's description.
   * With WritingSurface's
   * <code class="property">append_drawn_things_to_description</code>
   * property set to true, anything drawn
   * on it can be included in the WritingSurface's description.
   * </p>
   * <div class="display">
   * <div class="ajs-player-input">&gt; write "I will not poop in class" on blackboard</div>
   * <div class="ajs-p">You write "I will not poop in class" on the blackboard with the chalk.</div>
   *
   * <div class="ajs-player-input">&gt; examine blackboard</div>
   * <div class="ajs-p">It's a big blackboard. Written on it is a phrase: "I will not poop in class".</div>
   * </div>
   * <h3 class="examples">Example:</h3>
   * <pre class="display"><code class="language-javascript">MyGame.createAsset({
   *   class: "Blackboard",
   *   name: "blackboard",
   *   descriptions: { look: "It's a big gradeschool-style blackboard. ", },
   *   place: { in: "Schoolroom" },
   * });
   * </code></pre>
   **/
  class WritingSurface extends AdventureJS.Assets.Thing {
    constructor(name, game_name, context_id = "", id = "") {
      super(name, game_name, context_id, id);
      this.class = "WritingSurface";

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

      this.append_written_strings_to_description = true;
      this.append_drawn_things_to_description = true;
    }
  }
  AdventureJS.Assets.WritingSurface = WritingSurface;
})();