cmd_sell.rb

znmud-0.0.1/cmd/zombie/cmd_sell.rb · 901 B

From the archive znmud-minimal-0.0.1.tar.gz

Download the archive   « Back to the archive contents

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

Site Stats

Snippets: 1791
Codebases: 571