Created
May 14, 2014 23:53
-
-
Save campaul/612a2a0634879a4a539c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
# The die | |
class d(object): | |
def __init__(self, sides): | |
super(d, self).__init__() | |
self.sides = sides | |
def __mul__(self, rolls): | |
return sum((random.randint(1, self.sides) for roll in xrange(rolls))) | |
# Example weapon roll | |
2 * d(10) + 4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment