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

  /**
   * @ajspath adventurejs.Atom.Asset.Matter.Tangible.Thing.Coathook
   * @augments adventurejs.Thing
   * @class adventurejs.Coathook
   * @ajsconstruct MyGame.createAsset({ "class":"Coathook", "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 A place to hang your hat. And coat, of course.
   * @ajstangiblecontainer on
   * @classdesc
   * <p>
   * <strong>Coathook</strong> is a simple subclass of
   * {@link adventurejs.Thing|Thing} that can have things
   * hung on it. By default it does not exclude anything
   * from being hung, which might lead to players hanging
   * odd things. See the example below for an example of
   * how to restrict a Coathook to cloathing.
   * </p>
   * <pre class="display"><code class="language-javascript">MyGame.createAsset({
   *   class: "Coathook",
   *   name: "coathook",
   *   synonyms: "hook",
   *   place: { in: "Foyer" },
   *   descriptions: { look: "It's a coathook. ", },
   *   aspects: { on: {
   *     with_classes: ["Clothing"]
   *   }, },
   * });
   * </code></pre>
   * <p>
   * It's also possible to allow only certain objects
   * to be hung.
   * </p>
   * <pre class="display"><code class="language-javascript">MyGame.createAsset({
   *   class: "Coathook",
   *   name: "coathook",
   *   place: { in: "Foyer" },
   *   descriptions: { look: "It's a coathook. ", },
   *   on: {
   *     with_assets: ["burberry coat", "mackintosh coat"]
   *   }
   * });
   * </code></pre>
   * <p>
   * The above example uses
   * <code class="property">with_classes</code>
   * and <code class="property">with_assets</code>
   * to limit what a
   * player can put in without having to write custom
   * failure code for every object. To learn more, see
   * <a href="/doc/Tangibles_Aspects.html">How to Use Aspects</a>.
   * </p>
   **/
  class Coathook extends adventurejs.Thing {
    constructor(name, game_name) {
      super(name, game_name);
      this.class = "Coathook";
      this.setIOVs(["put", "hang", "take", "tie"]);
      this.can.hang_things_on_this = true;
      this.is.listed_in_room = false;
      this.aspects.on = new adventurejs.Aspect("on", this.game_name).set({
        parent_id: this.id,
        maxcount: 1,
      });
    }
  }

  adventurejs.Coathook = Coathook;
})();