Skip to content

Instantly share code, notes, and snippets.

@practicingruby
Created November 21, 2013 15:24
Show Gist options
  • Select an option

  • Save practicingruby/7583494 to your computer and use it in GitHub Desktop.

Select an option

Save practicingruby/7583494 to your computer and use it in GitHub Desktop.
bats = Hazard.new(:bats)
bats.sensed("You hear a rustling sound.")
bats.encountered do |narrator|
narrator.say("Giant bats whisk you away to a new cavern!")
new_room = random_room
move(:bats, from: current_room, to: new_room)
move(:hunter, from: current_room, to: new_room)
end
# ...
wumpus = Hazard.new(:wumpus)
wumpus.sensed("You smell something horrifying.")
wumpus.encountered do |narrator|
narrator.finish_story("The wumpus gobbled you up!")
end
# ...
pit = Hazard.new(:pit)
pit.sensed("You feel a very cold wind flowing through the cavern.")
pit.encountered do |narrator|
narrator.finish_story("You fell into a bottomless pit. Enjoy the ride!")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment