Class: L4DExplosive

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

Overview

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

Author:

  • Sebastian Staudt

Instance Attribute Summary

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) ⇒ L4DExplosive

Creates a new instance of an explosivve 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



20
21
22
23
24
25
# File 'lib/steam/community/l4d/l4d_explosive.rb', line 20

def initialize(weapon_name, weapon_data)
  super weapon_data

  @id    = weapon_name
  @shots = weapon_data['thrown'].to_i
end

Instance Method Details

#avg_kills_per_shotFloat

Returns the average number of killed zombies for one shot of this explosive

Returns:

  • (Float)

    The average number of kills per shot



30
31
32
# File 'lib/steam/community/l4d/l4d_explosive.rb', line 30

def avg_kills_per_shot
  1 / avg_shots_per_kill
end