-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdie.py
More file actions
48 lines (35 loc) · 796 Bytes
/
die.py
File metadata and controls
48 lines (35 loc) · 796 Bytes
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
# a die simulator
import random, time
dots = {
'0': '',
'1': '5',
'2': '19',
'3': '159',
'4': '1379',
'5': '13579',
'6': '134679'
}
i = 0
class Die:
def __init__(self, char='#'):
self.number = 0
self.char = char
def __str__(self):
out = '╭' + ('─' * 7) + '╮\n'
i = 0
for row in range(3):
out += '│ '
for col in range(3):
i += 1
out += (self.char if str(i) in dots[str(self.number)] else ' ') + ' '
out += '│\n'
out += '╰' + ('─' * 7) + '╯\n'
return out
def roll(self):
self.number = random.randint(1, 6)
die = Die('●')
while True:
print(die)
die.roll()
input()
time.sleep(0.1)