Expression = ValueExpression (Operation ValueExpression)*
71d202d8h2 + 34d6 + 2d8 - 2
The top level expression is evaluated from left to right, no exceptions, no pemdas here!
- Add:
+ - Subtract:
-
- Flat modifiers:
7,-8,-29384. These are signed integers and internally support up to 32 bits.
- Constant Die:
1d20,3d6kh,10d8L5. These represent dice with 1 or more sides and are written in andXfashion wherenis the number of dice rolled andXrepresents the range1, 2, ..., Xinclusive. E.g.,1d20reads as "Roll one number between 1 and 20 inclusive". Regex:/[0-9]+d[0-9]+/i - Range Die:
1d[-3 .. 3],1d[1..20](equivalent to1d20). These[a .. b]expressions represent consecutive whole numbers betweenaandbinclusive. - Enumeration Die:
1d[1,3,5],4d[1,1,1,2],10d[1,2,3,4](equivalent to10d4). Enumerations list out all the potential values that the dice expression can roll. Repetitions are allowed and respected and can be used to represent weighted outcomes.
- Keep High / Advantage:
KH,KH2,H,H4(case insensitive). Writing4d20h2reads as "Roll 4 dice representing numbers between 1 and 20 inclusive. Of those 4 results, keep the highest 2 values". E.g.,4d20h2 => [1,6,18,9] => [18, 9]. Regex:/k?h[0-9]*/i - Keep Low / Disadvantage:
LH,LH2,L,L4(case insensitive). Same behaviour as "Keep High" but you keep the lowest N results instead. Regex:/k?l[0-9]*/i - Total (default):
T. Add all of the resulting numbers together. Regex:/t?/i
Regex values provided only for demonstration purposes in order to convey some of the building blocks of these expressions. If you're interested in precisely what this parsers understands please look at the parser