Skip to content

Commit

Permalink
fix(dicer): fix dicer check when empty matches
Browse files Browse the repository at this point in the history
  • Loading branch information
fu050409 committed Mar 5, 2024
1 parent 8c921f9 commit 51f7ec9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/diceutils/dicer.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,16 @@ def check(roll_string: str):
matches: List[str] = re.findall(r"\d*[a-zA-Z]\w*|\d+|[-+*/()]", roll_string)
patterns = [r"\d*[dD]\d*", r"\d*[bB]\d+", r"\d*[pP]\d+", r"\d+"]

if not matches:
return False

for match in matches:
if match not in "-+*/()" and not any(
[re.match(pattern, match) for pattern in patterns]
):
return False

return True
else:
return True

def roll(self):
self.parse(roll_string=self.roll_string, explode=self.explode)
Expand Down

0 comments on commit 51f7ec9

Please sign in to comment.