Skip to content

Instantly share code, notes, and snippets.

@sinclairtarget
Created December 5, 2015 20:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sinclairtarget/854d495282519d22e777 to your computer and use it in GitHub Desktop.
Save sinclairtarget/854d495282519d22e777 to your computer and use it in GitHub Desktop.
Hobbit Game Code Now
has_sword = false
has_ring = false
has_luck = false
puts "You have entered the dragon's lair!!!!"
puts "Do you have a sword? [yes/no]:"
answer = gets.chomp
if answer == "yes"
has_sword = true
end
puts "Do you have a ring? [yes/no]:"
answer = gets.chomp
if answer == "yes"
has_ring = true
end
puts "Do you have luck? [yes/no]:"
answer = gets.chomp
if answer == "yes"
has_luck = true
end
puts "The dragon turns his head toward you!"
if has_sword and (has_ring or has_luck)
if has_ring and has_luck
puts "He breathes fire at you but misses! You put on the ring and disappear. You then sneak up behind him and CUT OFF HIS HEAD!"
elsif has_ring
puts "You turn invisible with the ring and he doesn't see you. You sneak up behind him and CUT OFF HIS HEAD!"
else
puts "He breathes fire at you but misses! You lunge in and CUT OFF HIS HEAD!"
end
elsif has_sword
puts "You raise your sword and charge. But you have no ring and no luck, so you get roasted before you reach the dragon."
else
puts "Why did you come in here without a sword? The dragon roasts you."
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment