mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-04 08:39:27 +00:00
Add shops support.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
require 'java'
|
||||
|
||||
java_import 'org.apollo.game.model.inv.Inventory'
|
||||
|
||||
# A shop containing items that can be sold.
|
||||
class Shop
|
||||
attr_reader :buys, :currency, :items, :inventory, :name, :npc_options
|
||||
|
||||
def initialize(name, items, currency, options, buys)
|
||||
@name = name
|
||||
@items = items
|
||||
@currency = currency
|
||||
@buys = buys
|
||||
@npc_options = options
|
||||
@inventory = Inventory.new(DEFAULT_CAPACITY, Inventory::StackMode::STACK_ALWAYS)
|
||||
|
||||
items.each { |item| @inventory.add(item.id, item.amount) }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# The `Currency` used by default.
|
||||
DEFAULT_CURRENCY = Currency.new(995, 'money')
|
||||
|
||||
# The default capacity of a shop.
|
||||
DEFAULT_CAPACITY = 30
|
||||
Reference in New Issue
Block a user