gamelocker_api 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d0f07d4ead2eb25d125e496142a7b7b0c57761bb
4
- data.tar.gz: eb651db6e2386a71048f92ee35d3a5ee6c905265
3
+ metadata.gz: d895e9ab4a3a13cc2dd5e6655285d9026c185543
4
+ data.tar.gz: fa319a0408670132ad5d17409a35319c8c83c7fc
5
5
  SHA512:
6
- metadata.gz: ed5baee98622eb312d264499ca5393a87531182980ec4420d3ffc221555f4b864656d9306648814c30936b147fcf7f5519b018350811a10f02892e197b451a5e
7
- data.tar.gz: a5441298514266ece5c5a585ba433787a267fca8f2210af0d6f249697448fd09179d87ee265216f2c69d91ea79ae4499b56e68a50b203ae752cb837e7b1a0beb
6
+ metadata.gz: a7adb17ecba60e9880a89bd70c7726cbc2c8f794f12c771debc907b5fabd34d3f79c7d69f8ba044c78dbd80d1e853f111ede210152996633ad14d86480346ef3
7
+ data.tar.gz: 6c945130e3485d26162bdb832e58bd3d47fe15331a57e15c93a809fb2db98949c49a131dd0a49ff215f14406de0286d41de3445d5a259c1808693d03736ecaa1
data/.gitignore CHANGED
@@ -1,9 +1,9 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.travis.yml CHANGED
@@ -1,5 +1,5 @@
1
- sudo: false
2
- language: ruby
3
- rvm:
4
- - 2.4.0
5
- before_install: gem install bundler -v 1.14.6
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.0
5
+ before_install: gem install bundler -v 1.14.6
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in gamelocker_api.gemspec
4
- gemspec
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in gamelocker_api.gemspec
4
+ gemspec
data/LICENSE.txt CHANGED
@@ -1,21 +1,21 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2017 Cyberarm
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Cyberarm
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -1,73 +1,73 @@
1
- # GameLockerAPI
2
-
3
- API client for the VainGlory Developer API (which is currently in alpha)
4
-
5
- ## Installation
6
-
7
- Add this line to your application's Gemfile:
8
-
9
- ```ruby
10
- gem "gamelocker_api"
11
- ```
12
-
13
- And then execute:
14
-
15
- $ bundle
16
-
17
- Or install it yourself as:
18
-
19
- $ gem install gamelocker_api
20
-
21
- ## Usage
22
- Get player(s) by In-game name
23
- ```ruby
24
- # Api Key and Region
25
- api = GameLockerAPI.new("API_KEY", "na")
26
- response = api.players("Cyberarm") # method :players always returns an Array
27
- p response.first # => GameLockerAPI::Player
28
- ```
29
- Get player by UUID
30
- ```ruby
31
- response = api.player("6168b9ca-e7c8-11e6-812b-06388a2f2ea7")
32
- p response # => GameLockerAPI::Player
33
- ```
34
- Get matches
35
- ```ruby
36
- response = api.matches
37
- p response # => [GameLockerAPI::Match, GameLockerAPI::Match]
38
- ```
39
- Get matches with players that have In-game names
40
- ```ruby
41
- response = api.matches({"filter[playerNames]" => "Cyberarm"}) # Note: Will only return the last 3 hours of matches by default, see https://developer.vainglorygame.com/docs#get-a-collection-of-matches
42
- p response # => [GameLockerAPI::Match, GameLockerAPI::Match]
43
- ```
44
- Get a match
45
- ```ruby
46
- match = api.match("0bf53e9a-268f-11e7-9456-063bc004098b")
47
- p match # => GameLockerAPI::Match
48
- ```
49
- Get telemetry
50
- ```ruby
51
- response = api.telemetry(match.telemetry_url)
52
- p response # => [GameLockerAPI::Telemetry::Event, GameLockerAPI::Telemetry::Event]
53
- ```
54
- Check if you're being rate limited
55
- ```ruby
56
- response.headers[:x_ratelimit_remaining] # => 9
57
- ```
58
- ## Supports
59
- * Telemetry
60
- * Player(s)
61
- * Match(s)
62
-
63
- ## Development
64
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
65
-
66
- ## Contributing
67
-
68
- Bug reports and pull requests are welcome on GitHub at https://github.com/cyberarm/gamelocker_api.
69
-
70
-
71
- ## License
72
-
73
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
1
+ # GameLockerAPI
2
+
3
+ API client for the VainGlory Developer API (which is currently in alpha)
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem "gamelocker_api"
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install gamelocker_api
20
+
21
+ ## Usage
22
+ Get player(s) by In-game name
23
+ ```ruby
24
+ # Api Key and Region
25
+ api = GameLockerAPI.new("API_KEY", "na")
26
+ response = api.players("Cyberarm") # method :players always returns an Array
27
+ p response.first # => GameLockerAPI::Player
28
+ ```
29
+ Get player by UUID
30
+ ```ruby
31
+ response = api.player("6168b9ca-e7c8-11e6-812b-06388a2f2ea7")
32
+ p response # => GameLockerAPI::Player
33
+ ```
34
+ Get matches
35
+ ```ruby
36
+ response = api.matches
37
+ p response # => [GameLockerAPI::Match, GameLockerAPI::Match]
38
+ ```
39
+ Get matches with players that have In-game names
40
+ ```ruby
41
+ response = api.matches({"filter[playerNames]" => "Cyberarm"}) # Note: Will only return the last 3 hours of matches by default, see https://developer.vainglorygame.com/docs#get-a-collection-of-matches
42
+ p response # => [GameLockerAPI::Match, GameLockerAPI::Match]
43
+ ```
44
+ Get a match
45
+ ```ruby
46
+ match = api.match("0bf53e9a-268f-11e7-9456-063bc004098b")
47
+ p match # => GameLockerAPI::Match
48
+ ```
49
+ Get telemetry
50
+ ```ruby
51
+ response = api.telemetry(match.telemetry_url)
52
+ p response # => [GameLockerAPI::Telemetry::Event, GameLockerAPI::Telemetry::Event]
53
+ ```
54
+ Check if you're being rate limited
55
+ ```ruby
56
+ api.headers[:x_ratelimit_remaining] # => 9
57
+ ```
58
+ ## Supports
59
+ * Telemetry
60
+ * Player(s)
61
+ * Match(s)
62
+
63
+ ## Development
64
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
65
+
66
+ ## Contributing
67
+
68
+ Bug reports and pull requests are welcome on GitHub at https://github.com/cyberarm/gamelocker_api.
69
+
70
+
71
+ ## License
72
+
73
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile CHANGED
@@ -1,10 +1,10 @@
1
- require "bundler/gem_tasks"
2
- require "rake/testtask"
3
-
4
- Rake::TestTask.new(:test) do |t|
5
- t.libs << "test"
6
- t.libs << "lib"
7
- t.test_files = FileList['test/**/*_test.rb']
8
- end
9
-
10
- task :default => :test
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task :default => :test
@@ -1,37 +1,37 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'gamelocker_api/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "gamelocker_api"
8
- spec.version = GameLockerAPI::VERSION
9
- spec.authors = ["Cyberarm"]
10
- spec.email = ["matthewlikesrobots@gmail.com"]
11
-
12
- spec.summary = %q{API client for the VainGlory Developer API}
13
- spec.description = %q{API client for the VainGlory Developer API}
14
- spec.homepage = "https://github.com/cyberarm/gamelocker_api"
15
- spec.license = "MIT"
16
-
17
- # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
- # to allow pushing to a single host or delete this section to allow pushing to any host.
19
- if spec.respond_to?(:metadata)
20
- spec.metadata['allowed_push_host'] = "https://rubygems.org"
21
- else
22
- raise "RubyGems 2.0 or newer is required to protect against " \
23
- "public gem pushes."
24
- end
25
-
26
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
- f.match(%r{^(test|spec|features)/})
28
- end
29
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
- spec.require_paths = ["lib"]
31
-
32
- spec.add_dependency "rest-client", "~> 2.0.1"
33
- spec.add_dependency "oj", "~> 2.18.5"
34
- spec.add_development_dependency "bundler", "~> 1.14"
35
- spec.add_development_dependency "rake", "~> 10.0"
36
- spec.add_development_dependency "minitest", "~> 5.0"
37
- end
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'gamelocker_api/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "gamelocker_api"
8
+ spec.version = GameLockerAPI::VERSION
9
+ spec.authors = ["Cyberarm"]
10
+ spec.email = ["matthewlikesrobots@gmail.com"]
11
+
12
+ spec.summary = %q{API client for the VainGlory Developer API}
13
+ spec.description = %q{API client for the VainGlory Developer API}
14
+ spec.homepage = "https://github.com/cyberarm/gamelocker_api"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against " \
23
+ "public gem pushes."
24
+ end
25
+
26
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
+ f.match(%r{^(test|spec|features)/})
28
+ end
29
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ spec.add_dependency "rest-client", "~> 2.0.1"
33
+ spec.add_dependency "oj", "~> 2.18.5"
34
+ spec.add_development_dependency "bundler", "~> 1.14"
35
+ spec.add_development_dependency "rake", "~> 10.0"
36
+ spec.add_development_dependency "minitest", "~> 5.0"
37
+ end
File without changes
@@ -20,62 +20,12 @@ class GameLockerAPI
20
20
  def self.match(data, solo = false)
21
21
  _matches = []
22
22
  temp_match = nil
23
- unless solo
24
- data['data'].each do |match|
25
- temp_match = Match.new
26
- _matches.push(temp_match)
27
- temp_match.uuid = match['id']
28
- temp_match.shard_id = match['attributes']['shardId']
29
- temp_match.created_at = match['attributes']['createdAt']
30
- temp_match.duration = match['attributes']['duration']
31
- temp_match.gamemode = match['attributes']['gameMode']
32
- temp_match.end_game_reason = match['attributes']['stats']['endGameReason']
33
- temp_match.telemetry_url = nil
34
- temp_match.rosters = []
35
- temp_match.red_team = []
36
- temp_match.blue_team= []
37
- temp_match.players = []
38
- temp_match.participants = []
39
- data['included'].each do |wanted|
40
- temp_match.telemetry_url = wanted['attributes']['URL'] if wanted['type'] == "asset" && match['relationships']['assets']['data'].first['id'] == wanted['id']
41
- thing = nil
42
- if wanted['id'] == match['relationships']['rosters']['data'][0]['id']
43
- thing = match['relationships']['rosters']['data'][0]['id']
44
- temp_match.rosters << compose_roster(data, thing, temp_match)
45
- elsif wanted['id'] == match['relationships']['rosters']['data'][1]['id']
46
- thing = match['relationships']['rosters']['data'][1]['id']
47
- temp_match.rosters << compose_roster(data, thing, temp_match)
48
- else
49
- next
50
- end
51
- end
52
- end
23
+ if solo
24
+ temp_match = Match.new(data)
53
25
  else
54
- temp_match = Match.new
55
- match = data['data']
56
- temp_match.uuid = match['id']
57
- temp_match.shard_id = match['attributes']['shardId']
58
- temp_match.created_at = match['attributes']['createdAt']
59
- temp_match.duration = match['attributes']['duration']
60
- temp_match.gamemode = match['attributes']['gameMode']
61
- temp_match.end_game_reason = match['attributes']['stats']['endGameReason']
62
- temp_match.rosters = []
63
- temp_match.red_team = []
64
- temp_match.blue_team= []
65
- temp_match.players = []
66
- temp_match.participants = []
67
- data['included'].each do |wanted|
68
- temp_match.telemetry_url = wanted['attributes']['URL'] if wanted['type'] == "asset" && match['relationships']['assets']['data'].first['id'] == wanted['id']
69
- thing = nil
70
- if wanted['id'] == match['relationships']['rosters']['data'][0]['id']
71
- thing = match['relationships']['rosters']['data'][0]['id']
72
- temp_match.rosters << compose_roster(data, thing, temp_match)
73
- elsif wanted['id'] == match['relationships']['rosters']['data'][1]['id']
74
- thing = match['relationships']['rosters']['data'][1]['id']
75
- temp_match.rosters << compose_roster(data, thing, temp_match)
76
- else
77
- next
78
- end
26
+ data['data'].each_with_index do |m, i|
27
+ temp_match = Match.new(data, i) # Need to pass index
28
+ _matches.push(temp_match)
79
29
  end
80
30
  end
81
31
  solo ? temp_match : _matches
@@ -86,37 +36,11 @@ class GameLockerAPI
86
36
  temp_player = nil
87
37
  unless solo
88
38
  data['data'].each do |local_player|
