// Cabinet.js
(function () {
/* global AdventureJS A */
/**
* @ajspath AdventureJS.Atom.Asset.Tangible.Entity.Container.SolidContainer.Cabinet
* @augments AdventureJS.Assets.SolidContainer
* @class AdventureJS.Assets.Cabinet
* @ajsconstruct MyGame.createAsset({ "class": "Cabinet", "name": "foo", [...] })
* @ajsconstructedby AdventureJS.Game#createAsset
* @ajsnavheading KitchenClasses
* @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>Cabinet</strong> is a subclass of
* {@link AdventureJS.Assets.Container|Container} /
* {@link AdventureJS.Assets.SolidContainer|SolidContainer}. Cabinets can be
* locked and unlocked with a {@link AdventureJS.Assets.Key|Key}
* (or {@link AdventureJS.Assets.Lockpick|Lockpick}).
*
* The interaction is determined by properties on both the
* Cabinet and the Key.
* The Cabinet 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 cabinet with a key.
* <pre class="display"><code class="language-javascript">MyGame.createAsset({
* class: "Cabinet",
* name: "utility cabinet",
* place: { in: "Garage" },
* is: { locked: true },
* dov: { unlock: { with_assets: ['steel key'], }, },
* });
* MyGame.createAsset({
* class: "Key",
* name: "steel key",
* place: { in: "Garage" },
* iov: { unlock: { with_assets: ['utility cabinet'], }, },
* });
* </code></pre>
**/
class Cabinet extends AdventureJS.Assets.SolidContainer {
constructor(name, game_name, context_id = "", id = "") {
super(name, game_name, context_id, id);
this.class = "Cabinet";
this.singular = "cabinet";
this.plural = "cabinets";
this.singularPluralPairs = [["cabinet", "cabinets"]];
this.unsetDOVs(["take", "put", "give"]);
this.setDOVs(["close", "open"]);
this.setDOV({
unlock: {
with_nothing: false,
automatically: true,
automatically_after_use: true,
},
});
this.setDOV({ lock: { with_nothing: false } });
this.setIOVs(["take", "put"]);
this.is.closed = true;
// this.is.locked = true;
this.aspects.in = new AdventureJS.Helpers.Aspect(
"in",
this.game_name,
this.id
).set({
list_contents_in_examine: true,
know_contents_with_parent: false,
see_contents_with_parent: false,
capacity: {
height: 6,
width: 6,
depth: 6,
count: 10,
weight: 100,
},
});
}
}
AdventureJS.Assets.Cabinet = Cabinet;
})();