#
# 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