89
- temp_player = Player.new
90
-
91
- temp_player.uuid = local_player['id']
92
- temp_player.level = local_player['attributes']['stats']['level']
93
- temp_player.lifetime_gold = local_player['attributes']['stats']['lifetimeGold']
94
- temp_player.loss_streak = local_player['attributes']['stats']['lossStreak']
95
- temp_player.played = local_player['attributes']['stats']['played']
96
- temp_player.played_ranked = local_player['attributes']['stats']['played_ranked']
97
- temp_player.win_streak = local_player['attributes']['stats']['winStreak']
98
- temp_player.wins = local_player['attributes']['stats']['wins']
99
- temp_player.xp = local_player['attributes']['stats']['xp']
100
- temp_player.name = local_player['attributes']['name']
101
- temp_player.created_at = local_player['attributes']['createdAt']
102
-
39
+ temp_player = Player.new(local_player)
103
40
  temp_players.push(temp_player)
104
41
  end
105
42
  else
106
- temp_player = Player.new
107
-
108
- local_player = data['data']
109
- temp_player.uuid = local_player['id']
110
- temp_player.level = local_player['attributes']['stats']['level']
111
- temp_player.lifetime_gold = local_player['attributes']['stats']['lifetimeGold']
112
- temp_player.loss_streak = local_player['attributes']['stats']['lossStreak']
113
- temp_player.played = local_player['attributes']['stats']['played']
114
- temp_player.played_ranked = local_player['attributes']['stats']['played_ranked']
115
- temp_player.win_streak = local_player['attributes']['stats']['winStreak']
116
- temp_player.wins = local_player['attributes']['stats']['wins']
117
- temp_player.xp = local_player['attributes']['stats']['xp']
118
- temp_player.name = local_player['attributes']['name']
119
- temp_player.created_at = local_player['attributes']['createdAt']
43
+ temp_player = Player.new(data['data'])
120
44
  end
121
45
 
122
46
  solo ? temp_player : temp_players
@@ -128,84 +52,5 @@ class GameLockerAPI
128
52
  # Expects a roster uuid
129
53
  def self.participant(roster)
130
54
  end
131
-
132
- private
133
- def self.compose_roster(data, roster, temp_match)
134
- temp_roster = Roster.new
135
- temp_roster.uuid = roster
136
- temp_roster.participants = []
137
- data['included'].each do |local_roster|
138
- next unless local_roster['type'] == "roster"
139
- if local_roster['id'] == roster
140
- temp_roster.aces_earned = local_roster['attributes']['stats']['acesEarned']
141
- temp_roster.gold = local_roster['attributes']['stats']['gold']
142
- temp_roster.hero_kills = local_roster['attributes']['stats']['heroKills']
143
- temp_roster.kraken_captures = local_roster['attributes']['stats']['krakenCaptures']
144
- temp_roster.side = local_roster['attributes']['stats']['side']
145
- temp_roster.turret_kills = local_roster['attributes']['stats']['turretKills']
146
- temp_roster.turrets_remaining = local_roster['attributes']['stats']['turretsRemaining']
147
-
148
- local_roster['relationships']['participants']['data'].each do |pat|
149
- data['included'].each do |local_participant|
150
- next unless local_participant['id'] == pat['id']
151
- temp_participant = Participant.new
152
- temp_participant.uuid = local_participant['id']
153
- temp_participant.assists = local_participant['attributes']['stats']['assists']
154
- temp_participant.crystal_mine_captures = local_participant['attributes']['stats']['crystalMineCaptures']
155
- temp_participant.deaths = local_participant['attributes']['stats']['deaths']
156
- temp_participant.farm = local_participant['attributes']['stats']['farm']
157
- temp_participant.first_afk_time = local_participant['attributes']['stats']['firstAfkTime']
158
- temp_participant.gold = local_participant['attributes']['stats']['gold']
159
- temp_participant.gold_mine_captures = local_participant['attributes']['stats']['goldMineCaptures']
160
- temp_participant.item_grants = local_participant['attributes']['stats']['itemGrants']
161
- temp_participant.item_sells = local_participant['attributes']['stats']['itemSells']
162
- temp_participant.item_uses = local_participant['attributes']['stats']['itemUses']
163
- temp_participant.items = local_participant['attributes']['stats']['items']
164
- temp_participant.jungle_kills = local_participant['attributes']['stats']['jungleKills']
165
- temp_participant.karma_level = local_participant['attributes']['stats']['karmaLevel']
166
- temp_participant.kills = local_participant['attributes']['stats']['kills']
167
- temp_participant.kraken_captures = local_participant['attributes']['stats']['krakenCaptures']
168
- temp_participant.level = local_participant['attributes']['stats']['level']
169
- temp_participant.minion_kills = local_participant['attributes']['stats']['minionKills']
170
- temp_participant.non_jungle_minion_kills = local_participant['attributes']['stats']['nonJungleMinionKills']
171
- temp_participant.skill_tier = local_participant['attributes']['stats']['skillTier']
172
- temp_participant.skin_key = local_participant['attributes']['stats']['skinKey']
173
- temp_participant.turret_captures = local_participant['attributes']['stats']['turretCaptures']
174
- temp_participant.went_afk = local_participant['attributes']['stats']['wentAfk']
175
- temp_participant.winner = local_participant['attributes']['stats']['winner']
176
- temp_participant.actor = local_participant['attributes']['actor']
177
-
178
- temp_player = Player.new
179
- data['included'].each do |local_player|
180
- next unless local_player['id'] == local_participant['relationships']['player']['data']['id']
181
- temp_player.uuid = local_player['id']
182
- temp_player.level = local_player['attributes']['stats']['level']
183
- temp_player.lifetime_gold = local_player['attributes']['stats']['lifetimeGold']
184
- temp_player.loss_streak = local_player['attributes']['stats']['lossStreak']
185
- temp_player.played = local_player['attributes']['stats']['played']
186
- temp_player.played_ranked = local_player['attributes']['stats']['played_ranked']
187
- temp_player.win_streak = local_player['attributes']['stats']['winStreak']
188
- temp_player.wins = local_player['attributes']['stats']['wins']
189
- temp_player.xp = local_player['attributes']['stats']['xp']
190
- temp_player.name = local_player['attributes']['name']
191
- temp_player.created_at = local_player['attributes']['createdAt']
192
- end
193
- temp_participant.player = temp_player
194
- temp_match.players.push(temp_player)
195
-
196
- temp_match.participants.push(temp_participant)
197
- temp_roster.participants.push(temp_participant)
198
- end
199
- end
200
- end
201
- end
202
-
203
- if temp_roster.side.include?("red")
204
- temp_match.red_team.push(temp_roster)
205
- elsif temp_roster.side.include?("blue")
206
- temp_match.blue_team.push(temp_roster)
207
- end
208
- return temp_roster
209
- end
210
55
  end
