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

  /**
   * @ajspath adventurejs.Atom.Asset.Matter.Tangible.Thing.Furniture.Desk
   * @augments adventurejs.Furniture
   * @class adventurejs.Desk
   * @ajsconstruct MyGame.createAsset({ "class":"Desk", "name":"foo", [...] })
   * @ajsconstructedby adventurejs.Game#createAsset
   * @ajsnavheading FurnitureClasses
   * @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 Get back to work!
   * @tutorial Tangibles_AboutTangibles
   * @ajstangiblecontainer behind
   * @ajstangiblecontainer attached
   * @classdesc
   * <p>
   * <strong>Desk</strong> is child class of
   * {@link adventurejs.Furniture|Furniture}.
   * In order to add {@link adventurejs.Drawer|Drawers},
   * create separate Drawer assets and attach them to a Desk,
   * as in this example.
   * </p>
   * <pre class="display"><code class="language-javascript">MyGame.createAsset({
   *   class: "Desk",
   *   name: "desk",
   *   place: { in: "Office" },
   *   descriptions: {
   *     look: function()
   *     {
   *       return "It's a heavy wooden desk, with an old office chair.
   *       It has three drawers stacked vertically. The top drawer is
   *       $( top drawer is| open or| closed )."
   *     },
   *   },
   * });
   * MyGame.createAsset({
   *   class: "Drawer",
   *   name: "top drawer",
   *   descriptions: { look: "The top drawer is $( top drawer is| open or| closed ). ", },
   *   adjectives: "desk",
   *   place: { attached: "desk" },
   *   dov: { unlock: { with_assets: ['tiny brass key'], }, },
   *   is: { locked: true, listed_in_parent: false },
   * });
   * </code></pre>
   * <p>
   * The above example uses $(string) substitutions to
   * create a dynamic description. To learn more, see
   * <a href="/doc/Scripting_CustomTemplates.html">Custom Templates</a>.
   * </p>
   * <p>
   * While you can add multiple drawers to a desk, that can lead to problems
   * with disambiguation, leading to player interactions like this one.
   * </p>
   * <pre class="display border outline">
   * <span class="input">&gt; examine drawers</i>
   * Which drawer do you mean? The top drawer, the middle drawer, or the bottom drawer?
   * </pre>
   * <p>
   * You can address this by creating a
   * {@link adventurejs.Collection|Collection}.
   * To learn more, see
   * <a href="/doc/Tangibles_Collections.html">Collections</a>.
   * </p>
   **/
  class Desk extends adventurejs.Furniture {
    constructor(name, game_name) {
      super(name, game_name);
      this.class = "Desk";

      this.noun = "desk";
      this.plural = "desks";
      this.singlePluralPairs = [["desk", "desks"]];

      this.setDOV("write");
      this.append_written_strings_to_description = true;
      this.quirks.jump_means_jump_on = false; // as in "bounce on"
      this.quirks.jump_means_jump_off = true; // as in "leap from"

      this.default_aspect = "on";

      this.can.jump_to = true;
      (this.can.jump_from = true),
        this.aspects.on.set({
          list_in_room: true,
          list_in_examine: true,
          player: {
            posture: "stand",
            can: {
              enter: true,
              kneel: true,
              stand: true,
              jump: true,
              sit: true,
            },
          },
        });

      this.aspects.behind = new adventurejs.Aspect(
        "behind",
        this.game_name
      ).set({
        parent_id: this.id,
        list_in_room: false,
        list_in_examine: true,
        player: {
          posture: "kneel",
          can: {
            enter: true,
            kneel: true,
            stand: true,
          },
        },
      });

      this.aspects.attached = new adventurejs.Aspect(
        "attached",
        this.game_name
      ).set({
        parent_id: this.id,
        list_in_room: false,
        list_in_examine: true,
        player_can_add_assets_to_contents: false,
        player_can_remove_assets_from_contents: false,
      });
    }
  }
  adventurejs.Desk = Desk;
})();