steam-condenser 0.10.1 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. data/VERSION.yml +2 -2
  2. data/lib/datagram_channel.rb +30 -33
  3. data/lib/exceptions/packet_format_exception.rb +7 -3
  4. data/lib/exceptions/rcon_ban_exception.rb +7 -5
  5. data/lib/exceptions/rcon_no_auth_exception.rb +8 -6
  6. data/lib/exceptions/timeout_exception.rb +10 -4
  7. data/lib/socket_channel.rb +11 -17
  8. data/lib/steam/community/cacheable.rb +5 -7
  9. data/lib/steam/community/css/css_map.rb +31 -0
  10. data/lib/steam/community/css/css_stats.rb +116 -0
  11. data/lib/steam/community/css/css_weapon.rb +33 -0
  12. data/lib/steam/community/dods/dods_stats.rb +3 -3
  13. data/lib/steam/community/game_stats.rb +14 -13
  14. data/lib/steam/community/game_weapon.rb +3 -5
  15. data/lib/steam/community/l4d/abstract_l4d_stats.rb +4 -2
  16. data/lib/steam/community/l4d/l4d_explosive.rb +2 -2
  17. data/lib/steam/community/l4d/l4d_map.rb +3 -3
  18. data/lib/steam/community/steam_group.rb +2 -4
  19. data/lib/steam/community/steam_id.rb +2 -2
  20. data/lib/steam/community/tf2/tf2_class.rb +17 -17
  21. data/lib/steam/community/tf2/tf2_class_factory.rb +17 -17
  22. data/lib/steam/community/tf2/tf2_engineer.rb +9 -9
  23. data/lib/steam/community/tf2/tf2_medic.rb +9 -9
  24. data/lib/steam/community/tf2/tf2_sniper.rb +7 -7
  25. data/lib/steam/community/tf2/tf2_spy.rb +9 -9
  26. data/lib/steam/community/tf2/tf2_stats.rb +9 -9
  27. data/lib/steam/packets/a2a_ack_packet.rb +11 -9
  28. data/lib/steam/packets/a2a_ping_packet.rb +5 -4
  29. data/lib/steam/packets/a2m_get_servers_batch2_packet.rb +13 -12
  30. data/lib/steam/packets/a2s_info_packet.rb +8 -7
  31. data/lib/steam/packets/a2s_player_packet.rb +6 -6
  32. data/lib/steam/packets/a2s_rules_packet.rb +5 -5
  33. data/lib/steam/packets/a2s_serverquery_getchallenge_packet.rb +4 -3
  34. data/lib/steam/packets/m2a_server_batch_packet.rb +20 -22
  35. data/lib/steam/packets/rcon/rcon_auth_request.rb +5 -5
  36. data/lib/steam/packets/rcon/rcon_auth_response.rb +6 -6
  37. data/lib/steam/packets/rcon/rcon_exec_request.rb +5 -5
  38. data/lib/steam/packets/rcon/rcon_exec_response.rb +2 -2
  39. data/lib/steam/packets/rcon/rcon_goldsrc_request.rb +7 -7
  40. data/lib/steam/packets/rcon/rcon_goldsrc_response.rb +8 -8
  41. data/lib/steam/packets/rcon/rcon_packet.rb +12 -16
  42. data/lib/steam/packets/rcon/rcon_packet_factory.rb +19 -19
  43. data/lib/steam/packets/request_with_challenge.rb +5 -5
  44. data/lib/steam/packets/s2a_info2_packet.rb +28 -30
  45. data/lib/steam/packets/s2a_info_base_packet.rb +11 -16
  46. data/lib/steam/packets/s2a_info_detailed_packet.rb +30 -28
  47. data/lib/steam/packets/s2a_player_packet.rb +7 -9
  48. data/lib/steam/packets/s2a_rules_packet.rb +8 -12
  49. data/lib/steam/packets/s2c_challenge_packet.rb +7 -6
  50. data/lib/steam/packets/steam_packet.rb +7 -6
  51. data/lib/steam/packets/steam_packet_factory.rb +37 -38
  52. data/lib/steam/servers/game_server.rb +76 -86
  53. data/lib/steam/servers/goldsrc_server.rb +5 -5
  54. data/lib/steam/servers/master_server.rb +24 -24
  55. data/lib/steam/servers/source_server.rb +17 -19
  56. data/lib/steam/sockets/goldsrc_socket.rb +43 -46
  57. data/lib/steam/sockets/master_server_socket.rb +11 -13
  58. data/lib/steam/sockets/rcon_socket.rb +15 -17
  59. data/lib/steam/sockets/source_socket.rb +21 -21
  60. data/lib/steam/sockets/steam_socket.rb +25 -28
  61. data/lib/steam/steam_player.rb +3 -1
  62. data/lib/stringio_additions.rb +48 -0
  63. data/test/datagram_channel_tests.rb +8 -8
  64. data/test/query_tests.rb +15 -14
  65. data/test/rcon_tests.rb +32 -31
  66. data/test/socket_channel_tests.rb +7 -7
  67. data/test/steam/communtiy/steam_community_test_suite.rb +5 -2
  68. data/test/steam_community_tests.rb +4 -3
  69. data/test/stringio_additions_tests.rb +77 -0
  70. metadata +15 -8
  71. data/lib/byte_buffer.rb +0 -126
  72. data/lib/exceptions/buffer_underflow_exception.rb +0 -8
  73. data/test/byte_buffer_tests.rb +0 -76
