CoralMUD-0.18/
CoralMUD-0.18/core/
CoralMUD-0.18/data/
CoralMUD-0.18/data/help/
CoralMUD-0.18/data/players/
CoralMUD-0.18/data/socials/
CoralMUD-0.18/lib/automap/
CoralMUD-0.18/lib/items/
$room_flags = [:hidden]

class Room
  define_creatable
  define_editor :room_editor
  define_editor_field({:name=>"vtag", :filter=>:filt_to_tag, :type=>:vtag})
  define_editor_field({:name=>"zone", :filter=>:filt_to_area, :type=>:namespace})
  define_editor_field({:name=>"name", :filter=>:filt_none})
  define_editor_field({:name=>"sector", :filter=>:filt_to_sect})
  define_editor_field({:name=>"flags", :filter=>:filt_to_flag, :filter_key=>$room_flags, :type=>:flags})

  define_editor_field({:name=>"description",:arg_type=>:arg_none, :filter=>:filt_none,
    :proc_fun=>proc do |ed, ch, obj, arg|
      ch.editing.unshift(obj.desc)
      ch.view "Editing description." + ENDL
    end,

    :display=>proc do |obj|
      ["#{mxptag('send description')}#R[#Wdescription#R]:#{mxptag('/send')}","#n"+obj.desc,"----"]
    end
  })
  define_editor_field({:name=>"exit", :filter=>:filt_to_exit,
    # proc exits.  I wrote it out like this because it was difficult to read.
    # What do we do when exits command is accessed?  It's filtered by filt_to_exit.  
    :proc_fun=>lambda do |ed, ch, obj, arg|
      direction = arg[0] # already correct format.  Guarenteed to be a valid direction 0-5.
      command = arg[1] # What to do that direction.

      puts direction
      puts command
      puts arg[2]

      case command.downcase
        when "edit" then ch.editing.unshift(obj.exit_list[direction]); ch.text_to_player "Editing exit." + ENDL
        when "link" then ch.view "This is not yet supported." + ENDL 
        when "dig" 
          supplied = nil
          if arg[2]
            supplied = Tag.find_any_obj arg[2]
            if supplied && supplied[0].is_a?(Room)
              supplied = supplied[0]
            else
              ch.view "That's not a valid room." + ENDL
              return
            end
          end
          if supplied
            r = ch.buildwalk(direction, supplied)
          else
            r = ch.buildwalk(direction)
          end
          if r
            ch.view "Room created with a two way link." + ENDL
            #ch.editing.unshift(obj.exit_list[direction]);
          end
        else ch.view "#{command} wasn't valid." +ENDL + "Did you mean: edit, link, or dig?" + ENDL
      end
    end,
    # proc to define how we display this field.   It's only needed because we have a non-generic field.
    # Note that if we didn't include this it would not be displayed at all.
    :display=>proc do |obj|
      str = []      
      str << "#YExit parameters: [edit, dig, link]#n"
      4.times do |i|
        ex = obj.exit_list[i]
        if ex
          str << (("%-20s" % "#R[#{mxptag('send "&text;"')}#Wexit #{i.exit_code_to_s} edit#{mxptag('/send')}#R]: #{ex.to_s}#w"))
        else
          str << (("%-20s" % "#R[#{mxptag('send "&text;"')}#Wexit #{i.exit_code_to_s} dig#{mxptag('/send')}#R])#w"))
        end
      end
      str << ("#R==========================================================================#n")
      str
    end
  })

  # add delete option
  define_editor_field({:name=>"delete", :arg_type=>:arg_none, :filter=>:filt_none,
    :proc_fun=>proc do |ed, ch, obj, arg|
      ch.execute_command("done") # leave the editor just in time.
      obj.do_delete # rely on the object to implement a way to delete it.
    end,
    :display=>proc do |obj|
      [mxptag('send delete')+ "#R[#WDELETE#R]:" + mxptag('/send') + "   Deletes Entire Room"]
    end
    })
end