forked from geekcomputers/Python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dice_rolling_simulator.py
98 lines (67 loc) · 3.04 KB
/
dice_rolling_simulator.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
#Made on May 27th, 2017
#Made by SlimxShadyx
#Dice Rolling Simulator
import random
#These variables are used for user input and while loop checking.
correct_word = False
dice_checker = False
dicer = False
roller_loop = False
#Checking the user input to start the program.
while correct_word == False:
user_input_raw = raw_input("\r\nWelcome to the Dice Rolling Simulator! We currently support 6, 8, and 12 sided die! \
Type [start] to begin!\r\n?>")
#Converting the user input to lower case.
user_input = (user_input_raw.lower())
if user_input == 'start':
correct_word = True
else:
print "Please type [start] to begin!\r\n"
#Main program loop. Exiting this, exits the program.
while roller_loop == False:
#Second While loop to ask the user for the certain die they want.
while dice_checker == False:
user_dice_chooser = raw_input("\r\nGreat! Begin by choosing a die! [6] [8] [10]\r\n?>")
user_dice_chooser = int(user_dice_chooser)
if user_dice_chooser == 6:
dice_checker = True
elif user_dice_chooser == 8:
dice_checker = True
elif user_dice_chooser == 12:
dice_checker = True
else:
print "\r\nPlease choose one of the applicable options!\r\n"
#Another inner while loop. This one does the actual rolling, as well as
#allowing the user to re-roll without restarting the program.
while dicer == False:
if user_dice_chooser == 6:
dice_6 = random.randint(1,6)
print "\r\nYou rolled a " + str(dice_6) + "!\r\n"
dicer = True
user_exit_checker_raw = raw_input("\r\nIf you want to roll another die, type [roll]. To exit, type [exit].\r\n?>")
user_exit_checker = (user_exit_checker_raw.lower())
if user_exit_checker == 'roll':
dicer = False
elif user_exit_checker == 'exit':
roller_loop = True
elif user_dice_chooser == 8:
dice_8 = random.randint(1,8)
print "\r\nYou rolled a " + str(dice_8) + "!"
dicer = True
user_exit_checker_raw = raw_input("\r\nIf you want to roll another die, type [roll]. To exit, type [exit].\r\n?>")
user_exit_checker = (user_exit_checker_raw.lower())
if user_exit_checker == 'roll':
dicer = False
elif user_exit_checker == 'exit':
roller_loop = True
elif user_dice_chooser == 12:
dice_12 = random.randint(1,12)
print "\r\nYou rolled a " + str(dice_12) + "!"
dicer = True
user_exit_checker_raw = raw_input("\r\nIf you want to roll another die, type [roll]. To exit, type [exit].\r\n?>")
user_exit_checker = (user_exit_checker_raw.lower())
if user_exit_checker == 'roll':
dicer = False
elif user_exit_checker == 'exit':
roller_loop = True
print "Thanks for using the Dice Rolling Simulator! Have a great day! =)"