https://github.com/maelys-mcardle/adventure
adventure is an interactive fiction engine.
https://github.com/maelys-mcardle/adventure
interactive-fiction text-adventure text-adventure-engine
Last synced: about 2 months ago
JSON representation
adventure is an interactive fiction engine.
- Host: GitHub
- URL: https://github.com/maelys-mcardle/adventure
- Owner: maelys-mcardle
- License: mit
- Created: 2017-10-10T21:07:18.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-03-25T22:43:14.000Z (about 7 years ago)
- Last Synced: 2024-10-23T21:14:08.491Z (6 months ago)
- Topics: interactive-fiction, text-adventure, text-adventure-engine
- Language: JavaScript
- Homepage: http://www.maelys.bio
- Size: 536 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Adventure
- [Adventure](#adventure)
- [Overview](#overview)
- [Installing Adventure](#installing-adventure)
- [Playing a game](#playing-a-game)
- [Creating games](#creating-games)
- [Adventure API](#adventure-api)## Overview
Adventure is a game engine for [text adventures](https://en.wikipedia.org/wiki/Interactive_fiction).
It lets you create interactive fiction without needing to learn how to program.
Games are written in a declarative language instead which is used to define the
game world and the actions within it.
## Installing Adventure
Make sure you have [NodeJS](https://nodejs.org/) installed. Then run:
```
npm install -g https://github.com/maelys-mcardle/adventure
```## Playing a game
An interactive console for the engine be started with the command:
```bash
adventure
```The game will present an empty prompt. You can load a new story
with the `load` command:```
> load path/to/story
```Use the `help` command to get a listing of all possible commands.
## Creating games
Games in Adventure are called stories. There are resources provided to help
you write them:* The [documentation](documentation) directory contains information on
how to write stories.
* The [examples](examples) directory contains sample stories written for
Aventure, that you can try out and see how they're put together.## Adventure API
You can also integrate Adventure in your own [NodeJS](https://nodejs.org/)
projects.Install Adventure inside your project by running the following command:
```bash
npm install --save maelys-mcardle/adventure
```Then you can use the game engine in your code:
```js
'use strict';// Import the module for the Adventure API.
const adventure = require('adventure');// Loads a story from a directory. Here it loads a sample.
let story = adventure.loadStory('node_modules/adventure/examples/thehouse');// Get the output from the story in its initial state.
let text = adventure.getStoryOutput(story);
console.log(text);/* Output:
[ 'You are in the bedroom. It hasn\'t changed since your childhood.
Your pink bed sheets. The blue walls. Your plush animals. Your polly pocket
and transformers lining the shelves. Traces of your teenage self - the boxes
of video games you kept perfectly. The computer you built, and rebuilt. An
entire life that suddenly stops midway through university.',
'A letter is on the bedside table.' ]
*/// Get examples of eligible inputs that the player could use.
// It provides one example per unique thing the protagonist can do.
let inputExamples = adventure.getInputExamples(story);
console.log(inputExamples);/* Output:
[ 'go to the upstairs hallway',
'read the letter',
'describe world' ]
*/// Alternatively, get all the eligible inputs that the player could use.
let allEligibleInputs = adventure.getAllInputs(story);
console.log(allEligibleInputs);/* Output:
[ 'go to the upstairs hallway',
'go to upstairs hallway',
'go the upstairs hallway',
'go upstairs hallway',
'travel to the upstairs hallway',
...
'inspect at the world',
'examine world',
'examine at world',
'examine the world',
'examine at the world' ]
*/// Execute a player input, which will move the story forward.
let [updatedStory, newText] =
adventure.evaluateInput(story, 'walk to upstairs hallway');
console.log(newText);/* Output:
[ 'You are in the upstairs hallway. Paintings line the wall.' ]
*/
```