Class: Portal2Item
- Inherits:
-
Object
- Object
- Portal2Item
- Includes:
- GameItem
- Defined in:
- lib/steam/community/portal2/portal2_item.rb
Overview
Represents a Portal 2 item
Constant Summary collapse
- BOTS =
[ :pbody, :atlas ]
Instance Attribute Summary
Attributes included from GameItem
#attributes, #backpack_position, #class, #count, #defindex, #id, #level, #name, #quality, #slot, #type
Instance Method Summary collapse
-
#bots_equipped? ⇒ Boolean
Returns the symbols for each bot this player has equipped this item.
-
#equipped? ⇒ Boolean
Returns whether this item is equipped by this player at all.
-
#initialize(inventory, item_data) ⇒ Portal2Item
constructor
Creates a new instance of a Portal2Item with the given data.
Methods included from GameItem
Constructor Details
#initialize(inventory, item_data) ⇒ Portal2Item
Creates a new instance of a Portal2Item with the given data
16 17 18 19 20 21 22 23 |
# File 'lib/steam/community/portal2/portal2_item.rb', line 16 def initialize(inventory, item_data) super @equipped = {} BOTS.each_index do |class_id| @equipped[BOTS[class_id]] = (item_data[:inventory] & (1 << 16 + class_id) != 0) end end |
Instance Method Details
#bots_equipped? ⇒ Boolean
Returns the symbols for each bot this player has equipped this item
26 27 28 |
# File 'lib/steam/community/portal2/portal2_item.rb', line 26 def bots_equipped? @equipped.reject { |bot_id, equipped| !equipped } end |
#equipped? ⇒ Boolean
Returns whether this item is equipped by this player at all
31 32 33 |
# File 'lib/steam/community/portal2/portal2_item.rb', line 31 def equipped? @equipped.has_value? true end |