Module: Natural20::Container
- Included in:
- ItemLibrary::Chest, ItemLibrary::Ground, Lootable
- Defined in:
- lib/natural_20/concerns/container.rb
Instance Method Summary collapse
Instance Method Details
#retrieve(battle, source, target, items) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/natural_20/concerns/container.rb', line 19 def retrieve(battle, source, target, items) items.each do |item_with_count| item, qty = item_with_count if item.equipped unequip(item.name, transfer_inventory: false) source.add_item(item.name) else source_item = target.deduct_item(item.name, qty) source.add_item(item.name, qty, source_item) battle.trigger_event!(:object_received, source, item_type: item.name) end end end |
#store(battle, source, target, items) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/natural_20/concerns/container.rb', line 6 def store(battle, source, target, items) items.each do |item_with_count| item, qty = item_with_count source_item = source.deduct_item(item.name, qty) target.add_item(item.name, qty, source_item) battle.trigger_event!(:object_received, target, item_type: item.name) end end |