examples/example1.rb in room-0.1.1 vs examples/example1.rb in room-0.1.2
- old
+ new
@@ -6,10 +6,11 @@
"Type 'look' to look around."
else
"This is Room," |
"a virtual world for you to explore." |
"At any time, you can type 'help', but it won't do anything." |
+ "I recommend falling back to 'look' instead." |
"" |
"Start by entering the room."
end
end
@@ -31,10 +32,14 @@
("There is a pencil sharpener on your right." if have? :pencil) |
("Right behind you, there's a chute you could jump into." if @sharpened_pencil) |
"Everything else is a blur."
end
+ def pencil
+ "That's not even close to a sentence. Where's the verb??"
+ end
+
def look_closet
@looked_left = true
"It looks like a normal closet." |
(@chipped_paint ? "Except you chipped some of the paint off." : "The white paint is a little chipped, though.")
end
@@ -107,10 +112,11 @@
"That's a mighty fine pencil sharpener. Red."
else
huh?
end
end
+ dup :look_right
def jump_into_chute
if @sharpened_pencil
"Throwing caution to the wind, you jump into the chute and die." |
"Just kidding! You find yourself on skis," |
@@ -133,17 +139,19 @@
"In the closet." |
"It's too dark to see. You might be stuck!" |
(if @got_pencil
"No wait, you can still exit the closet."
else
- "You stub your toe on something sharp. It feels like a pencil."
+ "You stub your toe on something sharp. It feels like a pencil." |
+ "You suddenly want to get the pencil."
end)
end
def stub_toe
"You already did that!"
end
+ dup :stub
def open_door
"The door won't budge."
end
dup :open_the_door
@@ -162,11 +170,12 @@
if @got_pencil
"What pencil?"
else
take :pencil
@got_pencil = true
- "Awesome, a pencil! You place the pencil in your pocket."
+ "Awesome, a pencil! You place the pencil in your pocket." |
+ "Something has changed around you."
end
end
dup :get_the_pencil
def exit
@@ -188,10 +197,20 @@
def eat_snow
"That was delicious." |
go("skiing2")
end
- dup :eat_the_snow
+ dup :eat_the_snow, :swallow
+
+ def spit_snow
+ "You spit out that nasty snow!" |
+ go("skiing2")
+ end
+ dup :spit
+
+ def ski
+ go("skiing2")
+ end
end
class Skiing2 < Room
def look
@looked ||= 0