Skip to content

Instantly share code, notes, and snippets.

@campaul
Created May 14, 2014 23:53
Show Gist options
  • Save campaul/612a2a0634879a4a539c to your computer and use it in GitHub Desktop.
Save campaul/612a2a0634879a4a539c to your computer and use it in GitHub Desktop.
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