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

(function () {
  /* global adventurejs A */

  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) {
    this.game.log(
      "L1525",
      "log",
      "high",
      "[parseVerb.js] parseVerb() receive: " + verb,
      "Parser"
    );
    var keys = Object.keys(this.dictionary.verbs);
    for (var i = 0; i < keys.length; i++) {
      if (this.dictionary.testVerbSynonyms(verb, keys[i])) {
        this.game.log(
          "L1526",
          "log",
          "high",
          "[parseVerb.js] parseVerb() found: " +
            this.dictionary.verbs[keys[i]].name,
          "Parser"
        );
        return this.dictionary.verbs[keys[i]].name;
      }
    }
    return false;
  };
})();