@@ -1,7 +1,7 @@
1
1
  # This code is free software; you can redistribute it and/or modify it under the
2
2
  # terms of the new BSD License.
3
3
  #
4
- # Copyright (c) 2009, Sebastian Staudt
4
+ # Copyright (c) 2009-2010, Sebastian Staudt
5
5
 
6
6
  require 'steam/community/dods/dods_weapon'
7
7
  require 'steam/community/game_stats'
@@ -22,7 +22,7 @@ class DoDSStats < GameStats
22
22
  if @class_stats.nil?
23
23
  @class_stats = {}
24
24
  @xml_data.elements.each('stats/classes/class') do |class_data|
25
- @class_stats[class_data.attributes["key"]] = DoDSClass.new class_data
25
+ @class_stats[class_data.attributes['key']] = DoDSClass.new class_data
26
26
  end
27
27
  end
28
28
 
@@ -43,5 +43,5 @@ class DoDSStats < GameStats
43
43
 
44
44
  @weapon_stats
45
45
  end
46
-
46
+
47
47
  end
@@ -1,21 +1,12 @@
1
1
  # This code is free software; you can redistribute it and/or modify it under the
2
2
  # terms of the new BSD License.
3
3
  #
4
- # Copyright (c) 2008-2009, Sebastian Staudt
4
+ # Copyright (c) 2008-2010, Sebastian Staudt
5
5
 
6
- require "open-uri"
7
- require "rexml/document"
6
+ require 'open-uri'
7
+ require 'rexml/document'
8
8
 
9
- require "steam/community/game_achievement"
10
-
11
- class GameStats
12
- end
13
-
14
- require 'steam/community/defense_grid/defense_grid_stats'
15
- require "steam/community/dods/dods_stats"
16
- require "steam/community/l4d/l4d_stats"
17
- require "steam/community/l4d/l4d2_stats"
18
- require "steam/community/tf2/tf2_stats"
9
+ require 'steam/community/game_achievement'
19
10
 
20
11
  # The GameStats class represents the game statistics for a single user and a
21
12
  # specific game
@@ -30,15 +21,23 @@ class GameStats
30
21
  # depending on the game selected
31
22
  def self.create_game_stats(steam_id, game_name)
32
23
  case game_name
24
+ when 'cs:s'
25
+ require 'steam/community/css/css_stats'
26
+ CSSStats.new(steam_id)
33
27
  when 'defensegrid:awakening'
28
+ require 'steam/community/defense_grid/defense_grid_stats'
34
29
  DefenseGridStats.new(steam_id)
