dota 0.0.12 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Guardfile +1 -1
- data/README.md +145 -112
- data/data/heroes.yml +327 -0
- data/data/items.yml +714 -0
- data/lib/dota.rb +8 -1
- data/lib/dota/api/basic_match.rb +52 -0
- data/lib/dota/api/basic_player.rb +61 -0
- data/lib/dota/api/client.rb +12 -2
- data/lib/dota/api/cosmetic/rarity.rb +1 -9
- data/lib/dota/api/entity.rb +13 -0
- data/lib/dota/api/friend.rb +1 -9
- data/lib/dota/api/hero.rb +2 -111
- data/lib/dota/api/item.rb +1 -240
- data/lib/dota/api/league.rb +6 -8
- data/lib/dota/api/live_match.rb +29 -35
- data/lib/dota/api/live_match/player.rb +29 -22
- data/lib/dota/api/live_match/side.rb +25 -11
- data/lib/dota/api/match.rb +30 -117
- data/lib/dota/api/match/draft.rb +1 -9
- data/lib/dota/api/match/player.rb +7 -59
- data/lib/dota/api/match/side.rb +41 -0
- data/lib/dota/api/scheduled_match.rb +32 -0
- data/lib/dota/api/team.rb +1 -9
- data/lib/dota/version.rb +1 -1
- data/spec/dota/api/cosmetic/rarity_spec.rb +2 -2
- data/spec/dota/api/hero_spec.rb +2 -6
- data/spec/dota/api/item_spec.rb +1 -5
- data/spec/dota/api/live_match/player_spec.rb +76 -8
- data/spec/dota/api/live_match/side_spec.rb +42 -8
- data/spec/dota/api/live_match_spec.rb +5 -16
- data/spec/dota/api/match/draft_spec.rb +4 -1
- data/spec/dota/api/match/player_spec.rb +7 -3
- data/spec/dota/api/match/side_spec.rb +54 -0
- data/spec/dota/api/match_spec.rb +0 -62
- data/spec/dota/api/scheduled_match_spec.rb +36 -0
- data/spec/dota_spec.rb +56 -7
- data/spec/fixtures/vcr_cassettes/GetScheduledLeagueGames.yml +112 -0
- metadata +15 -5
- data/lib/dota/api/live_match/scoreboard.rb +0 -31
- data/spec/dota/api/live_match/scoreboard_spec.rb +0 -25
@@ -1,80 +1,28 @@
|
|
1
1
|
module Dota
|
2
2
|
module API
|
3
3
|
class Match
|
4
|
-
class Player
|
5
|
-
|
6
|
-
|
7
|
-
attr_reader :raw
|
8
|
-
|
9
|
-
def initialize(raw)
|
10
|
-
@raw = raw
|
11
|
-
end
|
12
|
-
|
13
|
-
def id
|
14
|
-
raw["account_id"]
|
15
|
-
end
|
4
|
+
class Player < BasicPlayer
|
5
|
+
# See https://wiki.teamfortress.com/wiki/WebAPI/GetMatchHistory#Player_Slot
|
6
|
+
SLOT_GAP = 128
|
16
7
|
|
17
8
|
def slot
|
18
|
-
raw["player_slot"]
|
9
|
+
slot = raw["player_slot"]
|
10
|
+
slot -= SLOT_GAP if slot >= SLOT_GAP
|
11
|
+
slot + 1
|
19
12
|
end
|
20
13
|
|
21
14
|
def status
|
22
|
-
|
23
|
-
when 0
|
24
|
-
:played
|
25
|
-
when 1
|
26
|
-
:left_safe
|
27
|
-
when 2
|
28
|
-
:abandoned
|
29
|
-
else
|
30
|
-
:bot
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def hero
|
35
|
-
Hero.new(raw["hero_id"])
|
36
|
-
end
|
37
|
-
|
38
|
-
def level
|
39
|
-
raw["level"]
|
40
|
-
end
|
41
|
-
|
42
|
-
def kills
|
43
|
-
raw["kills"]
|
15
|
+
STATUS[raw["leaver_status"]]
|
44
16
|
end
|
45
17
|
|
46
18
|
def deaths
|
47
19
|
raw["deaths"]
|
48
20
|
end
|
49
21
|
|
50
|
-
def assists
|
51
|
-
raw["assists"]
|
52
|
-
end
|
53
|
-
|
54
|
-
def last_hits
|
55
|
-
raw["last_hits"]
|
56
|
-
end
|
57
|
-
|
58
|
-
def denies
|
59
|
-
raw["denies"]
|
60
|
-
end
|
61
|
-
|
62
|
-
def gold
|
63
|
-
raw["gold"]
|
64
|
-
end
|
65
|
-
|
66
22
|
def gold_spent
|
67
23
|
raw["gold_spent"]
|
68
24
|
end
|
69
25
|
|
70
|
-
def gpm
|
71
|
-
raw["gold_per_min"]
|
72
|
-
end
|
73
|
-
|
74
|
-
def xpm
|
75
|
-
raw["xp_per_min"]
|
76
|
-
end
|
77
|
-
|
78
26
|
def hero_damage
|
79
27
|
raw["hero_damage"]
|
80
28
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Dota
|
2
|
+
module API
|
3
|
+
class Match
|
4
|
+
class Side < Entity
|
5
|
+
def id
|
6
|
+
raw["team_id"]
|
7
|
+
end
|
8
|
+
|
9
|
+
def name
|
10
|
+
raw["name"]
|
11
|
+
end
|
12
|
+
|
13
|
+
def logo_id
|
14
|
+
raw["logo"]
|
15
|
+
end
|
16
|
+
|
17
|
+
def complete?
|
18
|
+
raw["team_complete"] == 1
|
19
|
+
end
|
20
|
+
|
21
|
+
def tower_status
|
22
|
+
raw["tower_status"]
|
23
|
+
end
|
24
|
+
|
25
|
+
def barracks_status
|
26
|
+
raw["barracks_status"]
|
27
|
+
end
|
28
|
+
|
29
|
+
def players
|
30
|
+
raw["players"].map do |raw_player|
|
31
|
+
Player.new(raw_player)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def captain_id
|
36
|
+
raw["captain"]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Dota
|
2
|
+
module API
|
3
|
+
class ScheduledMatch < Entity
|
4
|
+
def league_id
|
5
|
+
raw["league_id"]
|
6
|
+
end
|
7
|
+
|
8
|
+
def game_id
|
9
|
+
raw["game_id"]
|
10
|
+
end
|
11
|
+
|
12
|
+
def teams
|
13
|
+
raw["teams"].map do |raw_team|
|
14
|
+
raw_team["name"] = raw_team.delete("team_name")
|
15
|
+
Team.new(raw_team)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def starts_at
|
20
|
+
Time.at(raw["starttime"])
|
21
|
+
end
|
22
|
+
|
23
|
+
def description
|
24
|
+
raw["comment"]
|
25
|
+
end
|
26
|
+
|
27
|
+
def final?
|
28
|
+
raw["final"]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/dota/api/team.rb
CHANGED
data/lib/dota/version.rb
CHANGED
@@ -5,8 +5,8 @@ describe Dota::API::Cosmetic::Rarity do
|
|
5
5
|
end
|
6
6
|
end
|
7
7
|
|
8
|
-
specify("#id") { expect(rarity.id).to
|
8
|
+
specify("#id") { expect(rarity.id).to eq 7 }
|
9
9
|
specify("#order") { expect(rarity.order).to eq 6 }
|
10
10
|
specify("#color") { expect(rarity.color).to eq "#e4ae39" }
|
11
|
-
specify("#name") { expect(rarity.name).to
|
11
|
+
specify("#name") { expect(rarity.name).to eq "Immortal" }
|
12
12
|
end
|
data/spec/dota/api/hero_spec.rb
CHANGED
@@ -1,14 +1,10 @@
|
|
1
1
|
describe Dota::API::Hero do
|
2
|
-
let(:hero)
|
3
|
-
VCR.use_cassette("GetMatchDetails") do
|
4
|
-
test_client.matches(sample_match_id).players.first.hero
|
5
|
-
end
|
6
|
-
end
|
2
|
+
let(:hero) { described_class.new(69) }
|
7
3
|
|
8
4
|
specify ".all" do
|
9
5
|
heroes = described_class.all
|
10
6
|
expect(heroes.first).to be_a described_class
|
11
|
-
expect(heroes.count).to eq
|
7
|
+
expect(heroes.count).to eq 109
|
12
8
|
end
|
13
9
|
|
14
10
|
specify "#id" do
|
data/spec/dota/api/item_spec.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
describe Dota::API::LiveMatch::Player do
|
2
|
-
let(:
|
2
|
+
let(:live_match) do
|
3
3
|
VCR.use_cassette("GetLiveLeagueGames") do
|
4
|
-
|
5
|
-
first_match = matches.first
|
6
|
-
players = first_match.players
|
7
|
-
players.first
|
4
|
+
test_client.live_matches.first
|
8
5
|
end
|
9
6
|
end
|
7
|
+
let(:player) do
|
8
|
+
live_match.radiant.players.at(3)
|
9
|
+
end
|
10
10
|
|
11
11
|
specify "#id" do
|
12
12
|
expect(player.id).to eq 34145091
|
@@ -20,7 +20,75 @@ describe Dota::API::LiveMatch::Player do
|
|
20
20
|
expect(player.hero).to be_a Dota::API::Hero
|
21
21
|
end
|
22
22
|
|
23
|
-
specify "#
|
24
|
-
expect(player.
|
23
|
+
specify "#kills" do
|
24
|
+
expect(player.kills).to eq 4
|
25
|
+
end
|
26
|
+
|
27
|
+
specify "#deaths" do
|
28
|
+
expect(player.deaths).to eq 6
|
29
|
+
end
|
30
|
+
|
31
|
+
specify "#assists" do
|
32
|
+
expect(player.assists).to eq 15
|
33
|
+
end
|
34
|
+
|
35
|
+
specify "#slot" do
|
36
|
+
expect(player.slot).to eq 4
|
37
|
+
|
38
|
+
expect(live_match.radiant.players.map(&:slot)).to eq [1, 2, 3, 4, 5]
|
39
|
+
expect(live_match.dire.players.map(&:slot)).to eq [1, 2, 3, 4, 5]
|
40
|
+
end
|
41
|
+
|
42
|
+
specify "#last_hits" do
|
43
|
+
expect(player.last_hits).to eq 42
|
44
|
+
end
|
45
|
+
|
46
|
+
specify "#denies" do
|
47
|
+
expect(player.denies).to eq 3
|
48
|
+
end
|
49
|
+
|
50
|
+
specify "#gold" do
|
51
|
+
expect(player.gold).to eq 3131
|
52
|
+
end
|
53
|
+
|
54
|
+
specify "#level" do
|
55
|
+
expect(player.level).to eq 19
|
56
|
+
end
|
57
|
+
|
58
|
+
specify "#gpm" do
|
59
|
+
expect(player.gpm).to eq 279
|
60
|
+
end
|
61
|
+
|
62
|
+
specify "#xpm" do
|
63
|
+
expect(player.xpm).to eq 409
|
64
|
+
end
|
65
|
+
|
66
|
+
specify "#ultimate_state" do
|
67
|
+
expect(player.ultimate_state).to eq 3
|
68
|
+
end
|
69
|
+
|
70
|
+
specify "#ultimate_cooldown" do
|
71
|
+
expect(player.ultimate_cooldown).to eq 0
|
72
|
+
end
|
73
|
+
|
74
|
+
specify "#items" do
|
75
|
+
expect(player.items.count).to eq 6
|
76
|
+
expect(player.items.first).to be_an Dota::API::Item
|
77
|
+
end
|
78
|
+
|
79
|
+
specify "#respawn_timer" do
|
80
|
+
expect(player.respawn_timer).to eq 0
|
81
|
+
end
|
82
|
+
|
83
|
+
specify "#position_x" do
|
84
|
+
expect(player.position_x).to eq -4874.2314453125
|
85
|
+
end
|
86
|
+
|
87
|
+
specify "#position_y" do
|
88
|
+
expect(player.position_y).to eq -4778.44677734375
|
89
|
+
end
|
90
|
+
|
91
|
+
specify "#net_worth" do
|
92
|
+
expect(player.net_worth).to eq 11531
|
25
93
|
end
|
26
|
-
end
|
94
|
+
end
|
@@ -1,25 +1,59 @@
|
|
1
1
|
describe Dota::API::LiveMatch::Side do
|
2
|
-
let(:
|
2
|
+
let(:live_match) do
|
3
3
|
VCR.use_cassette("GetLiveLeagueGames") do
|
4
|
-
|
5
|
-
first_match = matches.first
|
6
|
-
first_match.dire
|
4
|
+
test_client.live_matches.first
|
7
5
|
end
|
8
6
|
end
|
7
|
+
let(:radiant) { live_match.radiant }
|
8
|
+
let(:dire) { live_match.dire }
|
9
9
|
|
10
10
|
specify "#id" do
|
11
|
-
expect(
|
11
|
+
expect(radiant.id).to eq 1677303
|
12
|
+
expect(dire.id).to eq 1846074
|
12
13
|
end
|
13
14
|
|
14
15
|
specify "#name" do
|
15
|
-
expect(
|
16
|
+
expect(radiant.name).to eq "ReallyCoolGuys"
|
17
|
+
expect(dire.name).to eq "Haunti Gaming"
|
16
18
|
end
|
17
19
|
|
18
20
|
specify "#logo_id" do
|
19
|
-
expect(
|
21
|
+
expect(radiant.logo_id).to eq 29595255080842763
|
22
|
+
expect(dire.logo_id).to eq 547513665869798854
|
20
23
|
end
|
21
24
|
|
22
25
|
specify "#complete?" do
|
23
|
-
expect(
|
26
|
+
expect(radiant.complete?).to eq false
|
27
|
+
expect(dire.complete?).to eq false
|
28
|
+
end
|
29
|
+
|
30
|
+
specify "#score" do
|
31
|
+
expect(radiant.score).to eq 42
|
32
|
+
expect(dire.score).to eq 54
|
33
|
+
end
|
34
|
+
|
35
|
+
specify "#series_wins" do
|
36
|
+
expect(radiant.series_wins).to eq 0
|
37
|
+
expect(dire.series_wins).to eq 0
|
38
|
+
end
|
39
|
+
|
40
|
+
specify "#tower_status" do
|
41
|
+
expect(radiant.tower_status).to eq 1540
|
42
|
+
expect(dire.tower_status).to eq 1958
|
43
|
+
end
|
44
|
+
|
45
|
+
specify "#barracks_status" do
|
46
|
+
expect(radiant.barracks_status).to eq 3
|
47
|
+
expect(dire.barracks_status).to eq 63
|
48
|
+
end
|
49
|
+
|
50
|
+
specify "#players" do
|
51
|
+
players = radiant.players
|
52
|
+
expect(players.count).to eq 5
|
53
|
+
expect(players.first).to be_a Dota::API::LiveMatch::Player
|
54
|
+
|
55
|
+
players = dire.players
|
56
|
+
expect(players.count).to eq 5
|
57
|
+
expect(players.first).to be_a Dota::API::LiveMatch::Player
|
24
58
|
end
|
25
59
|
end
|
@@ -1,8 +1,7 @@
|
|
1
1
|
describe Dota::API::LiveMatch do
|
2
2
|
let(:live_match) do
|
3
3
|
VCR.use_cassette("GetLiveLeagueGames") do
|
4
|
-
|
5
|
-
matches.first
|
4
|
+
test_client.live_matches.first
|
6
5
|
end
|
7
6
|
end
|
8
7
|
|
@@ -26,14 +25,6 @@ describe Dota::API::LiveMatch do
|
|
26
25
|
expect(live_match.stream_delay).to eq 120
|
27
26
|
end
|
28
27
|
|
29
|
-
specify "#radiant_wins" do
|
30
|
-
expect(live_match.radiant_wins).to eq 0
|
31
|
-
end
|
32
|
-
|
33
|
-
specify "#dire_wins" do
|
34
|
-
expect(live_match.dire_wins).to eq 0
|
35
|
-
end
|
36
|
-
|
37
28
|
specify "#radiant" do
|
38
29
|
expect(live_match.radiant).to be_a Dota::API::LiveMatch::Side
|
39
30
|
end
|
@@ -50,13 +41,11 @@ describe Dota::API::LiveMatch do
|
|
50
41
|
expect(live_match.league_tier).to eq "Amateur"
|
51
42
|
end
|
52
43
|
|
53
|
-
specify "#
|
54
|
-
|
55
|
-
expect(players.count).to eq 11
|
56
|
-
expect(players.first).to be_a Dota::API::LiveMatch::Player
|
44
|
+
specify "#duration" do
|
45
|
+
expect(live_match.duration).to eq 2840.2998046875
|
57
46
|
end
|
58
47
|
|
59
|
-
specify "#
|
60
|
-
expect(live_match.
|
48
|
+
specify "#roshan_timer" do
|
49
|
+
expect(live_match.roshan_timer).to eq 278
|
61
50
|
end
|
62
51
|
end
|