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

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

	var p = adventurejs.Parser.prototype;

  /**
   * Exclude from a list of assets all assets that are not global substances.
   * @method adventurejs.Parser#selectGlobalSubstance
   * @memberOf adventurejs.Parser
   * @param {Array} list 
   * @returns {Array}
   */
   p.selectGlobalSubstance = function Parser_selectGlobalSubstance(list) 
  {
		if(typeof list !== "object" ) 
    {
			console.warn("selectGlobalSubstance received non-array", list);
			return [];
		}
		var foundObjects = [];
		for(var i = 0; i < list.length; i++) 
    {
      var object = list[i];
      var asset_aspect_substance = object.split(":");
      if( 1 < asset_aspect_substance.length ) {
        // discard substance-in-tangible
        continue;
      } else {
        object = this.game.getAsset( list[i] );
      }

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

    return foundObjects;
	}
  
}());