Skip to content

Instantly share code, notes, and snippets.

@sunlee-newyork
Last active December 10, 2015 12:08
Show Gist options
  • Save sunlee-newyork/4432215 to your computer and use it in GitHub Desktop.
Save sunlee-newyork/4432215 to your computer and use it in GitHub Desktop.
class Cyoza
def initialize
start_game
end
def start_game
puts "Welcome to Choose Your Own Zombie Adventure!"
sleep 1.5
puts "The game will start in..."
sleep 1.5
3.downto(1).each { |x| puts x ; sleep 1 }
puts "Alright, Before we begin, what is your name?"
STDOUT.flush
@player_name = gets.capitalize.chomp
puts "Hello, #{@player_name}. You are the only human survivor. GET READY TO UNLEASH YOUR FURY."
sleep 1.5
puts "First of all, do you have your zombie kit? \nPress [y/n]"
STDOUT.flush
inv_prep
end
def restart_game
puts "GAME OVER. Restarting in..."
sleep 1.5
3.downto(1).each { |x| puts x ; sleep 1 }
start_game
end
def inv_prep
@inv = []
player_input = gets.chomp
case player_input
when "y" then ask_item0
when "n" then look_for_item0
else puts "Sorry, please answer with 'y' or 'n'."
end
end
def ask_item0
puts "Great! We need to create an inventory before we kick some zombie ass."
puts "Type the weapon currently strapped to your back."
STDOUT.flush
@item0 = gets.downcase.chomp
@inv.push @item0
puts "You have saved the #{@item0} in your inventory!"
sleep 1.5
ask_item1
end
def look_for_item0
puts "That's no good, #{@player_name}! Let's head over to the local department store and get ourselves a nice shotgun. "
sleep 1.5
puts "Ah, we have two options: Walmart or deli. Which would you like?"
STDOUT.flush
w_search = gets.downcase.chomp
case w_search
when "walmart" then puts "You scan the fruit section and on top of the orange pile there is a shotgun!"
when "deli" then you_died
end
end
def you_died
puts "You walked into the local deli and suddenly a zombie is making out with your brain. THE END."
restart_game
end
def ready_for_battle
puts "Alright! You now have your battle weapons ready."
sleep 1.5
puts "See you next time for the second chapter of CYOZA!"
sleep 1.5
end
def ask_item1
@sec_items = %w[grenade medkit banana]
puts "Of the following, which one is in your right pocket? Grenade, medkit, banana."
STDOUT.flush
item1 = gets.chomp
case item1
when "grenade" then ready_for_battle
when "medkit" then ready_for_battle
when "banana" then ready_for_battle
else item1_notfound
end
end
def item1_notfound
puts "Sorry, please choose one of the following:"
puts @sec_items.inspect
@sec_items.each do |x|
puts x
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment