-
Notifications
You must be signed in to change notification settings - Fork 0
/
RollDice.py
101 lines (81 loc) · 1.81 KB
/
RollDice.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import time
import random
import re
roll = "You rolled a {}!"
def dice20():
d20 = random.randrange(1, 21)
print("Rolling...")
time.sleep(0.5)
global roll
print(roll.format(d20))
if d20 == 20:
print("CRITICAL SUCCESS!")
elif d20 == 1:
print("CRITICAL FAIL!")
def dice4():
d4 = random.randrange(1, 5)
print("Rolling...")
time.sleep(0.5)
global roll
print(roll.format(d4))
def dice6():
d6 = random.randrange(1, 7)
print("Rolling...")
time.sleep(0.5)
global roll
print(roll.format(d6))
def dice8():
d8 = random.randrange(1, 9)
print("Rolling...")
time.sleep(0.5)
global roll
print(roll.format(d8))
def dice10():
d10 = random.randrange(1, 11)
print("Rolling...")
time.sleep(0.5)
global roll
print(roll.format(d10))
def dice12():
d12 = random.randrange(1, 13)
print("Rolling...")
time.sleep(0.5)
global roll
print(roll.format(d12))
def dice100():
d100 = random.randrange(1, 101)
print("Rolling...")
time.sleep(0.5)
global roll
print(roll.format(d100))
def Choice():
print("1) d4")
print("2) d6")
print("3) d8")
print("4) d10")
print("5) d%")
print("6) d12")
print("7) d20")
while True:
try:
userChoice = int(input("Please choose a dice to roll."))
break
except:
print("Please choose from the available options.")
if userChoice == 1:
dice4()
elif userChoice == 2:
dice6()
elif userChoice == 3:
dice8()
elif userChoice == 4:
dice10()
elif userChoice == 5:
dice100()
elif userChoice == 6:
dice12()
elif userChoice == 7:
dice20()
else:
print("Please choose from the available options.")
Choice()