Require shops to use names instead of ids

This commit is contained in:
Major-
2016-02-14 16:11:47 +00:00
parent 6eebdd1f11
commit 1a86e286bb
2 changed files with 48 additions and 10 deletions
+4 -3
View File
@@ -18,15 +18,16 @@ def create_shop(hash)
end
npcs, name = hash[:npcs], hash[:name]
npcs = [npcs] unless npcs.is_a?(Array)
currency = hash[:currency] || DEFAULT_CURRENCY
options = hash[:npc_options] || [1]
buys = hash[:buys] || :own
items = hash.delete(:items).collect { |data| ShopItem.new(*data) }
items = hash.delete(:items).collect { |data| ShopItem.new(lookup_item(data[0]), data[1]) }
shop = Shop.new(name, items, currency, options, buys)
npcs.each { |npc| SHOPS[npc] = shop }
npcs.map { |name| lookup_npc(name) }.each { |npc| SHOPS[npc] = shop }
end
private
@@ -297,4 +298,4 @@ def buy(shop, player, message, currency)
end
# Declares the open_shop attribute, which contains the id of the currently open shop.
declare_attribute(:open_shop, -1)
declare_attribute(:open_shop, -1)