211
56
  end
@@ -2,5 +2,129 @@ class GameLockerAPI
2
2
  class Match
3
3
  attr_accessor :uuid, :shard_id, :blue_team, :red_team, :rosters, :participants, :players
4
4
  attr_accessor :created_at, :duration, :gamemode, :end_game_reason, :telemetry_url
5
+
6
+ def initialize(data, index = nil)
7
+ if index
8
+ self.uuid = data['data'][index]['id']
9
+ self.shard_id = data['data'][index]['attributes']['shardId']
10
+ self.created_at = data['data'][index]['attributes']['createdAt']
11
+ self.duration = data['data'][index]['attributes']['duration']
12
+ self.gamemode = data['data'][index]['attributes']['gameMode']
13
+ self.end_game_reason = data['data'][index]['attributes']['stats']['endGameReason']
14
+ else
15
+ self.uuid = data['data']['id']
16
+ self.shard_id = data['data']['attributes']['shardId']
17
+ self.created_at = data['data']['attributes']['createdAt']
18
+ self.duration = data['data']['attributes']['duration']
19
+ self.gamemode = data['data']['attributes']['gameMode']
20
+ self.end_game_reason = data['data']['attributes']['stats']['endGameReason']
21
+ end
22
+ self.telemetry_url = nil
23
+ self.rosters = []
24
+ self.red_team = []
25
+ self.blue_team= []
26
+ self.players = []
27
+ self.participants = []
28
+
29
+ if index
30
+ data['included'].each do |wanted|
31
+ self.telemetry_url = wanted['attributes']['URL'] if wanted['type'] == "asset" && data['data'][index]['relationships']['assets']['data'].first['id'] == wanted['id']
32
+ thing = nil
33
+ if wanted['id'] == data['data'][index]['relationships']['rosters']['data'][0]['id']
34
+ thing = data['data'][index]['relationships']['rosters']['data'][0]['id']
35
+ self.rosters << compose_roster(data, thing, self)
36
+ elsif wanted['id'] == data['data'][index]['relationships']['rosters']['data'][1]['id']
37
+ thing = data['data'][index]['relationships']['rosters']['data'][1]['id']
38
+ self.rosters << compose_roster(data, thing, self)
39
+ else
40
+ next
41
+ end
42
+ end
43
+ else
44
+ data['included'].each do |wanted|
45
+ self.telemetry_url = wanted['attributes']['URL'] if wanted['type'] == "asset" && data['data']['relationships']['assets']['data'].first['id'] == wanted['id']
46
+ thing = nil
47
+ if wanted['id'] == data['data']['relationships']['rosters']['data'][0]['id']
48
+ thing = data['data']['relationships']['rosters']['data'][0]['id']
49
+ self.rosters << compose_roster(data, thing, self)
50
+ elsif wanted['id'] == data['data']['relationships']['rosters']['data'][1]['id']
51
+ thing = data['data']['relationships']['rosters']['data'][1]['id']
52
+ self.rosters << compose_roster(data, thing, self)
53
+ else
54
+ next
55
+ end
56
+ end
57
+ end
58
+
59
+ return self
60
+ end
61
+
62
+ def compose_roster(data, roster, temp_match)
63
+ temp_roster = Roster.new
64
+ temp_roster.uuid = roster
65
+ temp_roster.participants = []
66
+ data['included'].each do |local_roster|
67
+ next unless local_roster['type'] == "roster"
68
+ if local_roster['id'] == roster
69
+ temp_roster.aces_earned = local_roster['attributes']['stats']['acesEarned']
70
+ temp_roster.gold = local_roster['attributes']['stats']['gold']
71
+ temp_roster.hero_kills = local_roster['attributes']['stats']['heroKills']
72
+ temp_roster.kraken_captures = local_roster['attributes']['stats']['krakenCaptures']
73
+ temp_roster.side = local_roster['attributes']['stats']['side']
74
+ temp_roster.turret_kills = local_roster['attributes']['stats']['turretKills']
75
+ temp_roster.turrets_remaining = local_roster['attributes']['stats']['turretsRemaining']
76
+
77
+ local_roster['relationships']['participants']['data'].each do |pat|
78
+ data['included'].each do |local_participant|
79
+ next unless local_participant['id'] == pat['id']
80
+ temp_participant = Participant.new
81
+ temp_participant.uuid = local_participant['id']
82
+ temp_participant.assists = local_participant['attributes']['stats']['assists']
83
+ temp_participant.crystal_mine_captures = local_participant['attributes']['stats']['crystalMineCaptures']
84
+ temp_participant.deaths = local_participant['attributes']['stats']['deaths']
85
+ temp_participant.farm = local_participant['attributes']['stats']['farm']
86
+ temp_participant.first_afk_time = local_participant['attributes']['stats']['firstAfkTime']
87
+ temp_participant.gold = local_participant['attributes']['stats']['gold']
88
+ temp_participant.gold_mine_captures = local_participant['attributes']['stats']['goldMineCaptures']
89
+ temp_participant.item_grants = local_participant['attributes']['stats']['itemGrants']
90
+ temp_participant.item_sells = local_participant['attributes']['stats']['itemSells']
91
+ temp_participant.item_uses = local_participant['attributes']['stats']['itemUses']
92
+ temp_participant.items = local_participant['attributes']['stats']['items']
93
+ temp_participant.jungle_kills = local_participant['attributes']['stats']['jungleKills']
94
+ temp_participant.karma_level = local_participant['attributes']['stats']['karmaLevel']
95
+ temp_participant.kills = local_participant['attributes']['stats']['kills']
96
+ temp_participant.kraken_captures = local_participant['attributes']['stats']['krakenCaptures']
97
+ temp_participant.level = local_participant['attributes']['stats']['level']
98
+ temp_participant.minion_kills = local_participant['attributes']['stats']['minionKills']
99
+ temp_participant.non_jungle_minion_kills = local_participant['attributes']['stats']['nonJungleMinionKills']
100
+ temp_participant.skill_tier = local_participant['attributes']['stats']['skillTier']
101
+ temp_participant.skin_key = local_participant['attributes']['stats']['skinKey']
102
+ temp_participant.turret_captures = local_participant['attributes']['stats']['turretCaptures']
103
+ temp_participant.went_afk = local_participant['attributes']['stats']['wentAfk']
104
+ temp_participant.winner = local_participant['attributes']['stats']['winner']
105
+ temp_participant.actor = local_participant['attributes']['actor']
106
+
107
+ temp_player = nil
108
+ data['included'].each do |local_player|
109
+ next unless local_player['id'] == local_participant['relationships']['player']['data']['id']
110
+ temp_player = Player.new(local_player)
111
+ end
112
+ temp_participant.player = temp_player
113
+ temp_match.players.push(temp_player)
114
+
115
+ temp_match.participants.push(temp_participant)
116
+ temp_roster.participants.push(temp_participant)
117
+ end
118
+ end
119
+ end
120
+ end
121
+
122
+ if temp_roster.side.include?("red")
123
+ temp_match.red_team.push(temp_roster)
124
+ elsif temp_roster.side.include?("blue")
125
+ temp_match.blue_team.push(temp_roster)
126
+ end
127
+ return temp_roster
128
+ end
5
129
  end
