Skip to content

Instantly share code, notes, and snippets.

@e-eight
e-eight / dice.py
Created Aug 12, 2019
RPG dice roller
View dice.py
import random
import re
import sys
def roll(dices=1, sides=20, modifier=0):
troll = sum(random.randint(1, sides) for dice in range(dices)) + modifier
return troll
def main():
dice_pattern = re.compile(r'(\d*)d(\d*)([+-]?\d*)')