Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Dragon
- attr_accessor :color
- def initialize(input_name, color)
- @name = input_name
- @asleep = false
- @stuff_in_belly = 10
- @stuff_in_intestines = 0
- @color = color
- if @color == "blue" || @color == "green"
- @stuff_in_belly = 5
- @stuff_in_intestines = 5
- end
- end
- def paint(color)
- @color = color.to_s
- end
- def special_power
- case @color
- when "blue"
- puts "#{@name} breathes ICE and freezes you. See you after you defrost."
- when "red"
- puts "#{@name} runs at superspeed, leaving fire in their wake and is lost forever."
- exit
- when "green"
- puts "#{@name} suddenly speaks in fluent French and you both share a baguette."
- when "purple"
- puts "#{@name} jumps so high, that they make a hole in the ceiling."
- else
- puts "#{@name}'s special power is being a really nice dragon companion."
- end
- end
- def power_word
- case @color
- when "red"
- power_words = ["fire", "smoke", "charred marshmallows", "lava"]
- when "blue"
- power_words = ["ice", "snowflakes", "existential angst", "frozen hot chocolate"]
- when "green"
- power_words = ["berets", "tiny Eiffel Tower key-chains", "eclairs", "croissants"]
- when "purple"
- power_words = ["pogo sticks", "trampolines", "Moon Shoes: the hottest toy of 2002", "Air Jordans"]
- else
- power_words = ["bubbles", "cats", "sprinkles", "daisies"]
- end
- return power_words
- end
- def feed
- puts "#{@name} ate food."
- @stuff_in_belly = 10
- passage_of_time
- end
- def toss
- puts "You tossed #{@name} into the air"
- puts "They giggle, and it singes your eyebrows"
- passage_of_time
- dragon_art_toss
- end
- def walk
- puts "You take #{@name} out for a walk"
- @stuff_in_intestines = 0
- passage_of_time
- end
- def put_to_bed
- puts "You put #{@name} to bed"
- @asleep = true
- 3.times do
- random = rand(4)
- if @asleep
- passage_of_time
- end
- if @asleep
- puts "#{@name} snores. They fill the room with #{power_word[random]}."
- end
- end
- if @asleep
- @asleep = false
- puts "#{@name} wakes up slowly."
- dragon_art_awake
- end
- end
- def rock
- puts "You rock #{@name} gently to sleep."
- @asleep = true
- passage_of_time
- if @asleep
- @asleep = false
- puts "But they wake up after you stop."
- end
- end
- end
- private
- def dragon_art_toss
- puts "|\___/|"
- puts "(,\ /,)\ "
- puts " / / \ "
- puts "(@_^_@)/ \ "
- puts "W//W_/ \ "
- puts "(//) | \ "
- puts "(/ /) _|_ / ) \ "
- puts "(// /) '/,_ _ _/ (~^-."
- puts "(( // )) ,-{ _ `."
- puts "(( /// )) '/\ / |"
- puts "(( ///)) `. { }"
- puts "((/ )) .----~-.\ \-"
- puts "///.----..> \ "
- puts " ///-._ _ _ _} "
- end
- def dragon_art_awake
- puts '( ) /\ _ ( '
- puts ' \ | ( \ ( \.( ) _____'
- puts ' \ \ \ ` ` ) \ ( ___ / _ \ '
- puts '(_` \+ . x ( .\ \/ \____-----------/ (o) \_'
- puts '- .- \+ ; ( O \____'
- puts' ) \_____________ ` \ /'
- puts "'(__ +- .( -'.- <. - _ VVVVVVV VV V /"
- puts "(_____ ._._: <_ - <- _ (-- _AAAAAAA__A_/ |"
- puts '. /./.+- . .- / +-- - . \______________//_ \_______'
- puts "(__ ' /x / x _/ ( \___' \ /"
- puts ", x / ( ' . / . / | \ /"
- puts " / / _/ / + / \/"
- puts " ' (__/ / \ "
- end
- def hungry?
- return @stuff_in_belly <=2
- end
- def poopy?
- return @stuff_in_intestines >= 8
- end
- def passage_of_time
- if @stuff_in_belly > 0
- @stuff_in_belly -= 1
- @stuff_in_intestines +=1
- else
- if @asleep
- @asleep = false
- puts "#{@name} wakes up."
- end
- puts "They were starving! In desperation, they ATE you!"
- exit
- end
- if @stuff_in_intestines >= 10
- @stuff_in_intestines = 0
- puts "#{@name} had an accident..."
- end
- if hungry?
- if @asleep
- @asleep = false
- puts "#{@name} suddenly wakes up!"
- end
- puts "#{@name}'s stomach is grumbling..."
- end
- if poopy?
- if @asleep
- @asleep = false
- puts "#{@name} suddenly wakes up!"
- end
- puts "#{@name} is doing the potty dance..."
- end
- end
- puts "Welcome to the Baby Dragon 5000!"
- puts "What is your dragon's name?"
- name = gets.chomp
- puts "What color is your dragon? (Hint: blue, red, green, and purple make stunning dragons)"
- color = gets.chomp
- dragon = Dragon.new(name, color)
- puts "There are a lot of fun things to do with your dragon. Enter \"done\" when you are tired of him."
- options = %w(feed toss walk put\ to\ bed rock special\ power paint)
- puts "You can:"
- options.each do |option|
- puts option.capitalize
- end
- response = ""
- until response == "done"
- puts "What would you like to do next?"
- response = gets.chomp.downcase
- case response
- when "feed"
- dragon.feed
- when "toss"
- dragon.toss
- when "put to bed"
- dragon.put_to_bed
- when "rock"
- dragon.rock
- when "walk"
- dragon.walk
- when "special power"
- dragon.special_power
- when "paint"
- print "What color would you like to paint your dragon? "
- color = gets.chomp.downcase
- dragon.paint(color)
- when "done"
- puts "Your dragon will miss you! Come back soon!"
- else
- print "Sorry, you can't do that!"
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement