znmud-0.0.1/benchmark/
znmud-0.0.1/cmd/
znmud-0.0.1/cmd/emotes/
znmud-0.0.1/cmd/objects/
znmud-0.0.1/cmd/tiny/
znmud-0.0.1/doc/
znmud-0.0.1/farts/
znmud-0.0.1/lib/
znmud-0.0.1/lib/combat/
znmud-0.0.1/lib/core/bodytypes/
znmud-0.0.1/lib/engine/
znmud-0.0.1/lib/farts/
znmud-0.0.1/logs/
#
# file::    cmd_goto.rb
#
# Released under the terms of the TeensyMUD Public License
# See LICENSE file for additional information.
#
module Cmd

  bindtextdomain("cmd")

  # Priv. command that allows teleporting
  # Can teleport to a room number or to a players name
  def cmd_goto(args)
    case args
    when /(\d+)/ # Room number
	found = false
	r = get_object($1.to_i)
	if r
		if r.is_a? Room and r.id != location
			found = true
			get_object(location).say(_("%{name} vanished into a puff of smoke!" % {:name => name}), id)
			get_object(location).delete_contents(id)
			self.location = r.id
			get_object(r.id).add_contents(id)
			get_object(location).say(_("%{name} arrives out of thin air!" % {:name => name}), id)
			parse(_("look"))
		end
	end
	sendto _("That is not a room id") if not found
    when /^mob\s+(.+)/
	who = $1
	mobs = []
	world.find_objects(who).each do |o|
		if o.location
			mobs << o if o.is_a? Mobile and o.location > 0
		end
	end
	case mobs.size
	when 0
		sendto _("You are unable to locate an active mobile with that name")
	when 1
		get_object(location).say(_("%{name} vanished into a puff of smoke!" % {:name => name}), id)
		get_object(location).delete_contents(id)
		self.location = mobs[0].location
		get_object(mobs[0].location).add_contents(id)
		get_object(location).say(_("%{name} arrives out of thin air!" % {:name => name}), id)
		parse(_("look"))
	else
		msg = ""
		mobs.each do |mob|
			mobroom = get_object(mob.location)
			msg << " #{mob.name} - #{mobroom.name} (#{mob.location})\n"
		end
		msg << "Too many to pick from, choose the room number.\n"
		sendto(msg)
	end
    when /(\w+)/ # Players name
      targetname = $1
      found = false
      world.connected_characters.each do |pid| 
      	if get_object(pid).name =~ /#{targetname}/i
		found = true
		target = get_object(pid)
		if target.location == location
			sendto _("%{pronoun} is standing right in front of you." % {:pronoun => target.pronoun.ucfirst})
		else
			get_object(location).say(_("%{name} vanished into a puff of smoke!" % {:name => name}), id)
			get_object(location).delete_contents(id)
			self.location = target.location
			get_object(target.location).add_contents(id)
			get_object(location).say(_("%{name} arrives out of thin air!" % {:name => name}), id)
			parse(_("look"))
		end
	end
      end
      sendto(_("Player %{name} not found" % {:name => targetname})) if not found
    else
      sendto _("Usage: @goto (room# | playername | mob mobilename)")
    end
  end

end