roll method
Rolls the dice and returns the result, a random number between 1 and the amount of sides. It is returned with the dice that was rolled in a DiceRoll object, which also contains the results of the individual dice.
Implementation
DiceRoll roll() {
if (needsModifier) {
throw Exception("Dice is being rolled without an actual modifier."
"Use `copyWithModifierValue`.\n"
"Expected modifier: $modifierWithSign");
}
final arr = <int>[];
for (var i = 0; i < amount; i++) {
arr.add(Random().nextInt(sides) + 1);
}
return DiceRoll(dice: this, results: arr);
}