# Untitled

Jun 23rd, 2021
1,059
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import random
2. running = True
3.
4. class Die:
5.     def __init__(self, val):
6.         self.cap = '_________'
7.         self.r1=self.r2=self.r3='|         |'
8.         self.assign_pips(val)
9.
10.     def assign_pips(self, val):
11.         d1 = '|o        |'
12.         d2 = '|o       o|'
13.         dc = '|    o    |'
14.
15.         if val == 1:
16.             self.r2 = dc
17.         if val == 2:
18.             self.r1 = d1
19.             self.r3 = self.r1[::-1]
20.         if val ==3:
21.             self.r1 = d1
22.             self.r2 = dc
23.             self.r3 = self.r1[::-1]
24.         if val ==4:
25.             self.r1 = self.r3 = d2
26.         if val ==5:
27.             self.r1 = self.r3 = d2
28.             self.r2 = dc
29.         if val ==6:
30.             self.r1 = self.r2 = self.r3 = d2
31.
32.     def display(self):
33.         print_list = [self.cap, self.r1, self.r2, self.r3, self.cap]
34.         print("\n".join(print_list))
35.
36. def roll(die_count):
37.     roll_total = 0
38.     for x in range(die_count):
39.         val = random.randint(1,6)
40.         d = Die(val)
41.         d.display()
42.         roll_total+=val
43.     print(f'Total: {roll_total}')
44.
45. while running:
46.     die_count = int(input('How many die would you like to use?'))
47.     roll(die_count)
RAW Paste Data