make dice count optional (default 1)
This commit is contained in:
parent
c5b9a13b53
commit
17c899fb70
1 changed files with 2 additions and 2 deletions
|
@ -4,7 +4,7 @@ import random, re
|
||||||
from src import ModuleManager, utils
|
from src import ModuleManager, utils
|
||||||
|
|
||||||
ERROR_FORMAT = "Incorrect format! Format must be [number]d[number], e.g. 1d20"
|
ERROR_FORMAT = "Incorrect format! Format must be [number]d[number], e.g. 1d20"
|
||||||
RE_DICE = re.compile("^([1-9]\d*)d([1-9]\d*)((?:[-+][1-9]\d{,2})*)$", re.I)
|
RE_DICE = re.compile("^([1-9]\d*)?d([1-9]\d*)((?:[-+][1-9]\d{,2})*)$", re.I)
|
||||||
RE_MODIFIERS = re.compile("([-+]\d+)")
|
RE_MODIFIERS = re.compile("([-+]\d+)")
|
||||||
|
|
||||||
MAX_DICE = 6
|
MAX_DICE = 6
|
||||||
|
@ -19,7 +19,7 @@ class Module(ModuleManager.BaseModule):
|
||||||
match = RE_DICE.match(event["args_split"][0])
|
match = RE_DICE.match(event["args_split"][0])
|
||||||
if match:
|
if match:
|
||||||
roll = match.group(0)
|
roll = match.group(0)
|
||||||
dice_count = int(match.group(1))
|
dice_count = int(match.group(1) or "1")
|
||||||
side_count = int(match.group(2))
|
side_count = int(match.group(2))
|
||||||
modifiers = RE_MODIFIERS.findall(match.group(3))
|
modifiers = RE_MODIFIERS.findall(match.group(3))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue