steam-condenser 0.14.0 → 1.0.1
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.
- data/Gemfile +3 -0
- data/Gemfile.lock +22 -0
- data/LICENSE +1 -1
- data/README.md +14 -6
- data/Rakefile +35 -0
- data/lib/{stringio_additions.rb → core_ext/stringio.rb} +1 -1
- data/lib/{exceptions/packet_format_exception.rb → errors/packet_format_error.rb} +5 -5
- data/lib/{exceptions/rcon_ban_exception.rb → errors/rcon_ban_error.rb} +5 -5
- data/lib/{exceptions/rcon_no_auth_exception.rb → errors/rcon_no_auth_error.rb} +5 -5
- data/lib/{exceptions/steam_condenser_exception.rb → errors/steam_condenser_error.rb} +3 -3
- data/lib/errors/timeout_error.rb +28 -0
- data/lib/{exceptions/web_api_exception.rb → errors/web_api_error.rb} +8 -8
- data/lib/steam/community/alien_swarm/alien_swarm_mission.rb +86 -11
- data/lib/steam/community/alien_swarm/alien_swarm_stats.rb +38 -15
- data/lib/steam/community/alien_swarm/alien_swarm_weapon.rb +29 -8
- data/lib/steam/community/app_news.rb +91 -27
- data/lib/steam/community/cacheable.rb +65 -21
- data/lib/steam/community/css/css_map.rb +39 -9
- data/lib/steam/community/css/css_stats.rb +32 -12
- data/lib/steam/community/css/css_weapon.rb +46 -10
- data/lib/steam/community/defense_grid/defense_grid_stats.rb +129 -17
- data/lib/steam/community/dods/dods_class.rb +66 -10
- data/lib/steam/community/dods/dods_stats.rb +20 -7
- data/lib/steam/community/dods/dods_weapon.rb +35 -24
- data/lib/steam/community/game_achievement.rb +50 -19
- data/lib/steam/community/game_class.rb +16 -5
- data/lib/steam/community/game_inventory.rb +37 -4
- data/lib/steam/community/game_item.rb +64 -3
- data/lib/steam/community/game_stats.rb +81 -16
- data/lib/steam/community/game_weapon.rb +29 -11
- data/lib/steam/community/l4d/abstract_l4d_stats.rb +91 -65
- data/lib/steam/community/l4d/abstract_l4d_weapon.rb +38 -8
- data/lib/steam/community/l4d/l4d2_map.rb +30 -5
- data/lib/steam/community/l4d/l4d2_stats.rb +83 -45
- data/lib/steam/community/l4d/l4d2_weapon.rb +20 -6
- data/lib/steam/community/l4d/l4d_explosive.rb +13 -5
- data/lib/steam/community/l4d/l4d_map.rb +35 -7
- data/lib/steam/community/l4d/l4d_stats.rb +23 -10
- data/lib/steam/community/l4d/l4d_weapon.rb +11 -7
- data/lib/steam/community/portal2/portal2_inventory.rb +4 -0
- data/lib/steam/community/portal2/portal2_item.rb +13 -1
- data/lib/steam/community/portal2/portal2_stats.rb +10 -6
- data/lib/steam/community/steam_game.rb +74 -0
- data/lib/steam/community/steam_group.rb +48 -14
- data/lib/steam/community/steam_id.rb +295 -64
- data/lib/steam/community/tf2/tf2_class.rb +66 -7
- data/lib/steam/community/tf2/tf2_class_factory.rb +14 -7
- data/lib/steam/community/tf2/tf2_engineer.rb +26 -6
- data/lib/steam/community/tf2/tf2_golden_wrench.rb +37 -10
- data/lib/steam/community/tf2/tf2_inventory.rb +4 -0
- data/lib/steam/community/tf2/tf2_item.rb +13 -1
- data/lib/steam/community/tf2/tf2_medic.rb +20 -5
- data/lib/steam/community/tf2/tf2_sniper.rb +15 -5
- data/lib/steam/community/tf2/tf2_spy.rb +20 -6
- data/lib/steam/community/tf2/tf2_stats.rb +20 -6
- data/lib/steam/community/web_api.rb +50 -32
- data/lib/steam/packets/c2m_checkmd5_packet.rb +1 -1
- data/lib/steam/packets/m2a_server_batch_packet.rb +3 -2
- data/lib/steam/packets/m2s_requestrestart_packet.rb +3 -3
- data/lib/steam/packets/rcon/rcon_packet_factory.rb +4 -4
- data/lib/steam/packets/request_with_challenge.rb +1 -1
- data/lib/steam/packets/s2a_info_base_packet.rb +1 -1
- data/lib/steam/packets/s2a_info_detailed_packet.rb +10 -10
- data/lib/steam/packets/s2a_player_packet.rb +5 -1
- data/lib/steam/packets/s2a_rules_packet.rb +4 -3
- data/lib/steam/packets/s2m_heartbeat2_packet.rb +2 -2
- data/lib/steam/packets/steam_packet.rb +1 -1
- data/lib/steam/packets/steam_packet_factory.rb +12 -16
- data/lib/steam/servers/game_server.rb +38 -32
- data/lib/steam/servers/goldsrc_server.rb +10 -1
- data/lib/steam/servers/master_server.rb +42 -21
- data/lib/steam/servers/server.rb +4 -5
- data/lib/steam/servers/source_server.rb +20 -5
- data/lib/steam/sockets/goldsrc_socket.rb +53 -22
- data/lib/steam/sockets/master_server_socket.rb +14 -4
- data/lib/steam/sockets/rcon_socket.rb +39 -6
- data/lib/steam/sockets/source_socket.rb +19 -15
- data/lib/steam/sockets/steam_socket.rb +33 -23
- data/lib/steam/steam_player.rb +86 -11
- data/lib/steam-condenser/community.rb +24 -24
- data/lib/steam-condenser/servers.rb +2 -2
- data/lib/steam-condenser/version.rb +3 -3
- data/steam-condenser.gemspec +23 -0
- data/test/query_tests.rb +12 -12
- data/test/rcon_tests.rb +3 -3
- data/test/steam/communtiy/steam_community_test_suite.rb +12 -0
- data/test/steam/communtiy/steam_group_tests.rb +6 -5
- data/test/steam/communtiy/steam_id_tests.rb +6 -5
- data/test/steam_community_tests.rb +3 -3
- data/test/stringio_additions_tests.rb +7 -7
- metadata +61 -43
- data/lib/exceptions/timeout_exception.rb +0 -24
- data/test/datagram_channel_tests.rb +0 -42
- data/test/socket_channel_tests.rb +0 -43
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
steam-condenser (1.0.0)
|
|
5
|
+
bzip2-ruby (~> 0.2.7)
|
|
6
|
+
multi_json (~> 1.0.3)
|
|
7
|
+
|
|
8
|
+
GEM
|
|
9
|
+
remote: http://rubygems.org/
|
|
10
|
+
specs:
|
|
11
|
+
bzip2-ruby (0.2.7)
|
|
12
|
+
multi_json (1.0.3)
|
|
13
|
+
rake (0.9.2)
|
|
14
|
+
yard (0.7.2)
|
|
15
|
+
|
|
16
|
+
PLATFORMS
|
|
17
|
+
ruby
|
|
18
|
+
|
|
19
|
+
DEPENDENCIES
|
|
20
|
+
rake (~> 0.9.2)
|
|
21
|
+
steam-condenser!
|
|
22
|
+
yard (~> 0.7.2)
|
data/LICENSE
CHANGED
data/README.md
CHANGED
|
@@ -10,9 +10,16 @@ Currently it is implemented in Java, PHP and Ruby.
|
|
|
10
10
|
* Linux, MacOS X or Windows
|
|
11
11
|
* Ruby 1.8.6 or newer
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
The following gems are required:
|
|
14
|
+
|
|
15
|
+
* `bzip2-ruby` (for Source servers sending compressed responses)
|
|
16
|
+
* `json` (for the Web API features)
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
To install Steam Condenser as a Ruby gem use the following command:
|
|
21
|
+
|
|
22
|
+
gem install steam-condenser
|
|
16
23
|
|
|
17
24
|
## License
|
|
18
25
|
|
|
@@ -27,9 +34,10 @@ included LICENSE file.
|
|
|
27
34
|
|
|
28
35
|
## See Also
|
|
29
36
|
|
|
30
|
-
* [Steam Condenser home](
|
|
31
|
-
* [Documentation](http://
|
|
32
|
-
* [GitHub project page](
|
|
37
|
+
* [Steam Condenser home](https://koraktor.de/steam-condenser)
|
|
38
|
+
* [Documentation](http://rubydoc.info/gems/steam-condenser)
|
|
39
|
+
* [GitHub project page](https://github.com/koraktor/steam-condenser)
|
|
40
|
+
* [Wiki](https://github.com/koraktor/steam-condenser/wiki)
|
|
33
41
|
* [Google group](http://groups.google.com/group/steam-condenser)
|
|
34
42
|
* [Ohloh profile](http://www.ohloh.net/projects/steam-condenser)
|
|
35
43
|
|
data/Rakefile
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
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-2011, Sebastian Staudt
|
|
5
|
+
|
|
6
|
+
require 'rubygems'
|
|
7
|
+
require 'rubygems/package_task'
|
|
8
|
+
|
|
9
|
+
Gem::PackageTask.new Gem::Specification.load 'steam-condenser.gemspec' do |pkg|
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# Check if YARD is installed
|
|
13
|
+
begin
|
|
14
|
+
require 'yard'
|
|
15
|
+
|
|
16
|
+
# Create a rake task +:doc+ to build the documentation using YARD
|
|
17
|
+
YARD::Rake::YardocTask.new do |yardoc|
|
|
18
|
+
yardoc.name = 'doc'
|
|
19
|
+
yardoc.files = [ 'lib/**/*.rb', 'LICENSE', 'README.md' ]
|
|
20
|
+
yardoc.options = [ '--private', '--title', 'Metior — API Documentation' ]
|
|
21
|
+
end
|
|
22
|
+
rescue LoadError
|
|
23
|
+
# Create a rake task +:doc+ to show that YARD is not installed
|
|
24
|
+
desc 'Generate YARD Documentation (not available)'
|
|
25
|
+
task :doc do
|
|
26
|
+
$stderr.puts 'You need YARD to build the documentation. Install it using `gem install yard`.'
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Task for cleaning documentation and package directories
|
|
31
|
+
desc 'Clean documentation and package directories'
|
|
32
|
+
task :clean do
|
|
33
|
+
FileUtils.rm_rf 'doc'
|
|
34
|
+
FileUtils.rm_rf 'pkg'
|
|
35
|
+
end
|
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
#
|
|
4
4
|
# Copyright (c) 2008-2011, Sebastian Staudt
|
|
5
5
|
|
|
6
|
-
require '
|
|
6
|
+
require 'errors/steam_condenser_error'
|
|
7
7
|
|
|
8
|
-
# This
|
|
8
|
+
# This error class indicates a problem when parsing packet data from the
|
|
9
9
|
# responses received from a game or master server
|
|
10
10
|
#
|
|
11
11
|
# @author Sebastian Staudt
|
|
12
|
-
class
|
|
12
|
+
class PacketFormatError < SteamCondenserError
|
|
13
13
|
|
|
14
|
-
# Creates a new `
|
|
14
|
+
# Creates a new `PacketFormatError` instance
|
|
15
15
|
#
|
|
16
|
-
# @param [String] message The message to attach to the
|
|
16
|
+
# @param [String] message The message to attach to the error
|
|
17
17
|
def initialize(message)
|
|
18
18
|
super message
|
|
19
19
|
end
|
|
@@ -3,18 +3,18 @@
|
|
|
3
3
|
#
|
|
4
4
|
# Copyright (c) 2009-2011, Sebastian Staudt
|
|
5
5
|
|
|
6
|
-
require '
|
|
6
|
+
require 'errors/steam_condenser_error'
|
|
7
7
|
|
|
8
|
-
# This
|
|
9
|
-
#
|
|
8
|
+
# This error class indicates that the IP address your accessing the game server
|
|
9
|
+
# from has been banned by the server
|
|
10
10
|
#
|
|
11
11
|
# You or the server operator will have to unban your IP address on the server.
|
|
12
12
|
#
|
|
13
13
|
# @author Sebastian Staudt
|
|
14
14
|
# @see GameServer#rcon_auth
|
|
15
|
-
class
|
|
15
|
+
class RCONBanError < SteamCondenserError
|
|
16
16
|
|
|
17
|
-
# Creates a new `
|
|
17
|
+
# Creates a new `RCONBanError` instance
|
|
18
18
|
def initialize
|
|
19
19
|
super 'You have been banned from this server.'
|
|
20
20
|
end
|
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
#
|
|
4
4
|
# Copyright (c) 2008-2011, Sebastian Staudt
|
|
5
5
|
|
|
6
|
-
require '
|
|
6
|
+
require 'errors/steam_condenser_error'
|
|
7
7
|
|
|
8
|
-
# This
|
|
9
|
-
#
|
|
8
|
+
# This error class indicates that you have not authenticated yet with the game
|
|
9
|
+
# server you're trying to send commands via RCON
|
|
10
10
|
#
|
|
11
11
|
# @author Sebastian Staudt
|
|
12
12
|
# @see GameServer#rcon_auth
|
|
13
13
|
# @see GameServer#rcon_exec
|
|
14
|
-
class
|
|
14
|
+
class RCONNoAuthError < SteamCondenserError
|
|
15
15
|
|
|
16
|
-
# Creates a new `
|
|
16
|
+
# Creates a new `RCONNoAuthError` instance
|
|
17
17
|
def initialize
|
|
18
18
|
super 'Not authenticated yet.'
|
|
19
19
|
end
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
#
|
|
4
4
|
# Copyright (c) 2008-2011, Sebastian Staudt
|
|
5
5
|
|
|
6
|
-
# This
|
|
7
|
-
#
|
|
6
|
+
# This error class is used as a base class for all errors related to Steam
|
|
7
|
+
# Condenser's operation
|
|
8
8
|
#
|
|
9
9
|
# @author Sebastian Staudt
|
|
10
|
-
class
|
|
10
|
+
class SteamCondenserError < StandardError
|
|
11
11
|
end
|
|
@@ -0,0 +1,28 @@
|
|
|
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-2011, Sebastian Staudt
|
|
5
|
+
|
|
6
|
+
require 'errors/steam_condenser_error'
|
|
7
|
+
|
|
8
|
+
module SteamCondenser
|
|
9
|
+
|
|
10
|
+
# This error class indicates that an operation could not be finished within a
|
|
11
|
+
# reasonable amount of time
|
|
12
|
+
#
|
|
13
|
+
# This usually indicates that a server could not be contacted because of
|
|
14
|
+
# network problems.
|
|
15
|
+
#
|
|
16
|
+
# @author Sebastian Staudt
|
|
17
|
+
# @note {SteamSocket.timeout=} allows to set a custom timeout for socket
|
|
18
|
+
# operations
|
|
19
|
+
class TimeoutError < SteamCondenserError
|
|
20
|
+
|
|
21
|
+
# Creates a new `TimeoutError` instance
|
|
22
|
+
def initialize
|
|
23
|
+
super 'The operation timed out.'
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
@@ -3,26 +3,26 @@
|
|
|
3
3
|
#
|
|
4
4
|
# Copyright (c) 2011, Sebastian Staudt
|
|
5
5
|
|
|
6
|
-
require '
|
|
6
|
+
require 'errors/steam_condenser_error'
|
|
7
7
|
|
|
8
|
-
# This
|
|
9
|
-
#
|
|
8
|
+
# This error is raised when a Steam Web API request or a related action fails.
|
|
9
|
+
# This can have various reasons like an invalid Web API key or a broken
|
|
10
10
|
# request.
|
|
11
11
|
#
|
|
12
12
|
# @author Sebastian Staudt
|
|
13
13
|
# @see WebApi
|
|
14
|
-
class
|
|
14
|
+
class WebApiError < SteamCondenserError
|
|
15
15
|
|
|
16
|
-
# Creates a new `
|
|
16
|
+
# Creates a new `WebApiError` with an error message according to the given
|
|
17
17
|
# `cause`. If this cause is `:status_bad` (which will origin from the Web API
|
|
18
18
|
# itself) or `:http_error` the details about this failed request will be
|
|
19
19
|
# taken from `status_code` and `status_message`.
|
|
20
20
|
#
|
|
21
21
|
# @param [:http_error, :invalid_key, :status_bad, :unauthorized] cause A
|
|
22
|
-
# symbolic name for the problem which caused this
|
|
22
|
+
# symbolic name for the problem which caused this error:
|
|
23
23
|
#
|
|
24
24
|
# * `:http_error`: An error during the HTTP request itself will result
|
|
25
|
-
# in an
|
|
25
|
+
# in an error with this reason.
|
|
26
26
|
# * `:invalid_key`: This occurs when trying to set a Web API key that
|
|
27
27
|
# isn't valid, i.e. a 128 bit integer in a hexadecimal string.
|
|
28
28
|
# * `:status_bad`: This is caused by a successful request that fails
|
|
@@ -31,7 +31,7 @@ class WebApiException < SteamCondenserException
|
|
|
31
31
|
# and `status_message`.
|
|
32
32
|
# * `:unauthorized`: This happens when a Steam Web API request is
|
|
33
33
|
# rejected as unauthorized. This most likely means that you did not
|
|
34
|
-
# specify a valid Web API key using {
|
|
34
|
+
# specify a valid Web API key using {WebApi.api_key=}. A Web API key
|
|
35
35
|
# can be obtained from http://steamcommunity.com/dev/apikey.
|
|
36
36
|
#
|
|
37
37
|
# Other undefined reasons will cause a generic error message.
|
|
@@ -1,19 +1,94 @@
|
|
|
1
|
-
# This code is free software; you can redistribute it and/or modify it under
|
|
2
|
-
# terms of the new BSD License.
|
|
1
|
+
# This code is free software; you can redistribute it and/or modify it under
|
|
2
|
+
# the terms of the new BSD License.
|
|
3
3
|
#
|
|
4
|
-
# Copyright (c) 2010, Sebastian Staudt
|
|
4
|
+
# Copyright (c) 2010-2011, Sebastian Staudt
|
|
5
5
|
|
|
6
|
-
#
|
|
7
|
-
#
|
|
6
|
+
# This class holds statistical information about missions played by a player in
|
|
7
|
+
# Alien Swarm
|
|
8
|
+
#
|
|
9
|
+
# @author Sebastian Staudt
|
|
8
10
|
class AlienSwarmMission
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
# Returns the avarage damage taken by the player while playing a round in
|
|
13
|
+
# this mission
|
|
14
|
+
#
|
|
15
|
+
# @return [Float] The average damage taken by the player
|
|
16
|
+
attr_reader :avg_damage_taken
|
|
17
|
+
|
|
18
|
+
# Returns the avarage damage dealt by the player to team mates while playing
|
|
19
|
+
# a round in this mission
|
|
20
|
+
#
|
|
21
|
+
# @return [Float] The average damage dealt by the player to team mates
|
|
22
|
+
attr_reader :avg_friendly_fire
|
|
23
|
+
|
|
24
|
+
# Returns the avarage number of aliens killed by the player while playing a
|
|
25
|
+
# round in this mission
|
|
26
|
+
#
|
|
27
|
+
# @return [Float] The avarage number of aliens killed by the player
|
|
28
|
+
attr_reader :avg_kills
|
|
29
|
+
|
|
30
|
+
# Returns the highest difficulty the player has beat this mission in
|
|
31
|
+
#
|
|
32
|
+
# @return [String] The highest difficulty the player has beat this mission in
|
|
33
|
+
attr_reader :best_difficulty
|
|
34
|
+
|
|
35
|
+
# Returns the total damage taken by the player in this mission
|
|
36
|
+
#
|
|
37
|
+
# @return [Fixnum] The total damage taken by the player
|
|
38
|
+
attr_reader :damage_taken
|
|
39
|
+
|
|
40
|
+
# Returns the total damage dealt by the player to team mates in this mission
|
|
41
|
+
#
|
|
42
|
+
# @return [Fixnum] The total damage dealt by the player to team mates
|
|
43
|
+
attr_reader :friendly_fire
|
|
44
|
+
|
|
45
|
+
# Returns the number of successful rounds the player played in this mission
|
|
46
|
+
#
|
|
47
|
+
# @return [Fixnum] The number of successful rounds of this mission
|
|
48
|
+
attr_reader :games_successful
|
|
49
|
+
|
|
50
|
+
# Returns the URL to a image displaying the mission
|
|
51
|
+
#
|
|
52
|
+
# @return [String] The URL of the mission's image
|
|
53
|
+
attr_reader :img
|
|
54
|
+
|
|
55
|
+
# Returns the total number of aliens killed by the player in this mission
|
|
56
|
+
#
|
|
57
|
+
# @return [Fixnum] The total number of aliens killed by the player
|
|
58
|
+
attr_reader :kills
|
|
59
|
+
|
|
60
|
+
# Returns the file name of the mission's map
|
|
61
|
+
#
|
|
62
|
+
# @return [String] The file name of the mission's map
|
|
63
|
+
attr_reader :map_name
|
|
64
|
+
|
|
65
|
+
# Returns the name of the mission
|
|
66
|
+
#
|
|
67
|
+
# @return [String] The name of the mission
|
|
68
|
+
attr_reader :name
|
|
69
|
+
|
|
70
|
+
# Returns various statistics about the times needed to accomplish this
|
|
71
|
+
# mission
|
|
72
|
+
#
|
|
73
|
+
# This includes the best times for each difficulty, the average time and the
|
|
74
|
+
# total time spent in this mission.
|
|
75
|
+
#
|
|
76
|
+
# @return [Hash<Symbol, String>] Various time statistics about this mission
|
|
77
|
+
attr_reader :time
|
|
78
|
+
|
|
79
|
+
# Returns the number of games played in this mission
|
|
80
|
+
#
|
|
81
|
+
# @return [Fixnum] The number of games played in this mission
|
|
82
|
+
attr_reader :total_games
|
|
83
|
+
|
|
84
|
+
# Returns the percentage of successful games played in this mission
|
|
85
|
+
#
|
|
86
|
+
# @return [Float] The percentage of successful games played in this mission
|
|
87
|
+
attr_reader :total_games_percentage
|
|
14
88
|
|
|
15
|
-
# Creates a new instance of
|
|
16
|
-
#
|
|
89
|
+
# Creates a new mission instance of based on the given XML data
|
|
90
|
+
#
|
|
91
|
+
# @param [REXML::Element] mission_data The data representing this mission
|
|
17
92
|
def initialize(mission_data)
|
|
18
93
|
@avg_damage_taken = mission_data.elements['damagetakenavg'].text.to_f
|
|
19
94
|
@avg_friendly_fire = mission_data.elements['friendlyfireavg'].text.to_f
|
|
@@ -1,19 +1,25 @@
|
|
|
1
|
-
# This code is free software; you can redistribute it and/or modify it under
|
|
2
|
-
# terms of the new BSD License.
|
|
1
|
+
# This code is free software; you can redistribute it and/or modify it under
|
|
2
|
+
# the terms of the new BSD License.
|
|
3
3
|
#
|
|
4
|
-
# Copyright (c) 2010, Sebastian Staudt
|
|
4
|
+
# Copyright (c) 2010-2011, Sebastian Staudt
|
|
5
5
|
|
|
6
6
|
require 'steam/community/alien_swarm/alien_swarm_mission'
|
|
7
7
|
require 'steam/community/alien_swarm/alien_swarm_weapon'
|
|
8
8
|
|
|
9
|
-
#
|
|
10
|
-
#
|
|
9
|
+
# This class represents the game statistics for a single user in Alien Swarm
|
|
10
|
+
#
|
|
11
|
+
# @author Sebastian Staudt
|
|
11
12
|
class AlienSwarmStats < GameStats
|
|
12
13
|
|
|
14
|
+
# Returns general stats for the players
|
|
15
|
+
#
|
|
16
|
+
# @return [Hash<Symbol, Object>] The stats for the player
|
|
13
17
|
attr_reader :lifetime_stats
|
|
14
18
|
|
|
19
|
+
# The base URL for all images referenced in the stats
|
|
15
20
|
BASE_URL = 'http://steamcommunity.com/public/images/gamestats/swarm/'
|
|
16
21
|
|
|
22
|
+
# The names of all weapons in Alien Swarm
|
|
17
23
|
WEAPONS = [ 'Autogun', 'Cannon_Sentry', 'Chainsaw', 'Flamer',
|
|
18
24
|
'Grenade_Launcher', 'Hand_Grenades', 'Hornet_Barrage',
|
|
19
25
|
'Incendiary_Sentry', 'Laser_Mines', 'Marskman_Rifle', 'Minigun',
|
|
@@ -21,8 +27,11 @@ class AlienSwarmStats < GameStats
|
|
|
21
27
|
'Rifle', 'Rifle_Grenade', 'Sentry_Gun', 'Shotgun',
|
|
22
28
|
'Tesla_Cannon', 'Vindicator', 'Vindicator_Grenade' ]
|
|
23
29
|
|
|
24
|
-
# Creates
|
|
25
|
-
# game name
|
|
30
|
+
# Creates a new `AlienSwarmStats` instance by calling the super constructor
|
|
31
|
+
# with the game name `'alienswarm'`
|
|
32
|
+
#
|
|
33
|
+
# @param [String, Fixnum] steam_id The custom URL or the 64bit Steam ID of
|
|
34
|
+
# the user
|
|
26
35
|
def initialize(steam_id)
|
|
27
36
|
super steam_id, 'alienswarm'
|
|
28
37
|
|
|
@@ -54,8 +63,11 @@ class AlienSwarmStats < GameStats
|
|
|
54
63
|
end
|
|
55
64
|
end
|
|
56
65
|
|
|
57
|
-
# Returns
|
|
66
|
+
# Returns the favorites of this user like weapons and marine
|
|
67
|
+
#
|
|
58
68
|
# If the favorites haven't been parsed already, parsing is done now.
|
|
69
|
+
#
|
|
70
|
+
# @return [Hash<Symbol, Object>] The favorites of this player
|
|
59
71
|
def favorites
|
|
60
72
|
return unless public?
|
|
61
73
|
|
|
@@ -86,8 +98,12 @@ class AlienSwarmStats < GameStats
|
|
|
86
98
|
@favorites
|
|
87
99
|
end
|
|
88
100
|
|
|
89
|
-
# Returns
|
|
90
|
-
# used
|
|
101
|
+
# Returns the item stats for this user like ammo deployed and medkits
|
|
102
|
+
# used
|
|
103
|
+
#
|
|
104
|
+
# If the items haven't been parsed already, parsing is done now.
|
|
105
|
+
#
|
|
106
|
+
# @return [Hash<Symbol, Object>] The item stats of this player
|
|
91
107
|
def item_stats
|
|
92
108
|
return unless public?
|
|
93
109
|
|
|
@@ -119,9 +135,12 @@ class AlienSwarmStats < GameStats
|
|
|
119
135
|
@item_stats
|
|
120
136
|
end
|
|
121
137
|
|
|
122
|
-
# Returns
|
|
123
|
-
# Swarm missions
|
|
124
|
-
#
|
|
138
|
+
# Returns the stats for individual missions for this user containing all
|
|
139
|
+
# Alien Swarm missions
|
|
140
|
+
#
|
|
141
|
+
# If the mission stats haven't been parsed already, parsing is done now.
|
|
142
|
+
#
|
|
143
|
+
# @return [Hash<String, AlienSwarmMission>] The mission stats for this player
|
|
125
144
|
def mission_stats
|
|
126
145
|
return unless public?
|
|
127
146
|
|
|
@@ -135,8 +154,12 @@ class AlienSwarmStats < GameStats
|
|
|
135
154
|
@mission_stats
|
|
136
155
|
end
|
|
137
156
|
|
|
138
|
-
# Returns
|
|
139
|
-
#
|
|
157
|
+
# Returns the stats for individual weapons for this user containing all
|
|
158
|
+
# Alien Swarm weapons
|
|
159
|
+
#
|
|
160
|
+
# If the weapon stats haven't been parsed already, parsing is done now.
|
|
161
|
+
#
|
|
162
|
+
# @return [Hash<String, AlienSwarmWeapon>] The weapon stats for this player
|
|
140
163
|
def weapon_stats
|
|
141
164
|
return unless public?
|
|
142
165
|
|