Playing the game
Install the game locally like:
$ npm install -g adventurejs $ adventurejs Welcome to ADVENTURE! Original development by Willie Crowther. Major features added by Don Woods. Conversion to BDS C by J. R. Jaeger. Unix standardization by Jerry D. Pohl. JS porting & tweaks by Ray Myers. Would you like instructions? >
Using the game through an API
You can also use this project as an API, so that the game iself can be used in all kinds of funky ways.
npm install --save adventurejs
yarn add adventurejs
const adventure = ;
Starting a new game:
const game = adventure;game; // -> ["", " Welcome to ADVENTURE!", ...]
Note: every call to
.advance() will return an array of lines to show to the user.
Advancing the game:
game; // <- Takes a line from the user// -> ["You are standing at the end of a road before a small brick", ...]game; // <- Returns 'true' when the game is in an irreconcilable game-over state.
Saving / Loading:
The game state object is JSON-serializable, so saving the game to file could look like:
const fs = ;fs;
.makeState() method can accept a JS object to initialize itself, so loading could look like:
const raw = fs;const data = JSON;const loadedGame = adventure;