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

  # Ask a merchant to make an offer on an item
  def cmd_offer(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 offer.")
		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, :offer, item.id)
		end
	else
		sendto _("Which one do you want to offer to?")
	end
  end

end