{
  "name": "adventure",
  "version": "2.8.0",
  "description": "quickly hack together a nodeschool adventure",
  "main": "index.js",
  "dependencies": {
    "inherits": "~2.0.1",
    "minimist": "~0.2.0",
    "mkdirp": "~0.5.0",
    "split": "~0.3.0",
    "terminal-menu": "~0.2.0",
    "through2": "~0.5.1",
    "x256": "~0.0.1"
  },
  "devDependencies": {
    "tape": "^2.13.2",
    "adventure-verify": "^2.0.0"
  },
  "scripts": {
    "test": "tape test/*.js"
  },
  "repository": {
    "type": "git",
    "url": "git://github.com/substack/adventure.git"
  },
  "homepage": "https://github.com/substack/adventure",
  "keywords": [
    "nodeschool",
    "adventure",
    "workshop",
    "education",
    "edutainment"
  ],
  "author": {
    "name": "James Halliday",
    "email": "mail@substack.net",
    "url": "http://substack.net"
  },
  "license": "MIT",
  "readme": "# adventure\n\nquickly hack together a [nodeschool](http://nodeschool.io) adventure\n\nThis is an alternative to the\n[workshopper](https://www.npmjs.org/package/workshopper)\nmodule, which you should also look at.\n\n`workshopper` is more convention-driven and fully-featured, but expects a\nparticular (configurable) filesystem organization for problems.\n\n`adventure` is entirely api-driven and has fewer configuration options.\n\n# tutorial\n\nYou can fork this tutorial from the\n[example-adventure](https://github.com/substack/example-adventure) repo.\n\nFirst make a `runner.js`. This is the file you can wire up to the `package.json`\n`\"bin\"` field.\n\n``` js\n#!/usr/bin/env node\n\nvar adventure = require('adventure');\nvar shop = adventure('example-adventure');\n\nshop.add('dinosaurs', function () { return require('./dinosaurs') });\nshop.add('robots', function () { return require('./robots') });\nshop.add('wowsers', function () { return require('./wowsers') });\n\nshop.execute(process.argv.slice(2));\n```\n\nYou simply `.add(name, fn)` each of the adventures in your problem set and then\n`.execute()` the adventure with the command-line arguments.\n\nThe interface to problem files is very simple. The simplest version of a problem\nis just an object with a `.problem` string and `.verify` function.\n\nHere's what we can put in `dinosaurs/index.js`:\n\n``` js\nexports.problem = 'Make a dinosaur sound.\\n'\n    + 'Use `$ADVENTURE_COMMAND verify YOUR_TEXT...` to make your sound.'\n;\n\nexports.verify = function (args, cb) {\n    if (/RAWR/.test(args)) {\n        console.log('Wow that is a convincing dinosaur.\\n');\n        cb(true);\n    }\n    else if (/rawr/i.test(args)) {\n        console.log('Close, but too quiet. Try louder.\\n');\n        cb(false);\n    }\n    else {\n        console.log(\"That doesn't sound like a dinosaur at all.\\n\");\n        cb(false);\n    }\n};\n```\n\nYou don't need to put this in a file necessarily even, you just need to return\nan object with these properties from the function you pass to `.add()`.\n\nYour `verify(args, cb)` function will get the arguments passed to it on the\ncommand-line and a callback that you can use to indicate whether the solution\nwas successful or not.\n\nYou can return many different kinds of objects in your `.problem` or `.solution`\nfunctions: a string, a buffer, a stream, or a function that returns a string, a\nbuffer, or a stream.\n\nNow in `robots/index.js` we can use streams for the problem and solution:\n\n``` js\nvar fs = require('fs');\nvar path = require('path');\n\nexports.problem = fs.createReadStream(__dirname + '/problem.txt');\nexports.solution = fs.createReadStream(__dirname + '/solution.txt');\n\nexports.verify = function (args, cb) {\n    var res = require(path.resolve(args[0]));\n    if (/beep/.test(res) && /boop/.test(res)) {\n        console.log('That sounds about right!\\n');\n        cb(true);\n    }\n    else if (/beep/.test(res) || /boop/.test(res)) {\n        console.log('Hmm that sounds partly convincing but try harder.\\n');\n        cb(false);\n    }\n    else {\n        console.log(\"That doesn't sound like a robot at all.\\n\");\n        cb(false);\n    }\n};\n```\n\nFinally, we can use\n[adventure-verify](https://npmjs.org/package/adventure-verify)\nto verify solutions using [tape](https://npmjs.org/package/tape) with\nfriendly [colorized tap output](https://npmjs.org/package/tap-colorize).\n\nIn `wowsers/index.js` we can use\n[adventure-verify](https://npmjs.org/package/adventure-verify) to do:\n\n``` js\nvar fs = require('fs');\nvar path = require('path');\nvar verify = require('adventure-verify');\n\nexports.problem = fs.createReadStream(__dirname + '/problem.txt');\nexports.solution = fs.createReadStream(__dirname + '/solution.txt');\n\nexports.verify = verify({ modeReset: true }, function (args, t) {\n    var f = require(path.resolve(args[0]));\n    t.equal(typeof f, 'function', 'you exported a function');\n    t.equal(f(2,3), 6, '2 * 3 = 6');\n    t.equal(f(1,1), 1, '1 * 1 = 1');\n    t.equal(f(0.5,0.5), 0.25, '0.5 * 0.5 = 0.25');\n    t.end();\n});\n```\n\nHere we use `modeReset` so that when a user does `console.log()` or\n`console.error()` in their solution, their text shows up as the terminal default\ninstead of getting mixed up with the TAP colors.\n\nNow just fill in the `problem.txt` and `solution.txt` files and you will have a\nworking nodeschool-style adventure! Yay!\n\n# methods\n\n``` js\nvar adventure = require('adventure')\n```\n\n## var shop = adventure(opts)\n\nCreate a new nodeschool workshop adventure.\n\noptions are:\n\n* `opts.name` - name of your adventure (required)\n* `opts.command` - the name of the adventure command (inferred from `opts.name`)\n* `opts.title` - title to use for your adventure\n(default: `opts.name.toUpperCase()`)\n* `opts.datadir` - directory used to store the current level and the list of\ncompleted levels. default: `'~/.config/' + opts.name`\n\n* `opts.colors` - object mapping color types to `[r,g,b]` arrays\n* `opts.colors.pass` - show passing solution messages with this color\n* `opts.colors.fail` - show failing solution messages with this color\n* `opts.colors.info` - show extra info with this color\n\n* `opts.fg` - menu foreground color\n* `opts.bg` - menu background color\n\nIf `opts` is a string, it will be treated as the `opts.name`.\n\n## shop.add(name, fn)\n\nYour `fn()` should return a problem object in the format described below.\n\n## shop.execute(args)\n\nRun whatever commands are specified in the command-line `args`.\n\n## shop.showMenu(opts)\n\nIf you don't want to let `.execute()` show the menu, you can show the menu\nyourself explicitly with `.showMenu()`.\n\nThe options are:\n\n* `opts.fb` - foreground color\n* `opts.bg` - background color\n* `opts.title` - menu title text\n\n## shop.select(name)\n\nYou can explicitly select a level with this method if you don't want to rely on\nthe user to select a menu for themselves from the graphical menu.\n\n# problem object format\n\nProblems must have a `verify()` function. All other fields are optional.\n\n## problem.verify(args, cb)\n\nThis function will be called when a user attempts to verify a problem with the\n`verify` command on the command-line.\n\nYou will get an array of the arguments given after the `verify` command in\n`args`.\n\nYou must call `cb(ok)` with `ok`, a boolean containing whether the solution was\nacceptible.\n\nCheck out [adventure-verify](https://npmjs.org/package/adventure-verify)\nfor a higher-level way of verifying solutions with\n[tape](https://npmjs.org/package/tape).\n\n## problem.run(args)\n\nThis function will be called when the user uses the `run` command from the\ncommand-line. You can implement this if you want to but it doesn't make sense\nfor all problems.\n\n## problem.problem\n\nThis message will be displayed when a user selects the problem from the menu.\n\n`problem.problem` can be a string, a buffer, a stream, or a function that\nreturns a string, a buffer, or a stream.\n\n## problem.solution\n\nThis message will be displayed when a user successfully completes a problem,\nafter the success notification.\n\n`problem.solution` can be a string, a buffer, a stream, or a function that\nreturns a string, a buffer, or a stream.\n\n## problem.pass\n\nThis message will be displayed when a user successfully completes a level. The\ndefault `problem.pass` is says `YOUR SOLUTION IS CORRECT` in a box of made of\n`@`s.\n\n`problem.pass` can be a string, a buffer, a stream, or a function that\nreturns a string, a buffer, or a stream.\n\n## problem.fail\n\nThis message will be displayed when a user's solution fails to pass all the\ntests. The default `problem.fail` is says `YOUR SOLUTION IS NOT CORRECT` in a\nbox of made of `#`s.\n\n`problem.fail` can be a string, a buffer, a stream, or a function that\nreturns a string, a buffer, or a stream.\n\n# events\n\n## shop.on('pass', function (name) {})\n\nThis event fires when a solution passed.\n\n## shop.on('fail', function (name) {})\n\nThis event fires when a solution failed.\n\n## shop.on('finished', function () {})\n\nThis event fires when all the levels are completed.\n\n# problem variables\n\nThese variables will be automatically replaced any time you use them in any of\nthe problem messages, whether in a string, a buffer, a stream, or a function\nthat returns a string, a buffer, or a stream.\n\n* `$ADVENTURE_NAME` - the name of the adventure\n* `$ADVENTURE_COMMAND` - the name of the adventure command\n\n# usage\n\nThe `.execute(args)` function accepts these commands:\n\n```\n$COMMAND\n$COMMAND menu\n\n  Show the menu.\n\n$COMMAND verify [ARGS...]\n\n  Verify the currently selected problem with ARGS.\n\n$COMMAND run [ARGS...]\n\n  Run the currently selected problem with ARGS.\n  Not all problems support `run`.\n\n$COMMAND solution\n\n  Show the solution for the currently selected problem.\n\n$COMMAND print\n\n  Print the text of the currently selected level.\n\n$COMMAND selected\n\n  Print the name of the currently selected level.\n \n$COMMAND select LEVEL\n\n  Set the currently selected LEVEL.\n\n$COMMAND list\n\n  List the available levels.\n\n$COMMAND completed\n\n  List the completed levels.\n \n$COMMAND reset\n\n  Reset the list of completed levels.\n\n$COMMAND help\n\n  Show this message.\n\n```\n\n# install\n\nWith [npm](https://npmjs.org) do:\n\n```\nnpm install adventure\n```\n\n# license\n\nMIT\n",
  "readmeFilename": "readme.markdown",
  "bugs": {
    "url": "https://github.com/substack/adventure/issues"
  },
  "_id": "adventure@2.8.0",
  "_shasum": "6f11d9f1ff7ac32732c13ac6f7a6b336c74a548c",
  "_resolved": "git+ssh://git@github.com:a0viedo/adventure.git#4709c4ec2ad2793b4cc26f01092b48e793d0df7c",
  "_from": "adventure@git+ssh://git@github.com:a0viedo/adventure.git#nodeschoolba"
}
