def _roll_dtable(self, dice: str, times=1, modifier=0):
"""Rolls a set of die in the format 2d12
By default only one set of die is rolled, without a
modifier. Example 3d20 5 1 will roll three 1d20 dice for
five seperate instances, with a +1 modifier added to the total."""
if times < 1:
raise RollError("You need to have at least one roll instance.")
elif times > 20:
raise RollError("Cannot roll more than 20 instances at a time.")
die, maximum = self.parse_dice(dice)
rolls_raw = list(range(times))
if modifier < 0:
sign = ""
else:
sign = "+"
rolls = [(str("Roll {}".format(x + 1)), self.roll_dice(die, maximum), sign + str(modifier))
for x in rolls_raw]
final = [x + (str(x[1] + modifier),) for x in rolls]
headers = ["Roll", "Result", "Modifier", "Total"]
t = tabulate(final, headers=headers)
await self.bot.say("```{}```".format(t))
评论列表
文章目录