Created
January 19, 2013 22:32
-
-
Save sunlee-newyork/4575622 to your computer and use it in GitHub Desktop.
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
class Cyoza | |
def initialize | |
start_game | |
end | |
def start_game | |
sleep 0.5 | |
"Welcome to Choose Your Own Zombie Adventure!\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
sleep 0.5 | |
"The game will start in... ".each_char {|x| print x.chomp ; sleep 0.05; $stdout.flush } | |
sleep 0.5 | |
3.downto(1).each { |x| print x ; sleep 1 } | |
sleep 0.5 | |
"\nBefore we begin, what is your name?\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
@player_name = gets.capitalize.chomp | |
sleep 0.5 | |
"Hello, #{@player_name}.\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
sleep 0.5 | |
"You are the only human survivor.\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
sleep 0.5 | |
"GET READY TO UNLEASH YOUR FURY.\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
sleep 0.5 | |
"First of all, do you have your zombie kit? \n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
sleep 0.5 | |
"Press [y/n]\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
inv_prep | |
end | |
def ask_to_startover | |
sleep 0.5 | |
"Do you want to start over?\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
sleep 0.5 | |
"Press [y/n]\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
while player_input = gets.downcase.chomp | |
if player_input == "y" | |
restart_game | |
elsif player_input == "n" | |
abort("GAME OVER.") | |
else | |
"Sorry, please answer with 'y' or 'n'.".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
end | |
end | |
end | |
def restart_game | |
"Restarting...".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
sleep 0.5 | |
puts "NOW." | |
sleep 1 | |
start_game | |
end | |
def look_for_item0 | |
sleep 0.5 | |
"That's no good, #{@player_name}!\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
sleep 0.5 | |
"Let's head over to the local department store and get ourselves a nice shotgun.\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
sleep 0.5 | |
"Ah, we have two options: Walmart or deli.\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
sleep 0.5 | |
"Which do you enter?\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
STDOUT.flush | |
while w_search = gets.downcase.chomp | |
if w_search == "walmart" | |
player_gets_attacked | |
elsif w_search == "deli" | |
sleep 0.5 | |
"You make a run for the deli.\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
sleep 0.5 | |
"You pass the front door...\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
sleep 0.5 | |
"...and the owner starts making out with your BRAIIIN.\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
ask_to_startover | |
else | |
sleep 0.5 | |
"Walmart or the deli are the two only uncharred buildlings around.\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
sleep 0.5 | |
"Which one will it be?\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
end | |
end | |
end | |
def inv_prep | |
while player_input = gets.chomp | |
if player_input == "y" | |
ask_item0 | |
elsif player_input == "n" | |
look_for_item0 | |
else | |
sleep 0.5 | |
"Sorry, please answer with 'y' or 'n'.\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
end | |
end | |
end | |
def stage_two | |
sleep 0.5 | |
"This marks the end of Chapter 1 in Choose Your Own Zombie Adventure.\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
sleep 0.5 | |
"Congratulations! You have made it this far.\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
sleep 0.5 | |
"Let's see how you'll do in the next chapter, coming soon!\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
ask_to_startover | |
end | |
def display_inv | |
sleep 0.5 | |
"Alright! You now have your battle weapons ready!\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
sleep 0.5 | |
"Here is what you'll be using to kick zombie ass:\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
sleep 0.5 | |
@inv.push @sec_items | |
@inv.each do |x| | |
puts x | |
end | |
sleep 0.5 | |
stage_two | |
end | |
def item1_notfound | |
sleep 0.5 | |
"Sorry, please choose one of the following:\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
@sec_items.each do |x| | |
puts x | |
end | |
end | |
def ask_item2_fromgrenade | |
@sec_items.delete_at(0) | |
sleep 0.5 | |
"Awesome, the perfect zombie apocolypse defense!\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
sleep 0.5 | |
"Let's see what you've got in your left pocket.\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
sleep 0.5 | |
"Which one of these did you pull out?\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
sleep 0.5 | |
@sec_items.each do |x| | |
puts x | |
end | |
STDOUT.flush | |
while @item2 = gets.downcase.chomp | |
if @item2 == "medkit" | |
sleep 0.52 | |
"You'll want to keep that head on your shoulder, it seems to be in working condition.\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
display_inv | |
elsif @item2 == "banana" | |
sleep 0.5 | |
"Why do you have a banana in your pocket? Maybe it'll come into use... MAYBE.\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
display_inv | |
else | |
item1_notfound | |
end | |
end | |
end | |
def ask_item2_frommedkit | |
@sec_items.delete_at(1) | |
sleep 0.5 | |
"You'll want to keep that head on your shoulder, it seems to be in working condition.\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
sleep 0.5 | |
"Let's see what you've got in your left pocket.\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
sleep 0.5 | |
"Which one of these did you pull out?\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
sleep 0.5 | |
@sec_items.each do |x| | |
puts x | |
end | |
STDOUT.flush | |
while @item2 = gets.downcase.chomp | |
if @item2 == "grenade" | |
sleep 0.5 | |
"Awesome, the perfect zombie apocolypse defense!\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
display_inv | |
elsif @item2 == "banana" | |
sleep 0.5 | |
"Why do you have a banana in your pocket? Maybe it'll come into use... MAYBE.\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
display_inv | |
else | |
item1_notfound | |
end | |
end | |
end | |
def ask_item2_frombanana | |
@sec_items.delete_at(2) | |
sleep 0.5 | |
"Why do you have a banana in your pocket? Maybe it'll come into use... MAYBE.\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
sleep 0.5 | |
"Let's see what you've got in your left pocket.\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
sleep 0.5 | |
"Which one of these did you pull out?\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
sleep 0.5 | |
@sec_items.each do |x| | |
puts x | |
end | |
STDOUT.flush | |
while @item2 = gets.downcase.chomp | |
if @item2 == "grenade" | |
sleep 0.5 | |
"Awesome, the perfect zombie apocolypse defense!\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
display_inv | |
elsif @item2 == "medkit" | |
sleep 0.5 | |
"You'll want to keep that head on your shoulder, it seems to be in working condition.\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
display_inv | |
else | |
item1_notfound | |
end | |
end | |
end | |
def ask_item1 | |
@sec_items = %w[grenade medkit banana] | |
sleep 0.5 | |
"Of the following, which one is in your right pocket?\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
sleep 0.5 | |
@sec_items.each do |x| | |
puts x | |
end | |
STDOUT.flush | |
while @item1 = gets.downcase.chomp | |
if @item1 == "grenade" | |
ask_item2_fromgrenade | |
elsif @item1 == "medkit" | |
ask_item2_frommedkit | |
elsif @item1 == "banana" | |
ask_item2_frombanana | |
else item1_notfound | |
end | |
end | |
end | |
def ask_item0 | |
@inv = [] | |
sleep 0.5 | |
"Great! We need to create an inventory before we kick some zombie ass.\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
sleep 0.5 | |
"Type the weapon currently strapped to your back.\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
STDOUT.flush | |
@item0 = gets.downcase.chomp | |
@inv.push @item0 | |
sleep 0.5 | |
"You have saved the #{@item0} in your inventory!\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
ask_item1 | |
end | |
def player_gets_attacked | |
sleep 0.5 | |
"Well whaddaya know, Walmart FTW.\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
sleep 0.5 | |
"As you reach for the closest rifle...\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
sleep 0.5 | |
"...zombies start flooding through the back door!!!\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
sleep 0.5 | |
"You run away with the rifle and run into the wall.\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
sleep 0.5 | |
"Do you make a left or right?\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
STDOUT.flush | |
while turn = gets.downcase.chomp | |
if turn == "left" | |
sleep 0.5 | |
"Too bad you chose to make a left...\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
sleep 0.5 | |
"...because that grandma zombie is now feasting on your neck!\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
ask_to_startover | |
elsif turn == "right" | |
sleep 0.5 | |
"You swerve around...\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
sleep 0.5 | |
"...and run straight into a loving zombie embrace.\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
ask_to_startover | |
else | |
sleep 0.5 | |
"Zombies are right behind you! Is it a left or right?\n".each_char {|x| print x ; sleep 0.05; $stdout.flush } | |
end | |
end | |
end | |
end | |
Cyoza.new |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment