steam-condenser 1.3.5 → 1.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +228 -0
- data/CONTRIBUTING.md +59 -0
- data/Gemfile.lock +12 -13
- data/README.md +9 -4
- data/lib/steam-condenser/version.rb +1 -1
- data/lib/steam/community/alien_swarm/alien_swarm_mission.rb +10 -9
- data/lib/steam/community/alien_swarm/alien_swarm_stats.rb +74 -72
- data/lib/steam/community/css/css_map.rb +2 -2
- data/lib/steam/community/css/css_stats.rb +54 -56
- data/lib/steam/community/css/css_weapon.rb +4 -4
- data/lib/steam/community/game_item.rb +2 -3
- data/lib/steam/community/game_leaderboard.rb +22 -15
- data/lib/steam/community/l4d/abstract_l4d_stats.rb +64 -61
- data/lib/steam/community/l4d/l4d2_stats.rb +26 -21
- data/lib/steam/community/steam_id.rb +8 -11
- data/lib/steam/community/web_api.rb +19 -14
- data/lib/steam/packets/s2a_info2_packet.rb +16 -14
- data/lib/steam/packets/s2a_info_detailed_packet.rb +24 -19
- data/lib/steam/packets/steam_packet_factory.rb +7 -2
- data/lib/steam/servers/game_server.rb +3 -2
- data/lib/steam/servers/master_server.rb +1 -1
- data/lib/steam/sockets/source_socket.rb +4 -9
- data/pkg/steam-condenser-1.3.5.gem +0 -0
- data/pkg/steam-condenser-1.3.5/Gemfile +7 -0
- data/pkg/steam-condenser-1.3.5/Gemfile.lock +45 -0
- data/pkg/steam-condenser-1.3.5/LICENSE +25 -0
- data/pkg/steam-condenser-1.3.5/README.md +70 -0
- data/pkg/steam-condenser-1.3.5/Rakefile +46 -0
- data/pkg/steam-condenser-1.3.5/lib/core_ext/stringio.rb +91 -0
- data/pkg/steam-condenser-1.3.5/lib/errors/packet_format_error.rb +13 -0
- data/pkg/steam-condenser-1.3.5/lib/errors/rcon_ban_error.rb +22 -0
- data/pkg/steam-condenser-1.3.5/lib/errors/rcon_no_auth_error.rb +21 -0
- data/pkg/steam-condenser-1.3.5/lib/errors/steam_condenser_error.rb +26 -0
- data/pkg/steam-condenser-1.3.5/lib/errors/timeout_error.rb +28 -0
- data/pkg/steam-condenser-1.3.5/lib/errors/web_api_error.rb +57 -0
- data/pkg/steam-condenser-1.3.5/lib/steam-condenser.rb +18 -0
- data/pkg/steam-condenser-1.3.5/lib/steam-condenser/community.rb +24 -0
- data/pkg/steam-condenser-1.3.5/lib/steam-condenser/servers.rb +24 -0
- data/pkg/steam-condenser-1.3.5/lib/steam-condenser/version.rb +11 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/alien_swarm/alien_swarm_mission.rb +119 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/alien_swarm/alien_swarm_stats.rb +186 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/alien_swarm/alien_swarm_weapon.rb +49 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/app_news.rb +133 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/cacheable.rb +199 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/css/css_map.rb +61 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/css/css_stats.rb +142 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/css/css_weapon.rb +69 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/defense_grid/defense_grid_stats.rb +238 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/dods/dods_class.rb +90 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/dods/dods_stats.rb +62 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/dods/dods_weapon.rb +67 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/dota2/dota2_beta_inventory.rb +30 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/dota2/dota2_inventory.rb +30 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/dota2/dota2_item.rb +33 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/game_achievement.rb +109 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/game_class.rb +22 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/game_inventory.rb +171 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/game_item.rb +156 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/game_item_schema.rb +131 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/game_leaderboard.rb +205 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/game_leaderboard_entry.rb +43 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/game_stats.rb +175 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/game_weapon.rb +41 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/l4d/abstract_l4d_stats.rb +185 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/l4d/abstract_l4d_weapon.rb +56 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/l4d/l4d2_map.rb +90 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/l4d/l4d2_stats.rb +174 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/l4d/l4d2_weapon.rb +38 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/l4d/l4d_explosive.rb +34 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/l4d/l4d_map.rb +65 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/l4d/l4d_stats.rb +73 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/l4d/l4d_weapon.rb +26 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/portal2/portal2_inventory.rb +30 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/portal2/portal2_item.rb +55 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/portal2/portal2_stats.rb +33 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/steam_game.rb +193 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/steam_group.rb +129 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/steam_id.rb +498 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/tf2/tf2_beta_inventory.rb +28 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/tf2/tf2_class.rb +92 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/tf2/tf2_class_factory.rb +40 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/tf2/tf2_engineer.rb +43 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/tf2/tf2_golden_wrench.rb +70 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/tf2/tf2_inventory.rb +30 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/tf2/tf2_item.rb +55 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/tf2/tf2_medic.rb +35 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/tf2/tf2_sniper.rb +28 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/tf2/tf2_spy.rb +41 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/tf2/tf2_stats.rb +77 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/web_api.rb +130 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/community/xml_data.rb +27 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/a2m_get_servers_batch2_packet.rb +59 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/a2s_info_packet.rb +24 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/a2s_player_packet.rb +31 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/a2s_rules_packet.rb +32 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/a2s_serverquery_getchallenge_packet.rb +25 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/c2m_checkmd5_packet.rb +31 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/m2a_server_batch_packet.rb +52 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/m2c_isvalidmd5_packet.rb +34 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/m2s_requestrestart_packet.rb +34 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/rcon/rcon_auth_request.rb +28 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/rcon/rcon_auth_response.rb +30 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/rcon/rcon_exec_request.rb +28 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/rcon/rcon_exec_response.rb +37 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/rcon/rcon_goldsrc_request.rb +35 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/rcon/rcon_goldsrc_response.rb +34 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/rcon/rcon_packet.rb +57 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/rcon/rcon_packet_factory.rb +43 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/rcon/rcon_terminator.rb +29 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/request_with_challenge.rb +19 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/s2a_info2_packet.rb +74 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/s2a_info_base_packet.rb +25 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/s2a_info_detailed_packet.rb +59 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/s2a_logstring_packet.rb +30 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/s2a_player_packet.rb +44 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/s2a_rules_packet.rb +48 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/s2c_challenge_packet.rb +35 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/s2m_heartbeat2_packet.rb +72 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/steam_packet.rb +52 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/packets/steam_packet_factory.rb +108 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/servers/game_server.rb +392 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/servers/goldsrc_server.rb +74 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/servers/master_server.rb +188 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/servers/server.rb +115 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/servers/source_server.rb +117 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/sockets/goldsrc_socket.rb +142 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/sockets/master_server_socket.rb +34 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/sockets/rcon_socket.rb +103 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/sockets/source_socket.rb +78 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/sockets/steam_socket.rb +91 -0
- data/pkg/steam-condenser-1.3.5/lib/steam/steam_player.rb +143 -0
- data/pkg/steam-condenser-1.3.5/steam-condenser.gemspec +26 -0
- data/pkg/steam-condenser-1.3.5/test/core_ext/test_stringio.rb +59 -0
- data/pkg/steam-condenser-1.3.5/test/fixtures/invalid.xml +2 -0
- data/pkg/steam-condenser-1.3.5/test/fixtures/sonofthor.xml +882 -0
- data/pkg/steam-condenser-1.3.5/test/fixtures/status_goldsrc +3 -0
- data/pkg/steam-condenser-1.3.5/test/fixtures/status_source +3 -0
- data/pkg/steam-condenser-1.3.5/test/fixtures/valve-members.xml +231 -0
- data/pkg/steam-condenser-1.3.5/test/helper.rb +48 -0
- data/pkg/steam-condenser-1.3.5/test/steam/community/test_cacheable.rb +100 -0
- data/pkg/steam-condenser-1.3.5/test/steam/community/test_steam_group.rb +83 -0
- data/pkg/steam-condenser-1.3.5/test/steam/community/test_steam_id.rb +144 -0
- data/pkg/steam-condenser-1.3.5/test/steam/community/test_web_api.rb +98 -0
- data/pkg/steam-condenser-1.3.5/test/steam/packets/test_steam_packet.rb +37 -0
- data/pkg/steam-condenser-1.3.5/test/steam/servers/test_game_server.rb +296 -0
- data/pkg/steam-condenser-1.3.5/test/steam/servers/test_goldsrc_server.rb +59 -0
- data/pkg/steam-condenser-1.3.5/test/steam/servers/test_master_server.rb +131 -0
- data/pkg/steam-condenser-1.3.5/test/steam/servers/test_server.rb +72 -0
- data/pkg/steam-condenser-1.3.5/test/steam/servers/test_source_server.rb +134 -0
- data/pkg/steam-condenser-1.3.5/test/steam/sockets/test_goldsrc_socket.rb +127 -0
- data/pkg/steam-condenser-1.3.5/test/steam/sockets/test_master_server_socket.rb +42 -0
- data/pkg/steam-condenser-1.3.5/test/steam/sockets/test_rcon_socket.rb +118 -0
- data/pkg/steam-condenser-1.3.5/test/steam/sockets/test_source_socket.rb +77 -0
- data/pkg/steam-condenser-1.3.5/test/steam/sockets/test_steam_socket.rb +97 -0
- data/steam-condenser.gemspec +2 -3
- data/test/steam/community/test_cacheable.rb +3 -0
- data/test/steam/community/test_web_api.rb +15 -2
- data/test/steam/packets/test_steam_packet.rb +1 -1
- data/test/steam/sockets/test_source_socket.rb +1 -1
- metadata +151 -27
@@ -0,0 +1,61 @@
|
|
1
|
+
# This code is free software; you can redistribute it and/or modify it under
|
2
|
+
# the terms of the new BSD License.
|
3
|
+
#
|
4
|
+
# Copyright (c) 2010-2011, Sebastian Staudt
|
5
|
+
|
6
|
+
# Represents the stats for a Counter-Strike: Source map for a specific user
|
7
|
+
#
|
8
|
+
# @author Sebastian Staudt
|
9
|
+
class CSSMap
|
10
|
+
|
11
|
+
# Returns the name of this map
|
12
|
+
#
|
13
|
+
# @return [String] The name of this map
|
14
|
+
attr_reader :name
|
15
|
+
|
16
|
+
# Returns the number of rounds the player has lost on this map
|
17
|
+
#
|
18
|
+
# @return [Fixnum] The number of rounds lost
|
19
|
+
attr_reader :rounds_lost
|
20
|
+
|
21
|
+
# Returns the number of rounds the player has played on this map
|
22
|
+
#
|
23
|
+
# @return [Fixnum] The number of rounds played
|
24
|
+
attr_reader :rounds_played
|
25
|
+
|
26
|
+
# Returns the number of rounds the player has won on this map
|
27
|
+
#
|
28
|
+
# @return [Fixnum] The number of rounds won
|
29
|
+
attr_reader :rounds_won
|
30
|
+
|
31
|
+
# Creates a new instance of a Counter-Strike: Source class based on the
|
32
|
+
# given XML data
|
33
|
+
#
|
34
|
+
# @param [String] map_name The name of the map
|
35
|
+
# @param [Hash<String, Object>] maps_data The XML data of all maps
|
36
|
+
def initialize(map_name, maps_data)
|
37
|
+
@name = map_name
|
38
|
+
|
39
|
+
@favorite = (maps_data['favorite'] == @name)
|
40
|
+
@rounds_played = maps_data["#{@name}_rounds"].to_i
|
41
|
+
@rounds_won = maps_data["#{@name}_wins"].to_i
|
42
|
+
|
43
|
+
@rounds_lost = @rounds_played - @rounds_won
|
44
|
+
@rounds_won_percentage = (@rounds_played > 0) ? @rounds_won.to_f / @rounds_played : 0
|
45
|
+
end
|
46
|
+
|
47
|
+
# Returns whether this map is the favorite map of this player
|
48
|
+
#
|
49
|
+
# @return [Boolean] `true` if this is the favorite map
|
50
|
+
def favorite?
|
51
|
+
@favorite
|
52
|
+
end
|
53
|
+
|
54
|
+
# Returns the percentage of rounds the player has won on this map
|
55
|
+
#
|
56
|
+
# @return [Float] The percentage of rounds won
|
57
|
+
def rounds_won_percentage
|
58
|
+
(@rounds_played > 0) ? @rounds_won.to_f / @rounds_played : 0
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
@@ -0,0 +1,142 @@
|
|
1
|
+
# This code is free software; you can redistribute it and/or modify it under
|
2
|
+
# the terms of the new BSD License.
|
3
|
+
#
|
4
|
+
# Copyright (c) 2010-2013, Sebastian Staudt
|
5
|
+
|
6
|
+
require 'steam/community/css/css_map'
|
7
|
+
require 'steam/community/css/css_weapon'
|
8
|
+
|
9
|
+
# The is class represents the game statistics for a single user in
|
10
|
+
# Counter-Strike: Source
|
11
|
+
#
|
12
|
+
# @author Sebastian Staudt
|
13
|
+
class CSSStats < GameStats
|
14
|
+
|
15
|
+
# The names of the maps in Counter-Strike: Source
|
16
|
+
MAPS = [ 'cs_assault', 'cs_compound', 'cs_havana', 'cs_italy', 'cs_militia',
|
17
|
+
'cs_office', 'de_aztec', 'de_cbble', 'de_chateau', 'de_dust',
|
18
|
+
'de_dust2', 'de_inferno', 'de_nuke', 'de_piranesi', 'de_port',
|
19
|
+
'de_prodigy', 'de_tides', 'de_train' ]
|
20
|
+
|
21
|
+
# The names of the weapons in Counter-Strike: Source
|
22
|
+
WEAPONS = [ 'deagle', 'usp', 'glock', 'p228', 'elite', 'fiveseven', 'awp',
|
23
|
+
'ak47', 'm4a1', 'aug', 'sg552', 'sg550', 'galil', 'famas',
|
24
|
+
'scout', 'g3sg1', 'p90', 'mp5navy', 'tmp', 'mac10', 'ump45',
|
25
|
+
'm3', 'xm1014', 'm249', 'knife', 'grenade' ]
|
26
|
+
|
27
|
+
# Returns statistics about the last match the player played
|
28
|
+
#
|
29
|
+
# @return [Hash<Symbol, Object>] The stats of the last match
|
30
|
+
attr_reader :last_match_stats
|
31
|
+
|
32
|
+
# Returns overall statistics of this player
|
33
|
+
#
|
34
|
+
# @return [Hash<Symbol, Object>] The overall statistics
|
35
|
+
attr_reader :total_stats
|
36
|
+
|
37
|
+
# Creates a `CSSStats` instance by calling the super constructor
|
38
|
+
# with the game name `'cs:s'`
|
39
|
+
#
|
40
|
+
# @param [String, Fixnum] steam_id The custom URL or 64bit Steam ID of the
|
41
|
+
# user
|
42
|
+
# @macro cacheable
|
43
|
+
def initialize(steam_id)
|
44
|
+
super steam_id, 'cs:s'
|
45
|
+
|
46
|
+
if public?
|
47
|
+
last_match_data = @xml_data['stats']['lastmatch']
|
48
|
+
lifetime_data = @xml_data['stats']['lifetime']
|
49
|
+
summary_data = @xml_data['stats']['summary']
|
50
|
+
|
51
|
+
@last_match_stats = {}
|
52
|
+
@total_stats = {}
|
53
|
+
|
54
|
+
@last_match_stats[:cost_per_kill] = last_match_data['costkill'].to_f
|
55
|
+
@last_match_stats[:ct_wins] = last_match_data['ct_wins'].to_i
|
56
|
+
@last_match_stats[:damage] = last_match_data['dmg'].to_i
|
57
|
+
@last_match_stats[:deaths] = last_match_data['deaths'].to_i
|
58
|
+
@last_match_stats[:dominations] = last_match_data['dominations'].to_i
|
59
|
+
@last_match_stats[:favorite_weapon_id] = last_match_data['favwpnid'].to_i
|
60
|
+
@last_match_stats[:kills] = last_match_data['kills'].to_i
|
61
|
+
@last_match_stats[:max_players] = last_match_data['max_players'].to_i
|
62
|
+
@last_match_stats[:money] = last_match_data['money'].to_i
|
63
|
+
@last_match_stats[:revenges] = last_match_data['revenges'].to_i
|
64
|
+
@last_match_stats[:stars] = last_match_data['stars'].to_i
|
65
|
+
@last_match_stats[:t_wins] = last_match_data['t_wins'].to_i
|
66
|
+
@last_match_stats[:wins] = last_match_data['wins'].to_i
|
67
|
+
|
68
|
+
@total_stats[:blind_kills] = lifetime_data['blindkills'].to_i
|
69
|
+
@total_stats[:bombs_defused] = lifetime_data['bombsdefused'].to_i
|
70
|
+
@total_stats[:bombs_planted] = lifetime_data['bombsplanted'].to_i
|
71
|
+
@total_stats[:damage] = lifetime_data['dmg'].to_i
|
72
|
+
@total_stats[:deaths] = summary_data['deaths'].to_i
|
73
|
+
@total_stats[:domination_overkills] = lifetime_data['dominationoverkills'].to_i
|
74
|
+
@total_stats[:dominations] = lifetime_data['dominations'].to_i
|
75
|
+
@total_stats[:earned_money] = lifetime_data['money'].to_i
|
76
|
+
@total_stats[:enemy_weapon_kills] = lifetime_data['enemywpnkills'].to_i
|
77
|
+
@total_stats[:headshots] = lifetime_data['headshots'].to_i
|
78
|
+
@total_stats[:hits] = summary_data['shotshit'].to_i
|
79
|
+
@total_stats[:hostages_rescued] = lifetime_data['hostagesrescued'].to_i
|
80
|
+
@total_stats[:kills] = summary_data['kills'].to_i
|
81
|
+
@total_stats[:knife_kills] = lifetime_data['knifekills'].to_i
|
82
|
+
@total_stats[:logos_sprayed] = lifetime_data['decals'].to_i
|
83
|
+
@total_stats[:nightvision_damage] = lifetime_data['nvgdmg'].to_i
|
84
|
+
@total_stats[:pistol_rounds_won] = lifetime_data['pistolrounds'].to_i
|
85
|
+
@total_stats[:revenges] = lifetime_data['revenges'].to_i
|
86
|
+
@total_stats[:rounds_played] = summary_data['rounds'].to_i
|
87
|
+
@total_stats[:rounds_won] = summary_data['wins'].to_i
|
88
|
+
@total_stats[:seconds_played] = summary_data['timeplayed'].to_i
|
89
|
+
@total_stats[:shots] = summary_data['shots'].to_i
|
90
|
+
@total_stats[:stars] = summary_data['stars'].to_i
|
91
|
+
@total_stats[:weapons_donated] = lifetime_data['wpndonated'].to_i
|
92
|
+
@total_stats[:windows_broken] = lifetime_data['winbroken'].to_i
|
93
|
+
@total_stats[:zoomed_sniper_kills] = lifetime_data['zsniperkills'].to_i
|
94
|
+
|
95
|
+
@last_match_stats[:kdratio] = (@total_stats[:deaths] > 0) ? @last_match_stats[:kills].to_f / @last_match_stats[:deaths] : 0
|
96
|
+
@total_stats[:accuracy] = (@total_stats[:shots] > 0) ? @total_stats[:hits].to_f / @total_stats[:shots] : 0
|
97
|
+
@total_stats[:kdratio] = (@total_stats[:deaths] > 0) ? @total_stats[:kills].to_f / @total_stats[:deaths] : 0
|
98
|
+
@total_stats[:rounds_lost] = @total_stats[:rounds_played] - @total_stats[:rounds_won]
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
# Returns a map of `CSSMap` for this user containing all CS:S maps.
|
103
|
+
#
|
104
|
+
# If the maps haven't been parsed already, parsing is done now.
|
105
|
+
#
|
106
|
+
# @return [Hash<String, Object>] The map statistics for this user
|
107
|
+
def map_stats
|
108
|
+
return unless public?
|
109
|
+
|
110
|
+
if @map_stats.nil?
|
111
|
+
@map_stats = {}
|
112
|
+
maps_data = @xml_data['stats']['maps']
|
113
|
+
|
114
|
+
MAPS.each do |map_name|
|
115
|
+
@map_stats[map_name] = CSSMap.new(map_name, maps_data)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
@map_stats
|
120
|
+
end
|
121
|
+
|
122
|
+
# Returns a map of `CSSWeapon` for this user containing all CS:S weapons.
|
123
|
+
#
|
124
|
+
# If the weapons haven't been parsed already, parsing is done now.
|
125
|
+
#
|
126
|
+
# @return [Hash<String, Object>] The weapon statistics for this user
|
127
|
+
def weapon_stats
|
128
|
+
return unless public?
|
129
|
+
|
130
|
+
if @weapon_stats.nil?
|
131
|
+
@weapon_stats = {}
|
132
|
+
weapons_data = @xml_data['stats']['weapons']
|
133
|
+
|
134
|
+
WEAPONS.each do |weapon_name|
|
135
|
+
@weapon_stats[weapon_name] = CSSWeapon.new(weapon_name, weapons_data)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
@weapon_stats
|
140
|
+
end
|
141
|
+
|
142
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# This code is free software; you can redistribute it and/or modify it under
|
2
|
+
# the terms of the new BSD License.
|
3
|
+
#
|
4
|
+
# Copyright (c) 2010-2011, Sebastian Staudt
|
5
|
+
|
6
|
+
# Represents the stats for a Counter-Strike: Source weapon for a specific user
|
7
|
+
#
|
8
|
+
# @author Sebastian Staudt
|
9
|
+
class CSSWeapon
|
10
|
+
|
11
|
+
# Returns the number of hits achieved with this weapon
|
12
|
+
#
|
13
|
+
# @return [Fixnum] The number of hits achieved
|
14
|
+
attr_reader :hits
|
15
|
+
|
16
|
+
# Returns the name of this weapon
|
17
|
+
#
|
18
|
+
# @return [String] The name of this weapon
|
19
|
+
attr_reader :name
|
20
|
+
|
21
|
+
# Returns the number of kills achieved with this weapon
|
22
|
+
#
|
23
|
+
# @return [Fixnum] The number of kills achieved
|
24
|
+
attr_reader :kills
|
25
|
+
|
26
|
+
# Returns the number of shots fired with this weapon
|
27
|
+
#
|
28
|
+
# @return [Fixnum] The number of shots fired
|
29
|
+
attr_reader :shots
|
30
|
+
|
31
|
+
# Creates a new instance of a Counter-Strike: Source weapon based on the
|
32
|
+
# given XML data
|
33
|
+
#
|
34
|
+
# @param [String] weapon_name The name of the weapon
|
35
|
+
# @param [Hash<String, Object>] weapons_data The XML data of all weapons
|
36
|
+
def initialize(weapon_name, weapons_data)
|
37
|
+
@name = weapon_name
|
38
|
+
|
39
|
+
@favorite = (weapons_data['favorite'] == @name)
|
40
|
+
@kills = weapons_data["#{@name}_kills"].to_i
|
41
|
+
|
42
|
+
if @name != 'grenade' && @name != 'knife'
|
43
|
+
@hits = weapons_data["#{@name}_hits"].to_i
|
44
|
+
@shots = weapons_data["#{@name}_shots"].to_i
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# Returns the accuracy of this player with this weapon
|
49
|
+
#
|
50
|
+
# @return [Float] The accuracy with this weapon
|
51
|
+
def accuracy
|
52
|
+
(@shots > 0) ? @hits.to_f / @shots : 0
|
53
|
+
end
|
54
|
+
|
55
|
+
# Returns whether this weapon is the favorite weapon of this player
|
56
|
+
#
|
57
|
+
# @return [Boolean] `true` if this is the favorite weapon
|
58
|
+
def favorite?
|
59
|
+
@favorite
|
60
|
+
end
|
61
|
+
|
62
|
+
# Returns the kill-shot-ratio of this player with this weapon
|
63
|
+
#
|
64
|
+
# @return [Float] The kill-shot-ratio
|
65
|
+
def ksratio
|
66
|
+
(@shots > 0) ? @kills.to_f / @shots : 0
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
@@ -0,0 +1,238 @@
|
|
1
|
+
# This code is free software; you can redistribute it and/or modify it under
|
2
|
+
# the terms of the new BSD License.
|
3
|
+
#
|
4
|
+
# Copyright (c) 2009-2011, Sebastian Staudt
|
5
|
+
|
6
|
+
require 'steam/community/game_stats'
|
7
|
+
|
8
|
+
# This class represents the game statistics for a single user in Defense Grid:
|
9
|
+
# The Awakening
|
10
|
+
#
|
11
|
+
# @author Sebastian Staudt
|
12
|
+
class DefenseGridStats < GameStats
|
13
|
+
|
14
|
+
# Returns the bronze medals won by this player
|
15
|
+
#
|
16
|
+
# @return [Fixnum] Bronze medals won
|
17
|
+
attr_reader :bronze_medals
|
18
|
+
|
19
|
+
# Returns the damage done by this player
|
20
|
+
#
|
21
|
+
# @return [Float] Damage done
|
22
|
+
attr_reader :damage_done
|
23
|
+
|
24
|
+
# Returns the damage done during the campaign by this player
|
25
|
+
#
|
26
|
+
# @return [Float] Damage done during the campaign
|
27
|
+
attr_reader :damage_campaign
|
28
|
+
|
29
|
+
# Returns the damage done during challenges by this player
|
30
|
+
#
|
31
|
+
# @return [Float] Damage done during challenges
|
32
|
+
attr_reader :damage_challenge
|
33
|
+
|
34
|
+
# Returns the aliens encountered by this player
|
35
|
+
#
|
36
|
+
# @return [Fixnum] Aliens encountered
|
37
|
+
attr_reader :encountered
|
38
|
+
|
39
|
+
# Returns the gold medals won by this player
|
40
|
+
#
|
41
|
+
# @return [Fixnum] Gold medals won
|
42
|
+
attr_reader :gold_medals
|
43
|
+
|
44
|
+
# Returns the heat damage done by this player
|
45
|
+
#
|
46
|
+
# @return [Float] Heat damage done
|
47
|
+
attr_reader :heat_damage
|
48
|
+
|
49
|
+
# Returns the interest gained by the player
|
50
|
+
#
|
51
|
+
# @return [Fixnum] Interest gained
|
52
|
+
attr_reader :interest
|
53
|
+
|
54
|
+
# Returns the aliens killed by the player
|
55
|
+
#
|
56
|
+
# @return [Fixnum] Aliens killed
|
57
|
+
attr_reader :killed
|
58
|
+
|
59
|
+
# Returns the aliens killed during the campaign by the player
|
60
|
+
#
|
61
|
+
# @return [Fixnum] Aliens killed during the campaign
|
62
|
+
attr_reader :killed_campaign
|
63
|
+
|
64
|
+
# Returns the aliens killed during challenges by the player
|
65
|
+
#
|
66
|
+
# @return [Fixnum] Aliens killed during challenges
|
67
|
+
attr_reader :killed_challenge
|
68
|
+
|
69
|
+
# Returns the number of levels played by the player
|
70
|
+
#
|
71
|
+
# @return [Fixnum] Number of levels played
|
72
|
+
attr_reader :levels_played
|
73
|
+
|
74
|
+
# Returns the number of levels played during the campaign by the player
|
75
|
+
#
|
76
|
+
# @return [Fixnum] Number of levels played during the campaign
|
77
|
+
attr_reader :levels_played_campaign
|
78
|
+
|
79
|
+
# Returns the number of levels played during challenges by the player
|
80
|
+
#
|
81
|
+
# @return [Fixnum] Number of levels played during challenges
|
82
|
+
attr_reader :levels_played_challenge
|
83
|
+
|
84
|
+
# Returns the number of levels won by the player
|
85
|
+
#
|
86
|
+
# @return [Fixnum] Number of levels won
|
87
|
+
attr_reader :levels_won
|
88
|
+
|
89
|
+
# Returns the number of levels won during the campaign by the player
|
90
|
+
#
|
91
|
+
# @return [Fixnum] Number of levels during the campaign won
|
92
|
+
attr_reader :levels_won_campaign
|
93
|
+
|
94
|
+
# Returns the number of levels won during challenges by the player
|
95
|
+
#
|
96
|
+
# @return [Fixnum] Number of levels during challenges won
|
97
|
+
attr_reader :levels_won_challenge
|
98
|
+
|
99
|
+
# Returns the damage dealt by the orbital laser
|
100
|
+
#
|
101
|
+
# @return [Float] Damage dealt by the orbital laser
|
102
|
+
attr_reader :orbital_laser_fired
|
103
|
+
|
104
|
+
# Returns the number of times the orbital lasers has been fired by the player
|
105
|
+
#
|
106
|
+
# @return [Fixnum] Number of times the orbital laser has been fired
|
107
|
+
attr_reader :orbital_laser_damage
|
108
|
+
|
109
|
+
# Returns the amount of resources harvested by the player
|
110
|
+
#
|
111
|
+
# @return [Fixnum] Resources harvested by the player
|
112
|
+
attr_reader :resources
|
113
|
+
|
114
|
+
# Returns the silver medals won by this player
|
115
|
+
#
|
116
|
+
# @return [Fixnum] Silver medals won
|
117
|
+
attr_reader :silver_medals
|
118
|
+
|
119
|
+
# Returns the time played in seconds by the player
|
120
|
+
#
|
121
|
+
# @return [Float] Time played
|
122
|
+
attr_reader :time_played
|
123
|
+
|
124
|
+
# Creates a `DefenseGridStats` instance by calling the super constructor with
|
125
|
+
# the game name `'defensegrid:awakening'`
|
126
|
+
#
|
127
|
+
# @param [String, Fixnum] steam_id The custom URL or the 64bit Steam ID of
|
128
|
+
# the user
|
129
|
+
# @macro cacheable
|
130
|
+
def initialize(steam_id)
|
131
|
+
super(steam_id, 'defensegrid:awakening')
|
132
|
+
|
133
|
+
if public?
|
134
|
+
general_data = @xml_data['stats']['general']
|
135
|
+
|
136
|
+
@bronze_medals = general_data['bronze_medals_won']['value'].to_i
|
137
|
+
@silver_medals = general_data['silver_medals_won']['value'].to_i
|
138
|
+
@gold_medals = general_data['gold_medals_won']['value'].to_i
|
139
|
+
@levels_played = general_data['levels_played_total']['value'].to_i
|
140
|
+
@levels_played_campaign = general_data['levels_played_campaign']['value'].to_i
|
141
|
+
@levels_played_challenge = general_data['levels_played_challenge']['value'].to_i
|
142
|
+
@levels_won = general_data['levels_won_total']['value'].to_i
|
143
|
+
@levels_won_campaign = general_data['levels_won_campaign']['value'].to_i
|
144
|
+
@levels_won_challenge = general_data['levels_won_challenge']['value'].to_i
|
145
|
+
@encountered = general_data['total_aliens_encountered']['value'].to_i
|
146
|
+
@killed = general_data['total_aliens_killed']['value'].to_i
|
147
|
+
@killed_campaign = general_data['total_aliens_killed_campaign']['value'].to_i
|
148
|
+
@killed_challenge = general_data['total_aliens_killed_challenge']['value'].to_i
|
149
|
+
@resources = general_data['resources_recovered']['value'].to_i
|
150
|
+
@heat_damage = general_data['heatdamage']['value'].to_f
|
151
|
+
@time_played = general_data['time_played']['value'].to_f
|
152
|
+
@interest = general_data['interest_gained']['value'].to_f
|
153
|
+
@damage_done = general_data['tower_damage_total']['value'].to_f
|
154
|
+
@damage_campaign = general_data['tower_damage_total_campaign']['value'].to_f
|
155
|
+
@damage_challenge = general_data['tower_damage_total_challenge']['value'].to_f
|
156
|
+
@orbital_laser_fired = @xml_data['stats']['orbitallaser']['fired']['value'].to_i
|
157
|
+
@orbital_laser_damage = @xml_data['stats']['orbitallaser']['damage']['value'].to_f
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
# Returns stats about the aliens encountered by the player
|
162
|
+
#
|
163
|
+
# The Hash returned uses the names of the aliens as keys. Every value of the
|
164
|
+
# Hash is an Array containing the number of aliens encountered as the first
|
165
|
+
# element and the number of aliens killed as the second element.
|
166
|
+
#
|
167
|
+
# @return [Hash<String, Array<Fixnum>>] Stats about the aliens encountered
|
168
|
+
def alien_stats
|
169
|
+
return unless public?
|
170
|
+
|
171
|
+
if @alien_stats.nil?
|
172
|
+
alien_data = @xml_data['stats']['aliens']
|
173
|
+
@alien_stats = {}
|
174
|
+
aliens = %w{swarmer juggernaut crasher spire grunt bulwark drone manta dart
|
175
|
+
decoy rumbler seeker turtle walker racer stealth}
|
176
|
+
|
177
|
+
aliens.each do |alien|
|
178
|
+
@alien_stats[alien] = [
|
179
|
+
alien_data[alien]['encountered']['value'].to_i,
|
180
|
+
alien_data[alien]['killed']['value'].to_i
|
181
|
+
]
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
@alien_stats
|
186
|
+
end
|
187
|
+
|
188
|
+
# Returns stats about the towers built by the player
|
189
|
+
#
|
190
|
+
# The Hash returned uses the names of the towers as keys. Every value of
|
191
|
+
# the Hash is another Hash using the keys 1 to 3 for different tower levels.
|
192
|
+
# The values of these Hash is an Array containing the number of towers built
|
193
|
+
# as the first element and the damage dealt by this specific tower type as the
|
194
|
+
# second element.
|
195
|
+
#
|
196
|
+
# The Command tower uses the resources gained as second element.
|
197
|
+
# The Temporal tower doesn't have a second element.
|
198
|
+
#
|
199
|
+
# @return [Hash<String, Array<Fixnum>>] Stats about the towers built
|
200
|
+
def tower_stats
|
201
|
+
return unless public?
|
202
|
+
|
203
|
+
if @tower_stats.nil?
|
204
|
+
tower_data = @xml_data['stats']['towers']
|
205
|
+
@tower_stats = {}
|
206
|
+
towers = %w{cannon flak gun inferno laser meteor missile tesla}
|
207
|
+
|
208
|
+
towers.each do |tower|
|
209
|
+
@tower_stats[tower] = {}
|
210
|
+
(1..3).each do |i|
|
211
|
+
tower_level = tower_data[tower].detect { |t| t['level'].to_i == i }
|
212
|
+
@tower_stats[tower][i] = [
|
213
|
+
tower_level['built']['value'].to_i,
|
214
|
+
tower_level['damage']['value'].to_f
|
215
|
+
]
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
@tower_stats['command'] = {}
|
220
|
+
(1..3).each do |i|
|
221
|
+
tower_level = tower_data['command'].detect { |t| t['level'].to_i == i }
|
222
|
+
@tower_stats['command'][i] = [
|
223
|
+
tower_level['built']['value'].to_i,
|
224
|
+
tower_level['resource']['value'].to_f
|
225
|
+
]
|
226
|
+
end
|
227
|
+
|
228
|
+
@tower_stats['temporal'] = {}
|
229
|
+
(1..3).each do |i|
|
230
|
+
tower_level = tower_data['temporal'].detect { |t| t['level'].to_i == i }
|
231
|
+
@tower_stats['temporal'][i] = [ tower_level['built']['value'].to_i ]
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
@tower_stats
|
236
|
+
end
|
237
|
+
|
238
|
+
end
|