Class: Core::Game::Equipment

Inherits:
Hash
  • Object
show all
Defined in:
lib/game/equipment.rb

Constant Summary collapse

@@locations =
[
  :head,
  :torso,
  :larm,
  :rarm,
  :legs,
  :feet,
  :back,
]

Instance Method Summary collapse

Constructor Details

#initializeEquipment

Returns a new instance of Equipment.



13
14
15
# File 'lib/game/equipment.rb', line 13

def initialize
  super
end

Instance Method Details

#at(loc) ⇒ Object



30
31
32
# File 'lib/game/equipment.rb', line 30

def at(loc)
  return self[loc]
end

#equip(item, location, inventory) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/game/equipment.rb', line 16

def equip(item, location, inventory)
  if @@locations.include?(location)
    inventory.remove(item)
    ret = self[location]
    inventory.add(ret) if ret
    self.store(location, item)
    return ret
  end
end

#remove_at(location) ⇒ Object



25
26
27
28
29
# File 'lib/game/equipment.rb', line 25

def remove_at(location)
  ret = self[location]
  self[location] = nil
  return ret
end