lib/room.rb in room-0.1.0 vs lib/room.rb in room-0.1.1
- old
+ new
@@ -1,15 +1,14 @@
require "thread"
-require "readline"
def reload!
$commands = {}
- old_count = Room.rooms.keys.count
+ old_count = Room.rooms.keys.length
load FILENAME
- Room.rooms.keys.count - old_count
+ Room.rooms.keys.length - old_count
end
class String
def |(o)
if o.nil?
@@ -39,10 +38,14 @@
def go key
Room.go key
end
+ def be_secretive
+ $secretive = true
+ end
+
def inventory
$inventory ||= []
end
def have? item
@@ -58,27 +61,31 @@
end
def do action
Printer.puts
if action.strip == ""
- elsif (r = self.class.commands.detect { |c, m| c =~ action })
- command, method = r
- args = command.match(action).to_a.drop(1)
- Printer.puts self.send(method, *args).to_s.rstrip
elsif action == "reload!"
d = reload!
Printer.puts "A great wave of relief washes over you."
Printer.puts "The world seems larger by about #{d}." if d > 0
+ elsif (r = self.class.commands.detect { |c, m| c =~ action })
+ command, method = r
+ args = command.match(action).to_a.drop(1)
+ Printer.puts self.send(method, *args).to_s.rstrip
else
- Printer.puts unknown_command(action)
+ Printer.puts huh?(action)
end
end
+ def immediate *text
+ Printer.puts *text
+ end
+
def look
"A nondescript room."
end
- def unknown_command action = nil
+ def huh? action = nil
"I don't understand."
end
def unknown_room key
"" |