Fixed formatting.

This commit is contained in:
Fletcher Boyd 2013-09-04 18:30:04 +08:00
parent 146ae3c279
commit 4069dd21a3
89 changed files with 615 additions and 496 deletions

View file

@ -15,7 +15,7 @@ split_re = re.compile(r'([\d+-]*)d?(F|\d*)', re.I)
def nrolls(count, n):
"roll an n-sided die count times"
"""roll an n-sided die count times"""
if n == "F":
return [random.randint(-1, 1) for x in xrange(min(count, 100))]
if n < 2: # it's a coin
@ -28,16 +28,16 @@ def nrolls(count, n):
return [random.randint(1, n) for x in xrange(count)]
else: # fake it
return [int(random.normalvariate(.5 * (1 + n) * count,
(((n + 1) * (2 * n + 1) / 6. -
(.5 * (1 + n)) ** 2) * count) ** .5))]
(((n + 1) * (2 * n + 1) / 6. -
(.5 * (1 + n)) ** 2) * count) ** .5))]
@hook.command('roll')
#@hook.regex(valid_diceroll, re.I)
@hook.command
def dice(inp):
"dice <diceroll> -- Simulates dicerolls. Example of <diceroll>:" \
" 'dice 2d20-d5+4 roll 2'. D20s, subtract 1D5, add 4"
"""dice <diceroll> -- Simulates dicerolls. Example of <diceroll>:
'dice 2d20-d5+4 roll 2'. D20s, subtract 1D5, add 4"""
try: # if inp is a re.match object...
(inp, desc) = inp.groups()
@ -84,6 +84,6 @@ def dice(inp):
return "Thanks for overflowing a float, jerk >:["
if desc:
return "%s: %d (%s)" % (desc.strip(), total, ", ".join(rolls))
return "%s: %d (%s)" % (desc.strip(), total, ", ".join(rolls))
else:
return "%d (%s)" % (total, ", ".join(rolls))