A Node.js app for parsing Magic: The Gathering® rules text into an abstract syntax tree of card characteristics and game actions.
npm installto intall all the required dependencies.npm run buildto run the typescript and babel transpilers.
The transpiled js will be ready in /bin.
Just Node.js.
After installing, run /bin/index.js or the included npm script with two command line arguments, like so:
node ./bin/index <input file> <output file>
or
npm run start <input file> <output file>
...where <input file> is the path to a JSON-formatted array of MTGJSON-style card objects (only a text and name field are really required) and <output file> is the path Grok will output to.
Grok outputs a JSON-formatted array of card objects, each with a name and success field. success will be true if the entire card was parsed successfully, and false if it wasn't. if success is true, the object will also contain end and payload fields, where end is the length of the parsed text and payload is a representation of the card-text as an abstract syntax tree, the schema of which is evolving with the development of the project and is subject to change with each update.
This project is licensed under the MIT License - see the LICENSE.md file for details
Magic: The Gathering is copyright Wizards of the Coast. This project is not endorsed by or affiliated with Wizards of the Coast.
- Wizards of the Coast, for the great game they have made and continue to support.
- MTGJSON, for files that I have run dozens, if not hundreds of scripts on. just for fun.