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

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

  var p = adventurejs.Parser.prototype;

  /**
   * <p>
   * Convert some common compound prepositions into single words
   * to streamline preposition handling.
   * </p>
   * @memberOf adventurejs.Parser
   * @method adventurejs.Parser#stripArticles
   * @param {String} input Player input.
   * @returns {String}
   */
  p.stripArticles = function Parser_stripArticles(parsed_input) {
    this.game.log(
      "L1570",
      "log",
      "high",
      `[stripArticles.js] stripArticles() receive: ${parsed_input}`,
      "Parser"
    );
    parsed_input = parsed_input.replace(/ the /g, " ");
    parsed_input = parsed_input.replace(/^the /g, "");
    parsed_input = parsed_input.replace(/ a /g, " ");
    parsed_input = parsed_input.replace(/^a /g, "");
    parsed_input = parsed_input.replace(/ an /g, " ");
    parsed_input = parsed_input.replace(/^an /g, "");
    //input = input.replace(/ some /g, " ");

    this.game.log(
      "L1237",
      "log",
      "high",
      `[stripArticles.js] stripArticles() return:\n${parsed_input}`,
      "Parser"
    );
    return parsed_input;
  };
})();