// getPrintableObjectList.js
(function() {
/*global adventurejs A*/
"use strict";
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( params )
{
this.game.log('log','high',"Tangible.js > "+this.id+" getPrintableObjectList", 'Tangible' );
//console.log( "getPrintableObjectList", params.objects );
var objects = params.objects;
var exclusions = params.exclusions;
var list = "";
var definite = false;
if( "undefined" !== typeof params.article
&& "definite" === params.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] );
object.setKnown();
object.setSeen();
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;
//list += " ";
//list += object.name;
}
return list;
}
}());