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

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

  var p = adventurejs.Game.prototype;

  /**
   * Prompt user to press a key to continue.
   * @method adventurejs.Game#promptUser
   * @memberOf adventurejs.Game
   */
  p.promptUser = function Game_promptUser(
    msg = this.game.settings.prompt_text
  ) {
    if (this.game.enqueue_output) {
      this.game.enqueue_output = false;
      // @TODO do we have a problem if we were already enqueueing?
    }
    this.game.print(msg, "ajs-prompt");
    this.game.enqueue_output = true;
    document.addEventListener(
      "keydown",
      window[`${this.game_name}_clearPrompt`]
    );
  };
})();