From a1eb155b145a1d6aa702a34270d7a0f9d1d25add Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Tue, 13 Mar 2012 00:40:37 +1300 Subject: [PATCH] Small tweaks --- plugins/coin.py | 2 +- plugins/dice.py | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/plugins/coin.py b/plugins/coin.py index ddbd853..6cd4ace 100755 --- a/plugins/coin.py +++ b/plugins/coin.py @@ -41,5 +41,5 @@ def coin(inp): return "You flip a coin and get " + sidename + "." else: flips = flip_simple(count) - return "You flip %s coins and get "\ + return "You flip %s coins and get " \ "%s heads and %s tails." % (str(count), str(flips[0]), str(flips[1])) diff --git a/plugins/dice.py b/plugins/dice.py index c70f7f6..dd2ee2f 100755 --- a/plugins/dice.py +++ b/plugins/dice.py @@ -9,7 +9,8 @@ from util import hook whitespace_re = re.compile(r'\s+') -valid_diceroll = r'^([+-]?(?:\d+|\d*d(?:\d+|F))(?:[+-](?:\d+|\d*d(?:\d+|F)))*)( .+)?$' +valid_diceroll = r'^([+-]?(?:\d+|\d*d(?:\d+|F))(?:[+-](?:\d+|\d*d(?:\d+|' \ + 'F)))*)( .+)?$' valid_diceroll_re = re.compile(valid_diceroll, re.I) sign_re = re.compile(r'[+-]?(?:\d*d)?(?:\d+|F)', re.I) split_re = re.compile(r'([\d+-]*)d?(F|\d*)', re.I) @@ -23,12 +24,12 @@ def nrolls(count, n): if count < 100: return [random.randint(0, 1) for x in xrange(count)] else: # fake it - return [int(random.normalvariate(.5*count, (.75*count)**.5))] + return [int(random.normalvariate(.5 * count, (.75 * count) ** .5))] else: if count < 100: return [random.randint(1, n) for x in xrange(count)] else: # fake it - return [int(random.normalvariate(.5*(1+n)*count, + return [int(random.normalvariate(.5 * (1 + n) * count, (((n+1)*(2*n+1)/6.-(.5*(1+n))**2)*count)**.5))] @@ -36,8 +37,8 @@ def nrolls(count, n): #@hook.regex(valid_diceroll, re.I) @hook.command def dice(inp): - ".dice -- Simulates dicerolls. Example of : '.dice 2d20-d5+4 roll 2'." \ - "D20s, subtract 1D5, add 4" + ".dice -- Simulates dicerolls. Example of :" \ + " '.dice 2d20-d5+4 roll 2'. D20s, subtract 1D5, add 4" try: # if inp is a re.match object... (inp, desc) = inp.groups()