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

  /**
   * @ajstangiblecontainer in
   * @ajspath adventurejs.Atom.Asset.Matter.Tangible.Thing.Luggage.Knapsack
   * @augments adventurejs.Luggage
   * @class adventurejs.Knapsack
   * @ajsconstruct MyGame.createAsset({ "class":"Knapsack", "name":"foo", [...] })
   * @ajsconstructedby adventurejs.Game#createAsset
   * @ajsnavheading LuggageClasses
   * @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 For carrying your schoolbooks.
   * @tutorial Tangibles_Aspects
   * @classdesc
   * <p>
   * <strong>Knapsack</strong> is a subclass of
   * {@link adventurejs.Luggage|Luggage} that can be
   * worn and removed. It's possible to limit what can
   * be put in it by size, weight, and quantity.
   * It's also possible to restrict its contents to
   * certain classes or specific items.
   * </p>
   * <h3 class="examples">Example:</h3>
   * <p>
   * This example shows a Luggage instance that with
   * restrictions on the size, number, and weight of
   * things that can be put in it.
   * </p>
   * <pre class="display"><code class="language-javascript">MyGame.createAsset({
   *   class: "Knapsack",
   *   name: "knapsack",
   *   place: { in: "Closet" },
   *   descriptions: { look: "It's my favorite knapsack. I wear it everywhere. ", },
   *   adjectives: "favorite",
   *   in:
   *   {
   *     maxheight: 1,
   *     maxwidth: .5,
   *     maxdepth: .25,
   *     maxcount: 10, // can't hold more than 10 things
   *     maxweight: 100, // can't carry more than 100 units
   *   }
   * });
   * </code></pre>
   * <p>
   * This example shows a Knapsack instance that only
   * allows player to put certain items or classes in it.
   * </p>
   * <pre class="display"><code class="language-javascript">MyGame.createAsset({
   *   class: "Knapsack",
   *   name: "crapsack",
   *   place: { in: "Closet" },
   *   descriptions: { look: "I hate this knapsack. It's crap. ", },
   *   adjectives: "crappy",
   *   aspects: { in:
   *   {
   *     with_classes: ["Book", "Pen", "Pencil"], // any instance
   *     with_assets: ["pocket lint", "jacket fluff"], // specific items
   *   }, },
   * });
   * </code></pre>
   **/
  class Knapsack extends adventurejs.Luggage {
    constructor(name, game_name) {
      super(name, game_name);
      this.class = "Knapsack";

      this.singlePluralPairs = [["knapsack", "knapsacks"]];
      this.synonyms = ["rucksack"];

      this.setDOVs(["wear", "remove"]);

      this.aspects.in.maxheight = 1;
      this.aspects.in.maxwidth = 0.5;
      this.aspects.in.maxdepth = 0.25;
      this.aspects.in.maxcount = 10;
      this.aspects.in.maxsize = 3;
      this.aspects.in.maxweight = 100;
      this.dimensions.size = 3;

      // this.parts.zipper = {
      //     adjectives: "",
      //     descriptions: { look: "There's nothing special about the knapsack's zipper.", },
      //     nouns: "zipper",
      // };
    }
  }

  adventurejs.Knapsack = Knapsack;
})();