Class: Armory::Character::Item

Inherits:
Object
  • Object
show all
Defined in:
lib/armory/character.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeItem

Returns a new instance of Item.



58
59
60
# File 'lib/armory/character.rb', line 58

def initialize
  @gems = []
end

Instance Attribute Details

#durabilityObject

Returns the value of attribute durability.



55
56
57
# File 'lib/armory/character.rb', line 55

def durability
  @durability
end

#enchant_idObject

Returns the value of attribute enchant_id.



55
56
57
# File 'lib/armory/character.rb', line 55

def enchant_id
  @enchant_id
end

#gemsObject (readonly)

Returns the value of attribute gems.



56
57
58
# File 'lib/armory/character.rb', line 56

def gems
  @gems
end

#idObject

Returns the value of attribute id.



54
55
56
# File 'lib/armory/character.rb', line 54

def id
  @id
end

#levelObject

Returns the value of attribute level.



54
55
56
# File 'lib/armory/character.rb', line 54

def level
  @level
end

#max_durabilityObject

Returns the value of attribute max_durability.



55
56
57
# File 'lib/armory/character.rb', line 55

def max_durability
  @max_durability
end

#nameObject

Returns the value of attribute name.



54
55
56
# File 'lib/armory/character.rb', line 54

def name
  @name
end

#rarityObject

Returns the value of attribute rarity.



54
55
56
# File 'lib/armory/character.rb', line 54

def rarity
  @rarity
end

#slotObject

Returns the value of attribute slot.



54
55
56
# File 'lib/armory/character.rb', line 54

def slot
  @slot
end

Class Method Details

.from_armory(doc) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/armory/character.rb', line 62

def self.from_armory(doc)
  Item.new.tap do |item|
    item.id     = doc.attr('id').to_i
    item.name   = doc.attr('name')
    item.level  = doc.attr('level').to_i
    item.slot   = doc.attr('slot').to_i
    item.rarity = doc.attr('rarity').to_i

    item.durability     = doc.attr('durability').to_i
    item.max_durability = doc.attr('maxDurability').to_i
    item.enchant_id     = doc.attr('permanentEnchantItemId').to_i

    3.times do |i|
      gem = doc.attr("gem#{i}Id").to_i
      item.gems << gem if gem != 0
    end
  end
end