{"id":25172928,"url":"https://github.com/maz01001/dice_stats","last_synced_at":"2025-07-09T13:39:02.688Z","repository":{"id":275261702,"uuid":"918138103","full_name":"MAZ01001/dice_stats","owner":"MAZ01001","description":"DND dice rolls with statistics","archived":false,"fork":false,"pushed_at":"2025-04-23T07:41:38.000Z","size":122,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-23T08:36:47.616Z","etag":null,"topics":["animations","dice","dice-roller","dnd","permalinks","rng","statistics","success-change","tools","vector-graphics"],"latest_commit_sha":null,"homepage":"https://maz01001.github.io/dice_stats/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MAZ01001.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-17T10:21:42.000Z","updated_at":"2025-04-23T07:41:41.000Z","dependencies_parsed_at":"2025-04-03T22:28:13.782Z","dependency_job_id":"0f60484b-3910-4b4f-9417-0eda37500e9b","html_url":"https://github.com/MAZ01001/dice_stats","commit_stats":null,"previous_names":["maz01001/dice_stats"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MAZ01001/dice_stats","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MAZ01001%2Fdice_stats","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MAZ01001%2Fdice_stats/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MAZ01001%2Fdice_stats/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MAZ01001%2Fdice_stats/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MAZ01001","download_url":"https://codeload.github.com/MAZ01001/dice_stats/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MAZ01001%2Fdice_stats/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264468753,"owners_count":23613150,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["animations","dice","dice-roller","dnd","permalinks","rng","statistics","success-change","tools","vector-graphics"],"created_at":"2025-02-09T10:18:35.232Z","updated_at":"2025-07-09T13:39:02.664Z","avatar_url":"https://github.com/MAZ01001.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dice Stats\n\nDND dice rolls and statistics (success chance).\n\n- [Documentation](#documentation \"Scroll to section: Documentation\")\n- [Quick start](#quick-start \"Scroll to section: Quick start\")\n  - [Format](#format \"Scroll to section: Format\")\n- [Console DIY](#console-diy \"Scroll to section: Console DIY\")\n- [WIP](#wip \"Scroll to section: WIP\")\n\n\u003e \u003chttps://maz01001.github.io/dice_stats/\u003e\n\n## Documentation\n\nButtons at the bottom of the view box:\n\n\u003ctable\u003e\n   \u003ctr\u003e\u003cth\u003eButton\u003c/th\u003e                  \u003cth\u003eDescription\u003c/th\u003e\u003c/tr\u003e\n   \u003ctr\u003e\u003ctd\u003e\u003ckbd\u003eAdd\u0026nbsp;roll\u003c/kbd\u003e\u003c/td\u003e\u003ctd\u003eAdds a new (dice roll) block; Currently 100 blocks maximum.\u003c/td\u003e\u003c/tr\u003e\n   \u003ctr\u003e\n      \u003ctd\u003e\u003ckbd style=\"background-color:#800;color:#ff0\"\u003eClick\u0026nbsp;to\u0026nbsp;remove\u003c/kbd\u003e\u003c/td\u003e\n      \u003ctd\u003e\n         \u003cp\u003eSwitches between different modes for pointer action:\u003c/p\u003e\n         \u003cdl\u003e\n            \u003cdt\u003e\u003ckbd style=\"background-color:#800;color:#ff0\"\u003eClick\u0026nbsp;to\u0026nbsp;remove\u003c/kbd\u003e\u003c/dt\u003e\n            \u003cdd\u003eClick on dice to remove them; Double click on the empty dice area to remove the whole block.\u003c/dd\u003e\n            \u003cdt\u003e\u003ckbd style=\"background-color:#040;color:#0f0\"\u003eClick\u0026nbsp;to\u0026nbsp;rotate\u003c/kbd\u003e\u003c/dt\u003e\n            \u003cdd\u003eClick on dice to roll them (individually); Double click on the block or the dice area within it to roll all dice within that.\u003c/dd\u003e\n            \u003cdt\u003e\u003ckbd style=\"background-color:#630;color:#ff0\"\u003eSwipe\u0026nbsp;to\u0026nbsp;rotate\u003c/kbd\u003e\u003c/dt\u003e\n            \u003cdd\u003e\n               Same as \u003ckbd style=\"background-color:#040;color:#0f0\"\u003eClick\u0026nbsp;to\u0026nbsp;rotate\u003c/kbd\u003e, but also moving the mouse over dice rolls them (individually);\n               For touch start a swipe on a dice graphic and then moving over any dice on the screen rolls them (individually),\n               to scroll the page by swiping over dice simply start swiping, then tap anywhere with a second finger,\n               and it should cancel the \"dice rolling\" and revert back to normal swipe controls.\n            \u003c/dd\u003e\n         \u003c/dl\u003e\n      \u003c/td\u003e\n   \u003c/tr\u003e\n   \u003ctr\u003e\u003ctd\u003e\u003ci\u003eSource Code\u003c/i\u003e\u003c/td\u003e      \u003ctd\u003eLink to this Repository.\u003c/td\u003e\u003c/tr\u003e\n   \u003ctr\u003e\u003ctd\u003e\u003ckbd\u003ePermalink\u003c/kbd\u003e\u003c/td\u003e    \u003ctd\u003eCreate a permalink with the current setup (see \u003ca href=\"#url-hash-quick-start\" title=\"scroll to section: Quick start\"\u003eQuick start\u003c/a\u003e).\u003c/td\u003e\u003c/tr\u003e\n   \u003ctr\u003e\u003ctd\u003e\u003ckbd\u003eRoll\u0026nbsp;all\u003c/kbd\u003e\u003c/td\u003e\u003ctd\u003eRolls all dice on the page at once.\u003c/td\u003e\u003c/tr\u003e\n   \u003ctr\u003e\u003ctd\u003e--%\u003c/td\u003e                     \u003ctd\u003eShows the total chance of success for all blocks; is \"--%\" when not all blocks have dice and not all \u003ckbd\u003eValue\u003c/kbd\u003e fields are filled in (see below) or there are no blocks to begin with.\u003c/td\u003e\u003c/tr\u003e\n\u003c/table\u003e\n\nWithin each block:\n\n\u003ctable\u003e\n   \u003ctr\u003e\u003cth\u003eField\u003c/th\u003e                  \u003cth\u003eDescription\u003c/th\u003e\u003c/tr\u003e\n   \u003ctr\u003e\u003ctd\u003eName\u003c/td\u003e                   \u003ctd\u003eCustom name for this dice roll block (only visual change); Click to edit; Pressing \u003ckbd\u003eEnter\u003c/kbd\u003e or navigating away from it while it's empty will remove the entire block without further asking.\u003c/td\u003e\u003c/tr\u003e\n   \u003ctr\u003e\u003ctd\u003e\u003ckbd\u003eValue\u003c/kbd\u003e\u003c/td\u003e       \u003ctd\u003eNumber input field for comparing with dice roll result; When pressing \u003ckbd\u003eEnter\u003c/kbd\u003e here, all dice within this block are rolled.\u003c/td\u003e\u003c/tr\u003e\n   \u003ctr\u003e\u003ctd\u003e\u003ckbd\u003e\u0026ge;\u003c/kbd\u003e\u003c/td\u003e        \u003ctd\u003eSelection of comparison operator between \u003ckbd\u003eValue\u003c/kbd\u003e and dice roll result; Currently these are \u003ckbd\u003e\u0026ge;\u003c/kbd\u003e, \u003ckbd\u003e\u0026le;\u003c/kbd\u003e, \u003ckbd\u003e\u0026gt;\u003c/kbd\u003e, \u003ckbd\u003e\u0026lt;\u003c/kbd\u003e, and \u003ckbd\u003e=\u003c/kbd\u003e.\u003c/td\u003e\u003c/tr\u003e\n   \u003ctr\u003e\u003ctd\u003e\u003c/td\u003e                       \u003ctd\u003einitially invisible, when two or more dice are present, shows the dice roll result (sum of dice values).\u003c/td\u003e\u003c/tr\u003e\n   \u003ctr\u003e\u003ctd\u003e\u003ci\u003e[Dice\u0026nbsp;area]\u003c/i\u003e\u003c/td\u003e\u003ctd\u003eResizeable area; To revert back to automatic sizing, double-click on the bottom right corner.\u003c/td\u003e\u003c/tr\u003e\n   \u003ctr\u003e\u003ctd\u003e--%\u003c/td\u003e                    \u003ctd\u003eShows the chance of success of the condition of this block; is \"--%\" when \u003ckbd\u003eValue\u003c/kbd\u003e is not filled in or there are no dice.\u003c/td\u003e\u003c/tr\u003e\n   \u003ctr\u003e\u003ctd\u003e\u003ckbd\u003eAdd\u003c/kbd\u003e\u003c/td\u003e         \u003ctd\u003eAdds a new (\u003ckbd\u003eD20\u003c/kbd\u003e) dice to this block; Currently 48 dice maximum per block.\u003c/td\u003e\u003c/tr\u003e\n   \u003ctr\u003e\n      \u003ctd\u003e\u003ckbd\u003eD20\u003c/kbd\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003cp\u003eSelect the dice to add with \u003ckbd\u003eAdd\u003c/kbd\u003e; Currently supported dice are:\u003c/p\u003e\n\n   | Name            | Description       | Possible results     |\n   | --------------- | ----------------- | -------------------- |\n   | \u003ckbd\u003eC\u003c/kbd\u003e    | Two sided coin    | `{1, 2}`             |\n   | \u003ckbd\u003eD4\u003c/kbd\u003e   | Four sided dice   | `{1, 2, 3, 4}`       |\n   | \u003ckbd\u003eD6\u003c/kbd\u003e   | Six sided dice    | `{1, 2, ..., 6}`     |\n   | \u003ckbd\u003eD8\u003c/kbd\u003e   | Eight sided dice  | `{1, 2, ..., 8}`     |\n   | \u003ckbd\u003eD10\u003c/kbd\u003e  | Ten sided dice    | `{1, 2, ..., 10}`    |\n   | \u003ckbd\u003eD12\u003c/kbd\u003e  | Twelve sided dice | `{1, 2, ..., 12}`    |\n   | \u003ckbd\u003eD20\u003c/kbd\u003e  | Twenty sided dice | `{1, 2, ..., 20}`    |\n   | \u003ckbd\u003eD100\u003c/kbd\u003e | Ten sided dice    | `{10, 20, ..., 100}` |\n\n   \u003c/td\u003e\n   \u003c/tr\u003e\n\u003c/table\u003e\n\nWhen dice are rolled they are colored based on success (\u003cspan style=\"color:#0c0\"\u003egreen\u003c/span\u003e \u0026iff; success, \u003cspan style=\"color:#f44\"\u003ered\u003c/span\u003e \u0026iff; failure, and grey if the \u003ckbd\u003eValue\u003c/kbd\u003e field of that block is not filled in)\nand so is the border of the viewing box (same colors but all blocks need to be successful for it to count as successful).\n\nYou can also navigate this page with keyboard-only, touch-only should also work just fine.\n\nThe layout changes to a column with rows instead of rows with blocks when the screen width is smaller than its height (usually mobile devices have this ratio).\n\nScroll [UP](#documentation \"Scroll to start of section: Documentation\")\n    | [TOP](#dice-stats \"Scroll to top of document: Dice Stats\")\n\n## Quick start\n\nDirectly loading full dice roll setup from URL hash (#):\n\n- \u003chttps://maz01001.github.io/dice_stats/#D20\u003e\n\n  ```text\n  empty \u003e= { 1 * D20 }\n  ```\n\n- \u003chttps://maz01001.github.io/dice_stats/#2=2C,13+2D6+D12,123%3C=3D100d100\u003e\n\n  ```text\n  2 = { 2 * C }\n  13 \u003e= { 2 * D6 + 1 * D12 }\n  123 \u003c= { 4 * D100 }\n  ```\n\n- \u003chttps://maz01001.github.io/dice_stats/#150%3E12d20,15+2d12,5gtd8,roll\u003e\n\n  ```text\n  150 \u003e { 12 * D20 }\n  15 \u003e= { 2 * D12 }\n  5 \u003e { 1 * D8 }\n\n  roll all dice after loading\n  ```\n\n### Format\n\nThe general format is:\n\n`\"Name title\"` `Value` `Operator` `Dice list`\n\n- `\"Name title\"` any text within double quotes where `\"` is escaped as `\"\"` or `\\\"` and `\\` is escaped as `\\\\` (can be empty: `\"\"`)\n- `Value` any positive (finite) integer (including 0)\n- `Operator` one of `GE` `\u003e=` `LE` `\u003c=` `GT` `\u003e` `LT` `\u003c` `EQ` `=` `==` `===` (case insensitive)\n- `Dice list` list of `amount` `dice type` with `+` as separator (and at the beginning)\n  - `Amount` positive integer smaller than 2\u003csup\u003e53\u003c/sup\u003e (automatically caps at `MAX_DICE`)\n  - `Dice type` one of `C` `D4` `D6` `D8` `D10` `D12` `D20` `D100` (case insensitive) other dice like `D404` are parsed but ignored\n\nwhere each box is optional and the whole thing can be repeated with `,` as a separator (yes `,,,` is valid and creates 3 empty boxes)\n\nalso, copy-pasting url/format directly on the page loads that setup\n\nand for those that can read regular expressions:\n\n```javascript\n/(?!$)(?:\"((?:\\\\.|\"\"|[^\\\\\"])*)\")?(?:(?:(\\d*)([\u003e\u003c]=?|==?=?|[GL][ET]|EQ))?(\\+?\\d*(?:C+\\+?\\d*|(?:D\\d+)+(?:\\+\\d*)?)*(?:C+|(?:D\\d+)+))?|(\\d+)((?:\\+\\d*)?(?:C+\\+?\\d*|(?:D\\d+)+(?:\\+\\d*)?)*(?:C+|(?:D\\d+)+))?)(?:,|$)/giy\n```\n\nScroll [UP](#quick-start \"Scroll to start of section: Quick start\")\n    | [TOP](#dice-stats \"Scroll to top of document: Dice Stats\")\n\n## Console DIY\n\nInside the browser dev console, some limits can be adjusted:\n\n| Variable               | Description                                              | Default | Limit                             |\n| ---------------------- | -------------------------------------------------------- | ------- | --------------------------------- |\n| `Dice.ANIM_TIME`       | Animation speed of dice rolls in milliseconds            | 1000    | \u0026lbrack;0,\u0026infin;\u0026lbrack;         |\n| `Roll.PRINT_PRECISION` | Number of decimal places for percentages (only visually) | 5       | \u0026lbrack;0..20\u0026rbrack;             |\n| `Roll.MAX_DICE`        | Maximum amount of dice per block                         | 48      | \u0026lbrack;0..90071992547409\u0026rbrack; |\n| `Sheet.MAX_ROLLLS`     | Maximum amount of blocks                                 | 100     | \u0026lbrack;0..2\u003csup\u003e53\u003c/sup\u003e\u0026lbrack; |\n\nAlso, you can generate a number based on a dice type like so:\n\n```javascript\n// with supported dice\nDice.RNG(DiceType.C);    //=\u003e random in {1, 2}\nDice.RNG(DiceType.D4);   //=\u003e random in {1, 2, 3, 4}\nDice.RNG(DiceType.D6);   //=\u003e random in {1, 2, ..., 6}\nDice.RNG(DiceType.D8);   //=\u003e random in {1, 2, ..., 8}\nDice.RNG(DiceType.D10);  //=\u003e random in {1, 2, ..., 10}\nDice.RNG(DiceType.D12);  //=\u003e random in {1, 2, ..., 12}\nDice.RNG(DiceType.D20);  //=\u003e random in {1, 2, ..., 20}\nDice.RNG(DiceType.D100); //=\u003e random in {10, 20, ..., 100}\n// with custom dice\nDice.RNG(33); //=\u003e random in {1, 2, ..., 33}\nDice.RNG({max: 50, step: 5, faces: 10}); //=\u003e random in {5, 10, 15, ..., 50}\n```\n\nThe random number generator uses `MurmurHash3` for seeding (on page load) and then `sfc32` for generating random unsigned 32bit integers;\nAvailable by the global `RNG` class (see \u003chttps://github.com/MAZ01001/Math-Js#rngjs\u003e for more information) or use the same instance the dice use with the global constant `rng`.\n\n```javascript\n// (many features of my original RNG class have been removed here since they weren't needed)\nrng.val32; // gives a random unsigned 32bit integer\n// create a new RNG obj with seed \"seed\"\nconst random = new RNG(\"seed\");\nrandom.val32; // 2460423161\n```\n\nAnd access to the probability-calculation function via the `Probability` class:\n\n```javascript\nconst P = new Probability();\n\n// setup probability for a dice throw with: C, D12, D20, D20, D100, C, D10\nP.Setup([DiceType.C, DiceType.D12, DiceType.D20, DiceType.D20, DiceType.D100, DiceType.C, DiceType.D10]);\n// or\nP.Setup([2, 2, 10, 12, 20, 20, {max: 100, step: 10, faces: 10}]); // (slightly faster in ascending order)\n// (creates internal table of length 167 = 1 + 2 + 2 + 10 + 12 + 20 + 20 + 100)\n\n// check what is the chance of \"80 \u003e= sum of dice\" for a random dice roll\nconst chance = P.Check(80, (value, diceSum) =\u003e value \u003e= diceSum);\n// 0.395 → 39.5% for 80 \u003e= sum of dice when rolling given dice (simultaneously)\n```\n\nScroll [UP](#console-diy \"Scroll to start of section: Console DIY\")\n    | [TOP](#dice-stats \"Scroll to top of document: Dice Stats\")\n\n## WIP\n\n- better documentation in JSDoc\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaz01001%2Fdice_stats","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaz01001%2Fdice_stats","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaz01001%2Fdice_stats/lists"}