├── .gitignore
├── README.md
├── package-lock.json
├── package.json
├── rollup.config.mjs
├── sass.js
├── screenshot.png
├── src
├── copy
│ └── index.html
├── games
│ ├── ai
│ │ ├── config.json
│ │ ├── gamestate.json
│ │ └── vocabulary.json
│ ├── de
│ │ ├── config.json
│ │ ├── gamestate.json
│ │ ├── messages.json
│ │ └── vocabulary.json
│ ├── escape
│ │ ├── cell1.png
│ │ ├── cell2.png
│ │ ├── config.json
│ │ ├── gamestate.json
│ │ ├── messages.json
│ │ ├── narrow-passage.png
│ │ ├── stone-texture.png
│ │ └── vocabulary.json
│ ├── games.json
│ ├── messages.json
│ └── tutorial
│ │ ├── config.json
│ │ ├── gamestate.json
│ │ ├── messages.json
│ │ └── vocabulary.json
├── img
│ └── adventex.png
├── js
│ ├── const.js
│ ├── eventactionhandler.js
│ ├── eventhandler.js
│ ├── functions.js
│ ├── helper.js
│ ├── interpreter.js
│ ├── inventoryhandler.js
│ ├── json.js
│ ├── locationhandler.js
│ ├── main.js
│ └── parser.js
├── scss
│ └── main.scss
└── svg
│ └── icecream.svg
└── test
├── browser-sync.js
├── index.html
└── test.mjs
/.gitignore:
--------------------------------------------------------------------------------
1 | # Node
2 | node_modules
3 | dist
4 |
5 | ## OS X
6 | .DS_Store
7 | ._*
8 | .Spotlight-V100
9 | .Trashes
10 | deploy.sh
11 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Adventex
2 |
3 | Adventex is a simple interactive fiction (text adventure) game with its own adventure system. The adventure is defined by a couple of JSON files. The game is playable at [thoster.net](https://thoster.net/adventex).
4 |
5 | It starts with a demo adventure (kind of an escape room game) and a tutorial.
6 |
7 | 
8 |
9 | ## Prerequisites
10 |
11 | You need Node.js and npm.
12 |
13 | ## Install
14 |
15 | First, you need to install the npm dependencies:
16 | ```bash
17 | npm install
18 | ```
19 |
20 | ## Run
21 |
22 | You can serve Adventex locally:
23 | ```bash
24 | npm run serve
25 | ```
26 |
27 | or build it with:
28 | ```bash
29 | npm run build
30 | ```
31 |
32 | ## Unit Tests
33 |
34 | Unit tests only work with a real browser. Start them like this:
35 | ```bash
36 | npm run serve-tests
37 | ```
38 |
39 | ## Playing
40 |
41 | If you want to learn how to play text adventures, go to "options" and hit "tutorial". This is what you get if you enter *help*:
42 |
43 | Most of the time, typing something like *verb object* works. Example: *open door*.
44 |
45 | You can go to a possible direction typing *go (direction)*.
46 |
47 | You can examine the room or any object typing *examine (object)*. Look around with *look*.
48 |
49 | More complex sentences are possible, example: *open box with crowbar*.
50 |
51 | Type *inventory* to show all your collected items.
52 |
53 | Type *help verbs* to get a list of possible verbs.
54 |
55 | ## Adventure Creation
56 |
57 | Adventures in Adventex are created / edited using JSON files. Below is a detailed explanation of how to set up an adventure.
58 |
59 | ### Events
60 |
61 | Events define the actions and descriptions of different events in the adventure, such as starting the game or interacting with objects.
62 |
63 | #### Example: `src/games/tutorial/events.json`
64 |
65 | ```json
66 | {
67 | "events": {
68 | "start_event": {
69 | "name": "Awake",
70 | "description": "Welcome to the Adventex tutorial!\nAdventex is a simple text adventure (also called 'interactive fiction').\nYou can:\nExplore different locations, pick up items (into your 'inventory') and interact with objects and the environment to solve puzzles.\nYou interact with your environment by entering simple sentences, starting with a verb.\nFor a list of possible verbs, enter 'help verbs'.\nOften it is useful to examine objects: 'examine table'. If you want to see the description of the current location, enter 'look'.\nSome objects are portable, to pick up a book, enter 'take book'\nStart with exploring your environment by visiting the other room. To do so, enter 'go east'\n",
71 | "action_move_to_location": "start_location"
72 | },
73 | "tutorial_openclose": {
74 | "name": "Open/Close Tutorial",
75 | "description": "You can open and close doors and containers. Try 'open door' or 'close chest'.",
76 | "action_move_to_location": "next_location"
77 | }
78 | }
79 | }
80 | ```
81 |
82 | ### Locations
83 |
84 | Locations define the different places in the adventure, including their descriptions and possible exits.
85 |
86 | #### Example: `src/games/tutorial/locations.json`
87 |
88 | ```json
89 | {
90 | "locations": {
91 | "start_location": {
92 | "name": "Starting Room",
93 | "description": "You are in a small, dimly lit room. There is a door to the east.",
94 | "exits": {
95 | "east": "next_location"
96 | },
97 | "objects": ["book", "table"]
98 | },
99 | "next_location": {
100 | "name": "Next Room",
101 | "description": "You are in a larger room with a window. There is a door to the west.",
102 | "exits": {
103 | "west": "start_location"
104 | },
105 | "objects": ["chest", "window"]
106 | }
107 | }
108 | }
109 | ```
110 |
111 | ### Verbs
112 |
113 | Verbs define the actions that players can perform in the game. They are used to interact with objects and the environment.
114 |
115 | #### Example: `src/games/tutorial/verbs.json`
116 |
117 | ```json
118 | {
119 | "verbs": {
120 | "go": {
121 | "description": "Move to a different location.",
122 | "action": "move_to_location"
123 | },
124 | "take": {
125 | "description": "Pick up an item.",
126 | "action": "pick_up_item"
127 | },
128 | "examine": {
129 | "description": "Look at an object or location.",
130 | "action": "examine_object"
131 | },
132 | "look": {
133 | "description": "Look around the current location.",
134 | "action": "look_around"
135 | },
136 | "open": {
137 | "description": "Open a door or container.",
138 | "action": "open_object"
139 | },
140 | "close": {
141 | "description": "Close a door or container.",
142 | "action": "close_object"
143 | }
144 | }
145 | }
146 | ```
147 |
148 | ### Synonyms
149 |
150 | Synonyms allow players to use different words for the same action, making the game more flexible and user-friendly.
151 |
152 | #### Example: `src/games/tutorial/synonyms.json`
153 |
154 | ```json
155 | {
156 | "synonyms": {
157 | "take": [
158 | "get",
159 | "pick"
160 | ],
161 | "go": [
162 | "walk",
163 | "drive",
164 | "climb"
165 | ],
166 | "look": [
167 | "watch"
168 | ],
169 | "push": [
170 | "press"
171 | ],
172 | "extinguish": [
173 | "delete"
174 | ],
175 | "clean": [
176 | "wash"
177 | ],
178 | "into": [
179 | "inside"
180 | ]
181 | }
182 | }
183 | ```
184 |
185 | ### Key Components
186 |
187 | - **Events**: Define the actions and descriptions of different events in the adventure.
188 | - **Locations**: Define the different places in the adventure, including their descriptions and possible exits.
189 | - **Verbs**: Define the actions that players can perform in the game.
190 | - **Synonyms**: Allow players to use different words for the same action, making the game more flexible and user-friendly.
191 |
192 | By configuring these JSON files, you can create and customize your own text adventures in Adventex.
193 |
194 | If you need any additional details or modifications, feel free to ask!
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "adventex",
3 | "version": "1.1.0",
4 | "description": "A javascript text adventure framework",
5 | "author": {
6 | "name": "Stefan Ostermann",
7 | "url": "https://thoster.net"
8 | },
9 | "license": "MIT",
10 | "repository": {
11 | "type": "git",
12 | "url": "https://github.com/soster/adventex"
13 | },
14 | "scripts": {
15 | "clean": "recursive-delete 'dist'",
16 | "js": "rollup --config",
17 | "css": "node sass.js",
18 | "svg": "svgo -f src/svg dist/svg -r",
19 | "statics": "copyfiles -u 3 node_modules/jquery.terminal/js/jquery.terminal.min.js dist/js && copyfiles -u 3 node_modules/jquery/dist/jquery.min.js dist/js && copyfiles -u 4 node_modules/bootstrap/dist/css/bootstrap.min.css dist/css && copyfiles -u 3 node_modules/jquery.terminal/css/jquery.terminal.min.css dist/css",
20 | "img": "imagemin src/img/* --out-dir=dist/img --plugin=mozjpeg --plugin=pngcrush",
21 | "img-copy": "recursive-copy 'src/img' 'dist/img'",
22 | "copy": "recursive-copy 'src/copy' 'dist' && recursive-copy 'src/games' 'dist/games' && copyfiles -u 2 src/js/functions.js dist/js",
23 | "build-dirty": "npm-run-all -p js css img copy statics",
24 | "build": "npm-run-all -s clean build-dirty",
25 | "watch-css": "chokidar './src/**/*.scss' -c 'npm run css'",
26 | "watch-js": "chokidar './src/**/*.js' -c 'npm run js'",
27 | "watch-svg": "chokidar './src/**/*.svg' -c 'npm run svg'",
28 | "watch-img": "chokidar './src/img/**/*.*' -c 'npm run img'",
29 | "watch-copy": "chokidar './src/copy/**/*.*' -c 'npm run copy'",
30 | "watch": "npm-run-all -p build watch-css watch-js watch-svg watch-img watch-copy",
31 | "serve-start": "browser-sync start --files 'dist' --server 'dist'",
32 | "serve": "npm-run-all -p watch serve-start",
33 | "test": "mocha -r esm",
34 | "serve-tests": "browser-sync start --config 'test/browser-sync.js' "
35 | },
36 |
37 | "devDependencies": {
38 | "@rollup/plugin-commonjs": "^23.0.2",
39 | "@rollup/plugin-legacy": "^3.0.1",
40 | "@rollup/plugin-node-resolve": "^15.0.1",
41 | "babel": "^6.23.0",
42 | "browser-sync": "^2.26.14",
43 | "chai": "^4.3.6",
44 | "chokidar-cli": "^2.1.0",
45 | "copyfiles": "^2.4.1",
46 | "esm": "^3.2.25",
47 | "imagemin-cli": "^7.0.0",
48 | "imagemin-mozjpeg": "^10.0.0",
49 | "imagemin-pngcrush": "^7.0.0",
50 | "mocha": "^10.1.0",
51 | "npm-run-all": "^4.1.5",
52 | "recursive-fs": "^2.1.0",
53 | "rollup": "^3.2.3",
54 | "rollup-plugin-minification": "^0.1.0",
55 | "sass": "^1.26.5",
56 | "svgo": "^2.8.0",
57 | "systemjs": "^6.13.0"
58 | },
59 | "dependencies": {
60 | "bootstrap": "npm:bootstrap@4.6.0",
61 | "jquery": "npm:jquery@^3.2.1",
62 | "jquery.terminal": "npm:jquery.terminal@^2.34.0"
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/rollup.config.mjs:
--------------------------------------------------------------------------------
1 | import resolve from '@rollup/plugin-node-resolve';
2 | import commonjs from '@rollup/plugin-commonjs';
3 | //import { terser } from "rollup-plugin-terser";
4 | //replacement because terser needs rollup 2 as a dependency:
5 | import { terser } from "rollup-plugin-minification";
6 |
7 | // `npm run build` -> `production` is true
8 | // `npm run dev` -> `production` is false
9 |
10 | const production = !process.env.ROLLUP_WATCH;
11 |
12 | export default {
13 | input: ['src/js/main.js'],
14 |
15 | output: {
16 | file: 'dist/js/main.js',
17 | format: 'umd', // immediately-invoked function expression — suitable for
162 |
163 |
164 |
165 |
166 |
167 |
168 |