Last active
August 29, 2015 14:04
-
-
Save andyweiss1982/dda75c9e8380e5ca04da to your computer and use it in GitHub Desktop.
Door Game
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Defining all the possible outcomes | |
numbererror = "I don't understand what you said. You need to type 1, 2 or 3." | |
lettererror = "I didn't catch that. You need to type K for keep or T for trade." | |
door1 = "MILLION DOLLARS" | |
door2 = "DOLLAR BILL" | |
door3 = "WHOLE LOT OF NOTHING" | |
prizepic1 = " | |
XXXXXXXXXXXXXXXXXXFEDERAL RESERVE NOTEXXXXXXXXXXXXXXXXXXX | |
XXX XX THE UNITED STATES OF AMERICA XXX XX | |
XXXX XX ------- ------------ XXXX XX | |
XXXX XX / jJ===-\\ \\ C7675 XXXX XX | |
XXXXXX OOO / jJ - - L \\ --- XXXXXX | |
XXXXX OOOOO | JJ | X | __ XXXXX | |
XXX 3 OOO | JJ --- X | OOOO 3 XXX | |
XXX | J|\\ /| | OOOOOO XXX | |
XXX C36799887 | / | | \\ | OOOO XXX | |
XXX | | | | -- XXX | |
XXX ------- \\ / \\ / XXX | |
X XX \\ ____________ / X XX | |
XX XXX 3_________ -------- ___ _______ 3 XXX XX | |
XX XXX ___ ONE MILLION DOLLARS i XXX XX | |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" | |
prizepic2 = " | |
XXXXXXXXXXXXXXXXXXFEDERAL RESERVE NOTEXXXXXXXXXXXXXXXXXXX | |
XXX XX THE UNITED STATES OF AMERICA XXX XX | |
XXXX XX ------- ------------ XXXX XX | |
XXXX XX / jJ===-\\ \\ C7675 XXXX XX | |
XXXXXX OOO / jJ - - L \\ --- XXXXXX | |
XXXXX OOOOO | JJ | X | __ XXXXX | |
XXX 3 OOO | JJ --- X | OOOO 3 XXX | |
XXX | J|\\ /| | OOOOOO XXX | |
XXX C36799887 | / | | \\ | OOOO XXX | |
XXX | | | | -- XXX | |
XXX ------- \\ / \\ / XXX | |
X XX \\ ____________ / X XX | |
XX XXX 3_________ -------- ___ _______ 3 XXX XX | |
XX XXX ___ ONE DOLLAR i XXX XX | |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" | |
prizepic3 = " | |
_ _ ___ _____ _ _ ___ _ _ ____ _ _ _ | |
| \\ | | / _ \\ |_ _| | | | | |_ _| | \\ | | / ___| | | | | | | | |
| \\| | | | | | | | | |_| | | | | \\| | | | _ | | | | | | | |
| |\\ | | |_| | | | | _ | | | | |\\ | | |_| | |_| |_| |_| | |
|_| \\_| \\___/ _|_|_ |_| |_| |___| |_| \\_| \\____| (_) (_) (_) | |
| \\ | | / _ \\ |_ _| | | | | |_ _| | \\ | | / ___| | | | | | | | |
| \\| | | | | | | | | |_| | | | | \\| | | | _ | | | | | | | |
| |\\ | | |_| | | | | _ | | | | |\\ | | |_| | |_| |_| |_| | |
|_| \\_| \\___/ _|_|_ |_| |_| |___| |_| \\_| \\____| (_) (_) (_) | |
| \\ | | / _ \\ |_ _| | | | | |_ _| | \\ | | / ___| | | | | | | | |
| \\| | | | | | | | | |_| | | | | \\| | | | _ | | | | | | | |
| |\\ | | |_| | | | | _ | | | | |\\ | | |_| | |_| |_| |_| | |
|_| \\_| \\___/ |_| |_| |_| |___| |_| \\_| \\____| (_) (_) (_)" | |
showdoors = " | |
__________ __________ __________ | |
| __ __ | | __ __ | | __ __ | | |
| | || | | | | || | | | | || | | | |
| | || | | | | || | | | | || | | | |
| |__||__| | | |__||__| | | |__||__| | | |
| __ __()| | __ __()| | __ __()| | |
| | || | | | | || | | | | || | | | |
| | || | | | | || | | | | || | | | |
| | || | | | | || | | | | || | | | |
| | || | | | | || | | | | || | | | |
| |__||__| | | |__||__| | | |__||__| | | |
|__________| |__________| |__________| | |
1 2 3 | |
" | |
#Game begins here | |
counter=0 | |
until counter == 50 | |
puts " " | |
counter += 1 | |
end | |
puts " | |
██████╗ █████╗ ███╗ ███╗███████╗████████╗██╗███╗ ███╗███████╗ | |
██╔════╝ ██╔══██╗████╗ ████║██╔════╝╚══██╔══╝██║████╗ ████║██╔════╝ | |
██║ ███╗███████║██╔████╔██║█████╗ ██║ ██║██╔████╔██║█████╗ | |
██║ ██║██╔══██║██║╚██╔╝██║██╔══╝ ██║ ██║██║╚██╔╝██║██╔══╝ | |
╚██████╔╝██║ ██║██║ ╚═╝ ██║███████╗ ██║ ██║██║ ╚═╝ ██║███████╗ | |
╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝" | |
puts "" | |
puts "In front of you there are three doors." | |
puts showdoors | |
puts "Behind each door there is some kind of prize." | |
puts "You will select a door, and the prize behind it is yours." | |
puts "" | |
puts "Sound good? Ready?" | |
puts "" | |
puts "OK then. Go ahead and select a door. You can type 1, 2 or 3." | |
puts "" | |
#Verifying user input = 1, 2 or 3 | |
inputok = false | |
until inputok | |
doorchoice = gets.chomp! | |
case doorchoice | |
when "1", "2", "3" | |
inputok = true | |
else | |
puts numbererror | |
end | |
end | |
#Outcomes of first choice | |
case doorchoice | |
when "1" | |
prize = door1 | |
when "2" | |
prize = door2 | |
when "3" | |
prize = door3 | |
end | |
counter=0 | |
until counter == 50 | |
puts " " | |
counter += 1 | |
end | |
#showing the first prize | |
puts "Congratulations! You won a #{prize}!" | |
if prize == door1 | |
puts prizepic1 | |
elsif prize == door2 | |
puts prizepic2 | |
else | |
puts prizepic3 | |
end | |
puts "" | |
#keep or trade 1 | |
puts "But now, you have a big decision to make." | |
puts "Would you like to keep your prize?" | |
puts "Or would you like to trade it for what's behind another door?" | |
puts "" | |
puts "You can type K for keep or T for trade." | |
#Verifying keep or trade | |
inputok = false | |
until inputok | |
keepchoice = gets.chomp.upcase! | |
case keepchoice | |
when "K", "T" | |
inputok = true | |
else | |
puts lettererror | |
end | |
end | |
counter=0 | |
until counter == 50 | |
puts " " | |
counter += 1 | |
end | |
#results of keepchoice 1 | |
case keepchoice | |
when "K" | |
puts "OK then. Have it your way." | |
puts "I guess you'll never know what's behind the other doors." | |
puts "" | |
puts "Now take your #{prize} and get out of here!" | |
puts "" | |
if prize == door1 | |
puts prizepic1 | |
elsif prize == door2 | |
puts prizepic2 | |
else | |
puts prizepic3 | |
end | |
exit | |
when "T" | |
puts "OK then. Which new door would you like to choose?" | |
puts showdoors | |
inputok = false | |
until inputok | |
secondchoice = gets.chomp! | |
if secondchoice == doorchoice | |
counter=0 | |
until counter == 50 | |
puts " " | |
counter += 1 | |
end | |
puts "That's the same door you already chose!" | |
puts "" | |
puts "Take your #{prize} and get out of here!" | |
puts "" | |
if prize == door1 | |
puts prizepic1 | |
elsif prize == door2 | |
puts prizepic2 | |
else | |
puts prizepic3 | |
end | |
puts "" | |
exit | |
elsif secondchoice == "1" | |
inputok = true | |
elsif secondchoice == "2" | |
inputok = true | |
elsif secondchoice == "3" | |
inputok = true | |
else puts numbererror | |
end | |
end | |
else puts lettererror | |
end | |
counter=0 | |
until counter == 50 | |
puts " " | |
counter += 1 | |
end | |
case secondchoice | |
when "1" | |
prize = door1 | |
when "2" | |
prize = door2 | |
when "3" | |
prize = door3 | |
end | |
puts "Congratulations! You won a #{prize}!" | |
puts "" | |
if prize == door1 | |
puts prizepic1 | |
elsif prize == door2 | |
puts prizepic2 | |
else puts prizepic3 | |
end | |
puts "" | |
puts "Hopefully you like this prize more than the last one." | |
puts "" | |
puts "Would you like to keep your prize?" | |
puts "" | |
puts "Or would you like to trade it for what's behind the final door?" | |
puts "" | |
puts "You can type K for keep or T for trade." | |
puts "" | |
#Verifying second keep or trade | |
inputok = false | |
until inputok | |
secondkeepchoice = gets.chomp.upcase! | |
case secondkeepchoice | |
when "K", "T" | |
inputok = true | |
else | |
puts lettererror | |
end | |
end | |
counter=0 | |
until counter == 50 | |
puts " " | |
counter += 1 | |
end | |
case secondkeepchoice | |
when "K" | |
puts "OK then. Have it your way." | |
puts "I guess you'll never know what's behind the final door." | |
puts "" | |
puts "Now take your #{prize} and get out of here!" | |
puts "" | |
if prize == door1 | |
puts prizepic1 | |
elsif prize == door2 | |
puts prizepic2 | |
else | |
puts prizepic3 | |
end | |
exit | |
when "T" | |
puts "OK then. Which new door would you like to choose?" | |
puts "" | |
puts showdoors | |
inputok = false | |
until inputok | |
finalchoice = gets.chomp! | |
if finalchoice == secondchoice or finalchoice == doorchoice | |
counter=0 | |
until counter == 50 | |
puts " " | |
counter += 1 | |
end | |
puts "You already chose that door!" | |
puts "" | |
puts "Take your #{prize} and get out of here!" | |
puts "" | |
if prize == door1 | |
puts prizepic1 | |
elsif prize == door2 | |
puts prizepic2 | |
else puts prizepic3 | |
end | |
exit | |
elsif secondchoice == "1" | |
inputok = true | |
elsif secondchoice == "2" | |
inputok = true | |
elsif secondchoice == "3" | |
inputok = true | |
else puts numbererror | |
end | |
end | |
else puts lettererror | |
end | |
counter=0 | |
until counter == 50 | |
puts " " | |
counter += 1 | |
end | |
case finalchoice | |
when "1" | |
prize = door1 | |
when "2" | |
prize = door2 | |
when "3" | |
prize = door3 | |
end | |
puts "Congratulations! You won a #{prize}!" | |
puts "" | |
if prize == door1 | |
puts prizepic1 | |
elsif prize == door2 | |
puts prizepic2 | |
else puts prizepic3 | |
end | |
puts "" | |
puts "I really hope you like your #{prize}," | |
puts "because there are no more doors to open." | |
puts "" | |
puts "Now take your #{prize} and get out of here!" | |
puts "" | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment