Class: AlienSwarmWeapon

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

Overview

This class holds statistical information about weapons used by a player in Alien Swarm

Author:

  • Sebastian Staudt

Instance Attribute Summary collapse

Attributes included from GameWeapon

#id, #kills, #shots

Instance Method Summary collapse

Methods included from GameWeapon

#avg_shots_per_kill

Constructor Details

#initialize(weapon_data) ⇒ AlienSwarmWeapon

Creates a new weapon instance based on the assigned weapon XML data

Parameters:

  • weapon_data (Hash<String, Object>)

    The data representing this weapon



39
40
41
42
43
44
45
46
47
# File 'lib/steam/community/alien_swarm/alien_swarm_weapon.rb', line 39

def initialize(weapon_data)
  super

  @accuracy      = weapon_data['accuracy'].to_f
  @damage        = weapon_data['damage'].to_i
  @friendly_fire = weapon_data['friendlyfire'].to_i
  @name          = weapon_data['name']
  @shots         = weapon_data['shotsfired'].to_i
end

Instance Attribute Details

#accuracyFloat (readonly)

Returns the accuracy of the player with this weapon

Returns:

  • (Float)

    The accuracy of the player with this weapon



19
20
21
# File 'lib/steam/community/alien_swarm/alien_swarm_weapon.rb', line 19

def accuracy
  @accuracy
end

#damageFixnum (readonly)

Returns the damage achieved with this weapon

Returns:

  • (Fixnum)

    The damage achieved with this weapon



24
25
26
# File 'lib/steam/community/alien_swarm/alien_swarm_weapon.rb', line 24

def damage
  @damage
end

#friendly_fireFixnum (readonly)

Returns the damage dealt to team mates with this weapon

Returns:

  • (Fixnum)

    The damage dealt to team mates with this weapon



29
30
31
# File 'lib/steam/community/alien_swarm/alien_swarm_weapon.rb', line 29

def friendly_fire
  @friendly_fire
end

#nameString (readonly)

Returns the name of this weapon

Returns:

  • (String)

    The name of this weapon



34
35
36
# File 'lib/steam/community/alien_swarm/alien_swarm_weapon.rb', line 34

def name
  @name
end