Skip to content

Instantly share code, notes, and snippets.

View e-eight's full-sized avatar

Soham Pal e-eight

View GitHub Profile
@e-eight
e-eight / dice.py
Created August 12, 2019 00:51
RPG dice roller
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*)')