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

  # Drink from either a fountain or something in your inventory
  def cmd_drink(args)
    from_keyword = _("from")
    case args
    when nil, ""
        sendto(_("Drink what?"))
    when /^(#{from_keyword}|)\s*(.*)/i
    	what = $2
	fromobj = nil
	objs = find_inv(what)
	case objs.size
	when 0
		# Not in inventory, check room
		objs = get_object(location).find_objects(what)
		case objs.size
		when 0
			sendto(_("Unable to find %{from}." % {:from => what}))
		when 1
			fromobj = objs[0]
		else
			sendto(_("Which one?"))
		end
	when 1
		fromobj = objs[0]
	else
		sendto(_("Which one?"))
	end
	if fromobj
		if fromobj.has_val? :fountain
			add_event(fromobj.id, id, :drink)
		elsif fromobj.kind_of? Container
			if fromobj.has_type? "Liquid"
				add_event(fromobj.id, id, :drink)
			else
				sendto(_("You can not drink from that."))
			end
		else
			sendto(_("You can not drink that."))
		end
	end
     else
	sendto(_("Drink FROM what?"))
     end
  end

end