Module: GameItem
- Included in:
- Portal2Item, TF2Item
- Defined in:
- lib/steam/community/game_item.rb
Overview
Provides basic functionality to represent an item in a game
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#backpack_position ⇒ Object
readonly
Returns the value of attribute backpack_position.
-
#class ⇒ Object
readonly
Returns the value of attribute class.
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#defindex ⇒ Object
readonly
Returns the value of attribute defindex.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#level ⇒ Object
readonly
Returns the value of attribute level.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#quality ⇒ Object
readonly
Returns the value of attribute quality.
-
#slot ⇒ Object
readonly
Returns the value of attribute slot.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(inventory, item_data) ⇒ Object
Creates a new instance of a GameItem with the given data.
-
#tradeable? ⇒ Boolean
Returns whether this item is tradeable.
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
11 12 13 |
# File 'lib/steam/community/game_item.rb', line 11 def attributes @attributes end |
#backpack_position ⇒ Object (readonly)
Returns the value of attribute backpack_position.
11 12 13 |
# File 'lib/steam/community/game_item.rb', line 11 def backpack_position @backpack_position end |
#class ⇒ Object (readonly)
Returns the value of attribute class.
11 12 13 |
# File 'lib/steam/community/game_item.rb', line 11 def class @class end |
#count ⇒ Object (readonly)
Returns the value of attribute count.
11 12 13 |
# File 'lib/steam/community/game_item.rb', line 11 def count @count end |
#defindex ⇒ Object (readonly)
Returns the value of attribute defindex.
11 12 13 |
# File 'lib/steam/community/game_item.rb', line 11 def defindex @defindex end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
11 12 13 |
# File 'lib/steam/community/game_item.rb', line 11 def id @id end |
#level ⇒ Object (readonly)
Returns the value of attribute level.
11 12 13 |
# File 'lib/steam/community/game_item.rb', line 11 def level @level end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/steam/community/game_item.rb', line 11 def name @name end |
#quality ⇒ Object (readonly)
Returns the value of attribute quality.
11 12 13 |
# File 'lib/steam/community/game_item.rb', line 11 def quality @quality end |
#slot ⇒ Object (readonly)
Returns the value of attribute slot.
11 12 13 |
# File 'lib/steam/community/game_item.rb', line 11 def slot @slot end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
11 12 13 |
# File 'lib/steam/community/game_item.rb', line 11 def type @type end |
Instance Method Details
#initialize(inventory, item_data) ⇒ Object
Creates a new instance of a GameItem with the given data
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/steam/community/game_item.rb', line 15 def initialize(inventory, item_data) @defindex = item_data[:defindex] @backpack_position = item_data[:inventory] & 0xffff @class = inventory.item_schema[@defindex][:item_class] @count = item_data[:quantity] @id = item_data[:id] @level = item_data[:level] @name = inventory.item_schema[@defindex][:item_name] @quality = inventory.qualities[item_data[:quality]] @slot = inventory.item_schema[@defindex][:item_slot] @tradeable = !(item_data[:flag_cannot_trade] == true) @type = inventory.item_schema[@defindex][:item_type_name] unless inventory.item_schema[@defindex][:attributes].nil? @attributes = inventory.item_schema[@defindex][:attributes] end end |
#tradeable? ⇒ Boolean
Returns whether this item is tradeable
34 35 36 |
# File 'lib/steam/community/game_item.rb', line 34 def tradeable? @tradeable end |