Class: L4D2Weapon

Inherits:
Object
  • Object
show all
Includes:
AbstractL4DWeapon
Defined in:
lib/steam/community/l4d/l4d2_weapon.rb

Overview

This class represents the statistics of a single weapon for a user in Left4Dead 2

Author:

  • Sebastian Staudt

Instance Attribute Summary collapse

Attributes included from AbstractL4DWeapon

#accuracy, #headshots_percentage, #id, #kill_percentage, #shots

Attributes included from GameWeapon

#id, #kills, #shots

Instance Method Summary collapse

Methods included from GameWeapon

#avg_shots_per_kill

Constructor Details

#initialize(weapon_name, weapon_data) ⇒ L4D2Weapon

Creates a new instance of a weapon based on the given XML data

Parameters:

  • weapon_name (String)

    The name of this weapon

  • weapon_data (Hash<String, Object>)

    The XML data of this weapon



30
31
32
33
34
35
36
# File 'lib/steam/community/l4d/l4d2_weapon.rb', line 30

def initialize(weapon_name, weapon_data)
  super

  @damage          = weapon_data['damage'].to_i
  @kill_percentage = weapon_data['pctkills'].to_f * 0.01
  @weapon_group    = weapon_data['group']
end

Instance Attribute Details

#damageFixnum (readonly)

Returns the amount of damage done by the player with this weapon

Returns:

  • (Fixnum)

    The damage done by this weapon



19
20
21
# File 'lib/steam/community/l4d/l4d2_weapon.rb', line 19

def damage
  @damage
end

#weapon_groupString (readonly)

Returns the weapon group this weapon belongs to

Returns:

  • (String)

    The group this weapon belongs to



24
25
26
# File 'lib/steam/community/l4d/l4d2_weapon.rb', line 24

def weapon_group
  @weapon_group
end