import { roll } from 'roll-parser';
import { createMockRng } from 'roll-parser/testing';
const result = roll('3d6', { rng: createMockRng([4, 2, 6]) });
JSON.stringify(result);
// {
// "total": 12,
// "notation": "3d6",
// "expression": "3d6",
// "rendered": "3d6[4, 2, 6] = 12",
// "rolls": [
// { "sides": 6, "result": 4, "modifiers": ["kept"], "critical": false, "fumble": false },
// { "sides": 6, "result": 2, "modifiers": ["kept"], "critical": false, "fumble": false },
// { "sides": 6, "result": 6, "modifiers": ["kept"], "critical": true, "fumble": false }
// ],
// "parts": {
// "type": "dice", "count": 3, "sides": 6,
// "rolls": [ ...the same three objects... ],
// "total": 12, "start": 0, "end": 3
// }
// }
Complete roll result with all metadata — what roll and evaluate return.
The top level is
Readonly— a result describes one completed evaluation and is never re-targeted. Therollsarray and thepartstree stay mutable so consumers can annotate or re-sort their own views.Fully JSON-serializable; this is exactly what the CLI's
--jsonflag emits.