Skip to content

Instantly share code, notes, and snippets.

@farcaller
Created June 10, 2009 18:03
Show Gist options
  • Save farcaller/127387 to your computer and use it in GitHub Desktop.
Save farcaller/127387 to your computer and use it in GitHub Desktop.
diff --git a/d20tools/postparser.py b/d20tools/postparser.py
index f3af4fe..638c529 100644
--- a/d20tools/postparser.py
+++ b/d20tools/postparser.py
@@ -3,10 +3,16 @@ import re, random
RX_DICE = re.compile(r'[^>](?P<dname>(?P<cnt>\d+)d(?P<dice>\d+)(?P<mod>[-+]\d+|))')
RX_DIRECT = re.compile(r'^((\w+), *)+:') # FIXME
+RDEV = None
+
def dice_roll(x, y, z):
+ global RDEV
+ if not RDEV:
+ RDEV = open('/dev/random')
s = 0
for i in range(x):
- s += random.randint(1, y)
+ v = (ord(RDEV.read(1)) % y) + 1
+ s += v
s += z
return s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment