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

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

	var p = adventurejs.Parser.prototype;

  /**
   * Handle verb input. Verify a string against dictionary verbs. 
   * If string is a verb alias (ex: 'look at' is an alias for 'examine'), 
   * replace it with the primary verb.
   * @memberOf adventurejs.Parser
   * @method adventurejs.Parser#parseVerb
   * @param {String} verb One word from input string.
   * @returns {String}
   */
   p.parseVerb = function Parser_parseVerb( verb ) 
  {
		//console.log( "parseVerb",verb );
    var keys = Object.keys( this.dictionary.verbs );
    for( var i = 0; i < keys.length; i++) 
    {
      if( this.dictionary.testVerbSynonyms( verb, keys[i] ) ) 
      {
        return this.dictionary.verbs[ keys[i] ].name;
      }
    }
    return false;
	}

}());