|
| 1 | +#Made on May 27th, 2017 |
| 2 | +#Made by SlimxShadyx |
| 3 | + |
| 4 | +#Dice Rolling Simulator |
| 5 | + |
| 6 | +import random |
| 7 | + |
| 8 | +#These variables are used for user input and while loop checking. |
| 9 | +correct_word = False |
| 10 | +dice_checker = False |
| 11 | +dicer = False |
| 12 | +roller_loop = False |
| 13 | + |
| 14 | +#Checking the user input to start the program. |
| 15 | +while correct_word == False: |
| 16 | + |
| 17 | + 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?>") |
| 18 | + |
| 19 | + #Converting the user input to lower case. |
| 20 | + user_input = (user_input_raw.lower()) |
| 21 | + |
| 22 | + if user_input == 'start': |
| 23 | + correct_word = True |
| 24 | + |
| 25 | + else: |
| 26 | + print "Please type [start] to begin!\r\n" |
| 27 | + |
| 28 | +#Main program loop. Exiting this, exits the program. |
| 29 | +while roller_loop == False: |
| 30 | + |
| 31 | + #Second While loop to ask the user for the certain die they want. |
| 32 | + while dice_checker == False: |
| 33 | + user_dice_chooser = raw_input("\r\nGreat! Begin by choosing a die! [6] [8] [10]\r\n?>") |
| 34 | + |
| 35 | + user_dice_chooser = int(user_dice_chooser) |
| 36 | + |
| 37 | + if user_dice_chooser == 6: |
| 38 | + dice_checker = True |
| 39 | + |
| 40 | + elif user_dice_chooser == 8: |
| 41 | + dice_checker = True |
| 42 | + |
| 43 | + elif user_dice_chooser == 12: |
| 44 | + dice_checker = True |
| 45 | + |
| 46 | + else: |
| 47 | + print "\r\nPlease choose one of the applicable options!\r\n" |
| 48 | + |
| 49 | + #Another inner while loop. This one does the actual rolling, as well as allowing the user to re-roll without restarting the program. |
| 50 | + while dicer == False: |
| 51 | + |
| 52 | + if user_dice_chooser == 6: |
| 53 | + dice_6 = random.randint(1,6) |
| 54 | + print "\r\nYou rolled a " + str(dice_6) + "!\r\n" |
| 55 | + dicer = True |
| 56 | + |
| 57 | + user_exit_checker_raw = raw_input("\r\nIf you want to roll another die, type [roll]. To exit, type [exit].\r\n?>") |
| 58 | + user_exit_checker = (user_exit_checker_raw.lower()) |
| 59 | + |
| 60 | + if user_exit_checker == 'roll': |
| 61 | + dicer = False |
| 62 | + |
| 63 | + elif user_exit_checker == 'exit': |
| 64 | + roller_loop = True |
| 65 | + |
| 66 | + |
| 67 | + elif user_dice_chooser == 8: |
| 68 | + dice_8 = random.randint(1,8) |
| 69 | + print "\r\nYou rolled a " + str(dice_8) + "!" |
| 70 | + dicer = True |
| 71 | + |
| 72 | + user_exit_checker_raw = raw_input("\r\nIf you want to roll another die, type [roll]. To exit, type [exit].\r\n?>") |
| 73 | + user_exit_checker = (user_exit_checker_raw.lower()) |
| 74 | + |
| 75 | + if user_exit_checker == 'roll': |
| 76 | + dicer = False |
| 77 | + |
| 78 | + elif user_exit_checker == 'exit': |
| 79 | + roller_loop = True |
| 80 | + |
| 81 | + elif user_dice_chooser == 12: |
| 82 | + dice_12 = random.randint(1,12) |
| 83 | + print "\r\nYou rolled a " + str(dice_12) + "!" |
| 84 | + dicer = True |
| 85 | + |
| 86 | + user_exit_checker_raw = raw_input("\r\nIf you want to roll another die, type [roll]. To exit, type [exit].\r\n?>") |
| 87 | + user_exit_checker = (user_exit_checker_raw.lower()) |
| 88 | + |
| 89 | + if user_exit_checker == 'roll': |
| 90 | + dicer = False |
| 91 | + |
| 92 | + elif user_exit_checker == 'exit': |
| 93 | + roller_loop = True |
| 94 | + |
| 95 | +print "Thanks for using the Dice Rolling Simulator! Have a great day! =)" |
| 96 | + |
0 commit comments