Class: DoDSWeapon
- Inherits:
-
Object
- Object
- DoDSWeapon
- Includes:
- GameWeapon
- Defined in:
- lib/steam/community/dods/dods_weapon.rb
Overview
Represents the stats for a Day of Defeat: Source weapon for a specific user
Instance Attribute Summary collapse
-
#headshots ⇒ Fixnum
readonly
Returns the number of headshots achieved with this weapon.
-
#hits ⇒ Fixnum
readonly
Returns the number of hits achieved with this weapon.
-
#name ⇒ String
readonly
Returns the name of this weapon.
Attributes included from GameWeapon
Instance Method Summary collapse
-
#avg_hits_per_kill ⇒ Float
Returns the average number of hits needed for a kill with this weapon.
-
#headshot_percentage ⇒ Float
Returns the percentage of headshots relative to the shots hit with this weapon.
-
#hit_percentage ⇒ Float
Returns the percentage of hits relative to the shots fired with this weapon.
-
#initialize(weapon_data) ⇒ DoDSWeapon
constructor
Creates a new instance of a Day of Defeat: Source weapon based on the given XML data.
Methods included from GameWeapon
Constructor Details
#initialize(weapon_data) ⇒ DoDSWeapon
Creates a new instance of a Day of Defeat: Source weapon based on the given XML data
34 35 36 37 38 39 40 41 42 |
# File 'lib/steam/community/dods/dods_weapon.rb', line 34 def initialize(weapon_data) super weapon_data @headshots = weapon_data['headshots'].to_i @id = weapon_data['key'] @name = weapon_data['name'] @shots = weapon_data['shotsfired'].to_i @hits = weapon_data['shotshit'].to_i end |
Instance Attribute Details
#headshots ⇒ Fixnum (readonly)
Returns the number of headshots achieved with this weapon
18 19 20 |
# File 'lib/steam/community/dods/dods_weapon.rb', line 18 def headshots @headshots end |
#hits ⇒ Fixnum (readonly)
Returns the number of hits achieved with this weapon
28 29 30 |
# File 'lib/steam/community/dods/dods_weapon.rb', line 28 def hits @hits end |
#name ⇒ String (readonly)
Returns the name of this weapon
23 24 25 |
# File 'lib/steam/community/dods/dods_weapon.rb', line 23 def name @name end |
Instance Method Details
#avg_hits_per_kill ⇒ Float
Returns the average number of hits needed for a kill with this weapon
47 48 49 |
# File 'lib/steam/community/dods/dods_weapon.rb', line 47 def avg_hits_per_kill @hits.to_f / @kill end |
#headshot_percentage ⇒ Float
Returns the percentage of headshots relative to the shots hit with this weapon
55 56 57 |
# File 'lib/steam/community/dods/dods_weapon.rb', line 55 def headshot_percentage @headshots.to_f / @hits end |
#hit_percentage ⇒ Float
Returns the percentage of hits relative to the shots fired with this weapon
63 64 65 |
# File 'lib/steam/community/dods/dods_weapon.rb', line 63 def hit_percentage @hits.to_f / @shots end |