Dice: break out the !roll handler
This commit is contained in:
parent
1aa7a542f2
commit
f5b367406b
@ -264,15 +264,28 @@ class Dice(Module):
|
|||||||
global output
|
global output
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
def do_roll(self, dicestr):
|
||||||
|
"""
|
||||||
|
Roll some dice and get the result (with broken out rolls).
|
||||||
|
|
||||||
|
Keyword arguments:
|
||||||
|
dicestr - format:
|
||||||
|
N#X/YdS+M label
|
||||||
|
N#: do the following roll N times (optional)
|
||||||
|
X/: take the top X rolls of the Y times rolled (optional)
|
||||||
|
Y : roll the die specified Y times (optional, defaults to 1)
|
||||||
|
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()
|
||||||
|
|
||||||
def do(self, connection, event, nick, userhost, what, admin_unlocked):
|
def do(self, connection, event, nick, userhost, what, admin_unlocked):
|
||||||
match = re.search('!roll\s+(.*)$', what)
|
match = re.search('!roll\s+(.*)$', what)
|
||||||
if match:
|
if match:
|
||||||
dicestr = match.group(1)
|
dicestr = match.group(1)
|
||||||
self.build()
|
return self.reply(connection, event, nick + ": " + self.do_roll(dicestr))
|
||||||
yacc.parse(dicestr)
|
|
||||||
reply = self.get_result()
|
|
||||||
if reply is not "":
|
|
||||||
return self.reply(connection, event, nick + ': ' + reply)
|
|
||||||
|
|
||||||
match = re.search('!ctech\s+(.*)$', what)
|
match = re.search('!ctech\s+(.*)$', what)
|
||||||
if match:
|
if match:
|
||||||
|
Loading…
Reference in New Issue
Block a user