Skip to content

Instantly share code, notes, and snippets.

@dimanyc dimanyc/Game
Created Mar 12, 2015

Embed
What would you like to do?
Game
def cls
system ('cls') #for cmd
system ('clear') #for mac / linux
end
class String
def green; "\033[32m#{self}\033[0m" end #< colorizing all instances of the main class String and method green. Solution taken from here: http://stackoverflow.com/questions/1489183/colorized-ruby-output
def red; "\033[31m#{self}\033[0m" end
def brown; "\033[33m#{self}\033[0m" end
def bg_blue; "\033[44m#{self}\033[0m" end
def bold; "\033[1m#{self}\033[22m" end
def magenta; "\033[35m#{self}\033[0m" end
end
class Prompt
def q1(a)
case when a.start_with?("ye") || a.start_with?("1")
cls
puts "Fine...".green
sleep(1.5)
cls
sleep(1.5)
puts "format c:".bg_blue
sleep(1.5)
puts "and yea, Game Over!..."
end
case when a.start_with?("no") || a.start_with?("2")
cls
puts "Ummmmmm, nope. Still going to format".red
sleep(1.5)
cls
sleep(1.5)
puts "format c:".bg_blue
sleep(1.5)
puts "and yea, Game Over!..."
end
case when a.start_with?("Ttry") || a.start_with?("3")
cls
puts "Ahh! Fiesty! Fine. Let's play a game ".green
sleep(2)
puts
sleep(1.5)
puts "I'm going to ask you 3 questions. If you answer them correctly, I may reconsider".green
sleep(3)
cls
end
end
def q2(a)
if a.to_s.start_with?("808")
puts "Your Kung-Fu is strong!".green
sleep(1.5)
puts "Moving on...".green
else
puts "ummmmmm, nope. Format C!".red
sleep(1.5)
cls
sleep(1.5)
puts "format c:".bg_blue
sleep(1.5)
puts "and yea, Game Over!..."
end
end
def q3(a)
if a.to_s.start_with?("den")
puts "Dennis Ritchie <=> Dennis Rodman (just in case you meant Rodman)".green
sleep(3)
puts "Moving on...".green
else
puts "[drumroll]nnnnnnnope. Format-format-format![/drumroll]".red
sleep(1.5)
cls
sleep(1.5)
puts "format c:".bg_blue
sleep(1.5)
puts "and yea, Game Over!..."
end
end
def q4(a)
if a.to_s.start_with?("noth")
puts "You win!".green
sleep(1.5)
cls
puts"═─═─═─═─═─═───═─═─═─═─═─═─═───═─═─═─═─═─".magenta
puts"─═───═─═───═─═───═─────═─═───═─═─═─═────".magenta
puts"═─═─═─═─═─═───═─═─═══─═───═─═─═─═───═─═─".magenta
puts"─═───═─═─═───══▒██▓█████─═─═─═─═─═─═─═──".magenta
puts"──═─═─═───═─═▓███▒▓═█▒█████─═─═───═───═─".magenta
puts"─═─═───═─═─▓██─▒▒═─═─═─═─▓██───═─═─═─═─═".magenta
puts"═─═─═─═─═─███▒═─═─▒─▒─▒───▒███═───═───═─".magenta
puts"─═─═─═─═─█▓═████─▒─▒─▒═▒─██████▒─═─═─═─═".magenta
puts"═─═────▓██═█████▓─═─▒═▒─═██▓█─██═─────═─".magenta
puts"─═─═─═─██▒▒█─▓─═█═─▒═▒─══█─═─═▒██═─═─═─═".magenta
puts"═─═─═─██──█───▒─█▓═─▒══─██████▓▓█▓═───═─".magenta
puts"─═─═─██═─═▓▓██████─▒─██═▓█▓▒═▓██─█───═─═".magenta
puts"═─═──██─═─██▒─═─█▓═─═─█▒═█═───██═██─═─═─".magenta
puts"─═─═██─═─═██───═█═─═──█▒─█▓▓─█▓═─═█▒───═".magenta
puts"═─═██══─═─═██▓██▓─═─═─▓─═─████▒─▒─███─═─".magenta
puts"─═─█▓──▒─═──██▓──██▓══▒█─═─═─═─▒═▒─██═──".magenta
puts"───██══─▒─═─═─═─▓▓▓████▓──▒─═─▒══──▓█─═─".magenta
puts"─═─═██─▒─▒─▒═▒─═▒█▒══▓██═▒─▒═▒══─═██▓═─═".magenta
puts"═─═─═█──══▒═▒═▒─═▒███▓▓█▒─▒─▒─═─═▓█─═─═─".magenta
puts"─═─═─███─═─▒═▒═▒─═───══█─▒═▒─▒─═▒██──═─═".magenta
puts"═─═─▒████─▒══─▒─═─▒─═══─▒═▒─▒─═─███▓═───".magenta
puts"───═█████▓─═─▒═▒═▒═══▒═▒─══▒─═─██▓██─═──".magenta
puts"═─═─███═▓██─═─═─▒─▒═▒─══▒═▒─═─██─▓██──═─".magenta
puts"─═─═███▒▓▓██─═─═─▒═▒═▒─═══─═▒█▓▓▓███─═─═".magenta
puts"──═─▓████──██▒═─▒─▒─▒═▒───═██▒═─███▒═─═─".magenta
puts"───═─═▓█▒═─═▒██▓─═─═───═─███─═─═██─═─═─═".magenta
puts"═───═─══██═─═─▓███████████▓─═─▓██─────═─".magenta
puts"───═───═─██═─═─═─███▓███───═─██▓─═─═─═──".magenta
puts"═─═─═─═─═─██▓─═─═██─═─██═──███──═─═─═─═─".magenta
puts"───═─═─═─═─▒██─═▓██═─═██═▓██─═───═─────═".magenta
puts"═─═─═─═─═─═─═██▓███─═─████▒─═─═─═─═─═─═─".magenta
puts"─═─═─═─═─═─═─═▓██████▓████─═─═───═─═────".magenta
puts"═─═─═─═─═─═───█═█─█████─██▒─═───═─═───═─".magenta
puts"─═───═─═─═─═─═█═██████████▓──═─═─═─────═".magenta
puts"──═─═───═─═─═─█████▓███████─═─═─═─═─═─═─".magenta
puts"─═─═─═─═─═───▒█████████████═───═─═─═───═".magenta
puts"═─═─═─═─═─═─═▓█████████████───═───═─═─═─".magenta
puts"─═─═─═─═─═─═─██████████████═─═─═───═───═".magenta
puts"═─═───═─═─═─═██████████████─═─═─═─═───═─".magenta
puts"─═─═─═─═─═─═─██████████████▓───═─═─═───═".magenta
puts"═───═─═─═─═─▒███████████████═─═─═─═─═─═─".magenta
puts"───═─═─═─═─═▒███████▓███▓█▓█───═─═─═─═──".magenta
puts"──═─────═───████████████████═─═─────═─═─".magenta
puts"─═───═─═─═─═████████████████─═─═─═─═─═──".magenta
puts"═───────═─═─████████████████═─═─────═─═─".magenta
puts"─═─═─═─────═████████████████─═─═─═─═─═─═".magenta
puts"═─═─═───═─═─████████████████▓─═─═─═─═─═─".magenta
puts"─═─═───═───██▓██████═█▓███▓▒█▒───═─═─═─═".magenta
puts"═─═─═─═─═─═█═─══▒─▓▓▓█═══─═─▓█──═─═───═─".magenta
puts"─═─═─═─═─═─█▒═─═▒▓██─██▒─═─▓█▓─═─═─═───═".magenta
puts"──═───═─═─═▒██████▓───██████▓─═─═─═─═───".magenta
puts"─═─═─═───═─═───═─═─═─═─═─═───═─═─═───═─═".magenta
puts"────═───═─═─═─═───═─═─═───═─═───═─═─═─═─".magenta
puts"───═─═─═─═───═─═─═─═─═─═─═─═───═─═─═─═──".magenta
puts"═─═─═───═─═─═─═───═─────═─═─═─═─═───═─═─".magenta
else
puts "You were close....".red
sleep(1.5)
cls
sleep(1.5)
puts "format c:".bg_blue
sleep(1.5)
puts "and yea, Game Over!..."
end
end
end
class Player
attr_accessor :name
end
cls
player = Player.new
puts "Enter Your Name"
player.name = gets.chomp.to_s.capitalize
puts
cls
sleep(1.5)
puts "Wake up, #{player.name}".green
sleep(1.5)
prompt = Prompt.new
###first prompt
puts ""
puts "I am about to format your hard drive. Would you like me to proceed?".green
puts ""
puts ""
sleep(1.5)
puts "Available answers:"
puts "1) Yes. 2) No. 3) Try me, n00b"
answer = gets.chomp.to_s.downcase
prompt.q1(answer)
###second prompt
cls
puts ""
puts "What do you get if you add 2 to 200 four times?".green
puts ""
puts "you have 30 seconds to answer".red
puts ""
puts "HINT: 2 x n07 f0Un|}".brown
puts ""
sleep(1.5)
answer2 = gets.chomp.to_s
prompt.q2(answer2)
###third prompt
cls
puts ""
puts "This game is written in Ruby. Ruby is written in C, and C is written by?".green
puts ""
puts "you have 30 seconds to answer".red
puts ""
puts "HINT: I'm using start_with so you can just give me the first name".brown
puts ""
sleep(1.5)
answer3 = gets.chomp.to_s.downcase
prompt.q3(answer3)
###fourth prompt
cls
puts ""
puts "What is greater than God,".green
sleep(1)
puts ""
puts "more evil than the devil,".green
sleep(1)
puts ""
puts "the poor have it,".green
sleep(1)
puts ""
puts "the rich need it,".green
puts ""
sleep(1)
puts "and if you eat it, you'll die?".green
puts ""
sleep(1)
puts "NO HINT THIS TIME!".red
puts ""
sleep(1.5)
answer4 = gets.chomp.to_s.downcase
prompt.q4(answer4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.