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

  var p = adventurejs.Game.prototype;

  /**
   * Utility to allow authors to inject custom scripts
   * to be called after parseInput and before inputParseBegin,
   * allowing complete override of turn.
   * @memberOf adventurejs.Game
   * @method adventurejs.Game#createPreScript
   * @kind function
   * @param {Object} object A generic object with properties to copy into a new classed object.
   * @returns {Object} The object that was passed in.
   */
  p.createPreScript = function Game_createPreScript(object) {
    var game = this;
    Object.entries(object).forEach(([id, value]) => {
      game.pre_scripts[id] = value;
    });
    return object;
  };
})();