Pre-release
Adventure.js Docs Downloads
Score: 0 Moves: 0
// selectMatter.js

(function() {
  /*global adventurejs A*/ 
  "use strict";

	var p = adventurejs.Parser.prototype;

  /**
   * Exclude from a list of assets all non-matter assets.
   * @method adventurejs.Parser#selectMatter
   * @memberOf adventurejs.Parser
   * @param {Array} list 
   * @returns {Array}
   */
   p.selectMatter = function Parser_selectMatter(list) 
  {
    if("string" === typeof list) list = [list];
		if( !Array.isArray( list ) ) 
    {
      this.game.log( "warn", "critical", "selectMatter.js > received non-array", 'Parser' );
			return [];
		}
		var foundObjects = [];
		for(var i = 0; i < list.length; i++) 
    {
			var object = this.game.getAsset( list[i] );

      if( object instanceof adventurejs.Matter ) 
      {
        foundObjects.push( list[i] );
			}
		}

    return foundObjects;
	}
  
}());