// Chest.js
(function () {
/*global adventurejs A*/
"use strict";
/**
* @ajspath adventurejs.Atom.Asset.Matter.Tangible.Thing.Container.SolidContainer.Chest
* @augments adventurejs.SolidContainer
* @class adventurejs.Chest
* @ajsconstruct MyGame.createAsset({ "class":"Chest", "name":"foo", [...] })
* @ajsconstructedby adventurejs.Game#createAsset
* @ajsnavheading TreasureClasses
* @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 Maybe there's gold inside! Arg a trap!
* @ajstangiblecontainer in
* @classdesc <strong>Chest</strong> is a subclass of
* {@link adventurejs.Container|Container} /
* {@link adventurejs.SolidContainer|SolidContainer}. Chests can be
* locked and unlocked with a {@link adventurejs.Key|Key}
* (or {@link adventurejs.Lockpick|Lockpick}).
*
* The interaction is determined by properties on both the
* Chest and the Key.
* The Chest will have the Key ID listed in its
* <code class="property">asset.dov.unlock.with_assets</code>.
* The Key will also have a list of Asset IDs it can unlock in its
* <code class="property">asset.iov.unlock.with_assets</code>
* property.
* (You can set just one or the other in your game file.
* As long as one is set, the Key and Lock will be associated during
* initialization. )
* See the example below to create locked chest with a key.
* <pre class="display"><code class="language-javascript">MyGame.createAsset({
* class: "Chest",
* name: "treasure chest",
* place: { in: "Treasure Room" },
* is: { locked: true },
* dov: { unlock: { with_assets: ['brass key'], }, },
* });
* MyGame.createAsset({
* class: "Key",
* name: "brass key",
* place: { in: "Treasure Room" },
* iov: { unlock: { with_assets: ['treasure chest'], }, },
* });
* </code></pre>
**/
class Chest extends adventurejs.SolidContainer {
constructor(name, game_name) {
super(name, game_name);
this.class = "Chest";
this.noun = "chest";
this.plural = "chests";
this.singlePluralPairs = [["chest", "chests"]];
this.unsetDOVs(["take", "put", "give"]); // depends on size of chest - up to author
this.setDOVs(["close", "open"]);
this.setDOV({
unlock: { with_nothing: false },
});
this.setDOV({
lock: { with_nothing: false },
});
this.is.closed = true;
this.is.locked = true;
this.aspects.in = new adventurejs.Aspect("in", this.game_name).set({
parent_id: this.id,
list_in_examine: true,
maxheight: 6,
maxwidth: 6,
maxdepth: 6,
maxcount: 10,
maxsize: 20,
maxweight: 100,
});
}
}
adventurejs.Chest = Chest;
})();