class Container
def initialize(type, max)
@type = type
@max = max
if @type == 0
@items = []
elsif @type == 1
@gold = 0
end
end
def place_gold(amount)
a = amount + @gold
if a <= @max
@gold += amount
end
end
def add_item(item_id)
a = @items.length + 1
if a <= @max
@items.push(item_id)
end
end
def take_gold(amount)
if amount <= max
@gold -= amount
$game_party.gain_gold(amount)
end
end
def take_item(item_id)
for i in @items.size
if @items[i] == item_id
@items.delete_at(i)
$game_party.gain_item(item_id, 1)
end
end
end
end
container = Container.new(type, max)
container.add_item(item_id)
container.place_gold(amount)
container.take_item(item_id)
container.take_gold(amount)
def add_items(item_array)
a = @items.length + item_array.length
if a <= @max
for i in item_array.length
b = @items.length
if b <= @max
@items.push(item_array[i])
end
end
end
end
class Container
def initialize(type, max)
@type = type
@max = max
if @type == 0
@items = []
elsif @type == 1
@gold = 0
end
end
def place_gold(amount)
a = amount + @gold
if a <= @max
@gold += amount
end
end
def add_item(item_array)
a = @items.length + item_array.length
if a <= @max
for i in item_array.length
b = @items.length
if b <= @max
@items.push(item_array[i])
end
end
end
end
def take_gold(amount)
if amount <= max
@gold -= amount
$game_party.gain_gold(amount)
end
end
def take_item(item_id)
for i in @items.size
if @items[i] == item_id
@items.delete_at(i)
$game_party.gain_item(item_id, 1)
end
end
end
def get_contents
return @items if @type == 0
return @gold if @type == 1
return nil
end
end