/
ascii_dice.py
74 lines (60 loc) · 1.08 KB
/
ascii_dice.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
import time
import random
dice1 = """
__________
| |
| |
| O |
| |
|_________|"""
dice2 = """
__________
| |
| O |
| |
| O |
|_________|"""
dice3 = """
__________
| |
| O |
| O |
| O |
|_________|"""
dice4 = """
__________
| |
| O O |
| |
| O O |
|_________|"""
dice5 = """
__________
| |
| O O |
| O |
| O O |
|_________|"""
dice6 = """
__________
| |
| O O |
| O O |
| O O |
|_________|"""
dice_list = (dice1, dice2, dice3, dice4, dice5, dice6)
# Seconds that the dice animation will be shown
animation_duration_time = 10
time_end = time.time() + animation_duration_time
def roll_dice():
while time.time() < time_end:
print(random.choice(dice))
time.sleep(1)
def dice():
die1 = random.randint(1, 6)
die2 = random.randint(1, 6)
dice = die1 + die2
print("You roll a", die1, "and", die2, "for a total of", dice)
print(dice_list[die1 - 1])
print(dice_list[die2 - 1], '\n')
return dice