don't rebuild parser on every dice roll

This commit is contained in:
Brian S. Stephan 2018-01-17 10:30:07 -06:00
parent 69906aa474
commit 7dbe30a411
1 changed files with 4 additions and 1 deletions

View File

@ -35,6 +35,10 @@ class DiceRoller(object):
output = ""
def __init__(self):
"""Build the parsing tables."""
self.build()
def roll_dice(self, keep, dice, size):
"""Takes the parsed dice string for a single roll (eg 3/4d20) and performs
the actual roll. Returns a string representing the result.
@ -253,7 +257,6 @@ class DiceRoller(object):
dS: roll a S-sided die
+M: add M to the result (-M for subtraction) (optional)
"""
self.build()
yacc.parse(dicestr)
return self.get_result()