1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
|
[](http://www.rolisteam.org)
# Table of Contents
* [DiceParser](#diceparser--what-is-it-)
* [Roll a die](#how-to-roll-a-die)
* [List of operator](#list-of-operator)
* [Keep](#keep)
* [Explode and Keep](#explode-and-keep)
* [Keep Lower dice](#keep-lower-dice)
* [Sort](#sort)
* [Count](#count)
* [Reroll](#reroll)
* [Reroll until](#reroll-until)
* [Explode](#explode)
* [Add](#add)
* [Occurence](#occurence)
* [Backward Jump](#backward-jump)
* [Paint](#paint)
* [Merge](#merge)
* [Filter](#filter)
* [if](#if)
* [Group](#group)
* [Spread](#spread)
* [Unique](#unique)
* [All The same](#allsame)
* [Value list](#Value-list)
* [Switch/Case](#Switch-case)
* [Comment (\#)](#comment-)
* [Functions](#Functions)
* [Managing the output](#the-output)
* [Shortcuts](#shortcuts)
* [Final Result](#final-result)
* [Dice Result](#dice-result)
* [Arithmetic](#arithmetic)
* [Arithmetic and Dice](#arithmetic-and-dice)
* [Validator](#validator)
* [Scalar](#scalar)
* [Boolean Condition](#boolean-condition)
* [Operation Condition](#operation-condition)
* [Composite Validator](#composite-validator)
* [List operator](#list-operator)
* [Text](#text-values)
* [Number](#number-values)
* [Change the odd](#change-the-odd)
* [Miscellaneous examples](#examples)
* [Best Practices](#best-practices)
* [Platforms](#roll-dice-on-each-platform)
* [Discord bot](#discord-bot)
* [Bug report](#bug-report-and-new-features)
# Documentation:
## DiceParser: What is it ?
DiceParser is a software component dedicated to roll dice through simple commands. This software component is available on different platform.
Such as: discord bot, included in Rolisteam, on twitter etc.
## About examples in this documentation
To make it clear, all examples in this documentation do not show the start up prefix.
Please, remember to add the proper prefix given where you run dice command: Rolisteam, discord, IRC…
If you don't know, try `!`.
The prefix allows the system to identify your command.
## How to roll a die
It is real simple. you have to call:
```
1d6
```
The first number is the count of dice you want to roll. The second number should be die's faces count.
### Examples
```
1d6
```
Roll one six sided die.
```
1d10
```
Roll one ten sided die.
```
5d10
```
Roll five ten sided die.
```
777d6
```
Roll 777 six sided die.
Thanks of several operations and options, you can tune a bit your rolling command: see [List of operator](#list-of-operator).
### Roll dice in Range
```
4d[-1..1]
```
Rolling 4 dice with value between -1 to 1. (Fudge/Fate system)
```
3d[0..9]
```
Rolling 3 dice with 10 faces starting at 0.
```
3d[-20..-9]
```
Rolling 3 dice, values are between -20 and -9.
### Instruction: Roll two (or more) kinds of dice at once
Adding (or any arithmetic operations) results from two (or more) kinds of dice is easy:
```
1d10+1d8
```
To display all results without making any operations with those results. Use `;` to mark several instructions.
```
1d10;1d6 # 2 instructions
```
or
```
5d6;1d10;4d100;3d20 # 4 instructions
```
### Merge
It is possible to merge every instruction inside a huge one.
The operator merge is dedicated to that.
It is useful when you need to manage all diceresult as the same result.
For example, if you need to keep the higher dice between a d6 and d8.
```
d6;d8mk1
```
More details about k operator in [List of operator](#list-of-operator) .
### Computation between instructions
Thanks to variable system, it is possible to reference the result of a specific instruction.
- To reference the first instruction: `$1`
- To reference the second instruction: `$2`
- To reference the third instruction: `$3`
etc…
the number of instruction is not limited.
```
8d10;$1c[>6];$1c1;$2-$3
```
* The first instruction rolls 8 (10 sided) dice
* The second instruction counts how many dice are higher than 6.
* The third instruction counts how many dice are equal to 1.
* The fourth instruction subtracts the result of the third instruction from the result of second one.
## List of operators
* k: Keep
* K: Explode and keep
* kl: Keep lower
* s: Sort
* c: Count
* r: Reroll
* R: Reroll until
* e: Explode
* a: Reroll and add
* @: Backward Jump
* p: Paint dice
* m: Merge
* i: if
* ;: Next instruction
* g: Group
* b: bind
* \#: Comment
### Keep
```
kX
```
The option sorts the resulting die list and selects the X higher dice.
### Explode and Keep
```
KX
```
Dices explode if their value are at the die **maximum**, the option sorts the resulting die list, then it selects the X higher dice.
#### Examples
```
6d10K4
```
Roll 6 10-sided dices, each 10 explodes. So the value of exploded dices is greater than 10.
Result: 40 details: 23 [10,10,3],9,5,3,1,1
Another way to write this command is:
```
6d10e10k4
```
This way allows you to change the explode threshold.
In order to compute the number you want to keep, the k operator manages variable. You can't directly put the computation behind the k but you can refer to a previous computation.
```
# Good
5-3;10d10k$1
```
```
# BAD
10d10k5-3
```
```
# BAD
10d10k(5-3)
```
### Keep Lower dice
```
klX
```
The option sorts the resulting die list, then it selects the X lowest dice.
### Sort
```
3D10s
```
The dice list is sorted in descending order.
```
10d6sl
```
It rolls 6 dice at 6 faces and then they are sorted in ascending order
### Count
```
3D10c[Validator]
```
Count how many dice respect the condition and display the number (See Validator for more details about syntax)
### Reroll
```
3D10r[Validator]
```
Reroll the die if the previous value fits the validator (See Validator for more details about syntax).
### Reroll until
```
3D10R[Validator]
```
Works like "Reroll", but continue to roll the dice until the condition is false.
### Explode
```
3D10e[Validator]
```
Explode while the value fits the Validator (See Validator for more details about syntax).
### Examples
```
3D10e10
```
While dice value is equal to 10, the dice is rolled again and its result is added to the previous dice value.
> Result: **49 details: 8, 12 [10,2], 29 [10,10,9]**
```
3D10e[>8]
```
While the dice value is greater than 8, the dice is rolled again and its result is added to the previous dice value.
> Result: **35 details: 3, 27 [9,10,8], 5**
### Add
```
3D10a[Validator]
```
Reroll the die if its value fits the Validator and add the new value to the previous one. It does that only once.
### Occurrence
```
10d10o
```
Count and sort occurrences of each value.
Result: `3x1,1x2,3x4,2x9,1x10 - [1,1,1,2,4,4,4,9,9,10]`
```
10d10o2,7
```
Count and sort occurrence when they occur at least 2 times, the value is 7 or more.
Result: `2x8 - [1,2,3,5,6,7,8,8,9,10]`
```
10d10o2[<6]
```
Count and sort occurrence when they occur at least 2 times, the value should respect the validator (here less than 6).
Result: `2x3,2x5 - [3,3,5,5,6,6,6,7,7,8]`
#### Errors
```
10d10o[<6]
```
This command is triggering a warning. As occurrence operator can have 0 or 2 parameters. But only one validator is unsupported yet.
### Backward Jump
This operator is dedicated to apply its next operator to the second to last result.
For example:
```
8D10c[>=7]+@c[=10]
```
c[=10] in this command is counting the number of 10 in the result of 8D10, if you remove the @, it will try to count the number of 10 in the result of c[>=7]. The result of c[>=7] is a scalar number (1 or 2 ... (max value 8)); it is not dice list.
### Paint
```
8D10p[1:blue]
```
Paint the first die in the list in blue
```
8d10p[2:blue]
```
Paint the two first dice in the list in blue.
https://gist.github.com/obiwankennedy/62101383d411e55d205e44df78aa5299
The amount of color is depending on the client application of DiceParser.
- With Rolisteam, you may set any Qt color's name or set the Hexcode of your color: #ff28AC.
- The cli application supports few colors: black, white, blue, red, black, green, yellow.
### Filter
Filter operator allows you to ignore some dice results given a validator.
```
4d6f[!=6]
```
Result:
> total: 11 - details[5 2 6 4]
the 6 is ignored.
### Merge
Merge operator is used for gathering several dice rolls from different die type into one dice result and then you may apply any kind of operator.
```
1d6;1d8mk1
```
This command merges together the result from the d6 and the d8. Then, it applied the k operator on both result to keep the best.
Be careful, this operator merges the instruction list. Instruction reference (such as $1 etc..) won't work after merge operator.
### Spead
It makes exploded dice as new dice.
The operator is trigged by *y*.
```
4d6e6y6k3
```
First Result: `10 [6, 4], 3, 3, 2`
Result after spead: `6, 4, 3, 2`
Final result: `6+4+3 = 13`
### All the same
This operator is temporary. It is dedicated to answer issue about Tunnels and Trolls system. It is why the marker operator is `t`.
Dice explode when all dice has the same value.
```
2d6t
```
> # Explode twice because 2,1
Result: 12 - details:[2d6t (5 [2,1,2] 7 [2,1,4])]
> # Nothing happened
Result: 10 - details:[2d6t (4 6)]
### Unique
It makes exploded dice as new dice.
```
4d6e6u
```
Result: 6 4 3 3 2
Final result: 6+4+3 = 13
### Value list
Build your own value list and apply any dice operator.
```
[10,25,43,8]k1
```
Get a higher score from several instructions:
```
1d10;2d6+9;1d20;[$1,$2,$3,$4]k1
```
Each value is transformed into a die.
### Bind
Bind works exactly as merge but it keeps instruction array untouched.
```
!2d8;2d12b;$2k2;$2k2kl1;"your total is $3 with lowest: $4"
```
Roll two 8-sided dice and two 12-sided dice then bind their results. using this final result, we keep the 2 higher dice and then we isolate the lowest of the two highest.
At the end, we display the result inside a sentence.
### if
If operator means to allow you to do one thing if some conditions are true.
The if operator has 2 mandatory parameters:
* The condition (see validator)
* the instruction to do when it is true.
There are also 2 optional parameters
* the compare method
* the instruction to do when it is false.
> i*[]{}{}
* \*: the compare method
* []: the validator
* {}: the true instruction
* {}: the false instruction
#### Compare method
There are 4 different methods.
* **On Each**: the condition is tested on each die from the previous part of the command. \[Default method\]
* **On Each value** `?`: the condition is tested on each final value of die from the previous part of the command.
* **All Of Them** `*`: All dice must fit the condition to trigger the true instruction. If all dice do not fit the condition the false instruction is run.
* **One Of Them** `.`: at least one die must fit the condition to trigger the true instruction. If no dices fit the condition the false instruction is run.
* **On Scalar** `:`: the condition is evaluated on the scalar result of the dice roll.
#### Examples:
```
1d6i[<4]{3}
```
If the value of the die is less than 4, the die value is 3. (So 1, 2 , 3 become 3).
```
4d6e6i[=4]{-4}
```
If die has 4 as value, it removes it. \[Kuro System\]
```
4d6i.[=6]{+1d6}
```
if at least one die is equal to 6, then roll another d6 and add it to the result.
```
4d6i*[=6]{+1d6}
```
if all dice are equal to 6, then roll another d6 and add it to the result.
```
2d10i:[>15]{"Success"}{"Fail"}
```
if the sum of two dice is greater than 15, It displays "Success", otherwise it displays "Fail".
```
2d10i:[>15]{"Success %1 "}{"Fail %1"}
```
Same as above, but the final result is displayed beside Success or Fail.
```
2d10i:[>15]{"Success %1 [%2]"}{"Fail %1 [%2]"}
```
Same as above, but the result of each die is displayed inside square brackets.
### Group
Group dices, then count the number of group (7th sea system).
#### Complex output
Group operator can take a parameter to active the complex output.
This output will show each group and any left aside values if any.
To active this output, it is required to add a `s` just after the `g`. See the example below:
#### Example
```
3d20g10
```
This will roll 3 dices and then try to group them to make groups of 10. If you get `9 9 2`, you can only create one group whose value is more or equal to ten (`{9,2}`, the second `9` being "wasted").
The `g` operator is allowed to re-order dices to create groups. When rolling `4d20g10`, if you get `7 4 3 6`, the result will be `2` (`{7,3}` and `{6,4}`).
```
5d10gs10
```
Then, the final output will be:
```
2 ({7,3}, {6,4} - [2])
```
`{7,3}` and `{6,4}` are group, and `[2]` is left aside.
### Switch case (S)
Switch case operator allows you to transform number value into text.
Its goal is to make that easier than using several if. As you may expect, its syntax is close to if.
```
1d100S[<50]{"Low"}[>=50]{"Low"}
```
You may also add a default option
```
1d4S[=1]{"Low"}[=2]{"small"}[=3]{"medium"}{"big"}
```
Exclusive mode:
This mode is enabled when a `^` is following the `S`.
```
1d100S^[<25]{"Low"}[<50]{"small"}[<75]{"medium"}[>=75]{"big"}
```
### Comment (\#)
```
2D6 # Sword attack
```
Display "Sword attack" and the result of the two dice.
DiceParser ignores everything after the \#. The whole part is treated as one comment.
So DiceParser can answer the question:
```
1L[yes,no] # Am I evil ?
```
> Am I evil ?
yes
## Functions
DiceParser provides function to deal with instructions.
Some functions will come soon (e.g: max, min). It will allow to manage several commands at once.
### Repeat
> repeat(1d10,5)
Output:
```
2 - Details [2]
8 - Details [8]
3 - Details [3]
1 - Details [1]
10 - Details [10]
```
Attention! Be careful, `repeat` works badly with multiple instruction commands
## The output
DiceParser provides features to let you control the command output.
The final instruction must be a string instruction.
String instruction starts with `"` and ends with `"`.
Rolling:
> `"result"`
Output:
`result`
You can set string instruction inside if operator:
> 1d6i:[>3]{"Success"}{"Fail"}
Output:
`Success` or `Fail`
It offers a quick answer but sometimes you need to see the rolled values.
DiceParser can replace some special tags in order to see values, computation result and whatever.
### Shortcuts
There are 3 shortcut tags.
* `%1`: last scalar result from each instruction.
* `%2`: all dice results.
* `%3`: last scalar result from the last instruction.
The default output is `%1 details[%2]`.
So, it shows the last scalar result of each instruction and dice result.
`%1` and `%3` are equivalent when there is only one instruction (no \;).
They are really useful but if you have many instructions that can become a bit messy.
### Final result
It is also possible to set reference to the final value of specific instruction (the result should be a number or a string)
- To reference the first instruction: `$1`
- To reference the second instruction: `$2`
- To reference the third instruction: `$3`
There is no limit on instruction number.
#### String as final result
You can reference the sub result of a string result by adding `[x]` after the instruction reference.
Let see an example, it will be easier to understand.
```
2Lu[cats,dogs,rats,rabbits,bats,squirrels]
```
The default result looks like this:
> cats,bats
Now we want to make a sentence with this text:
```
2Lu[cats,dogs,rats,rabbits,bats,squirrels];"You love $1 and you are afraid of $1"
```
As $1 refers to "**cats,bats**", it will show:
> You love cats,bats and you are afraid of cats,bats
So, it is not really useful. In order to make it a bit better, we must add some sub-indexes.
```
2Lu[cats,dogs,rats,rabbits,bats,squirrels];"You love $1[0] and you are afraid of $1[1]"
```
then we have a proper output.
> You love cats and you are afraid of bats
#### Let see some examples:
```
8d10;$1c[>6];$1c1;$2-$3
```
The default output displays: `45,4,0,4 details[4,3,10,7,2,2,7,10]`
```
8d10;$1c[>6];$1c1;$2-$3i:[>0]{"%3 Success[%2]"}{i:[<0]{"Critical fail %3 [%2]"}{"Fail %3 [%2]"}}
```
Here, some output example:
* `4 Success[4,3,10,7,2,2,7,10]`
* `Fail 0 [10,3,1,1,2,2,7,5]` (2 success - 2 fails = 0)
* `Critical fail -2 [1,3,1,1,2,2,7,5]` (1 success - 3 fails = -2)
In this example, the critical fail happens when there are more fails than success.
In the next example, the critical fail happens when there was no success and a least one fail.
```
8d10;$1c[>6];$1c1;$2-$3;$4i:[=0]{"Fail $4 [%2]"}{$4i:[>0]{"$2 Success[%2]"}{$2i:[=0]{"Critical Fail $4 [%2]"}{"Fail $4 [%2]"}}}
```
Another example, to show how to combine string and dice result.
```
1d6+1;1L[gold coins,spell scrolls,weapons];"You found $1 $2"
```
> You found 5 gold coins
### Dice Result
DiceParser provides tags to display dice result (and each rolled values from a specific instruction).
To show dice values from a specific instruction, just add `@` followed by the instruction's number (e.g: `@1`)
```
2d6;3d8;"Result $2 - d8:[@2] - d6:[@1]"
```
The output:
> Result 15 - d8:[7,4,4] - d6:[3,6]`
### New line
You may need to display your result on several lines. It is really easy:
```
1d100;1d10;"Attack: $1\nDamage: $2"
```
This command will display:
> Attack: 31
Damage: 7
## Arithmetic
Rolisteam Dice Parser is able to compute primary arithmetic operation such as: +, -, /, * and it also manages those operator priority and it can also manage parenthesis.
```
8+8+8
```
> Result: 24
```
24-4
```
> Result: 20
```
(3+4)*2
```
> Result: 14
```
7/2
```
> Result: 3.5
```
(3+2D6)D10
```
> Roll 2 dice and add 3 to the sum of those dice. Then the result is used for rolling dice.
```
15|6
```
> Result: 2
```
15/6
```
> Result: 2.5
## Arithmetic and Dice
It is possible to use arithmetic operation on dice. Please pay attention that the default operation to translate a
dice list to scalar is the sum. So if you roll `3d6`, the result will be a list with 3 values {2, 5 ,1}. Now, we
change a bit the command `3d6+4`: It is resolved like this: {2, 5 ,1} = 8; 8+4 = 12. The final result is 12.
```
3d6+4
```
> Roll 3 dice; sum the result; and add 4
```
10D10-2
```
> Roll 10 dice; sum the result; and then subtract 2
```
87-1D20
```
> Subtract the result of 1 die to 87
```
(6-4)D10
```
> Subtract 4 to 6 and then roll two dice.
```
1D10/2
```
> Divide by 2 the result of 1 die.
```
(2+2)**2
```
> Result: 16
```
1d10**2
```
> Roll 1d10 then multiply the result by itself.
```
15|2
```
> Integer division of 15 by 2. Result: 7
```
15/2
```
> Division of 15 by 2. Result: 7.5
## Validator
There are five kinds of Validator:
* Scalar
* Range
* Boolean expression
* Operation Condition
* Composite
Any operator which requires validator (such as `a,r,e,c`) can use those three kinds.
### Scalar
The scalar value sets the validator on equality between the dice value and the validator
```
4d10e10
```
This command means: roll 4 dice and they explode on 10.
### Range
The range is defined as two bounds. You have to use square brackets and the two bounds are separated by `..`.
```
4d10c[8..10]
1d[-1..8]
```
### Boolean Condition
The command counts how many dice have values between >=8 and <=10.
```
4d10c[>7]
```
The command counts how many dice are aboved 7.
#### Compare Operator
The Rolisteam Dice Parser allows you to use several logic operators:
* Equal: `=`
* Greater or equal: `>=`
* Lesser or equal: `<=`
* Lesser: `<`
* Greater: `>`
* Different: `!=`
#### Compare methods
As the `if` operator, you can specify the compare method.
* **On Each**: the condition is tested on each die from the previous part of the command. \[Default method\]
* **On Each value** `?`: the condition is tested on each final value of die from the previous part of the command.
* **All Of Them** `*`: All dice must fit the condition to trigger the true instruction. If all dice do not fit the condition the false instruction is run.
* **One Of Them** `.`: at least one die must fit the condition to trigger the true instruction. If no dices fit the condition the false instruction is run.
* **On Scalar** `:`: the condition is evaluated on the scalar result of the dice roll.
##### Examples:
```
1L[7,8,9]c[>6]
```
This command will return 0 because, no die has been rolled, so the result of `1L[7,8,9]` is a final value.
```
1L[7,8,9]c[?>6]
```
Output: 1
```
5d6e6sc[>=8]
```
Output:
> 0
details: [8 [6,2] 2 1 1 1]
```
5d6e6f[?>=16]
```
Output:
As the final sum is equal to 11. It's less than 16 so the filter is filtering everything.
> 0
details: [2 4 1 3 1]
The final sum is higher than 16 so the whole result is accepted by the filter operator.
> 23
details: [3 6 3 5 6]
```
5d6e6sc[:>=8]
```
Output:
> 1
details: [8 [6,2] 2 1 1 1]
### Operation Condition
This validator offers modulo as operation and a Boolean Condition to validate the value:
```
4d10c[%2=0]
```
Count how many even numbers have been rolled.
```
4d10c[%2=1]
```
Count how many odd numbers have been rolled.
[modulo](https://en.wikipedia.org/wiki/Modulo_operation)
### Composite Validator
Validator can be the result of several validator.
```
4d10c[>4&%2=0]
```
Count all dice greater than 4 and even [6,8,10].
Composite Validator supports 3 logical operations:
* AND : `&`
* OR : `|`
* Exclusive OR : `^`
Composite Validator accepts as many validator as you need:
```
!9d100c[=1|=3|=5|=7|=11|=13|=17|=19|=23|=29|=31|=37|=41|=43|=47|=53|=59|=61|=67|=71|=73|=79|=83|=89|=97]
```
## List operator
* [Number](#number-values)
* [Change the odd](#change-the-odd)
### Text values
The L (or l) operator (meaning list) provides a way to pick up value from list.
```
1L[sword,bow,knife,gun,shotgun]
```
With comment
```
1L[yes,no] # Am I evil ?
```
> Am I evil ?
yes
### Getting unique values
The `u` parameter asks for unique values.
```
2Lu[yes,no]
```
This command can return `yes,no` or `no,yes`. The u make it impossible to return `yes,yes` or `no,no`
### Remove comma between values
By default, results are displayed with a comma between each values. You can remove the comma with the parameter `n`
```
2Ln[to,kyo]
```
This command can return `toto`, `kyokyo`, `tokyo`, `kyoto`.
### Unique with no comma
```
2Lun[to,kyo]
```
or
```
2Lnu[to,kyo]
```
Those commands can return `tokyo` or `kyoto`.
### Number values
If the value is a number, it is treated as well and you can do computation on it or use any operator.
```
1L[-1,0,1,2,3,4]+7
```
### Text and Number at the same time
It is not recommended to use text and number in the same list operator.
Currently, the behaviour changes given the result. If the chosen value is a number, you can do other computation, but otherwise, the result is displayed directly without any control on it.
The behaviour will change in future release to base the decision on the data set. If the data set only contains numbers, then computation is possible. Otherwise, it will be treated as string result.
### Change the odd
There are 2 main ways to control the odd on the pickup in the list.
#### The ant method
```
1L[2,2,3,3,3,3,4,4,4,5]
```
or
```
1L[arm,arm,leg,leg,chest,chest,chest,head]
```
#### The lazy method
By range:
```
1L[1,2,3,4,5,6[6..10]]
```
By weight:
```
1L[1[2],2[2],3[4]]
```
Several results:
```
1
3
1
2
2
1
2
3
1
2
3
2
2
3
```
## Examples
```
3D100
```
Roll 3 dice with 100 faces
```
10D10e[=10]s
```
Roll 10 dice with 10 faces, 10 explodes, and sort the result.
```
100291D66666666s
```
Roll 100291 dice with 66666666666 faces and sort result
```
15D10c[>7]
```
roll 15 dice with 10 faces and it counts number of dice which are above 7
```
1D8+2D6+7
```
roll 1 die with 8 faces and add the result to 2 dice with 6 faces and add 7.
```
D25
```
roll 1 die with 25 faces
```
88-1D20
```
88 minus the value of 1 die of 20 faces
```
8+8+8
```
compute: 24
```
1L[sword,bow,knife,gun,shotgun]
```
One of this word will be picked.
```
8D10c[Validator1]-@c[validator2]
```
Roll 8 dice with 10 faces then it counts how many dice respect the condition Validator1 and substract the number of dice which respect the validator2 and display the number (See Validator for more details about syntax)
```
8D10c[>=6]-@c[=1]
```
Old World in darkness system.
```
8D10c[>=7]+@c[=10]
```
Exalted 2nd edition system.
## Best Practices
As DiceParser provides more and more features, you may find several ways to do the same thing. We want here to explain the difference between those several approaches. Then you will be able to use the right one.
### Roll several kind of dice and sum them
**Bad**
```
2d8;2d10m
```
**Good**
```
2d8+2d10
```
The merge operator is useful when you want to use dice operator on all rolled dice.
**Bad**
```
1d20K1+1d10K1
```
**Good**
```
1d20+1d10
```
The k operator to keep as many dice as you roll is pretty useless because it is the default behaviour.
## Platform specific documentation
### Roll dice on each platform
| platform | start character(s) | more information |
|---|---|--- |
| Rolisteam |```!```| [Documentation](http://wiki.rolisteam.org/index.php/En:Dice) |
| Discord |```!```| To install DiceParser on your server [http://www.rolisteam.org/discord.html](http://www.rolisteam.org/discord.html) |
| Twitter | ```#roll``` | Twit any message starting with #roll following by dice command (e.g: ```#roll 2d6```) |
| dice | nothing | dice is a command line application to roll dice: ```dice "2d6"``` |
### Known Limitations
| platform | descriptions |
|---|---|
| Rolisteam | no support for comments yet. Rolisteam is a big software. You may not have all the most recent feature from diceparser. |
| Discord | If the command takes too much time. It is canceled |
| Twitter | Result should be short. No aliases |
| dice | |
# Discord Bot
Documentation of the bot is now inline with the bot.
## Prefix documentation
> !help prefix
## Macro documentation
> !help macro
[Examples and More information](https://invent.kde.org/rolisteam/rolisteam-diceparser/-/blob/master/community_macro.md)
## Alias documentation
> !help alias
## Conf documentation
> !help conf
## Difference between Aliases and Macros
Aliases is the feature of the bot, macro is a feature of the dice system behind the bot.
Aliases is a way to run several commands at once.
Macro is a way to run huge command by typing few letters. Macros may have parameters (such as dice number, threshold for success or whatever)
# Bug report and new features
Please fulfill a ticket in our [Bug tracker](https://invent.kde.org/kde/rolisteam-diceparser/issues/new) system.
Or contact us on [discord](https://discordapp.com/invite/MrMrQwX) or any [other ways](http://www.rolisteam.org/contact.html)
|