35
30
  when 'dod:s'
31
+ require 'steam/community/dods/dods_stats'
36
32
  DoDSStats.new(steam_id)
37
33
  when 'l4d'
34
+ require 'steam/community/l4d/l4d_stats'
38
35
  L4DStats.new(steam_id)
39
36
  when 'l4d2'
37
+ require 'steam/community/l4d/l4d2_stats'
40
38
  L4D2Stats.new(steam_id)
41
39
  when 'tf2'
40
+ require 'steam/community/tf2/tf2_stats'
42
41
  TF2Stats.new(steam_id)
43
42
  else
44
43
  new(steam_id, game_name)
@@ -61,8 +60,10 @@ class GameStats
61
60
  @privacy_state = @xml_data.elements['privacyState'].text
62
61
  if public?
63
62
  @app_id = @xml_data.elements['game/gameLink'].text.match(/http:\/\/store.steampowered.com\/app\/([1-9][0-9]+)/)[1]
63
+ @custom_url = @xml_data.elements['player/customURL'].text if @custom_url.nil?
64
64
  @game_name = @xml_data.elements['game/gameName'].text
65
65
  @hours_played = @xml_data.elements['stats/hoursPlayed'].text
66
+ @steam_id64 = @xml_data.elements['player/steamID64'].text.to_i if @steam_id64.nil?
66
67
  end
67
68
  end
68
69
 
@@ -1,13 +1,13 @@
1
1
  # This code is free software; you can redistribute it and/or modify it under the
2
2
  # terms of the new BSD License.
3
3
  #
4
- # Copyright (c) 2009, Sebastian Staudt
4
+ # Copyright (c) 2009-2010, Sebastian Staudt
5
5
 
6
6
  require 'abstract_class'
7
7
 
8
8
  # Super class for classes representing game weapons
9
9
  class GameWeapon
10
-
10
+
11
11
  include AbstractClass
12
12
 
13
13
  attr_reader :kills, :id, :shots
@@ -19,9 +19,7 @@ class GameWeapon
19
19
  # Returns the average number of shots needed for a kill with this weapon.
20
20
  # Calculates the value if needed.
21
21
  def avg_shots_per_kill
22
- if @avg_shots_per_kill.nil?
23
- @avg_shots_per_kill = @shots.to_f / @kills
24
- end
22
+ @avg_shots_per_kill = @shots.to_f / @kills if @avg_shots_per_kill.nil?
25
23
 
26
24
  @avg_shots_per_kill
27
25
  end
@@ -58,7 +58,6 @@ class AbstractL4DStats < GameStats
58
58
  @lifetime_stats = {}
59
59
  @lifetime_stats['finales_survived'] = @xml_data.elements['stats/lifetime/finales'].text.to_i
60
60
  @lifetime_stats['games_played'] = @xml_data.elements['stats/lifetime/gamesplayed'].text.to_i
61
- @lifetime_stats['finales_survived_percentage'] = @lifetime_stats['finales_survived'].to_f / @lifetime_stats['games_played']
62
61
  @lifetime_stats['infected_killed'] = @xml_data.elements['stats/lifetime/infectedkilled'].text.to_i
63
62
  @lifetime_stats['kills_per_hour'] = @xml_data.elements['stats/lifetime/killsperhour'].text.to_f
64
63
  @lifetime_stats['avg_kits_shared'] = @xml_data.elements['stats/lifetime/kitsshared'].text.to_f
@@ -66,6 +65,8 @@ class AbstractL4DStats < GameStats
66
65
  @lifetime_stats['avg_pills_shared'] = @xml_data.elements['stats/lifetime/pillsshared'].text.to_f
67
66
  @lifetime_stats['avg_pills_used'] = @xml_data.elements['stats/lifetime/pillsused'].text.to_f
68
67
  @lifetime_stats['time_played'] = @xml_data.elements['stats/lifetime/timeplayed'].text
68
+
69
+ @lifetime_stats['finales_survived_percentage'] = @lifetime_stats['finales_survived'].to_f / @lifetime_stats['games_played']
69
70
  end
70
71
 
71
72
  @lifetime_stats
@@ -122,13 +123,14 @@ class AbstractL4DStats < GameStats
122
123
  @versus_stats['games_played'] = @xml_data.elements['stats/versus/gamesplayed'].text.to_i
123
124
  @versus_stats['games_completed'] = @xml_data.elements['stats/versus/gamescompleted'].text.to_i
124
125
  @versus_stats['finales_survived'] = @xml_data.elements['stats/versus/finales'].text.to_i
125
- @versus_stats['finales_survived_percentage'] = @versus_stats['finales_survived'].to_f / @versus_stats['games_played']
126
126
  @versus_stats['points'] = @xml_data.elements['stats/versus/points'].text.to_i
127
127
  @versus_stats['most_points_infected'] = @xml_data.elements['stats/versus/pointsas'].text
128
128
  @versus_stats['games_won'] = @xml_data.elements['stats/versus/gameswon'].text.to_i
129
129
  @versus_stats['games_lost'] = @xml_data.elements['stats/versus/gameslost'].text.to_i
130
130
  @versus_stats['highest_survivor_score'] = @xml_data.elements['stats/versus/survivorscore'].text.to_i
131
131
 
132
+ @versus_stats['finales_survived_percentage'] = @versus_stats['finales_survived'].to_f / @versus_stats['games_played']
133
+
132
134
  self.class.const_get(:SPECIAL_INFECTED).each do |infected|
133
135
  @versus_stats[infected] = {}
134
136
  @versus_stats[infected]['special_attacks'] = @xml_data.elements["stats/versus/#{infected}special"].text.to_i
@@ -11,8 +11,8 @@ class L4DExplosive < GameWeapon
11
11
  def initialize(weapon_data)
12
12
  super weapon_data
13
13
 
14
- @id = weapon_data.name
15
- @shots = weapon_data.elements['thrown'].text.to_i
14
+ @id = weapon_data.name
15
+ @shots = weapon_data.elements['thrown'].text.to_i
16
16
  end
17
17
 
18
18
  # Returns the average number of kills for one shot of this explosive.
@@ -16,9 +16,9 @@ class L4DMap
16
16
 
17
17
  # Creates a new instance of L4DMap based on the assigned XML data
18
18
  def initialize(map_data)
19
- @best_time = map_data.elements['besttimeseconds'].text.to_f
20
- @id = map_data.name
21
- @name = map_data.elements['name'].text
19
+ @best_time = map_data.elements['besttimeseconds'].text.to_f
20
+ @id = map_data.name
21
+ @name = map_data.elements['name'].text
22
22
  @times_played = map_data.elements['timesplayed'].text.to_i
23
23
 
24
24
  case map_data.elements['medal'].text
@@ -1,7 +1,7 @@
1
1
  # This code is free software; you can redistribute it and/or modify it under the
2
2
  # terms of the new BSD License.
3
3
  #
4
- # Copyright (c) 2008-2009, Sebastian Staudt
4
+ # Copyright (c) 2008-2010, Sebastian Staudt
5
5
 
6
6
  require 'open-uri'
7
7
  require 'rexml/document'
@@ -51,9 +51,7 @@ class SteamGroup
51
51
  url = open("#{base_url}/memberslistxml?p=#{page}", {:proxy => true})
52
52
  member_data = REXML::Document.new(url.read).root
53
53
 
54
- if page == 1
55
- @group_id64 = member_data.elements['groupID64'].text.to_i
56
- end
54
+ @group_id64 = member_data.elements['groupID64'].text.to_i if page == 1
57
55
  total_pages = member_data.elements['totalPages'].text.to_i
58
56
 
59
57
  member_data.elements['members'].elements.each do |member|
@@ -54,8 +54,8 @@ class SteamId
54
54
 
55
55
  # Creates a new SteamId object using the SteamID64 converted from a server
56
56
  # SteamID given by +steam_id+
57
- def self.get_from_steam_id(steam_id)
58
- self.new(self.convert_steam_id_to_community_id(steam_id))
57
+ def self.from_steam_id(steam_id)
58
+ new(convert_steam_id_to_community_id(steam_id))
59
59
  end
60
60
 
61
61
  # Creates a new SteamId object for the given SteamID +id+, either numeric or
@@ -1,31 +1,31 @@
1
1
  # This code is free software; you can redistribute it and/or modify it under the
2
2
  # terms of the new BSD License.
3
3
  #
4
- # Copyright (c) 2008-2009, Sebastian Staudt
4
+ # Copyright (c) 2008-2010, Sebastian Staudt
5
5
 
6
6
  require 'steam/community/game_class'
7
7
 
8
8
  # Represents the stats for a Team Fortress 2 class for a specific user
9
9
  class TF2Class < GameClass
10
-
10
+
11
11
  attr_reader :max_buildings_destroyed, :max_captures, :max_damage,
12
12
  :max_defenses, :max_dominations, :max_kill_assists, :max_kills,
13
13
  :max_revenges, :max_score, :max_time_alive
14
-
14
+
15
15
  # Creates a new instance of TF2Class based on the assigned XML data
16
16
  def initialize(class_data)
17
- @name = class_data.elements["className"].text
18
- @max_buildings_destroyed = class_data.elements["ibuildingsdestroyed"].text.to_i
19
- @max_captures = class_data.elements["ipointcaptures"].text.to_i
20
- @max_damage = class_data.elements["idamagedealt"].text.to_i
21
- @max_defenses = class_data.elements["ipointdefenses"].text.to_i
22
- @max_dominations = class_data.elements["idominations"].text.to_i
23
- @max_kill_assists = class_data.elements["ikillassists"].text.to_i
24
- @max_kills = class_data.elements["inumberofkills"].text.to_i
25
- @max_revenges = class_data.elements["irevenge"].text.to_i
26
- @max_score = class_data.elements["ipointsscored"].text.to_i
27
- @max_time_alive = class_data.elements["iplaytime"].text.to_i
28
- @play_time = class_data.elements["playtimeSeconds"].text.to_i
17
+ @name = class_data.elements['className'].text
18
+ @max_buildings_destroyed = class_data.elements['ibuildingsdestroyed'].text.to_i
19
+ @max_captures = class_data.elements['ipointcaptures'].text.to_i
20
+ @max_damage = class_data.elements['idamagedealt'].text.to_i
21
+ @max_defenses = class_data.elements['ipointdefenses'].text.to_i
22
+ @max_dominations = class_data.elements['idominations'].text.to_i
23
+ @max_kill_assists = class_data.elements['ikillassists'].text.to_i
24
+ @max_kills = class_data.elements['inumberofkills'].text.to_i
25
+ @max_revenges = class_data.elements['irevenge'].text.to_i
26
+ @max_score = class_data.elements['ipointsscored'].text.to_i
27
+ @max_time_alive = class_data.elements['iplaytime'].text.to_i
28
+ @play_time = class_data.elements['playtimeSeconds'].text.to_i
29
29
  end
30
-
31
- end
30
+
31
+ end
@@ -1,36 +1,36 @@
1
1
  # This code is free software; you can redistribute it and/or modify it under the
2
2
  # terms of the new BSD License.
3
3
  #
4
- # Copyright (c) 2008-2009, Sebastian Staudt
4
+ # Copyright (c) 2008-2010, Sebastian Staudt
5
5
 
6
- require "abstract_class"
7
- require "steam/community/tf2/tf2_class"
8
- require "steam/community/tf2/tf2_engineer"
9
- require "steam/community/tf2/tf2_medic"
10
- require "steam/community/tf2/tf2_sniper"
11
- require "steam/community/tf2/tf2_spy"
6
+ require 'abstract_class'
7
+ require 'steam/community/tf2/tf2_class'
8
+ require 'steam/community/tf2/tf2_engineer'
9
+ require 'steam/community/tf2/tf2_medic'
10
+ require 'steam/community/tf2/tf2_sniper'
11
+ require 'steam/community/tf2/tf2_spy'
12
12
 
