#
# file:: cmd_sell.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")
# Sells an item to a merchant
def cmd_sell(args)
to = _("to")
buyer = []
who = nil
if args=~/(.*) #{to} (.*)/
args = $1
who = $2
end
items = find_inv(args)
if items.size == 0
sendto _("You do not have that to sell.")
return
end
if who
buyer = peopleinroom(who)
else
get_object(location).people(id).each do |p|
buyer << p if p.is_a? Merchant
end
end
case buyer.size
when 0
sendto _("Nodoby here is buying anything.")
when 1
items.each do |item|
add_event(id, buyer[0].id, :sell, item.id)
end
else
sendto _("Which one do you want to sell to?")
end
end
end