don't rebuild parser on every dice roll
This commit is contained in:
parent
69906aa474
commit
7dbe30a411
@ -35,6 +35,10 @@ class DiceRoller(object):
|
|||||||
|
|
||||||
output = ""
|
output = ""
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
"""Build the parsing tables."""
|
||||||
|
self.build()
|
||||||
|
|
||||||
def roll_dice(self, keep, dice, size):
|
def roll_dice(self, keep, dice, size):
|
||||||
"""Takes the parsed dice string for a single roll (eg 3/4d20) and performs
|
"""Takes the parsed dice string for a single roll (eg 3/4d20) and performs
|
||||||
the actual roll. Returns a string representing the result.
|
the actual roll. Returns a string representing the result.
|
||||||
@ -253,7 +257,6 @@ class DiceRoller(object):
|
|||||||
dS: roll a S-sided die
|
dS: roll a S-sided die
|
||||||
+M: add M to the result (-M for subtraction) (optional)
|
+M: add M to the result (-M for subtraction) (optional)
|
||||||
"""
|
"""
|
||||||
self.build()
|
|
||||||
yacc.parse(dicestr)
|
yacc.parse(dicestr)
|
||||||
return self.get_result()
|
return self.get_result()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user