13
13
  # The TF2ClassFactory is used to created instances of TF2Class based on the XML
14
14
  # input data
15
15
  class TF2ClassFactory
16
-
16
+
17
17
  include AbstractClass
18
-
18
+
19
19
  # Creates a new instance of TF2Class storing the statistics for a Team
20
20
  # Fortress 2 class with the assigned XML data
21
- def self.get_tf2_class(class_data)
22
- case class_data.elements("className")[0].text
23
- when "Engineer" then
21
+ def self.tf2_class(class_data)
22
+ case class_data.elements['className'].text
23
+ when 'Engineer' then
24
24
  return TF2Engineer.new(class_data)
25
- when "Medic" then
25
+ when 'Medic' then
26
26
  return TF2Medic.new(class_data)
27
- when "Sniper" then
27
+ when 'Sniper' then
28
28
  return TF2Sniper.new(class_data)
29
- when "Spy" then
29
+ when 'Spy' then
30
30
  return TF2Spy.new(class_data)
31
31
  else
32
32
  return TF2Class.new(class_data)
33
33
  end
34
34
  end
35
-
36
- end
35
+
36
+ end
@@ -1,23 +1,23 @@
1
1
  # This code is free software; you can redistribute it and/or modify it under the
2
2
  # terms of the new BSD License.
3
3
  #
4
- # Copyright (c) 2008-2009, Sebastian Staudt
4
+ # Copyright (c) 2008-2010, Sebastian Staudt
5
5
 
6
- require "steam/community/tf2/tf2_class"
6
+ require 'steam/community/tf2/tf2_class'
7
7
 
8
8
  # Represents the stats for the Team Fortress 2 engineer class for a specific
9
9
  # user
10
10
  class TF2Engineer < TF2Class
11
11
 
12
12
  attr_reader :max_buildings_built, :max_teleports, :max_sentry_kills
13
-
13
+
14
14
  # Creates a new instance of TF2Engineer based on the assigned XML data
15
15
  def initialize(class_data)
16
16
  super class_data
17
-
18
- @max_buildings_built = class_data.elements["ibuildingsbuilt"].text.to_i
19
- @max_teleports = class_data.elements["inumteleports"].text.to_i
20
- @max_sentry_kills = class_data.elements["isentrykills"].text.to_i
17
+
18
+ @max_buildings_built = class_data.elements['ibuildingsbuilt'].text.to_i
19
+ @max_teleports = class_data.elements['inumteleports'].text.to_i
20
+ @max_sentry_kills = class_data.elements['isentrykills'].text.to_i
21
21
  end
22
-
23
- end
22
+
23
+ end
@@ -1,20 +1,20 @@
1
1
  # This code is free software; you can redistribute it and/or modify it under the
2
2
  # terms of the new BSD License.
3
3
  #
4
- # Copyright (c) 2008-2009, Sebastian Staudt
4
+ # Copyright (c) 2008-2010, Sebastian Staudt
5
5
 
6
- require "steam/community/tf2/tf2_class"
6
+ require 'steam/community/tf2/tf2_class'
7
7
 
8
8
  # Represents the stats for the Team Fortress 2 medic class for a specific user
9
9
  class TF2Medic < TF2Class
10
-
10
+
11
11
  attr_reader :max_health_healed, :max_ubercharges
12
-
12
+
13
13
  def initialize(class_data)
14
14
  super class_data
15
-
16
- @max_health_healed = class_data.elements["ihealthpointshealed"].text.to_i
17
- @max_ubercharges = class_data.elements["inuminvulnerable"].text.to_i
15
+
16
+ @max_health_healed = class_data.elements['ihealthpointshealed'].text.to_i
17
+ @max_ubercharges = class_data.elements['inuminvulnerable'].text.to_i
18
18
  end
19
-
20
- end
19
+
20
+ end
@@ -1,18 +1,18 @@
1
1
  # This code is free software; you can redistribute it and/or modify it under the
