// getPrintableObjectList.js
(function () {
/* global adventurejs A */
var p = adventurejs.Game.prototype;
/**
*
* @method adventurejs.Game#getPrintableObjectList
* @memberOf adventurejs.Game
* @param {Object} objects An array of object ID strings.
* @param {Object} exclusions An array of of object ID strings to exclude.
* @returns {String} A formatted string.
*/
p.getPrintableObjectList = function Game_getPrintableObjectList({
article,
objects,
exclusions,
}) {
this.game.log(
"L1074",
"log",
"high",
`[getPrintableObjectList.js] getPrintableObjectList() receive:\n${objects.map((a) => a.id).join(", ")}`,
"Game"
);
var list = "";
var definite = false;
if ("definite" === article) {
definite = true;
}
// remove any exclusions from objects list
if ("undefined" !== typeof exclusions) {
// convert params string to array if needed
if ("string" === typeof exclusions) {
exclusions = [exclusions];
}
objects = objects.filter(function (objects) {
return exclusions.indexOf(objects) < 0;
});
}
for (var i = 0; i < objects.length; i++) {
// objects is a list of ids - get the full object
var object = this.getAsset(objects[i]);
if (i > 0 && i < objects.length - 1) {
list += ", ";
}
if (objects.length > 1 && i === objects.length - 1) {
list += " and ";
}
list += definite ? object.definite_name : object.indefinite_name;
}
return list;
};
})();