Pre-release
AdventureJS Docs Downloads Bundler Devlog
Score: 0 Moves: 0
// getNumeric.js

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

  var p = AdventureJS.Dictionary.prototype;

  /**
   * Determine whether string is recognized as a numeric word.
   * @memberOf AdventureJS.Dictionary
   * @method AdventureJS.Dictionary#getNumeric
   * @kind function
   * @param {String} word
   * @returns {String|Boolean}
   */
  p.getNumeric = function Dictionary_getNumeric(word) {
    this.game.log(
      "L1602",
      "log",
      "high",
      `[Dictionary.js] getNumeric receive: ${word}`,
      "Parser"
    );

    const ONES = [
      "zero",
      "one",
      "two",
      "three",
      "four",
      "five",
      "six",
      "seven",
      "eight",
      "nine",
      "ten",
      "eleven",
      "twelve",
      "thirteen",
      "fourteen",
      "fifteen",
      "sixteen",
      "seventeen",
      "eighteen",
      "nineteen",
    ];

    const TENS = [
      "twenty",
      "thirty",
      "forty",
      "fifty",
      "sixty",
      "seventy",
      "eighty",
      "ninety",
    ];

    const THOUSANDS = ["thousand", "million", "billion", "trillion"];

    if (
      ONES.includes(word) ||
      TENS.includes(word) ||
      THOUSANDS.includes(word)
    ) {
      this.game.log(
        "L1609",
        "log",
        "high",
        `[Dictionary.js] getNumeric found: ${word}`,
        "Parser"
      );
      return word;
    } else return false;
  };
})();