6
130
  end
File without changes
@@ -1,6 +1,44 @@
1
1
  class GameLockerAPI
2
2
  class Player
3
3
  attr_accessor :uuid, :name, :shard_id, :created_at
4
- attr_accessor :level, :lifetime_gold, :loss_streak, :win_streak, :played, :played_ranked, :wins, :xp
4
+ attr_accessor :games_played, :guild_tag, :karma_level, :level, :rank_points, :skill_tier, :wins, :xp
5
+ attr_accessor :total_games_played, :loses
6
+
7
+ def initialize(data)
8
+ self.uuid = data['id']
9
+ self.name = data['attributes']['name']
10
+ self.created_at = data['attributes']['createdAt']
11
+
12
+ self.games_played = data['attributes']['stats']['gamesPlayed']
13
+ self.guild_tag = data['attributes']['stats']['guildTag']
14
+ self.karma_level = data['attributes']['stats']['karmaLevel']
15
+ self.level = data['attributes']['stats']['level']
16
+ self.rank_points = data['attributes']['stats']['rank_points']
17
+ self.skill_tier = data['attributes']['stats']['skillTier']
18
+ self.wins = data['attributes']['stats']['wins']
19
+ self.xp = data['attributes']['stats']['xp']
20
+
21
+ calculate_total_games_played
22
+ calculate_loses
23
+ return self
24
+ end
25
+
26
+ def calculate_total_games_played
27
+ games = 0
28
+ self.games_played.each do |mode, n|
29
+ games+=n
30
+ end
31
+
32
+ self.total_games_played = games
33
+ end
34
+
35
+ def calculate_loses
36
+ games = 0
37
+ self.games_played.each do |mode, n|
38
+ games+=n
39
+ end
40
+
41
+ self.loses = games-wins
42
+ end
5
43
  end
