// getListableContents.js
(function () {
/* global adventurejs A */
var p = adventurejs.Tangible.prototype;
/**
* Get an array of assets within this asset that are listable in
* this asset's description, for example when player examines this.
* @memberOf adventurejs.Tangible
* @method adventurejs.Tangible#getListableContents
* @returns {Array}
*/
p.getListableContents = function Tangible_getListableContents() {
this.game.log(
"L1147",
"log",
"high",
`[getListableContents.js] ${this.id}.getListableContents()`,
"Tangible"
);
var masterlist = [];
for (var aspect in this.aspects) {
if (!this.hasAspectAt(aspect)) {
continue;
}
if (
this.aspects[aspect].list_contents_in_room &&
this.aspects[aspect].contents.length > 0
) {
if ("in" === aspect && this.is.closed && this.appearance.opacity >= 1) {
continue;
}
var list = this.aspects[aspect].contents;
for (var i = 0; i < list.length; i++) {
if (this.game.getAsset(list[i]).is.listed) {
masterlist.push(list[i]);
// recurse
masterlist = masterlist.concat(
this.game.getAsset(list[i]).getListableContents()
);
}
}
}
}
return masterlist;
};
})();