You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+15
Original file line number
Diff line number
Diff line change
@@ -82,6 +82,21 @@ const result = dice.roll("1d20").total;
82
82
console.log(result); // Outputs 4.
83
83
```
84
84
85
+
#### Limiting the number of rolls or sides
86
+
87
+
Limit the number of rolls or dice sides by providing a configuration object to the `Dice` constructor:
88
+
89
+
```typescript
90
+
const dice =newDice(null, null, {
91
+
maxRollTimes: 20, // limit to 20 rolls
92
+
maxDiceSides: 100, // limit to 100 dice faces
93
+
});
94
+
const result1 =dice.roll("50d10");
95
+
console.log(result1.errors); // Outputs ["Invalid number of rolls: 50. Maximum allowed: 20."]
96
+
const result2 =dice.roll("10d500");
97
+
console.log(result2.errors); // Outputs ["Invalid number of dice sides: 500. Maximum allowed: 500."]
98
+
```
99
+
85
100
#### Dice Expression Syntax
86
101
87
102
The dice rolling syntax is based on the system used by Roll20, a detailed explanation of which can be found on the [Roll20 Wiki](https://wiki.roll20.net/Dice_Reference#Roll20_Dice_Specification).
0 commit comments