Skip to content

Instantly share code, notes, and snippets.

@stephenhandley
Created March 29, 2012 10:24
Show Gist options
  • Save stephenhandley/2235677 to your computer and use it in GitHub Desktop.
Save stephenhandley/2235677 to your computer and use it in GitHub Desktop.
me llamo Beto McLoserville
class CYOAGame
INVALID_CHOICE = "INVALID_CHOICE_aw_fuuuuuck_naw"
ENTER_PROMPT = " ... "
def initialize(events)
@events = events
@input = nil
self.run(:setup_merch)
end
def run(event_name)
event = @events[event_name]
unless event
puts ":#{event_name} is not a valid game event. Exiting."
exit(0)
end
outcome = self.instance_eval(&event)
if outcome.is_a?(Symbol)
self.run(outcome)
else
self.say(outcome)
exit(0)
end
end
def show_choices(choices)
invalid_choice_response = choices.delete(INVALID_CHOICE)
choices.keys.each_with_index do |choice, index|
self.say("#{index + 1}. #{choice}")
end
choice_number = self.get_input.to_i - 1
if (choice_number < 0 || choice_number >= choices.length)
self.say(invalid_choice_response)
exit(0)
else
choices.values[choice_number]
end
end
def say(things_to_say, should_get_input = false)
unless things_to_say.respond_to?(:each)
things_to_say = [things_to_say]
end
things_to_say.each do |thing_to_say|
if should_get_input
puts(thing_to_say + ENTER_PROMPT)
self.get_input
else
puts(thing_to_say)
end
end
end
def say_and_get_input(things_to_say)
self.say(things_to_say, true)
end
def get_input
@input = STDIN.gets.chomp
end
def prompt_for_input(p = ">")
print("#{p} ")
self.get_input
end
end
CYOAGame.new({
:intro => Proc.new {
self.say("Welcome to the Vivian Girls Text Based Adventure Fun Time Game!")
self.say_and_get_input([
"When you see ... hit enter to continue! Let's try it",
"Good job!",
"Vivian Girls need a new tour manager and are hiring!"
])
self.say("This tour is only 3 days long, and it starts TONIGHT!")
self.show_choices({
"Apply for the position." => :picks_and_cables,
"Run away screaming. That seems way too daunting and impulsive." => "You probably made the wisest choice. Enjoy your life!",
INVALID_CHOICE => "That makes no sense to me at all. Get out of here."
})
},
:picks_and_cables => Proc.new {
self.say_and_get_input("You are a risk taker. I like that about you")
self.say("What's your name, anyways?")
@player_name = self.prompt_for_input("Name:")
self.say_and_get_input([
"Hey #{@player_name}, thanks for joining us",
"I know the tour is starting in an hour and this is pretty last minute",
"but do you think you could run to Main Drag (our local music store)"
])
self.say("and pick up some extra picks and cables for us?")
self.show_choices({
"Of course! No problem! Right away!" => :setup_merch,
"Shut the fuck up. I have my own shit to take care of before we leave!" => "Get the fuck out of here. We hate you.",
"Uh, I guess so?" => "Yeeeah...I guess so...I guuuuesssss we have to fire you.",
INVALID_CHOICE => "That makes no sense to me. I hate you. Leave now."
})
},
:setup_merch => Proc.new {
self.say_and_get_input([
"Way to go! I think things will work out between us",
"The first show is tonight at Maxwell's in Hoboken, NJ",
"Because you take so long running our errands for us",
"we don't leave Brooklyn until 7 pm!",
"We miss soundcheck and we are pissed at you, but the club is very understanding",
"You are lucky"
])
self.say([
"Now, you need to go set up the merch. How much should we charge for t-shirts?",
"(enter a numerical value between 5 and 15)"
])
@tshirt_price = self.prompt_for_input("Price:").to_i
if (@tshirt_price >= 5 and @tshirt_price <= 15)
:tshirt_math
elsif tshirtprice > 15
"No one would buy a shirt for that much. Get out of here, idiot."
elsif tshirtprice < 5
"Why do you want to give our shit away for free? Get out of here, idiot."
else
"WTF does that mean? Get out of here idiot."
end
},
:tshirt_math => Proc.new {
num_tshirts_sold = 15
self.say_and_get_input([
"We have a GREAT SHOW tonight and sell #{num_tshirts_sold} t-shirts!!",
"Awesome job, merch person!"
])
self.say("How much money did we make selling t-shirts?")
@tshirt_money = self.prompt_for_input("$").to_i
if (@tshirt_money == @tshirt_price * num_tshirts_sold)
:flat_tire
else
"If you can't add, you are fired."
end
},
:flat_tire => Proc.new {
self.say_and_get_input([
"Excellent math skills! Those are totally necessary for this job",
"Now, on with the tour",
"We are driving to DC, when all of a sudden we get a flat tire!",
])
self.say("What do we do!")
self.show_choices({
"Start crying and screaming 'I DONT KNOW WHAT TO DOOOOOO!!!'" => "Really? This is the decision you thought was correct? FIRED!",
"Call AAA" => :album_price,
"Call your mommy and start crying to her in secret" => "Even your mommy knows you are weak. FIRED!",
INVALID_CHOICE => "WTF that wasn't even an option. FIRED!"
})
},
:album_price => Proc.new {
self.say_and_get_input([
"Good job, fearless leader",
"We were slightly delayed, but now we are back on track",
"However, we miss soundcheck again",
"Lets not have this be a regular thing, OK #{@player_name}?",
"Wait. What is this that I heard?",
"Is it true you were just giving our albums away for free last night?",
"Are you fucking serious?"
])
self.say([
"Yeah thats not ok. How much should we charge?",
"(enter a numerical value between 5 and 15)"
])
@album_price = self.prompt_for_input("$").to_i
if (@album_price >= 5 and @album_price <= 15)
:dischord
elsif (@album_price > 15)
"Why do you want to rip off our loyal, loving fans? FIRED!"
elsif (@album_price < 5)
"Why do you want to bleed us dry? FIRED!"
else
"WTF does that mean? FIRED!"
end
},
:dischord => Proc.new {
@hoboken_merch_money = 500
self.say_and_get_input([
"Ok that seems fair",
"Oh yeah, forgot to mention this to you, #{@player_name}",
"Where did you run off to at the end of the show last night?",
"I had to go settle without you",
"We got paid $#{@hoboken_merch_money}, I put it in with our merch money.",
"Tonight's show in DC at Comet Ping Pong was awesome!",
"Ian MacKaye told us we could crash at Dischord house again if we want to",
"Tomorrow our show is in Baltimore"
])
self.say("Should we stay at Dischord house or should we start driving and stay at a motel?")
self.show_choices({
"Stay at Dischord house and ask Ian about Minor Threat all night." => :dc_merch_math,
"Leave DC and start the long, treacherous drive to Baltimore." => :nerdo,
INVALID_CHOICE => "That wasn't even an option. FIRED!"
})
},
:dc_merch_math => Proc.new {
num_albums_sold = 20
num_tshirts_sold = 10
self.say_and_get_input([
"You have a good head on your shoulders",
"After bugging Ian for a few hours, we head off",
"Last night we sold #{num_albums_sold} albums and #{num_tshirts_sold} t-shirts",
])
self.say("How much did we make in merch just in DC?")
@dc_merch_money = self.prompt_for_input("$").to_i
if (@dc_merch_money == (@album_price * num_albums_sold) + (@tshirt_price * num_tshirts_sold))
:solo_set_a
else
"Great! You can't do math! Fired."
end
},
:solo_set_a => Proc.new {
self.say("Are you down? Will you open for us tonight?")
self.show_choices({
"Um, I don't think so. I've never played a show before..." => "You are a poor sport and you want us to look bad. FIRED!",
"Uhhh ok. This is crazy!" => :going_solo,
"THIS IS NOT WHAT I SIGNED UP FOR." => "You are a poor sport and you want us to look bad. FIRED!",
INVALID_CHOICE => "FIREDFIREDFIREDFIREDFIRED"
})
},
:going_solo => Proc.new {
self.say_and_get_input([
"YOU ARE THE BEST!! WE LOVE YOU!",
"We knew you were the one for us right when we met",
"The show goes GREAT. You are a star",
"So much so, that as soon as we get back to Brooklyn",
"You tell us to 'fuck off' and get someone else",
"Because you are 'going solo'",
"But then you assure us that we will always be friends",
"We will always love you, #{@player_name}",
"But we have ONE MORE QUESTION before we let you go"
])
self.say("How much money have you collected on this tour for us?")
@total_money = self.prompt_for_input("$").to_i
if (@total_money == @dc_merch_money + @tshirt_money + @hoboken_merch_money)
:honest_soul_win
else
"You are either a liar, or you are bad at math. FIRED!"
end
},
:honest_soul_win => Proc.new {
self.say_and_get_input([
"You are a honest soul, #{@player_name}",
"You will not be forgotten."
])
self.say("YOU HAVE WON THE GAME! THE END!")
exit(0)
},
:nerdo => Proc.new {
self.say_and_get_input([
"Holy shit you are a nerd",
"We won't fire you over that",
"But we REALLY want to",
"It's only an HOUR drive to DC!",
"So now we will only refer to you as 'Nerdo McLoserville'"
])
self.say("Are you ok with that?")
self.show_choices({
"I guess so." => :solo_set_b,
"Uh, that's not my name. Don't call me that. It's not nice." => "We really wanted to call you Nerdo McLoserville.\nI guess we will just have to find someone else.",
INVALID_CHOICE => "FUCK YOOOOU. FIRED!"
})
},
:solo_set_b => Proc.new {
self.say_and_get_input([
"Ok awesome, Nerdo McLoserville",
"You are no longer in charge of holding onto the band money",
"Because now we know you have the worst judgement ever",
"Your only job is getting made fun of by us now",
"Ok so tonight is the last show...and it's in Baltimore",
"It's already sold out, but both of the opening bands are sick!",
"During soundcheck, we decide that you should play a solo set",
"Even though we kind of HATE you for not letting us stay at Dischord house",
"But if you don't open for us, NO ONE will",
"And that would be weird and awkward"
])
self.say("Are you down? Will you open for us tonight?")
self.show_choices({
"Um, I don't think so. I've never played a show before..." => "You are a poor sport and you want us to look bad. FIRED!",
"Uhhh ok. This is crazy!" => :nerdo_win,
"THIS IS NOT WHAT I SIGNED UP FOR." => "You are a poor sport and you want us to look bad. FIRED!",
INVALID_CHOICE => "FIREDFIREDFIREDFIREDFIRED"
})
},
:nerdo_win => Proc.new {
self.say_and_get_input([
"YOU ARE THE BEST!! WE LOVE YOU!",
"We knew you were the one for us right when we met",
"Even after all that DC drama",
"You saved us. The show goes GREAT. You are a star",
"So much so, that as soon as we get back to Brooklyn",
"You tell us to 'fuck off' and get someone else",
"Because you are 'going solo'",
"But then you assure us that we will always be friends",
"We will always hate you, Nerdo McLoserville"
])
self.say("But you have WON THE GAME! THE END!")
exit(0)
}
})
@stephenhandley
Copy link
Author

i forgotten i had done this couple months ago...

from http://iamkatygoodman.webs.com/adventure.htm

probably one of the last things i'll write in ruby for awhile honk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment