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

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

  var p = AdventureJS.Dictionary.prototype;

  /**
   * Takes an auxiliary verb or contraction
   * ("was", "were", "don't", "doesn't", etc)
   * and converts to the equivalent word according
   * to target pronouns.
   * @memberOf AdventureJS.Dictionary
   * @method AdventureJS.Dictionary#agree
   * @kind function
   * @param {String} pronoun
   * @ajsinternal
   */
  p.agree = function Dictionary_agree(
    word,
    pronouns = this.game.settings.game_pronouns
  ) {
    const input = this.game.getInput();
    const subject = input.getSubject();
    pronouns = subject.pronouns;

    const person = this.game.dictionary.inflections[pronouns].person;
    const singular = this.game.dictionary.inflections[pronouns].singular;

    const type =
      person === "first" && singular
        ? "first_person_singular"
        : person === "first"
          ? "first_person_plural"
          : person === "second"
            ? "second_person"
            : singular
              ? "third_person_singular"
              : "third_person_plural";

    // insert handling logic here
    let lookup = this.game.dictionary.agreements_lookup[word];
    if (!lookup) return word;
    let agreement = this.game.dictionary.agreements[lookup][type];
    if (!agreement) return word;
    console.warn({ agreement });

    return agreement;
  };
})();