// selectHeld.js
(function () {
/*global adventurejs A*/
var p = adventurejs.Parser.prototype;
/**
* Exclude from a list of assets all assets that are not being held by subject.
* @method adventurejs.Parser#selectHeld
* @memberOf adventurejs.Parser
* @param {Array} list
* @returns {Array}
*/
p.selectHeld = function Parser_selectHeld(list) {
if ("string" === typeof list) list = [list];
if (!Array.isArray(list)) {
this.game.log(
"L1236",
"warn",
"critical",
"selectHeld.js > received non-array",
"Parser"
);
return [];
}
var input = this.game.getInput();
var subject = input.getSubject();
var foundObjects = [];
for (var i = 0; i < list.length; i++) {
var object = this.game.getAsset(list[i]);
if (subject.isConnectedToAsset("hold", object, "to_dov")) {
foundObjects.push(list[i]);
}
}
//console.warn( "selectHeld returned " + JSON.stringify(foundObjects) );
return foundObjects;
};
})();