//isIdInMixedArray.js
/*global adventurejs A*/
"use strict";
/**
* Convert an array of arbitrary strings to an array of IDs useable by game objects.
* <ul><li>convert ' ' to '_'</li>
* <li>convert ' and ' to '&'</li>
* <li>convert '.' to '$'</li>
* </ul>
* @method adventurejs.Game#isIdInMixedArray
* @memberOf adventurejs.Game
* @param {Array} array
* @returns {Array}
*/
adventurejs.isIdInMixedArray = function Adventurejs_isIdInMixedArray( id, array )
{
var bool = false;
//console.error( 'array',array);
for( var i = 0; i < array.length; i++ )
{
var object_i = array[i];
// is it a string such as ["bed", "table"] ?
if( "string" === typeof object_i
&& object_i === id )
{
bool = true;
}
else if( Object( object_i ) === object_i ) // it's an object
{
var object_i_keys = Object.keys( object_i );
// we're expecting objects to have only one key such as
// [{desk: ["on"]}, {uncomfortable_looking_bed: ["on"]}]
for( var num in object_i_keys )
{
var object_i_key = object_i_keys[num];
if( object_i_key === id )
{
bool = true;
}
}
}
}
return bool;
}