{"_id":"text-adventure","_rev":"27-100b9af8e7eca485f6b9a8ff234c4709","name":"text-adventure","description":"Run you very own Text Adventure server","dist-tags":{"latest":"1.1.2"},"versions":{"0.0.1":{"name":"text-adventure","description":"Run you very own Text Adventure server","version":"0.0.1","author":{"name":"Brooks Child","email":"thebroox@gmail.com"},"license":"MIT License","repository":{"type":"git","url":"https://github.com/TheBroox/TextAdventure.js"},"dependencies":{"body-parser":"^1.12.0","express":"^4.12.0","express-session":"^1.10.3","open":"^0.0.5"},"scripts":{"start":"node server.js"},"gitHead":"e0c22904f10c444e924d7acf7688df3f802fdecc","bugs":{"url":"https://github.com/TheBroox/TextAdventure.js/issues"},"homepage":"https://github.com/TheBroox/TextAdventure.js","_id":"text-adventure@0.0.1","_shasum":"c144c6ce009089e4b516d69f5d765f84068eeb2e","_from":".","_npmVersion":"2.5.1","_nodeVersion":"0.12.0","_npmUser":{"name":"thebroox","email":"thebroox@gmail.com"},"maintainers":[{"name":"thebroox","email":"thebroox@gmail.com"}],"dist":{"shasum":"c144c6ce009089e4b516d69f5d765f84068eeb2e","tarball":"https://registry.npmjs.org/text-adventure/-/text-adventure-0.0.1.tgz","integrity":"sha512-B6tD3U3ovMUJ1RM3eeroxpKfy+OoX2u4zjO61148EKhTOlPR9V9mVNx8vUse6fUZi9nHQYqOK+ho++LMvHSX4g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCvmCy8TrxhmH2QdCfhuF1R3k27panawDK2GqO4rEnxMgIgdMvhkC2QKI6RQNlFxzPCrhCRQbE4hS44mfR5Z7SJYmw="}]}},"0.0.2":{"name":"text-adventure","version":"0.0.2","description":"Run you very own Text Adventure server","keywords":["text-adventure","interactive-fiction"],"author":{"name":"Brooks Child","email":"thebroox@gmail.com"},"license":"MIT License","files":["server.js","README.md","cartridges","console","terminal"],"repository":{"type":"git","url":"https://github.com/TheBroox/TextAdventure.js"},"dependencies":{"body-parser":"^1.12.0","express":"^4.12.0","express-session":"^1.10.3","open":"^0.0.5"},"scripts":{"start":"node server.js"},"bugs":{"url":"https://github.com/TheBroox/TextAdventure.js/issues"},"homepage":"https://github.com/TheBroox/TextAdventure.js","_id":"text-adventure@0.0.2","dist":{"shasum":"ed3f1d7985f923a3378f4ed54ebe2189e80b2f47","tarball":"https://registry.npmjs.org/text-adventure/-/text-adventure-0.0.2.tgz","integrity":"sha512-cZZUq3n6fb3OSbO73RFkA6K45IbbqNJ+jLSh8v1rM/z/Zo0Cq18JBgBo+Ur4ExUcMs9g5i/EBpo5XGydpK2hMg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD04TNrYfS4Y/HCFe8FmD2rG1y81rZ7NKGbac8ok/qlUgIgb+GmsoqNbnVcUuciZgW7iXQmJ9mymw5atOg71/9vBFo="}]},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"thebroox","email":"thebroox@gmail.com"},"maintainers":[{"name":"thebroox","email":"thebroox@gmail.com"}]},"0.1.0":{"name":"text-adventure","version":"0.1.0","description":"Run you very own Text Adventure server","keywords":["text-adventure","interactive-fiction"],"author":{"name":"Brooks Child","email":"thebroox@gmail.com"},"license":"MIT License","main":"server.js","scripts":{"start":"node server.js"},"files":["server.js","README.md","cartridges","console","terminal"],"repository":{"type":"git","url":"https://github.com/TheBroox/TextAdventure.js"},"dependencies":{"body-parser":"^1.12.0","express":"^4.12.0","express-session":"^1.10.3","open":"^0.0.5"},"bugs":{"url":"https://github.com/TheBroox/TextAdventure.js/issues"},"homepage":"https://github.com/TheBroox/TextAdventure.js","_id":"text-adventure@0.1.0","dist":{"shasum":"2be4beeba6ab6af3b4d111b30977148e6f9bcaea","tarball":"https://registry.npmjs.org/text-adventure/-/text-adventure-0.1.0.tgz","integrity":"sha512-SseoBCejMWJp7wKObreH3ONVQn5uE86Z3VXwzzl/GH0x38UCFhujszeM+OhrdQ703Wt9HsjbsBRTUxQQRtBQ5g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCQgosS8TOb+qHE16r+xsNH0hkMMjnIXFjT+LlkGE3SaAIhAP55lC5Ru9RbX43rDF60Y9BqKLYs21gdnquTb5tWIjcy"}]},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"thebroox","email":"thebroox@gmail.com"},"maintainers":[{"name":"thebroox","email":"thebroox@gmail.com"}]},"0.1.1":{"name":"text-adventure","version":"0.1.1","description":"Run you very own Text Adventure server","keywords":["text-adventure","interactive-fiction"],"author":{"name":"Brooks Child","email":"thebroox@gmail.com"},"license":"MIT License","main":"server.js","scripts":{"start":"node server.js"},"files":["server.js","README.md","cartridges","console","terminal"],"repository":{"type":"git","url":"https://github.com/TheBroox/TextAdventure.js"},"dependencies":{"body-parser":"^1.12.0","express":"^4.12.0","express-session":"^1.10.3","open":"^0.0.5"},"gitHead":"639a447d93a915560fa54b319fe04105d420aa51","bugs":{"url":"https://github.com/TheBroox/TextAdventure.js/issues"},"homepage":"https://github.com/TheBroox/TextAdventure.js","_id":"text-adventure@0.1.1","_shasum":"669228ba12b5bf8a211379a5cddd2a38121b4820","_from":".","_npmVersion":"2.6.0","_nodeVersion":"0.12.0","_npmUser":{"name":"thebroox","email":"thebroox@gmail.com"},"maintainers":[{"name":"thebroox","email":"thebroox@gmail.com"}],"dist":{"shasum":"669228ba12b5bf8a211379a5cddd2a38121b4820","tarball":"https://registry.npmjs.org/text-adventure/-/text-adventure-0.1.1.tgz","integrity":"sha512-Fj2nd7ZvuIa6FzF7QqlgYwGdpjrOcXCZDi20rFBbkJzvQ0whYUmY2MoRaGANowyajCcQB82qpXqhqoljcKBanA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGc8ohC5JrjquRh6iUS0BsvBSLCW86V61UxS28rfLJ5PAiB7xNeHKpvS11wHDP743IvoMvNwP+eKAb1L0aduSejdlw=="}]}},"1.0.0":{"name":"text-adventure","version":"1.0.0","description":"Run you very own Text Adventure server","keywords":["text-adventure","interactive-fiction"],"author":{"name":"Brooks Child","email":"thebroox@gmail.com"},"license":"MIT License","main":"server.js","scripts":{"start":"node server.js"},"files":["server.js","README.md","cartridges","console","terminal"],"repository":{"type":"git","url":"https://github.com/TheBroox/TextAdventure.js"},"dependencies":{"body-parser":"^1.12.0","express":"^4.12.0","express-session":"^1.10.3","open":"^0.0.5"},"gitHead":"cef8d1bcf69321c62513fdbd4fc868ebdad026f8","bugs":{"url":"https://github.com/TheBroox/TextAdventure.js/issues"},"homepage":"https://github.com/TheBroox/TextAdventure.js","_id":"text-adventure@1.0.0","_shasum":"101e634bf32f1547d011c4bf1f362c406899c667","_from":".","_npmVersion":"2.6.0","_nodeVersion":"0.12.0","_npmUser":{"name":"thebroox","email":"thebroox@gmail.com"},"maintainers":[{"name":"thebroox","email":"thebroox@gmail.com"}],"dist":{"shasum":"101e634bf32f1547d011c4bf1f362c406899c667","tarball":"https://registry.npmjs.org/text-adventure/-/text-adventure-1.0.0.tgz","integrity":"sha512-OzihPAK9xgSpIF6ecOAaxfkpiGpSrTuP3zCJoIhiMr3vOaFoeq+vf8h8hlVG1NDzyOLH0Zrtcbt01LsDh5dj7Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCTk17lW+9oh+7dVYeOsjzjEmPWyDAoo70j2v51Vt9ohAIgGF8h18XfxlVlZJuDKry1uSjEEUhCguQqzyRuQwPehEk="}]}},"1.0.1":{"name":"text-adventure","version":"1.0.1","description":"Run you very own Text Adventure server","keywords":["text-adventure","interactive-fiction"],"author":{"name":"Brooks Child","email":"thebroox@gmail.com"},"license":"MIT License","main":"server.js","scripts":{"start":"node server.js"},"files":["server.js","README.md","cartridges","console","terminal"],"repository":{"type":"git","url":"https://github.com/TheBroox/TextAdventure.js"},"dependencies":{"body-parser":"^1.12.0","express":"^4.12.0","express-session":"^1.10.3","open":"^0.0.5"},"gitHead":"da84481796a95cb7fb518af6c7ed35a982a1be10","bugs":{"url":"https://github.com/TheBroox/TextAdventure.js/issues"},"homepage":"https://github.com/TheBroox/TextAdventure.js","_id":"text-adventure@1.0.1","_shasum":"0e7d31f0d8f5a26144f0f99f6272fb593264c336","_from":".","_npmVersion":"2.6.0","_nodeVersion":"0.12.0","_npmUser":{"name":"thebroox","email":"thebroox@gmail.com"},"maintainers":[{"name":"thebroox","email":"thebroox@gmail.com"}],"dist":{"shasum":"0e7d31f0d8f5a26144f0f99f6272fb593264c336","tarball":"https://registry.npmjs.org/text-adventure/-/text-adventure-1.0.1.tgz","integrity":"sha512-WiUtCPLigModWHh5DIX9Bmh9NwQLCco/78wOo5yBO/y2tfbgAoaZ/o5C3VQoKVGmfv2nCkuVZLmHFYh2tDmqVA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEcakz4SnGAqDCsxU3gAX2/web9MX5jwPzGbyBLRTuNGAiEAqC/mNBoD1yCYNZG60Noz/sk6oZpRULhCxCMvDjZ2hjE="}]}},"1.0.2":{"name":"text-adventure","version":"1.0.2","description":"Run you very own Text Adventure server","keywords":["text-adventure","interactive-fiction"],"author":{"name":"Brooks Child","email":"thebroox@gmail.com"},"license":"MIT License","main":"server.js","scripts":{"start":"node server.js"},"files":["server.js","README.md","cartridges","console","terminal"],"repository":{"type":"git","url":"https://github.com/TheBroox/TextAdventure.js"},"dependencies":{"body-parser":"^1.12.0","express":"^4.12.0","express-session":"^1.10.3","open":"^0.0.5"},"gitHead":"59feb2077d5da96a685b90bc93178696eaf2a524","bugs":{"url":"https://github.com/TheBroox/TextAdventure.js/issues"},"homepage":"https://github.com/TheBroox/TextAdventure.js","_id":"text-adventure@1.0.2","_shasum":"9ee3139ae58b2ca2acac2fa6b611ce8b946d451f","_from":".","_npmVersion":"2.6.0","_nodeVersion":"0.12.0","_npmUser":{"name":"thebroox","email":"thebroox@gmail.com"},"maintainers":[{"name":"thebroox","email":"thebroox@gmail.com"}],"dist":{"shasum":"9ee3139ae58b2ca2acac2fa6b611ce8b946d451f","tarball":"https://registry.npmjs.org/text-adventure/-/text-adventure-1.0.2.tgz","integrity":"sha512-73Kt4u2BHNP6rsPIsXQeBl4SIO/iTAFdNLm1+nRJ7TEY/cFxrPpxD/H+i9EjFOBEAWhCccF10pHpak/iMWOn7Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIF7cRFMhv8UJWMFGW4lsFj8BugZwIqtWhADR0BcBEZuZAiEApV2xDalwR7H/vyRMyY5XqgYZ7dowKmyaPFpSsvidOmM="}]}},"1.1.0":{"name":"text-adventure","version":"1.1.0","description":"Run you very own Text Adventure server","keywords":["text-adventure","interactive-fiction"],"author":{"name":"Brooks Child","email":"thebroox@gmail.com"},"license":"MIT License","main":"server.js","scripts":{"start":"node server.js"},"files":["server.js","README.md","cartridges","console","terminal"],"repository":{"type":"git","url":"https://github.com/TheBroox/TextAdventure.js"},"dependencies":{"body-parser":"^1.12.0","express":"^4.12.0","express-session":"^1.10.3","open":"^0.0.5"},"gitHead":"bb675cf5f7055a6bb1387b5da5c59b050a9bef4f","bugs":{"url":"https://github.com/TheBroox/TextAdventure.js/issues"},"homepage":"https://github.com/TheBroox/TextAdventure.js","_id":"text-adventure@1.1.0","_shasum":"55d5bee27d85d0609c41dd51f7f8b9550cec9be3","_from":".","_npmVersion":"2.6.0","_nodeVersion":"0.12.0","_npmUser":{"name":"thebroox","email":"thebroox@gmail.com"},"maintainers":[{"name":"thebroox","email":"thebroox@gmail.com"}],"dist":{"shasum":"55d5bee27d85d0609c41dd51f7f8b9550cec9be3","tarball":"https://registry.npmjs.org/text-adventure/-/text-adventure-1.1.0.tgz","integrity":"sha512-Ohlxrkl9swMTm5V2dImfsLKQd4aE3ttAnQlLdSbv61qBcXNt4xamqGuL51ZCqkZJ934aEUZq8sa9YoNL4hv27Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFwM/WL1P8qzS/aKuy8I1NUrdmVa/fpigITdx5ps1rAHAiEA+DnEYRFvJyNzrc6TkTMRjm5W08j2NZA8v41QW+Jm/JQ="}]}},"1.1.1":{"name":"text-adventure","version":"1.1.1","description":"Run you very own Text Adventure server","keywords":["text-adventure","interactive-fiction"],"author":{"name":"Brooks Child","email":"thebroox@gmail.com"},"license":"MIT License","main":"server.js","scripts":{"start":"node server.js"},"files":["server.js","README.md","cartridges","console","terminal"],"repository":{"type":"git","url":"https://github.com/TheBroox/TextAdventure.js"},"dependencies":{"body-parser":"^1.12.0","express":"^4.12.0","express-session":"^1.10.3","open":"^0.0.5"},"gitHead":"2e0bfe32668cc26d6d56ecca381d81862eebdc7e","bugs":{"url":"https://github.com/TheBroox/TextAdventure.js/issues"},"homepage":"https://github.com/TheBroox/TextAdventure.js","_id":"text-adventure@1.1.1","_shasum":"2665e9cf610dffe6c9344a90109d465527cf3eb9","_from":".","_npmVersion":"2.6.0","_nodeVersion":"0.12.0","_npmUser":{"name":"thebroox","email":"thebroox@gmail.com"},"maintainers":[{"name":"thebroox","email":"thebroox@gmail.com"}],"dist":{"shasum":"2665e9cf610dffe6c9344a90109d465527cf3eb9","tarball":"https://registry.npmjs.org/text-adventure/-/text-adventure-1.1.1.tgz","integrity":"sha512-wWu+z4VmMgDZaZZ5l1GoxOH+xn4+LzpxXwOct+Y/nYRmpvJxrE92aEbzQCbe+/uBZbRSwOMkaLWZYa5y4yoXbQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHcAB443RIln81vAj9Nk0lk+0AMEB98oVONZHUkj+gH8AiAxnRNZ9fM1TunuI/1WinBMsdo0ntMgnkIO4eZwSGbl4w=="}]}},"1.1.2":{"name":"text-adventure","version":"1.1.2","description":"Run you very own Text Adventure server","keywords":["text-adventure","interactive-fiction"],"author":{"name":"Brooks Child","email":"thebroox@gmail.com"},"license":"MIT License","main":"server.js","scripts":{"start":"node server.js"},"files":["server.js","README.md","cartridges","console","terminal"],"repository":{"type":"git","url":"https://github.com/TheBroox/TextAdventure.js"},"dependencies":{"body-parser":"^1.12.0","express":"^4.12.0","express-session":"^1.10.3","open":"^0.0.5"},"gitHead":"48f6efa1faa41cc162f8dd281c73f39766acbf42","bugs":{"url":"https://github.com/TheBroox/TextAdventure.js/issues"},"homepage":"https://github.com/TheBroox/TextAdventure.js","_id":"text-adventure@1.1.2","_shasum":"159c780829c0047c56493a13fd6eb682757e5889","_from":".","_npmVersion":"2.6.0","_nodeVersion":"0.12.0","_npmUser":{"name":"thebroox","email":"thebroox@gmail.com"},"maintainers":[{"name":"thebroox","email":"thebroox@gmail.com"}],"dist":{"shasum":"159c780829c0047c56493a13fd6eb682757e5889","tarball":"https://registry.npmjs.org/text-adventure/-/text-adventure-1.1.2.tgz","integrity":"sha512-PYA0gDcC1FDq+gca+XA9CheVB+QgERsCYkNMouYq+Sja45x27J4q464XHJ54jHNNcZ76cog2bpldg20XeIziOQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCWzU5nI/tSknzDR7bgrNukyIuspMZvgbcZau48Y8xeVAIgZ4xJ215+t7zKX5ELe5SIn6dPNZQjMRLPU6E8l5+TXn8="}]}}},"readme":"# TextAdventure.js\n\nTextAdventure.js is a text adventure engine that runs on [Node.js](http://nodejs.org/) and makes use of [Express](http://expressjs.com/). A live demo can be seen [here](http://textadventure-thebroox.rhcloud.com/). The project has four main components: a simple server, a retro command line inspired web interface known as the Terminal, the text adventure engine itself colloquially called the Console and finally the cartridges (games) which are made up of two JavaScript objects. Each of these components is further explained its respective section below.\n\n## Server\n\nThe server is an extremely simple Node.js file. It fires up an instance of an Express server on port 3000 to which it serves the Terminal. All AJAX requests made to it are quickly passed to the Console to be executed. Responses are then dispatched back to the Terminal. To get TextAdventure up and running on port 3000 simply run the following command from the project's folder:\n\n```\nnode server.js\n```\n\n## Terminal\n\nThe Terminal consists of a single HTML file, a single CSS file and two JavaScript files (one of which is jQuery in case you need to run TextAdventure.js without an Internet connection). The Terminal's main job is to send the user's input to the Server and then display the Server's response to the user. The terminal has a few other creature comforts built in. First, it sends a \"dummy\" AJAX call to the server when the page loads to get the list of cartridges without requiring the user to input anything. Secondly, it keeps a record of the user's input that can be navigated via the UP and DOWN arrow keys. The terminal's CSS can easily be tweaked to your liking.\n\n## Console\n\nThe Console takes the user input passed to it by the Server, acts on it and then returns a string that is ultimately displayed to the user. Upon receiving the user input the first thing the Console does is run it through the Parser to convert it to a more easy to use JavaScript object; consisting of an action, a subject and an object. The Console then runs the appropriate functionality based on the following hierarchy:\n\n1. Does the action have a corresponding function in the cartridge\n2. Does the action have a corresponding function in the console\n3. Does the subject have a corresponding interaction\n\nFollowing the executions of the appropriate functionality, the updateLocation() function of the player's current location is run. If that function returns a string that string will be passed to the user in lieu of the string generated by the appropriate functionality. Finally, the console checks to see if the cartridge `gameOver` attribute has been set to true and if so will return the cartridge's `outroText`.\n\nThe console implements the following player commands: `die`, `drop`, `go`, `inventory`, `load`, `look`, `take` and `use`. Each console command returns an object with a two attributes. The first, `message`, is the text that will be displayed to the user. The second, `success`, is a boolean indicating whether the command was able to be executed given the user inputed subject. More detail is provided for each of the console commands below.\n\n### `die` Command\n\n`die` deletes the user's current game and returns a message to the user.\n\n### `drop` Command\n\n`drop` checks to see if the `player` has an item in their `inventory` that matches the command's subject. If so the item is removed from the `player`'s `inventory` and is added to the player's current location's items. A confirmation message or a failure message is passed back to the user.\n\n### `go` Command\n\n`go` checks to see if the command's subject matches one of the room's exits. If it does the player's current location's `teardown()` function is run followed by the destination location's `setup()` function. The player's current location is then updated to the destination location. The player's new current location's description is returned if this is the first time the player has visited this location, otherwise the location's room is returned. A failure message is displayed if the user fails to provide a subject that matches an exit.\n\n### `inventory` Command\n\n`inventory` returns an enumerated list of all the items contained in the player's inventory.\n\n### `load` Command\n\n`load` will only run if the player is not currently playing a game. Similarly, `load` is the only command a player can execute if they are not currently playing a game. `load` copies the content of the cartridge file that matches the subject into the list of active games maintained by the Console and assigns it to the user.\n\n### `look` Command\n\n`look` will return the player's current room's description if the subject is not passed to it. If a subject is passed to it `look` instead attempts to return the description of the item in the player's inventory matching the description. Failing that, `look` attempts to return the description of the matching item in the player's current room. Finally, if that fails it attempts to return the look interaction of the matching interactable in the player's current room. \n\n### `take` Command\n\n`take` checks to see if the player's current location has an item that matches the command's subject. If so the item is removed from the player's current location's list of items and is added to the player's inventory. A confirmation message or a failure message is then passed back to the user.\n\n### `use` Command\n\nThe `use` command will run the `use` function of the item in the player's inventory that matches the command's subject.\n\n## Cartridges\n\nCartridges are loaded into the Console and are then playable by the user. The Console does most of the heavy lifting while the Cartridge adds all the flavor. A Cartridge consists of two very important objects, `gameData` and `gameActions`, as well as any number of helper functions.\n\n### `gameData` Object\n\nThe `gameData` object has four required components; `commandCounter`, `gameOver`, `introText`, `outroText`, a `player` object and a `map` object. It can also contain any number of other fields, objects and functions as needed by the cartridge. Below is bare-bones architecture of the `gameData` object.\n\n```javaScript\nexports.gameData = {\n\tcommandCounter : 0,\n\tintroText : 'Lorem Ipsum',\n\tplayer : { },\n\tmap : {\t}\n};\n```\n\n#### `commandCounter`\n\nThe `commandCounter` is an int that keeps track of the number of inputs the user has submitted to the console for evaluation on this particular cartridge. The `commandCounter` can be initialized to any integer depending on the cartridges needs. The console will increment the number by one each time it receives a command.\n\n#### `gameOver`\n\n`gameOver` is a required boolean. After finishing all executing all code related to any given command the console checks `gameOver`. If it is true the `outroText` is added to the end of the string sent to the console and the game is deleted. If it is false nothing happens.\n\n#### `introText`\n\nThe console will display the `introText` to the user following a successful `load` command.\n\n#### `outroText`\n\nThe `outroText` string is added to the string sent to the terminal by the console if after finishing executing a command the `gameOver` boolean is set to true.\n\n#### `player` Object\n\nThe `player` object has two required elements, `currentLocation` and `inventory`. It can also contain any number of other fields, objects and functions as needed by the cartridge. Below is bare-bones architecture of the `player` object.\n\n```javaScript\nplayer : {\n\tcurrentLocation : 'MineEntrance',\n\tinventory : {}\n}\n```\n\n##### `currentLocation`\n\n`currentLocation` is a string that points to the location that `player` is currently interacting with. It must be populated with a string that points to a matching location within the `map` object. That location will be the player's starting location. The console will keep `currentLocation` updated as the player moves from location to location within the game.\n\n##### `inventory` Object\n\nA player's `inventory` is a collection of `items` that the `player` takes with them from location to location as they move around within the game. The inventory can be empty or can have any number of `item`s that player will begin the game already possessing. The `item` object is explained in greater later in this document.\n\n### `map` Object\n\nThe `map` is a collection of `location` objects. It can also contain any number of other fields, objects and functions as needed by the cartridge.\n\n#### `location` Objects\n\nEach `location` has a name/key and the follwoing attributes: `firstVisit`, `displayName`, `description`, an `interactables` object, and `items` object, and an `exits` object. It has three opitional functions that can be implemented if needed: `setup()`, `teardown()` and `updateLocation()`. It can also contain any number of other fields, objects and functions as needed by the cartridge.\n\n##### `firstVisit`\n\n`firstVisit` is a boolean that when true will cause the Console to display the `description` to the user upon entering this location via the `move` command. It it is instead false then the user will be presented with the `displayName` instead. The console will set `firstVisit` to false when the user uses the `move` command to leave a `location`.\n\n##### `displayName`\n\nThe user is presented with a location's `displayName` if `firstVisit` is set to false when the user makes use of the `go` command to enter this location.\n\n##### `description`\n\nThe user is presented with a location's `description` if `firstVisit` is set to true when the user makes use of the `go` command to enter this location. Additionaly, the user is presented with the 'description' if they issue the 'look' command without a subject.\n\n##### `interactables` Object\n\nA room may optionally have an `interactables` object. The `interatables` is a collection of interactions that the player can take while in this location. Each intractable object is it's own object within `interactables` which contains any number of key value pairs that map to its different interactions. An interaction can be either a string or a function that after executing any amount of arbitrary code returns a string. Below is an example of a barebones `interactables` object.\n\n```javaScript\ninteractables : {\n\tinteractable1 : { interaction : 'returnString' },\n\tinteractable2 : {\n\t\tinteraction1 : unshownHelperFunction(),\n\t\tinteraction2 : function(){\n\t\t\treturn 'returnString';\n\t\t}\n\t}\n}\n```\n\n##### `items` Object\n\nThe `items` objects is a collection of items contained within this location. An item is also a JavaScript object and its structure is detailed below.\n\n###### `item` Object\n\n`item` objects can exist in both a player's inventory or they can reside in the `items` object of a location. Users can use the `take` command to move an `item` from a location to the player's inventory. The `drop` command does the reverse. Items have some mandatory properties; namely, `description`, `displayName`, `hidden`, and `quantity`. Optionally, it can contain a `use` function and/or an `interactions` Object. An `item` can also contain any number of additional properties or functions as dictated by the design of the game.\n\n**`description`**\n\nThe 'description' of an `item` is the string returned when the user submits the 'look' command lists the item's name or `displayName` as the subject.\n\n**`displayName`**\n\nThe `displayName` of an item is the string used by the console in all text related to the item that is displayed to the user.\n\n**`hidden`**\n\n`hidden` is a boolean that if set to true will prevent the console from listing the item as in the location when constructing the location's description. Alternatively if `hidden` is set to true the item will be listed in the location's description.\n\n**`quantity`**\n\nAn item's `quantityy` must be a non-negative int. The `quantity` keeps track of how many of that specific item are contained within any given location of the player's inventory. The 'take' command causes the `quantity` to be decremented for the named item with the location's items object and incremented with the player's inventory. The `drop` command does the revers. If an item's quantity ever reaches zero it is deleted.\n\n**`use()` Function**\n\nThe `use()` function will run then the user issues the 'use' command and names the item as the item as the subject. The use function an execute any arbitrary code but must return a string that will be displayed to the user.\n\n**`interactions` Object**\n\nThe `interactions` Object of an item is identical to an `interactables` object of a location except that it is tied to the item and will move with said item.\n\n##### `exits` Object\n\nThe `exits` object contains any number of `exit` objects that detail how this location is connected to other locations within the `map`.\n\n###### `exit` Object\n\nAn `exit` object has two required keys; `displayName` and `destination`.\n\n**`displayName`**\n\nThe `display` name is the string that is displayed to the user in all text related to the exit. It is listed in the location's description.\n\n**`destination`**\n\nThe `displayName` is a string that matches the key to another `location` within the `map`. When the user issues the `go` command and names this exit as the subject the room listed in `destination` is the location the player's `currentLocation` will be changed to.\n\n##### `setup()` Function\n\nThe `setup()` is an optional function that is run after the player's `currentLocation` is changed to this location by the `go` command but before the locations description is generated and returned to the user. It is not required to return anything and anything that is returned will be ignored by the Console.\n\n##### `teardown()` Function\n\nThe `teardown()` is an optional function that is run before the player's `currentLocation` is changed from this location by the `go` command. It is not required to return anything and anything that is returned will be ignored by the Console.\n\n##### `updateLocation()` Function\n\nThe `updateLocation()` function of the player's `currentLocation` is run following the execution of any successfully interpreted input submitted by the user. The function is passed the `command` object as generated by the parser, consisting of an `action`, a `subject` and an `object`. If this function returns anything that return value will be displayed to the user in lieu of the string generated by the Console.\n\n### `gameActions` Object\n\nThe `gameActions` object holds functions that user can access as inputed actions. Functions within the object can feature new actions not implemented by the console or they can override the actions implemented in the console as explained in the Console section of this document. All function within the object are passed three parameters: a `game` object, a `command` object and a `consoleInterface` function. Each of the three parameters is explained below. All action functions must return a string that will be displayed to the user.\n\n#### `game` Object\n\nThe `game` object is an item that contains both the `gameData` object and the `gameActions` object. It is a handy way to access or alter the `gameData` object.\n\n#### `command` Object\n\nThe `command` object is the command that the user inputed after it has been parsed. It has three attributes: `action`, `subject` and `object`. The `action` will match the current action function. The `subject` is the what the action is to be performed on. The 'object' is the target of the action in conjunction with the `subject`.\n\n#### `consoleInterface` Function\n\nThe `consoleInterface` function is a way for cartridge actions to call the console implemented actions. It has the following signature `consoleInterface(game, command)`. Below is an example of cartridge action, `take` that simply call it's cartridge counterpart:\n\n```JavaScript\nexports.gameActions = {\n\ttake : function(game, command, consoleInterface){\n\t\treturn consoleInterface(game, command);\n\t}\n}\n```\n\n### Helper Functions\n\nA cartridge can contain any number of additional functions as its design dictates.","maintainers":[{"name":"thebroox","email":"thebroox@gmail.com"}],"time":{"modified":"2022-06-27T05:40:29.332Z","created":"2015-02-24T22:36:23.336Z","0.0.1":"2015-02-24T22:36:23.336Z","0.0.2":"2015-02-25T04:38:27.413Z","0.0.3":"2015-02-27T16:26:56.711Z","0.1.0":"2015-03-05T20:28:53.757Z","0.1.1":"2015-03-08T14:45:50.252Z","1.0.0":"2015-03-12T20:03:17.872Z","1.0.1":"2015-03-13T19:01:08.295Z","1.0.2":"2015-03-13T19:03:38.121Z","1.1.0":"2015-03-16T21:13:12.579Z","1.1.1":"2015-03-16T21:15:10.604Z","1.1.2":"2015-03-25T20:29:17.664Z"},"homepage":"https://github.com/TheBroox/TextAdventure.js","repository":{"type":"git","url":"https://github.com/TheBroox/TextAdventure.js"},"author":{"name":"Brooks Child","email":"thebroox@gmail.com"},"bugs":{"url":"https://github.com/TheBroox/TextAdventure.js/issues"},"license":"MIT License","readmeFilename":"README.md","keywords":["text-adventure","interactive-fiction"],"users":{"andfaulkner":true,"mbutler":true}}