6
44
  end
File without changes
@@ -1,19 +1,19 @@
1
- class GameLockerAPI
2
- class Telemetry
3
- attr_accessor :events
4
- Event = Struct.new(:time, :type, :payload)
5
- def initialize(telemetry_url)
6
- @events = []
7
- response = RestClient.get(telemetry_url)
8
- parse(response.body)
9
-
10
- return self
11
- end
12
-
13
- def parse(json)
14
- Oj.load(json).each do |event|
15
- @events << Event.new(Time.parse(event['time']), event['type'], event['payload'])
16
- end
17
- end
18
- end
19
- end
1
+ class GameLockerAPI
2
+ class Telemetry
3
+ attr_accessor :events
4
+ Event = Struct.new(:time, :type, :payload)
5
+ def initialize(telemetry_url)
6
+ @events = []
7
+ response = RestClient.get(telemetry_url)
8
+ parse(response.body)
9
+
10
+ return self
11
+ end
12
+
13
+ def parse(json)
14
+ Oj.load(json).each do |event|
15
+ @events << Event.new(Time.parse(event['time']), event['type'], event['payload'])
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,3 +1,3 @@
1
- class GameLockerAPI
2
- VERSION = "0.1.3"
3
- end
1
+ class GameLockerAPI
2
+ VERSION = "0.1.4"
3
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gamelocker_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyberarm
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-21 00:00:00.000000000 Z
11
+ date: 2018-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
123
  version: '0'
124
124
  requirements: []
125
125
  rubyforge_project:
126
- rubygems_version: 2.6.11
126
+ rubygems_version: 2.6.13
127
127
  signing_key:
128
128
  specification_version: 4
129
129
  summary: API client for the VainGlory Developer API