lib/IFMapper/Room.rb in ifmapper-0.9 vs lib/IFMapper/Room.rb in ifmapper-0.9.5

- old
+ new

@@ -42,10 +42,11 @@ @x = vars.shift @y = vars.shift if not vars.empty? and vars[0].kind_of?(String) @desc = vars.shift @desc.sub!(/\n/, ' ') + @desc.strip! end end def marshal_dump [ @name, @objects, @tasks, @exits, @darkness, @x, @y, @desc ] @@ -55,9 +56,30 @@ return @exits[dir] end def []=(dir, connection) @exits[dir] = connection + end + + # + # Return the number of doors present in room + # + def num_doors + num = 0 + @exits.each { |e| + next if not e + num += 1 if e.door? + } + return num + end + + # + # Return the number of exits present in room + # + def num_exits + num = 0 + @exits.each { |e| num += 1 if e } + return num end # # Return a direction from the vector of the exit that would take # us to the 'b' room more cleanly.