@@ -107,6 +107,18 @@ void main() {
107107* cap/clamp:
108108 * ` 4d20 C<5 ` -- roll 4d20, change any value < 5 to 5
109109 * ` 4d20 C>15 ` -- roll 4d20, change any value > 15 to 15
110+ * sorting results
111+ * ` 4d20 s ` -- results sorted in ascending order
112+ * ` 4d20 sd ` -- results sorted in descending order
113+
114+ * multiple expressions separated by comma
115+ * ` (1d8!,1d6!)kh ` -- rolls 1d8 and 1d6 exploding, and keeps the highest result
116+ * NOTE: each subexpression is evaluated into a result, and the individual rolls are discarded.
117+ * example: ` (1d8!,1d6!)kh `
118+ * ` 1d6! ` rolls a 6, and explodes with a 4. total: 10
119+ * ` 1d8! ` rolls an 8, and explodes with a 1. total: 9
120+ * the comma-separated results are each replaced -- the rolls are discarded, and the results now are ` 10,9 `
121+ * the highest is kept. the expression's total is 10.
110122
111123* scoring dice rolls:
112124 * counting:
@@ -234,16 +246,100 @@ Sometimes it's nice to change the output type so you can see the graph of result
234246
235247``` console
236248# show the result graph:
237- ❯ dart run example/main.dart -o pretty ' 3d6 #cs #cf'
238- (((3d6) #cs ) #cf ) ===> RollSummary(total: 9, results: [1(d6)❌, 3(d6), 5(d6)], critFailureCount: 1)
239- (((3d6) #cs ) #cf ) =count=> RollResult(total: 9, results: [1(d6)❌, 3(d6), 5(d6)])
240- ((3d6) #cs ) =count=> RollResult(total: 9, results: [1(d6), 3(d6), 5(d6)])
241- (3d6) =rollDice=> RollResult(total: 9, results: [1(d6), 3(d6), 5(d6)])
242-
243- ❯ dart run example/main.dart -o json ' 3d6 #cs #cf'
244- {"expression":"(((3d6) #cs ) #cf )","total":9,"results":[2,3,4],"detailedResults":{"expression":"(((3d6) #cs ) #cf )","opType":"count","nsides":6,"ndice":3,"results":[2,3,4],"left":{"expression":"((3d6) #cs )","opType":"count","nsides":6,"ndice":3,"results":[2,3,4],"left":{"expression":"(3d6)","opType":"rollDice","nsides":6,"ndice":3,"results":[2,3,4],"metadata":{"rolled":[2,3,4]}}}},"metadata":{"rolled":[2,3,4]}}
245-
249+ ❯ dart run example/main.dart -o pretty ' 3d6 #cs #cf'
250+ (((3d6) #cs ) #cf ) ===> RollSummary(total: 13, results: [6(d6✅), 5(d6), 2(d6)], critSuccessCount: 1)
251+ (((3d6) #cs ) #cf ) =count=> RollResult(total: 13, results: [6(d6✅), 5(d6), 2(d6)])
252+ ((3d6) #cs ) =count=> RollResult(total: 13, results: [6(d6✅), 5(d6), 2(d6)])
253+ (3d6) =rollDice=> RollResult(total: 13, results: [6(d6), 5(d6), 2(d6)])
246254
255+ ❯ dart run example/main.dart -o json ' 3d6 #cs #cf' | jq
256+ {
257+ "expression": "(((3d6) #cs ) #cf )",
258+ "total": 12,
259+ "results": [
260+ {
261+ "result": 4,
262+ "nsides": 6,
263+ "dieType": "polyhedral"
264+ },
265+ {
266+ "result": 5,
267+ "nsides": 6,
268+ "dieType": "polyhedral"
269+ },
270+ {
271+ "result": 3,
272+ "nsides": 6,
273+ "dieType": "polyhedral"
274+ }
275+ ],
276+ "detailedResults": {
277+ "expression": "(((3d6) #cs ) #cf )",
278+ "opType": "count",
279+ "results": [
280+ {
281+ "result": 4,
282+ "nsides": 6,
283+ "dieType": "polyhedral"
284+ },
285+ {
286+ "result": 5,
287+ "nsides": 6,
288+ "dieType": "polyhedral"
289+ },
290+ {
291+ "result": 3,
292+ "nsides": 6,
293+ "dieType": "polyhedral"
294+ }
295+ ],
296+ "left": {
297+ "expression": "((3d6) #cs )",
298+ "opType": "count",
299+ "results": [
300+ {
301+ "result": 4,
302+ "nsides": 6,
303+ "dieType": "polyhedral"
304+ },
305+ {
306+ "result": 5,
307+ "nsides": 6,
308+ "dieType": "polyhedral"
309+ },
310+ {
311+ "result": 3,
312+ "nsides": 6,
313+ "dieType": "polyhedral"
314+ }
315+ ],
316+ "left": {
317+ "expression": "(3d6)",
318+ "opType": "rollDice",
319+ "results": [
320+ {
321+ "result": 4,
322+ "nsides": 6,
323+ "dieType": "polyhedral"
324+ },
325+ {
326+ "result": 5,
327+ "nsides": 6,
328+ "dieType": "polyhedral"
329+ },
330+ {
331+ "result": 3,
332+ "nsides": 6,
333+ "dieType": "polyhedral"
334+ }
335+ ],
336+ "total": 12
337+ },
338+ "total": 12
339+ },
340+ "total": 12
341+ }
342+ }
247343```
248344
249345## Statistics output
0 commit comments