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_fill.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")

  # Fill from either a fountain with something in your inventory
  def cmd_fill(args)
    from_keyword = _("from")
    case args
    when nil, ""
        sendto(_("Drink what?"))
    when /^(.*)\s+#{from_keyword}\s+(.*)/i
    	what = $1
	from = $2
	fillobj = nil
	fromobj = nil
	objs = find_inv(what)
	case objs.size
	when 0
		sendto(_("You are not carrying %{what}." % {:what => what}))
	when 1
		fillobj = objs[0]
		# Found item to fill
		if fillobj.is_a? Container
			objs = get_object(location).find_objects(from)
			case objs.size
			when 0
				sendto(_("Unable to find %{from}." % {:from => from}))
			when 1
				fromobj = objs[0]
				if fromobj.has_val? :fountain
					liq = get_object(fromobj.val["fountain"])
					if liq
						if not fillobj.can_hold? liq.id
							sendto(_("You can not fill that with %{liq}." % {:liq => liq.name}))
							return
						end
						if fillobj.contents.size > 0
							if not fillobj.contents[0] == liq.id
								sendto(_("You can not mix liquids."))
								return
							end
						end
						if liq.is_a? Liquid
							sendto(_("You fill the %{what} with %{liq} from %{where}." % {:what => fillobj.name, :liq => liq.name, :where => fromobj.shortname}))
							msg = Msg.new _("^p1 fills ^o1 with %{liq} from ^o2." % {:liq => liq.name})
							msg.p1 = name
							msg.o1 = fillobj.shortname
							msg.o2 = fromobj.shortname
							sendroom(msg)
							fillobj.add_contents(liq.id) if fillobj.contents.size == 0
							if fillobj.has_val? :max_amt
								fillobj.liq_amt = fillobj.has_val? :max_amt
							else
								fillobj.liq_amt = Container.CONT_DEFAULT_MAX_AMT
							end
						else
							sendto(_("It is empty."))
						end
					else
						sendto(_("It is empty."))
					end
				else
					sendto(_("You can not fill from that."))
				end
			else
				sendto(_("Which one would you like to fill from?"))
			end
		else
			sendto(_("You can not fill that."))
		end
	else
		sendto(_("Fill which one?"))
	end
     else
	sendto(_("Fill what FROM where?"))
     end
  end

end