2
2
  # terms of the new BSD License.
3
3
  #
4
- # Copyright (c) 2008-2009, Sebastian Staudt
4
+ # Copyright (c) 2008-2010, Sebastian Staudt
5
5
 
6
- require "steam/community/tf2/tf2_class"
6
+ require 'steam/community/tf2/tf2_class'
7
7
 
8
8
  # Represents the stats for the Team Fortress 2 sniper class for a specific user
9
9
  class TF2Sniper < TF2Class
10
-
10
+
11
11
  # Creates a new instance of TF2Sniper based on the assigned XML data
12
12
  def initialize(class_data)
13
13
  super class_data
14
-
15
- @max_headshots = class_data.elements["iheadshots"].text.to_i
14
+
15
+ @max_headshots = class_data.elements['iheadshots'].text.to_i
16
16
  end
17
-
18
- end
17
+
18
+ end
@@ -1,21 +1,21 @@
1
1
  # This code is free software; you can redistribute it and/or modify it under the
2
2
  # terms of the new BSD License.
3
3
  #
4
- # Copyright (c) 2008-2009, Sebastian Staudt
4
+ # Copyright (c) 2008-2010, Sebastian Staudt
5
5
 
6
- require "steam/community/tf2/tf2_class"
6
+ require 'steam/community/tf2/tf2_class'
7
7
 
8
8
  # Represents the stats for the Team Fortress 2 spy class for a specific user
9
9
  class TF2Spy < TF2Class
10
-
10
+
11
11
  attr_reader :max_backstabs, :max_health_leeched
12
-
12
+
13
13
  # Creates a new instance of TF2Spy based on the assigned XML data
14
14
  def initialize(class_data)
15
15
  super class_data
16
-
17
- @max_backstabs = class_data.elements["ibackstabs"].text.to_i
18
- @max_health_leeched = class_data.elements["ihealthpointsleached"].text.to_i
16
+
17
+ @max_backstabs = class_data.elements['ibackstabs'].text.to_i
18
+ @max_health_leeched = class_data.elements['ihealthpointsleached'].text.to_i
19
19
  end
20
-
21
- end
20
+
21
+ end
@@ -1,16 +1,16 @@
1
1
  # This code is free software; you can redistribute it and/or modify it under the
2
2
  # terms of the new BSD License.
3
3
  #
4
- # Copyright (c) 2008-2009, Sebastian Staudt
4
+ # Copyright (c) 2008-2010, Sebastian Staudt
5
5
 
6
- require "steam/community/tf2/tf2_class"
6
+ require 'steam/community/tf2/tf2_class_factory'
7
7
 
8
8
  # The TF2Stats class represents the game statistics for a single user in Team
9
9
  # Fortress 2
10
10
  class TF2Stats < GameStats
11
11
 
12
12
  attr_reader :accumulated_points
13
-
13
+
14
14
  # Creates a TF2Stats object by calling the super constructor with the game
15
15
  # name "tf2"
16
16
  def initialize(steam_id)
@@ -20,7 +20,7 @@ class TF2Stats < GameStats
20
20
  @accumulated_points = @xml_data.elements['stats/accumulatedPoints'].text.to_i
21
21
  end
22
22
  end
23
-
23
+
24
24
  # Returns a Hash of TF2Class for this user containing all Team Fortress 2
25
25
  # classes. If the classes haven't been parsed already, parsing is done now.
26
26
  def class_stats
@@ -29,11 +29,11 @@ class TF2Stats < GameStats
29
29
  if @class_stats.nil?
30
30
  @class_stats = Hash.new
31
31
  @xml_data.elements.each('stats/classData') do |class_data|
32
- @class_stats[class_data.elements['className'].text] = TF2Class.new(class_data)
32
+ @class_stats[class_data.elements['className'].text] = TF2ClassFactory.tf2_class(class_data)
33
33
  end
34
34
  end
35
-
36
- return @class_stats
35
+
36
+ @class_stats
37
37
  end
38
-
39
- end
38
+
39
+ end