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_mend.rb

# This source code copyright (C) 2009 Craig Smith
# All rights reserved.
#
# Released under the terms of the TeensyMUD Public License
# See LICENSE file for additional information.
#

module Cmd

  bindtextdomain("cmd")

  # Mends crippled limbs (skill)
  def cmd_mend(args)
	s = _("self")
	m = _("me")
	case args
	when "", nil
		sendto _("Mend whom?")
	when s, m
		sendto _("Unfortunately you can not mend your own wounds.")
	else
		ppl = peopleinroom(args)
		case ppl.size
		when 0
			sendto _("You do not seem them here.")
		when 1
			# You can only mend one thing at a time
			# It takes 10 MV points minus - per level of skill
			cost = 10 - get_skill(:mend)
			cost = 0 if world.is_admin? id or cost < 0
			person = ppl[0]
			if person.body
				broken = []
				person.body.bodyparts.each do |bpid|
					broken << bpid if get_object(bpid).crippled
				end
				if broken.size > 0
					limbid = broken[rand(broken.size)]
					if get_stat(:mp) >= cost
						adjust_stat(:mp, -cost)
						limb = get_object(limbid)
						limb.crippled = false
						sendto _("You mend %{name}'s %{part}." % {:name => person.shortname, :part => limb.name })
						msg = Msg.new _("^p1 mends your crippled %{part}!" % {:part => limb.name})
						msg.p1 = name
						add_event(id, person.id, :show, msg)
						msg = Msg.new _("^p1 mends ^p2's crippled %{part}." % {:part => limb.name})
						msg.ch1 = self
						msg.ch2 = person
						sendroom(msg)
					else
						msg = Msg.new _("You do not have enough energy to mend ^n2 ^o1")
						msg.ch1 = self
						msg.ch2 = person
						msg.o1 = get_object(limbid).name
						sendto(msg)
					end
				else
					sendto _("You find no crippled limbs.")
				end
			else
				sendto _("They do not seemed injured.")
			end
		else
			sendto _("Which one?")
		end
	end
  end
end