Module: AbstractL4DWeapon
- Includes:
- GameWeapon
- Included in:
- L4D2Weapon, L4DWeapon
- Defined in:
- lib/steam/community/l4d/abstract_l4d_weapon.rb
Overview
This abstract class is a base class for weapons in Left4Dead and Left4Dead 2 as the weapon stats for both games are very similar
Instance Attribute Summary collapse
-
#accuracy ⇒ String
readonly
Returns the overall accuracy of the player with this weapon.
-
#headshots_percentage ⇒ String
readonly
Returns the percentage of kills with this weapon that have been headshots.
-
#id ⇒ String
readonly
Returns the ID of the weapon.
-
#kill_percentage ⇒ String
readonly
Returns the percentage of overall kills of the player that have been achieved with this weapon.
-
#shots ⇒ Fixnum
readonly
Returns the number of shots the player has fired with this weapon.
Attributes included from GameWeapon
Instance Method Summary collapse
-
#initialize(weapon_name, weapon_data) ⇒ Object
Creates a new instance of weapon from the given XML data and parses common data for both, ‘L4DWeapon` and `L4D2Weapon`.
Methods included from GameWeapon
Instance Attribute Details
#accuracy ⇒ String (readonly)
Returns the overall accuracy of the player with this weapon
19 20 21 |
# File 'lib/steam/community/l4d/abstract_l4d_weapon.rb', line 19 def accuracy @accuracy end |
#headshots_percentage ⇒ String (readonly)
Returns the percentage of kills with this weapon that have been headshots
24 25 26 |
# File 'lib/steam/community/l4d/abstract_l4d_weapon.rb', line 24 def headshots_percentage @headshots_percentage end |
#id ⇒ String (readonly)
Returns the ID of the weapon
29 30 31 |
# File 'lib/steam/community/l4d/abstract_l4d_weapon.rb', line 29 def id @id end |
#kill_percentage ⇒ String (readonly)
Returns the percentage of overall kills of the player that have been achieved with this weapon
35 36 37 |
# File 'lib/steam/community/l4d/abstract_l4d_weapon.rb', line 35 def kill_percentage @kill_percentage end |
#shots ⇒ Fixnum (readonly)
Returns the number of shots the player has fired with this weapon
40 41 42 |
# File 'lib/steam/community/l4d/abstract_l4d_weapon.rb', line 40 def shots @shots end |
Instance Method Details
#initialize(weapon_name, weapon_data) ⇒ Object
Creates a new instance of weapon from the given XML data and parses common data for both, ‘L4DWeapon` and `L4D2Weapon`
47 48 49 50 51 52 53 54 |
# File 'lib/steam/community/l4d/abstract_l4d_weapon.rb', line 47 def initialize(weapon_name, weapon_data) super weapon_data @accuracy = weapon_data['accuracy'].to_f * 0.01 @headshots_percentage = weapon_data['headshots'].to_f * 0.01 @id = weapon_name @shots = weapon_data['shots'].to_i end |