// Drawer.js
(function () {
/*global adventurejs A*/
"use strict";
/**
* @ajspath adventurejs.Atom.Asset.Matter.Tangible.Thing.Container.SolidContainer.Drawer
* @augments adventurejs.SolidContainer
* @class adventurejs.Drawer
* @ajsconstruct MyGame.createAsset({ "class":"Drawer", "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 Like you'd find in a desk.
* @ajstangiblecontainer in
* @classdesc
* <p>
* <strong>Drawer</strong> is a child class of
* {@link adventurejs.Container|Container} /
* {@link adventurejs.SolidContainer|SolidContainer}.
* A Drawer can easily be attached to a
* {@link adventurejs.Desk|Desk} (or any
* {@link adventurejs.Tangible|Tangible}, really),
* 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"><code class="language-javascript">
* <span class="input">< examine drawers</span>
* Which drawer do you mean? The top drawer, the middle drawer, or the bottom drawer?
* </code></pre>
* <p>
* You can address this by creating a
* {@link adventurejs.Collection|Collection}.
* To learn more about Collections, see
* <a href="/doc/Tangibles_Collections.html">Collections</a>.
* </p>
**/
class Drawer extends adventurejs.SolidContainer {
constructor(name, game_name) {
super(name, game_name);
this.class = "Drawer";
this.singlePluralPairs = [["drawer", "drawers"]];
this.unsetDOVs(["take", "put", "give"]);
this.setDOVs(["lock", "unlock"]);
this.setDOV({ open: { with_nothing: true } });
this.setDOV({ close: { with_nothing: true } });
this.is.closed = true;
this.is.hollow = true;
this.is.locked = false;
this.aspects.in = new adventurejs.Aspect("in", this.game_name).set({
parent_id: this.id,
list_in_examine: true,
maxheight: 1,
maxwidth: 3,
maxdepth: 2,
maxcount: 10,
maxsize: 4,
maxweight: 5,
});
this.is.fixed = true;
this.is.listed_in_room = false;
}
}
adventurejs.Drawer = Drawer;
})();