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,90 @@
|
|
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_class'
|
7
|
+
|
8
|
+
# Represents the stats for a Day of Defeat: Source class for a specific user
|
9
|
+
#
|
10
|
+
# @author Sebastian Staudt
|
11
|
+
class DoDSClass
|
12
|
+
|
13
|
+
include GameClass
|
14
|
+
|
15
|
+
# Returns the blocks achieved by the player with this class
|
16
|
+
#
|
17
|
+
# @return [Fixnum] The blocks achieved by the player
|
18
|
+
attr_reader :blocks
|
19
|
+
|
20
|
+
# Returns the bombs defused by the player with this class
|
21
|
+
#
|
22
|
+
# @return [Fixnum] The bombs defused by the player
|
23
|
+
attr_reader :bombs_defused
|
24
|
+
|
25
|
+
# Returns the bombs planted by the player with this class
|
26
|
+
#
|
27
|
+
# @return [Fixnum] the bombs planted by the player
|
28
|
+
attr_reader :bombs_planted
|
29
|
+
|
30
|
+
# Returns the number of points captured by the player with this class
|
31
|
+
#
|
32
|
+
# @return [Fixnum] The number of points captured by the player
|
33
|
+
attr_reader :captures
|
34
|
+
|
35
|
+
# Returns the number of times the player died with this class
|
36
|
+
#
|
37
|
+
# @return [Fixnum] The number of deaths by the player
|
38
|
+
attr_reader :deaths
|
39
|
+
|
40
|
+
# Returns the dominations achieved by the player with this class
|
41
|
+
#
|
42
|
+
# @return [Fixnum] The dominations achieved by the player
|
43
|
+
attr_reader :dominations
|
44
|
+
|
45
|
+
# Returns the ID of this class
|
46
|
+
#
|
47
|
+
# @return [String] The ID of this class
|
48
|
+
attr_reader :key
|
49
|
+
|
50
|
+
# Returns the number of enemies killed by the player with this class
|
51
|
+
#
|
52
|
+
# @return [Fixnum] The number of enemies killed by the player
|
53
|
+
attr_reader :kills
|
54
|
+
|
55
|
+
# Returns the number of rounds lost with this class
|
56
|
+
#
|
57
|
+
# @return [Fixnum] The number of rounds lost with this class
|
58
|
+
attr_reader :rounds_lost
|
59
|
+
|
60
|
+
# Returns the revenges achieved by the player with this class
|
61
|
+
#
|
62
|
+
# @return [Fixnum] The revenges achieved by the player
|
63
|
+
attr_reader :revenges
|
64
|
+
|
65
|
+
# Returns the number of rounds won with this class
|
66
|
+
#
|
67
|
+
# @return [Fixnum] The number of rounds won with this class
|
68
|
+
attr_reader :rounds_won
|
69
|
+
|
70
|
+
# Creates a new instance of a Day of Defeat: Source class based on the given
|
71
|
+
# XML data
|
72
|
+
#
|
73
|
+
# @param [Hash<String, Object>] class_data The XML data of the class
|
74
|
+
def initialize(class_data)
|
75
|
+
@blocks = class_data['blocks'].to_i
|
76
|
+
@bombs_defused = class_data['bombsdefused'].to_i
|
77
|
+
@bombs_planted = class_data['bombsplanted'].to_i
|
78
|
+
@captures = class_data['captures'].to_i
|
79
|
+
@deaths = class_data['deaths'].to_i
|
80
|
+
@dominations = class_data['dominations'].to_i
|
81
|
+
@key = class_data['key']
|
82
|
+
@kills = class_data['kills'].to_i
|
83
|
+
@name = class_data['name']
|
84
|
+
@play_time = class_data['playtime'].to_i
|
85
|
+
@rounds_lost = class_data['roundslost'].to_i
|
86
|
+
@rounds_won = class_data['roundswon'].to_i
|
87
|
+
@revenges = class_data['revenges'].to_i
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
@@ -0,0 +1,62 @@
|
|
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/dods/dods_class'
|
7
|
+
require 'steam/community/dods/dods_weapon'
|
8
|
+
require 'steam/community/game_stats'
|
9
|
+
|
10
|
+
# The is class represents the game statistics for a single user in Day of
|
11
|
+
# Defeat: Source
|
12
|
+
#
|
13
|
+
# @author Sebastian Staudt
|
14
|
+
class DoDSStats < GameStats
|
15
|
+
|
16
|
+
# Creates a `DoDSStats` instance by calling the super constructor with the
|
17
|
+
# game name `'DoD:S'`
|
18
|
+
#
|
19
|
+
# @param [String, Fixnum] steam_id The custom URL or 64bit Steam ID of the
|
20
|
+
# user
|
21
|
+
# @macro cacheable
|
22
|
+
def initialize(steam_id)
|
23
|
+
super steam_id, 'DoD:S'
|
24
|
+
end
|
25
|
+
|
26
|
+
# Returns a hash of `DoDSClass` for this user containing all DoD:S classes.
|
27
|
+
#
|
28
|
+
# If the classes haven't been parsed already, parsing is done now.
|
29
|
+
#
|
30
|
+
# @return [Hash<String, DoDSClass>] The class statistics for this user
|
31
|
+
def class_stats
|
32
|
+
return unless public?
|
33
|
+
|
34
|
+
if @class_stats.nil?
|
35
|
+
@class_stats = {}
|
36
|
+
@xml_data['stats']['classes']['class'].each do |class_data|
|
37
|
+
@class_stats[class_data['key']] = DoDSClass.new class_data
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
@class_stats
|
42
|
+
end
|
43
|
+
|
44
|
+
# Returns a Hash of `DoDSWeapon` for this user containing all DoD:S weapons.
|
45
|
+
#
|
46
|
+
# If the weapons haven't been parsed already, parsing is done now.
|
47
|
+
#
|
48
|
+
# @return [Hash<String, DoDSWeapon>] The weapon statistics for this user
|
49
|
+
def weapon_stats
|
50
|
+
return unless public?
|
51
|
+
|
52
|
+
if @weapon_stats.nil?
|
53
|
+
@weapon_stats = {}
|
54
|
+
@xml_data['stats']['weapons']['weapon'].each do |weapon_data|
|
55
|
+
@weapon_stats[weapon_data['key']] = DoDSWeapon.new weapon_data
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
@weapon_stats
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
@@ -0,0 +1,67 @@
|
|
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_weapon'
|
7
|
+
|
8
|
+
# Represents the stats for a Day of Defeat: Source weapon for a specific user
|
9
|
+
#
|
10
|
+
# @author Sebastian Staudt
|
11
|
+
class DoDSWeapon
|
12
|
+
|
13
|
+
include GameWeapon
|
14
|
+
|
15
|
+
# Returns the number of headshots achieved with this weapon
|
16
|
+
#
|
17
|
+
# @return [Fixnum] The number of headshots achieved
|
18
|
+
attr_reader :headshots
|
19
|
+
|
20
|
+
# Returns the name of this weapon
|
21
|
+
#
|
22
|
+
# @return [String] The name of this weapon
|
23
|
+
attr_reader :name
|
24
|
+
|
25
|
+
# Returns the number of hits achieved with this weapon
|
26
|
+
#
|
27
|
+
# @return [Fixnum] The number of hits achieved
|
28
|
+
attr_reader :hits
|
29
|
+
|
30
|
+
# Creates a new instance of a Day of Defeat: Source weapon based on the
|
31
|
+
# given XML data
|
32
|
+
#
|
33
|
+
# @param [Hash<String, Object>] weapon_data The XML data of the class
|
34
|
+
def initialize(weapon_data)
|
35
|
+
super weapon_data
|
36
|
+
|
37
|
+
@headshots = weapon_data['headshots'].to_i
|
38
|
+
@id = weapon_data['key']
|
39
|
+
@name = weapon_data['name']
|
40
|
+
@shots = weapon_data['shotsfired'].to_i
|
41
|
+
@hits = weapon_data['shotshit'].to_i
|
42
|
+
end
|
43
|
+
|
44
|
+
# Returns the average number of hits needed for a kill with this weapon
|
45
|
+
#
|
46
|
+
# @return [Float] The average number of hits needed for a kill
|
47
|
+
def avg_hits_per_kill
|
48
|
+
@hits.to_f / @kill
|
49
|
+
end
|
50
|
+
|
51
|
+
# Returns the percentage of headshots relative to the shots hit with this
|
52
|
+
# weapon
|
53
|
+
#
|
54
|
+
# @return [Float] The percentage of headshots
|
55
|
+
def headshot_percentage
|
56
|
+
@headshots.to_f / @hits
|
57
|
+
end
|
58
|
+
|
59
|
+
# Returns the percentage of hits relative to the shots fired with this
|
60
|
+
# weapon
|
61
|
+
#
|
62
|
+
# @return [Float] The percentage of hits
|
63
|
+
def hit_percentage
|
64
|
+
@hits.to_f / @shots
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
@@ -0,0 +1,30 @@
|
|
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) 2012, Sebastian Staudt
|
5
|
+
|
6
|
+
require 'steam/community/dota2/dota2_item'
|
7
|
+
require 'steam/community/game_inventory'
|
8
|
+
|
9
|
+
# Represents the inventory of a player of the DotA 2 beta
|
10
|
+
#
|
11
|
+
# @author Sebastian Staudt
|
12
|
+
class Dota2BetaInventory < GameInventory
|
13
|
+
|
14
|
+
# The Steam application ID of the DotA 2 beta
|
15
|
+
APP_ID = 205790
|
16
|
+
|
17
|
+
# Creates a new inventory object for the given SteamID64 in the DotA 2 beta
|
18
|
+
# (App ID 205790)
|
19
|
+
#
|
20
|
+
# @param [Fixnum] steam_id64 The 64bit SteamID of the player to get the
|
21
|
+
# inventory for
|
22
|
+
# @macro cacheable
|
23
|
+
def initialize(steam_id64)
|
24
|
+
super APP_ID, steam_id64
|
25
|
+
end
|
26
|
+
|
27
|
+
# The class representing DotA 2 items
|
28
|
+
@@item_class = Dota2Item
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
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) 2012, Sebastian Staudt
|
5
|
+
|
6
|
+
require 'steam/community/dota2/dota2_item'
|
7
|
+
require 'steam/community/game_inventory'
|
8
|
+
|
9
|
+
# Represents the inventory of a DotA 2 player
|
10
|
+
#
|
11
|
+
# @author Sebastian Staudt
|
12
|
+
class Dota2Inventory < GameInventory
|
13
|
+
|
14
|
+
# The Steam application ID of DotA 2
|
15
|
+
APP_ID = 570
|
16
|
+
|
17
|
+
# Creates a new inventory object for the given SteamID64 in DotA 2
|
18
|
+
# (App ID 570)
|
19
|
+
#
|
20
|
+
# @param [Fixnum] steam_id64 The 64bit SteamID of the player to get the
|
21
|
+
# inventory for
|
22
|
+
# @macro cacheable
|
23
|
+
def initialize(steam_id64)
|
24
|
+
super APP_ID, steam_id64
|
25
|
+
end
|
26
|
+
|
27
|
+
# The class representing DotA 2 items
|
28
|
+
@@item_class = Dota2Item
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,33 @@
|
|
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) 2012, Sebastian Staudt
|
5
|
+
|
6
|
+
require 'steam/community/game_item'
|
7
|
+
|
8
|
+
# Represents a DotA 2 item
|
9
|
+
#
|
10
|
+
# @author Sebastian Staudt
|
11
|
+
class Dota2Item
|
12
|
+
|
13
|
+
include GameItem
|
14
|
+
|
15
|
+
# Creates a new instance of a DotA 2 item with the given data
|
16
|
+
#
|
17
|
+
# @param [Dota2Inventory] inventory The inventory this item is contained in
|
18
|
+
# @param [Hash<Symbol, Object>] item_data The data specifying this item
|
19
|
+
# @raise [WebApiError] on Web API errors
|
20
|
+
def initialize(inventory, item_data)
|
21
|
+
super
|
22
|
+
|
23
|
+
@equipped = !item_data[:equipped].nil?
|
24
|
+
end
|
25
|
+
|
26
|
+
# Returns whether this item is equipped by this player at all
|
27
|
+
#
|
28
|
+
# @return [Boolean] Whether this item is equipped by this player at all
|
29
|
+
def equipped?
|
30
|
+
@equipped
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,109 @@
|
|
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) 2008-2012, Sebastian Staudt
|
5
|
+
|
6
|
+
require 'multi_json'
|
7
|
+
|
8
|
+
require 'steam/community/web_api'
|
9
|
+
|
10
|
+
# The GameAchievement class represents a specific achievement for a single game
|
11
|
+
# and for a single user
|
12
|
+
#
|
13
|
+
# It also provides the ability to load the global unlock percentages of all
|
14
|
+
# achievements of a specific game.
|
15
|
+
#
|
16
|
+
# @author Sebastian Staudt
|
17
|
+
class GameAchievement
|
18
|
+
|
19
|
+
# Returns the symbolic API name of this achievement
|
20
|
+
#
|
21
|
+
# @return [String] The API name of this achievement
|
22
|
+
attr_reader :api_name
|
23
|
+
|
24
|
+
# Returns the description of this achievement
|
25
|
+
#
|
26
|
+
# @return [String] The description of this achievement
|
27
|
+
attr_reader :description
|
28
|
+
|
29
|
+
# Return the game this achievement belongs to
|
30
|
+
#
|
31
|
+
# @return [Steam] The game this achievement belongs to
|
32
|
+
attr_reader :game
|
33
|
+
|
34
|
+
# Returns the url for the closed icon of this achievement
|
35
|
+
#
|
36
|
+
# @return [String] The url of the closed achievement icon
|
37
|
+
attr_reader :icon_closed_url
|
38
|
+
|
39
|
+
# Returns the url for the open icon of this achievement
|
40
|
+
#
|
41
|
+
# @return [String] The url of the open achievement icon
|
42
|
+
attr_reader :icon_open_url
|
43
|
+
|
44
|
+
# Returns the name of this achievement
|
45
|
+
#
|
46
|
+
# @return [String] The name of this achievement
|
47
|
+
attr_reader :name
|
48
|
+
|
49
|
+
# Returns the time this achievement has been unlocked by its owner
|
50
|
+
#
|
51
|
+
# @return [Time] The time this achievement has been unlocked
|
52
|
+
attr_reader :timestamp
|
53
|
+
|
54
|
+
# Returns the SteamID of the user who owns this achievement
|
55
|
+
#
|
56
|
+
# @return [Fixnum] The SteamID of this achievement's owner
|
57
|
+
attr_reader :user
|
58
|
+
|
59
|
+
# Loads the global unlock percentages of all achievements for the game with
|
60
|
+
# the given Steam Application ID
|
61
|
+
#
|
62
|
+
# @param [Fixnum] app_id The unique Steam Application ID of the game (e.g.
|
63
|
+
# `440` for Team Fortress 2). See
|
64
|
+
# http://developer.valvesoftware.com/wiki/Steam_Application_IDs for
|
65
|
+
# all application IDs
|
66
|
+
# @raise [WebApiError] if the request to Steam's Web API fails
|
67
|
+
# @return [Hash<Symbol, Float>] The symbolic achievement names with their
|
68
|
+
# corresponding unlock percentages
|
69
|
+
def self.global_percentages(app_id)
|
70
|
+
percentages = {}
|
71
|
+
|
72
|
+
data = WebApi.json('ISteamUserStats', 'GetGlobalAchievementPercentagesForApp', 2, { :gameid => app_id })
|
73
|
+
MultiJson.load(data, { :symbolize_keys => true })[:achievementpercentages][:achievements].each do |percentage|
|
74
|
+
percentages[percentage[:name].to_sym] = percentage[:percent]
|
75
|
+
end
|
76
|
+
|
77
|
+
percentages
|
78
|
+
end
|
79
|
+
|
80
|
+
# Creates the achievement with the given name for the given user and game
|
81
|
+
# and achievement data
|
82
|
+
#
|
83
|
+
# @param [SteamId] user The SteamID of the player this achievement belongs to
|
84
|
+
# @param [SteamGame] game The game this achievement belongs to
|
85
|
+
# @param [Hash<String, Object>] achievement_data The achievement data
|
86
|
+
# extracted from XML
|
87
|
+
def initialize(user, game, achievement_data)
|
88
|
+
@api_name = achievement_data['apiname']
|
89
|
+
@description = achievement_data['description']
|
90
|
+
@game = game
|
91
|
+
@icon_closed_url = achievement_data['iconClosed']
|
92
|
+
@icon_open_url = achievement_data['iconOpen']
|
93
|
+
@name = achievement_data['name']
|
94
|
+
@unlocked = (achievement_data['closed'].to_i == 1)
|
95
|
+
@user = user
|
96
|
+
|
97
|
+
if @unlocked && !achievement_data['unlockTimestamp'].nil?
|
98
|
+
@timestamp = Time.at(achievement_data['unlockTimestamp'].to_i)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
# Returns whether this achievement has been unlocked by its owner
|
103
|
+
#
|
104
|
+
# @return [Boolean] `true` if the achievement has been unlocked by the user
|
105
|
+
def unlocked?
|
106
|
+
@unlocked
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
@@ -0,0 +1,22 @@
|
|
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
|
+
# A module implementing basic functionality for classes representing player
|
7
|
+
# classes
|
8
|
+
#
|
9
|
+
# @author Sebastian Staudt
|
10
|
+
module GameClass
|
11
|
+
|
12
|
+
# Returns the name of this class
|
13
|
+
#
|
14
|
+
# @return [String] The name of this class
|
15
|
+
attr_reader :name
|
16
|
+
|
17
|
+
# Returns the time in minutes the player has played with this class
|
18
|
+
#
|
19
|
+
# @return [Fixnum] The time this class has been played
|
20
|
+
attr_reader :play_time
|
21
|
+
|
22
|
+
end
|