{"_id":"@3d-dice/dice-parser-interface","_rev":"1-f87204d5ed53c4e00c1d784a2fcdafc4","name":"@3d-dice/dice-parser-interface","dist-tags":{"latest":"0.2.1"},"versions":{"0.2.0":{"name":"@3d-dice/dice-parser-interface","author":{"name":"Frank Ali"},"description":"a parser interface that parses roll20 format strings using @3d-dice/dice-roller-parser for @3d-dice/dice-box","version":"0.2.0","keywords":["dice","dice-box","roller","roll","roll20","rpg","ttrpg","tabletop","dnd","d&d","dungeons","dragons","pathfinder"],"license":"MIT","homepage":"https://fantasticdice.games/","repository":{"type":"git","url":"git+https://github.com/3d-dice/dice-parser-interface.git"},"bugs":{"url":"https://github.com/3d-dice/dice-parser-interface/issues"},"main":"./src/index","dependencies":{"@3d-dice/dice-roller-parser":"^0.2.6"},"gitHead":"1fa1c6fe9235b0b134604044f1545220963416f4","_id":"@3d-dice/dice-parser-interface@0.2.0","_nodeVersion":"14.15.0","_npmVersion":"6.14.8","dist":{"integrity":"sha512-lpEt0yGCkBtZFOeKtkTkgZyPGfKCmUX6RdSHKk1hyBh60AGB36LhBwiT5Ad85DpYBj2itwyygKLD/o4TxPlUqA==","shasum":"88b28724c7b70e66f9955533e3abca13b6b6a3e8","tarball":"https://registry.npmjs.org/@3d-dice/dice-parser-interface/-/dice-parser-interface-0.2.0.tgz","fileCount":5,"unpackedSize":14206,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBGFmXwG5oGyLyXLzEBh2JExYx+/l2ZAs9ba/RnP+CN6AiAWHPVNFgzb4zws7v89uHjb0Hn3U+IHAGpMRUMKjH6jrQ=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJij7ABACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmpmng//QadK9+SotovSkd+A/w90PHSm4NnBE0j7IGY9F7klFPBNEx5l\r\ntZmsE2ngAgXki+ghyBIDr6c3nSkcti+Xb6GbQKqk1kTVIE0LawEkGNDBYeVP\r\nVPfSHGqgQwW5LeAoKjq1uqU7d/RKdpUuDlgNophBi+nyS5ZBv5nPOYFbao0i\r\nte/CFfVKvL9+45vmNu0gZkWsGAmfmbLmOIvHrW6+9zYD69xQpoVBvZQlhKDb\r\nPku8CHAUXV2vHPMfEPI64nQKBFofgNNz3dRH4MZpKUPU9jzc/r+RlmPtMjcX\r\nLilYH++8ffYCkIsc7pKj3mjPa+UYWH2f53osRjhpHHxLhTP30I4Snt20CzJR\r\nLMQLtqqERi7/YdmI0JgTs3Lcd2aZYZvjmNtrbCntXl8o/qzN7LvvPBSBOtfv\r\nkvorgXUjC7Cx+vOF7z7Op8pR7mM9heIEpuqu4Czo38Wy5CcraW5hBkJUGNJh\r\nSLayo+AYAfu4ELVR2rKnemVOFuJFrFv128sivoPgTTUmFeoEIXulFNdGd8zg\r\nPzCBbpAB2dw9MWmVcsFFfv5tvkSLpoo1AmVjmPt4ZZEc90LAQyR0Embewgux\r\nW6wZM/yv4n32/KuiTZ/dBDK7SY8zTJQbQaNdrIx2EE/2Hgc4zZ8c0g0ttOyH\r\nVrGzMtA+T+eOahQqd9Iyb11EwLEFV6RlRz8=\r\n=b9PG\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"3d-dice","email":"fantastic.3d.dice@gmail.com"},"directories":{},"maintainers":[{"name":"3d-dice","email":"fantastic.3d.dice@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/dice-parser-interface_0.2.0_1653583873111_0.556779838182804"},"_hasShrinkwrap":false},"0.2.1":{"name":"@3d-dice/dice-parser-interface","author":{"name":"Frank Ali"},"description":"a parser interface that parses roll20 format strings using @3d-dice/dice-roller-parser for @3d-dice/dice-box","version":"0.2.1","keywords":["dice","dice-box","roller","roll","roll20","rpg","ttrpg","tabletop","dnd","d&d","dungeons","dragons","pathfinder"],"license":"MIT","homepage":"https://fantasticdice.games/","repository":{"type":"git","url":"git+https://github.com/3d-dice/dice-parser-interface.git"},"bugs":{"url":"https://github.com/3d-dice/dice-parser-interface/issues"},"main":"./src/index","dependencies":{"@3d-dice/dice-roller-parser":"^0.2.6"},"gitHead":"6d139edd90518817e306704453e78b3223b4d1b5","_id":"@3d-dice/dice-parser-interface@0.2.1","_nodeVersion":"16.17.1","_npmVersion":"8.15.0","dist":{"integrity":"sha512-04fJt8FYtbPnzVt0Pi2Ow3vweN0t/lc+tkDDIG4bq9QkaIw/zD1zdLZirXtE8LFffJR3xXFh8PgflSAJMGoy4Q==","shasum":"5646b2edd811dea6c989c723152bd50af0f8d220","tarball":"https://registry.npmjs.org/@3d-dice/dice-parser-interface/-/dice-parser-interface-0.2.1.tgz","fileCount":5,"unpackedSize":14627,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDXyfauFwojYSPj62UiIGoKppYAOCtjx+OxIEzHnUGtbgIhAOrhJIVa2MlhIIpluwDr2iFMPDzn5P3Z04qbrDUWxzOV"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj47MTACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrgmQ/+Plyp9dJaUMqqu3r8YZnxGIp8QKlHVwCvX7ulGeCo8D75OnR9\r\n8wyP3FBUurCFFwGI6X3Yv4ml3XZwH9OFVQu57bBjuUZA9WOS16t681xs8ysi\r\nHWuXb4jAPtJBicmsVMM61plDtZsRG+IGTgSe2CawI4i7fC+iOfMYPRbyxqmz\r\nw5RZfFVwk1UIqtLVHEJd9jrf5DPIE80jX4G57KmhjTe9hR6oqtFJe8Q6z+F7\r\nEIFIRsDNlr3Gii8DQaeOf+yqeFmlCMiRtLaXP6VPcv03mSbUbCp82i2E9A25\r\nwum68J7dYTeDtf1iumHT76hYsB8lptU6FGSSYd4pRWQlufOnqFIU/bliLJVr\r\nuqxPxXb3kAAB5y/ljPjxN1v48KtJfSXx8VJXuZJpWJE5Ll8ENB1cbKfrymLh\r\nYi7CcLfXKtWaeqVJRF6vIeRNR9PXS8CIDYWyfaYN0anw2hLKk7vzBo1MZkWt\r\nU2oVJsqxhb2xUFMXq1uKzVXfqau+sFkzEl2L74uCUjHEFmpL9CKOjKM4kTp9\r\nK23mro8iIxnmFj9pa+n6M4jhOEShbCluBJaGsZbaVQyfH6joOayc8KWSaLrI\r\nxkpGuoEphXh6wGrDbclG+IjenQL0BQUZgQKJbzqUv8OJ/q5Sx4bw7hwIszw2\r\njlGsIy8q608zGwkAjvMfQHTkIv9KYAyIwbA=\r\n=Qmpu\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"3d-dice","email":"fantastic.3d.dice@gmail.com"},"directories":{},"maintainers":[{"name":"3d-dice","email":"fantastic.3d.dice@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/dice-parser-interface_0.2.1_1675866899490_0.02205200460642498"},"_hasShrinkwrap":false}},"time":{"created":"2022-05-26T16:51:13.070Z","0.2.0":"2022-05-26T16:51:13.314Z","modified":"2023-02-08T14:34:59.919Z","0.2.1":"2023-02-08T14:34:59.648Z"},"maintainers":[{"name":"3d-dice","email":"fantastic.3d.dice@gmail.com"}],"description":"a parser interface that parses roll20 format strings using @3d-dice/dice-roller-parser for @3d-dice/dice-box","homepage":"https://fantasticdice.games/","keywords":["dice","dice-box","roller","roll","roll20","rpg","ttrpg","tabletop","dnd","d&d","dungeons","dragons","pathfinder"],"repository":{"type":"git","url":"git+https://github.com/3d-dice/dice-parser-interface.git"},"author":{"name":"Frank Ali"},"bugs":{"url":"https://github.com/3d-dice/dice-parser-interface/issues"},"license":"MIT","readme":"# Dice Parser Interface\n\nThis module simply provides an interface between [@3d-dice/dice-roller-parser](https://github.com/3d-dice/dice-roller-parser) and [@3d-dice/dice-box](https://github.com/3d-dice/dice-box). Since `dice-roller-parser` is a fork of another person's module, I did not want to include this interface in that package.\n\n<sub>`FDP` (Fantastic Dice Parcer) has been renamed to `Dice Parser Interface` for symantics. The `@3d-dice/fdp` npm module has been depricated</sub>\n\n## What it does\nThis module allows for more advanced rolls with `dice-box`. All the rolls supported are documented at [Roll20 Dice Specification](https://roll20.zendesk.com/hc/en-us/articles/360037773133-Dice-Reference#DiceReference-Roll20DiceSpecification)\n\n## How to use it\nInstall the library using:\n```\nnpm install @3d-dice/dice-parser-interface\n```\n\nThen create a new instace of `dice-parser-interface`\n```javascript\nimport DiceParser from '@3d-dice/dice-parser-interface'\n\nconst DP = new DiceParser()\n```\n\nThe DP class now has methods to parse raw notations, process re-rolls and compute the final results from `dice-box`\n```html\n<form id=\"dice-to-roll\">\n  <input id=\"input--notation\" class=\"input\" placeholder=\"2d20\" autocomplete=\"off\" />\n</form>\n```\n```javascript\nconst form = document.getElementById(\"dice-to-roll\")\nconst notationInput = document.getElementById(\"input--notation\")\n\nconst submitForm = (e) => {\n  e.preventDefault();\n    const notation = DP.parseNotation(notationInput.value)\n}\n\nform.addEventListener(\"submit\", submitForm)\n```\n\n## Methods\n### `parseNotation`(`string`, default: `''`)\nAccepts a dice string input, parses it and returns a JSON representation of the parsed input.\n\nExample: `DP.parseNotation('4d6')`\n```json\n[\n  {\n    \"qty\": 4,\n    \"sides\": 6,\n    \"mods\": [],\n    \"rolls\": [\n      {\n        \"sides\": 6,\n        \"groupId\": 0,\n        \"rollId\": 0,\n        \"id\": 0,\n        \"theme\": \"sunset\",\n        \"result\": 1\n      },\n      {\n        \"sides\": 6,\n        \"groupId\": 0,\n        \"rollId\": 1,\n        \"id\": 1,\n        \"theme\": \"sunset\",\n        \"result\": 3\n      },\n      {\n        \"sides\": 6,\n        \"groupId\": 0,\n        \"rollId\": 2,\n        \"id\": 2,\n        \"theme\": \"sunset\",\n        \"result\": 6\n      },\n      {\n        \"sides\": 6,\n        \"groupId\": 0,\n        \"rollId\": 3,\n        \"id\": 3,\n        \"theme\": \"sunset\",\n        \"result\": 6\n      }\n    ],\n    \"value\": 16\n  }\n]\n```\n\nSee also: [Just parse the value](https://github.com/3d-dice/dice-roller-parser#just-parse-the-value)\n\n### `handleRerolls`(`array`, default:`[]`)\nThis method accepts an array of dice rolls (generated by `parseNotation`, updated by `dice-box`) and returns a new array of dice objects that need to be re-rolled. Examples of rolls that could generate rerolls include, exploding, penetrating, and compounding rolls (e.g.: `6d6!`). Reroll and reroll-once notation is also supported (e.g.: `2d12r1`).\n\n#### Dice Object:\n| Property | Type | Description |\n|-|-|-|\n|groupId|int|The group the reroll target belongs to|\n|rollId|int or string|The roll id of the die being rerolled. This will be incremented by `.1` for every reroll made|\n|side|int|The number of sides the reroll die has|\n|qty|int|The number of dice to be rolled. This will always be 1 on rerolls but is needed by `dice-box`|\n\nExample:\n```json\n[\n  {\n    \"groupId\": 0,\n    \"rollId\": \"2.1\",\n    \"sides\": 6,\n    \"qty\": 1\n  },\n  {\n    \"groupId\": 0,\n    \"rollId\": \"3.1\",\n    \"sides\": 6,\n    \"qty\": 1\n  }\n]\n```\n\n### `parseFinalResults`(`array`, default: `[]`)\nAfter all rolls and rerolls have completed, you can pass the results object to `parseFinalResults` to get the final results of the dice roll. This typically happens inside `dice-box`'s `onRollComplete` callback method. \n\nExample: \n```javascript\nconst results = DP.parseFinalResults(results)\n```\n\n## Putting it all together\n### Example HTML\n\n### Example JavaScript\n\n## Caveats\nOne thing this modules does not do is provide the interface for providing an input for the roll notation string or displaying the final results. It is expected that the developer will create their own inputs and outputs or use modules from [@3d-dice/dice-ui](https://github.com/3d-dice/dice-ui)\n\n","readmeFilename":"README.md"}