Module: RuneRb::Game::Entity::Helpers::Inventory

Included in:
Context
Defined in:
app/game/entity/helpers/inventory.rb

Overview

Since:

  • 0.9.3

Instance Method Summary collapse

Instance Method Details

#add_item(item_stack, at = nil) ⇒ Object

Adds an item stack to the inventory at a specific slot if provided

Parameters:

  • item_stack (RuneRb::Game::Item::Stack)

    the item stack to add

  • at (Integer) (defaults to: nil)

    the slot at which to add the item (else, the next available slot is used.)

Since:

  • 0.9.3


6
7
8
9
10
11
12
# File 'app/game/entity/helpers/inventory.rb', line 6

def add_item(item_stack, at = nil)
  if at
    @inventory[:container].data[at] = item_stack
  else
    @inventory[:container].add(item_stack)
  end
end

#remove_item(id, amt = 1) ⇒ Object

Removes an item with the specified parameters from the inventory container.

Parameters:

  • id (Integer)

    the id of the item to remove

  • amt (Integer) (defaults to: 1)

    the amount of the item to remove

Since:

  • 0.9.3


17
18
19
# File 'app/game/entity/helpers/inventory.rb', line 17

def remove_item(id, amt = 1)
  @inventory[:container].remove(id, amt)
end