Pre-release
AdventureJS Docs Downloads Devlog
Score: 0 Moves: 0
// renderAgreement.js
(function () {
  /* global AdventureJS A */

  var p = AdventureJS.Game.prototype;

  /**
   * Ensure that auxiliary verbs and contractions agree
   * with the parser's pronouns.
   * @method AdventureJS.Game#renderAgreement
   * @memberOf AdventureJS.Game
   * @param {string} token The original template such as {was}.
   * @returns string;
   */
  p.renderAgreement = function Game_renderAgreement(
    token,
    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[token];
    if (!lookup) return token;
    let agreement = this.game.dictionary.agreements[lookup][type];
    if (!agreement) return token;
    console.warn({ agreement });

    return agreement;
  }; // renderAgreement
})();