mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-06 08:40:03 +00:00
Add support for the same shop to belong to multiple npcs.
This commit is contained in:
@@ -13,11 +13,11 @@ SHOPS = {}
|
|||||||
|
|
||||||
# Creates the Shop from the specified Hash.
|
# Creates the Shop from the specified Hash.
|
||||||
def create_shop(hash)
|
def create_shop(hash)
|
||||||
unless hash.has_keys?(:items, :name, :npc_id)
|
unless hash.has_keys?(:items, :name, :npcs)
|
||||||
fail 'Shop name, npc, and items must be specified to create a shop.'
|
fail 'Shop name, npcs, and items must be specified to create a shop.'
|
||||||
end
|
end
|
||||||
|
|
||||||
npc_id, name = hash[:npc_id], hash[:name]
|
npcs, name = hash[:npcs], hash[:name]
|
||||||
currency = hash[:currency] || DEFAULT_CURRENCY
|
currency = hash[:currency] || DEFAULT_CURRENCY
|
||||||
|
|
||||||
options = hash[:npc_options] || [1]
|
options = hash[:npc_options] || [1]
|
||||||
@@ -26,7 +26,7 @@ def create_shop(hash)
|
|||||||
items = hash.delete(:items).collect { |data| ShopItem.new(*data) }
|
items = hash.delete(:items).collect { |data| ShopItem.new(*data) }
|
||||||
shop = Shop.new(name, items, currency, options, buys)
|
shop = Shop.new(name, items, currency, options, buys)
|
||||||
|
|
||||||
SHOPS[npc_id] = shop
|
npcs.each { |npc| SHOPS[npc] = shop }
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
Reference in New Issue
Block a user