valorant 0.1.4 → 0.1.5r1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/garbage.json +1484 -0
- data/lib/api/misc.rb +2 -1
- data/lib/api/utils/asset.rb +23 -0
- data/lib/api/utils/content.rb +43 -0
- data/lib/api/utils/leader.rb +0 -14
- data/lib/api/utils/match.rb +2 -2
- data/lib/api/utils/matches_history.rb +12 -0
- data/lib/api/utils/player.rb +5 -5
- data/lib/api/version.rb +1 -1
- metadata +7 -4
data/lib/api/misc.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require_relative 'utils/articles'
|
4
4
|
require_relative 'utils/leader_board'
|
5
5
|
require_relative 'utils/utilities'
|
6
|
+
require_relative 'utils/content'
|
6
7
|
|
7
8
|
module Valorant
|
8
9
|
# This class is used to fetch data from the Valorant API -> ENDPOINTS: /v1/website/, /v1/leaderboard/,
|
@@ -17,7 +18,7 @@ module Valorant
|
|
17
18
|
end
|
18
19
|
|
19
20
|
def self.content
|
20
|
-
fetch_resposne('v1/content')
|
21
|
+
Content.new(fetch_resposne('v1/content'))
|
21
22
|
end
|
22
23
|
|
23
24
|
def self.server_status(region)
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This class is used to create an Asset object
|
4
|
+
class Asset
|
5
|
+
attr_reader :name, :id, :asset_name, :localized_names, :type
|
6
|
+
|
7
|
+
def initialize(data, type)
|
8
|
+
@data = data
|
9
|
+
@type = type
|
10
|
+
@name = @data['name']
|
11
|
+
@id = @data['id']
|
12
|
+
@asset_name = @data['assetName']
|
13
|
+
|
14
|
+
fetch_localized_names
|
15
|
+
remove_instance_variable(:@data)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def fetch_localized_names
|
21
|
+
@localized_names = @data['localizedNames'].transform_keys(&:to_sym)
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'asset'
|
4
|
+
|
5
|
+
# This class is used to create a Content object
|
6
|
+
class Content
|
7
|
+
attr_reader :assets
|
8
|
+
|
9
|
+
def initialize(data)
|
10
|
+
@data = data
|
11
|
+
@assets = fetch_assets
|
12
|
+
remove_instance_variable(:@data)
|
13
|
+
end
|
14
|
+
|
15
|
+
def find_asset_by_name(name)
|
16
|
+
@assets.find { |asset| asset.name == name }
|
17
|
+
end
|
18
|
+
|
19
|
+
def agent_images(name)
|
20
|
+
agent = @assets.find { |asset| asset.name == name }
|
21
|
+
{ display_icon: "https://media.valorant-api.com/agents/#{agent.id}/displayicon.png",
|
22
|
+
display_icon_small: "https://media.valorant-api.com/agents/#{agent.id}/displayiconsmall.png",
|
23
|
+
bust_portrait: "https://media.valorant-api.com/agents/#{agent.id}/fullportrait.png",
|
24
|
+
full_portrait: "https://media.valorant-api.com/agents/#{agent.id}/fullportrait.png",
|
25
|
+
full_portrait_v2: "https://media.valorant-api.com/agents/#{agent.id}/fullportrait.png",
|
26
|
+
killfeed_portrait: "https://media.valorant-api.com/agents/#{agent.id}/killfeedportrait.png",
|
27
|
+
background: "https://media.valorant-api.com/agents/#{agent.id}/background.png" }
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def fetch_assets
|
33
|
+
@assets = []
|
34
|
+
@data.each_key do |type|
|
35
|
+
next if type == 'version'
|
36
|
+
|
37
|
+
@data[type].each do |asset|
|
38
|
+
@assets << Asset.new(asset, type)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
@assets
|
42
|
+
end
|
43
|
+
end
|
data/lib/api/utils/leader.rb
CHANGED
@@ -23,17 +23,3 @@ class Leader
|
|
23
23
|
@is_anonymized = data['IsAnonymized']
|
24
24
|
end
|
25
25
|
end
|
26
|
-
|
27
|
-
# DOCUMENTATION
|
28
|
-
|
29
|
-
# @PlayerCardID
|
30
|
-
# @TitleID
|
31
|
-
# @IsBanned
|
32
|
-
# @IsAnonymized
|
33
|
-
# @puuid
|
34
|
-
# @gameName
|
35
|
-
# @tagLine
|
36
|
-
# @leaderboardRank
|
37
|
-
# @rankedRating
|
38
|
-
# @numberOfWins
|
39
|
-
# @competitiveTier
|
data/lib/api/utils/match.rb
CHANGED
@@ -34,8 +34,8 @@ class Match
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def accuracy(name, tag)
|
37
|
-
|
38
|
-
[
|
37
|
+
result = @all_players.select { |player| player.name.gsub(' ', '') == name.gsub(' ', '') && player.tag == tag }
|
38
|
+
[result[0].headshots, result[0].bodyshots, result[0].legshots]
|
39
39
|
end
|
40
40
|
|
41
41
|
def fetch_game_info
|
@@ -26,6 +26,18 @@ class MatcheshHistory
|
|
26
26
|
[head_shots, body_shots, leg_shots]
|
27
27
|
end
|
28
28
|
|
29
|
+
def most_played(name, tag)
|
30
|
+
most_played = []
|
31
|
+
@matches.each do |match|
|
32
|
+
match.all_players.each do |player|
|
33
|
+
next unless player.name.gsub(' ', '') == name.gsub(' ', '') && player.tag == tag
|
34
|
+
|
35
|
+
most_played << player.character
|
36
|
+
end
|
37
|
+
end
|
38
|
+
most_played.max_by { |i| most_played.count(i) }
|
39
|
+
end
|
40
|
+
|
29
41
|
private
|
30
42
|
|
31
43
|
def fetch_matches(matches_json)
|
data/lib/api/utils/player.rb
CHANGED
@@ -47,14 +47,14 @@ class Player
|
|
47
47
|
def fetch_aesthetics_data
|
48
48
|
@player_card = @data['player_card']
|
49
49
|
@player_title = @data['player_title']
|
50
|
-
@assets_card =
|
51
|
-
@assets_agent =
|
50
|
+
@assets_card = keys_to_sym(@data['assets']['card']) # This is a hash
|
51
|
+
@assets_agent = keys_to_sym(@data['assets']['agent']) # This is a hash
|
52
52
|
end
|
53
53
|
|
54
54
|
def fetch_session_data
|
55
55
|
@session_playtime = @data['session_playtime']['seconds'].to_i
|
56
|
-
@behavior =
|
57
|
-
@ability_casts =
|
56
|
+
@behavior = keys_to_sym(@data['behavior']) # This is a hash
|
57
|
+
@ability_casts = keys_to_sym(@data['ability_casts']) # This is a hash
|
58
58
|
end
|
59
59
|
|
60
60
|
def fetch_performance_data
|
@@ -85,7 +85,7 @@ class Player
|
|
85
85
|
"#{platform["tpye"]} #{platform["os"].values.join(" ")}"
|
86
86
|
end
|
87
87
|
|
88
|
-
def
|
88
|
+
def keys_to_sym(hash)
|
89
89
|
hash.transform_keys(&:to_sym)
|
90
90
|
end
|
91
91
|
end
|
data/lib/api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: valorant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5r1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerard Hernandez
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-11-
|
11
|
+
date: 2022-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fast_jsonparser
|
@@ -52,12 +52,15 @@ files:
|
|
52
52
|
- Rakefile
|
53
53
|
- bin/console
|
54
54
|
- bin/setup
|
55
|
+
- garbage.json
|
55
56
|
- lib/api/account.rb
|
56
57
|
- lib/api/match.rb
|
57
58
|
- lib/api/misc.rb
|
58
59
|
- lib/api/mmr.rb
|
59
60
|
- lib/api/utils/article.rb
|
60
61
|
- lib/api/utils/articles.rb
|
62
|
+
- lib/api/utils/asset.rb
|
63
|
+
- lib/api/utils/content.rb
|
61
64
|
- lib/api/utils/leader.rb
|
62
65
|
- lib/api/utils/leader_board.rb
|
63
66
|
- lib/api/utils/match.rb
|
@@ -88,9 +91,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
88
91
|
version: 3.1.2
|
89
92
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
93
|
requirements:
|
91
|
-
- - "
|
94
|
+
- - ">"
|
92
95
|
- !ruby/object:Gem::Version
|
93
|
-
version:
|
96
|
+
version: 1.3.1
|
94
97
|
requirements: []
|
95
98
|
rubygems_version: 3.3.7
|
96
99
|
signing_key:
|