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

  var p = adventurejs.Game.prototype;

  /**
   * Print an inference to the display, appending it to the turn's input.
   * @method adventurejs.Game#print
   * @memberOf adventurejs.Game
   * @param {String} msg
   * @param {String} classes
   */
  p.printInferred = function Game_printInferred(msg = "", classes = "") {
    const input = this.game.getInput();
    if (!this.game.settings.print_inferred) return;
    if (input.getNoun(1) === "all") return;
    if (input.parsed_input === "all") return;
    if (input.parsed_input.includes(",")) return;
    if (input.verified_sentence.phrase1?.parsedNoun?.isPlural) return;
    if (this.game.parser.input_queue.length > 0) return;
    if (!classes.includes("ajs-inferred")) {
      classes += " ajs-inferred";
    }
    if (msg) msg = `(${msg})`;
    // send to display
    if (msg) this.game.print(msg, classes);
  };
})();