dotka 1.0.1 → 1.0.2
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/.gitignore +1 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +30 -0
- data/LICENSE +21 -0
- data/README.md +7 -0
- data/Rakefile +7 -0
- data/data/game_modes.json +90 -0
- data/data/heroes.json +547 -0
- data/data/items.json +1187 -0
- data/data/lobbies.json +42 -0
- data/data/regions.json +142 -0
- data/docs/todo.md +70 -0
- data/dotka.gemspec +12 -0
- data/lib/dotka/game_mode.rb +12 -0
- data/lib/dotka/hero.rb +15 -0
- data/lib/dotka/item.rb +15 -0
- data/lib/dotka/lobby.rb +12 -0
- data/lib/dotka/match.rb +39 -0
- data/lib/dotka/player.rb +68 -0
- data/lib/dotka/raw.rb +8 -0
- data/lib/dotka/region.rb +12 -0
- data/lib/dotka/skill.rb +16 -0
- data/lib/dotka/storage.rb +21 -0
- data/spec/dotka_spec.rb +40 -0
- data/spec/game_mode_spec.rb +17 -0
- data/spec/hero_spec.rb +19 -0
- data/spec/item_spec.rb +19 -0
- data/spec/lobby_spec.rb +17 -0
- data/spec/match_spec.rb +31 -0
- data/spec/player_spec.rb +53 -0
- data/spec/region_spec.rb +17 -0
- data/spec/storage_spec.rb +24 -0
- metadata +33 -1
data/data/lobbies.json
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"id": "-1",
|
4
|
+
"name": "Invalid"
|
5
|
+
},
|
6
|
+
{
|
7
|
+
"id": "0",
|
8
|
+
"name": "Public matchmaking"
|
9
|
+
},
|
10
|
+
{
|
11
|
+
"id": "1",
|
12
|
+
"name": "Practice"
|
13
|
+
},
|
14
|
+
{
|
15
|
+
"id": "2",
|
16
|
+
"name": "Tournament"
|
17
|
+
},
|
18
|
+
{
|
19
|
+
"id": "3",
|
20
|
+
"name": "Tutorial"
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"id": "4",
|
24
|
+
"name": "Co-op with bots"
|
25
|
+
},
|
26
|
+
{
|
27
|
+
"id": "5",
|
28
|
+
"name": "Team match"
|
29
|
+
},
|
30
|
+
{
|
31
|
+
"id": "6",
|
32
|
+
"name": "Solo Queue"
|
33
|
+
},
|
34
|
+
{
|
35
|
+
"id": "7",
|
36
|
+
"name": "Ranked"
|
37
|
+
},
|
38
|
+
{
|
39
|
+
"id": "8",
|
40
|
+
"name": "Solo Mid 1vs1"
|
41
|
+
}
|
42
|
+
]
|
data/data/regions.json
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"id": "111",
|
4
|
+
"name": "US West"
|
5
|
+
},
|
6
|
+
{
|
7
|
+
"id": "112",
|
8
|
+
"name": "US West"
|
9
|
+
},
|
10
|
+
{
|
11
|
+
"id": "114",
|
12
|
+
"name": "US West"
|
13
|
+
},
|
14
|
+
{
|
15
|
+
"id": "121",
|
16
|
+
"name": "US East"
|
17
|
+
},
|
18
|
+
{
|
19
|
+
"id": "122",
|
20
|
+
"name": "US East"
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"id": "123",
|
24
|
+
"name": "US East"
|
25
|
+
},
|
26
|
+
{
|
27
|
+
"id": "124",
|
28
|
+
"name": "US East"
|
29
|
+
},
|
30
|
+
{
|
31
|
+
"id": "131",
|
32
|
+
"name": "Europe West"
|
33
|
+
},
|
34
|
+
{
|
35
|
+
"id": "132",
|
36
|
+
"name": "Europe West"
|
37
|
+
},
|
38
|
+
{
|
39
|
+
"id": "133",
|
40
|
+
"name": "Europe West"
|
41
|
+
},
|
42
|
+
{
|
43
|
+
"id": "134",
|
44
|
+
"name": "Europe West"
|
45
|
+
},
|
46
|
+
{
|
47
|
+
"id": "135",
|
48
|
+
"name": "Europe West"
|
49
|
+
},
|
50
|
+
{
|
51
|
+
"id": "136",
|
52
|
+
"name": "Europe West"
|
53
|
+
},
|
54
|
+
{
|
55
|
+
"id": "142",
|
56
|
+
"name": "South Korea"
|
57
|
+
},
|
58
|
+
{
|
59
|
+
"id": "143",
|
60
|
+
"name": "South Korea"
|
61
|
+
},
|
62
|
+
{
|
63
|
+
"id": "151",
|
64
|
+
"name": "Southeast Asia"
|
65
|
+
},
|
66
|
+
{
|
67
|
+
"id": "152",
|
68
|
+
"name": "Southeast Asia"
|
69
|
+
},
|
70
|
+
{
|
71
|
+
"id": "153",
|
72
|
+
"name": "Southeast Asia"
|
73
|
+
},
|
74
|
+
{
|
75
|
+
"id": "161",
|
76
|
+
"name": "China"
|
77
|
+
},
|
78
|
+
{
|
79
|
+
"id": "163",
|
80
|
+
"name": "China"
|
81
|
+
},
|
82
|
+
{
|
83
|
+
"id": "171",
|
84
|
+
"name": "Australia"
|
85
|
+
},
|
86
|
+
{
|
87
|
+
"id": "181",
|
88
|
+
"name": "Russia"
|
89
|
+
},
|
90
|
+
{
|
91
|
+
"id": "182",
|
92
|
+
"name": "Russia"
|
93
|
+
},
|
94
|
+
{
|
95
|
+
"id": "183",
|
96
|
+
"name": "Russia"
|
97
|
+
},
|
98
|
+
{
|
99
|
+
"id": "184",
|
100
|
+
"name": "Russia"
|
101
|
+
},
|
102
|
+
{
|
103
|
+
"id": "191",
|
104
|
+
"name": "Europe East"
|
105
|
+
},
|
106
|
+
{
|
107
|
+
"id": "200",
|
108
|
+
"name": "South America"
|
109
|
+
},
|
110
|
+
{
|
111
|
+
"id": "204",
|
112
|
+
"name": "South America"
|
113
|
+
},
|
114
|
+
{
|
115
|
+
"id": "211",
|
116
|
+
"name": "South America"
|
117
|
+
},
|
118
|
+
{
|
119
|
+
"id": "212",
|
120
|
+
"name": "South America"
|
121
|
+
},
|
122
|
+
{
|
123
|
+
"id": "213",
|
124
|
+
"name": "South America"
|
125
|
+
},
|
126
|
+
{
|
127
|
+
"id": "221",
|
128
|
+
"name": "China"
|
129
|
+
},
|
130
|
+
{
|
131
|
+
"id": "222",
|
132
|
+
"name": "China"
|
133
|
+
},
|
134
|
+
{
|
135
|
+
"id": "223",
|
136
|
+
"name": "China"
|
137
|
+
},
|
138
|
+
{
|
139
|
+
"id": "231",
|
140
|
+
"name": "China"
|
141
|
+
}
|
142
|
+
]
|
data/docs/todo.md
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# TODO
|
2
|
+
|
3
|
+
- `match = Dotka.match(id)`:
|
4
|
+
- `match.id` returns an `integer`.
|
5
|
+
- `match.players` returns an `array` of `DotkaM::Player` instances.
|
6
|
+
- `match.winner` returns either `radiant` or `dire` (`string`).
|
7
|
+
- `match.duration` returns the match duration in seconds (`integer`).
|
8
|
+
- `match.start_time` returns the start time in seconds (`integer`, UTC).
|
9
|
+
- `match.lobby` returns an instance of `DotkaM::Lobby`.
|
10
|
+
- `match.game_mode` returns an instance of `DotkaM::GameMode`.
|
11
|
+
- `match.region` returns an instance of `DotkaM::Region`.
|
12
|
+
- *This method will return an instance of `DotkaM::Match`.*
|
13
|
+
|
14
|
+
- `matches = Dotka.matches(conditions)` where `conditions` is an `array` with these keys:
|
15
|
+
- `player_name` as a `string`.
|
16
|
+
- `hero_id` as an `integer`.
|
17
|
+
- `skill_type` as an `integer`: (0, 1, 2, 3) => (Any, Normal, High, Very High).
|
18
|
+
- `min_date` as an `integer` (UTC).
|
19
|
+
- `max_date` as an `integer` (UTC).
|
20
|
+
- `account_id` as an `integer` (for example, `70388657`).
|
21
|
+
- `start_at_match_id` as an `integer`.
|
22
|
+
- `amount_of_matches` as an `integer`.
|
23
|
+
- *This method will return an `array` of `DotkaM::Match` instances.*
|
24
|
+
|
25
|
+
- `player = Dotka.player(id)`:
|
26
|
+
- `player.account_id` returns an `integer`.
|
27
|
+
- `player.hero` returns an instance of `DotkaM::Hero`.
|
28
|
+
- `player.items` returns an `array` of `DotkaM::Item` instances.
|
29
|
+
- `player.kills` returns an `integer`.
|
30
|
+
- `player.deaths` returns an `integer`.
|
31
|
+
- `player.assists` returns an `integer`.
|
32
|
+
- `player.abandoned?` returns a `boolean`.
|
33
|
+
- `player.team` returns either `dire` or `radiant`.
|
34
|
+
- `player.gold` returns an `integer`.
|
35
|
+
- `player.last_hits` returns an `integer`.
|
36
|
+
- `player.denies` returns an `integer`.
|
37
|
+
- `player.gold_per_min` returns an `integer`.
|
38
|
+
- `player.xp_per_min` returns an `integer`.
|
39
|
+
- `player.hero_dmg` returns an `integer`.
|
40
|
+
- `player.tower_dmg` returns an `integer`.
|
41
|
+
- `player.hero_heal` returns an `integer`.
|
42
|
+
- `player.level` returns an `integer`.
|
43
|
+
- *This method will return an instance of `DotkaM::Player`.*
|
44
|
+
|
45
|
+
- `hero = Dotka.hero(id)`:
|
46
|
+
- `hero.id` returns an `integer`.
|
47
|
+
- `hero.name` returns a `string` (internal hero name).
|
48
|
+
- `hero.localized_name` returns a `string` (localized hero name in English).
|
49
|
+
- *This method will return an instance of `DotkaM::Hero`.*
|
50
|
+
|
51
|
+
- `item = Dotka.item(id)`:
|
52
|
+
- `item.id` returns an `integer`.
|
53
|
+
- `item.name` returns a `string` (internal item name).
|
54
|
+
- `item.localized_name` returns a `string` (localized item name in English).
|
55
|
+
- *This method will return an instance of `DotkaM::Item`.*
|
56
|
+
|
57
|
+
- `game_mode = Dotka.game_mode(id)`:
|
58
|
+
- `game_mode.id` returns an `integer`.
|
59
|
+
- `game_mode.localized_name` returns a `string` (localized game mode name in English).
|
60
|
+
- *This method will return an instance of `DotkaM::GameMode`.*
|
61
|
+
|
62
|
+
- `lobby = Dotka.lobby(id)`:
|
63
|
+
- `lobby.id` returns an `integer`.
|
64
|
+
- `lobby.localized_name` returns a `string` (localized lobby name in English).
|
65
|
+
- *This method will return an instance of `DotkaM::Lobby`.*
|
66
|
+
|
67
|
+
- `region = Dotka.region(id)`:
|
68
|
+
- `region.id` returns an `integer`.
|
69
|
+
- `region.localized_name` returns a `string` (localized region name in English).
|
70
|
+
- *This method will return an instance of `DotkaM::Region`.*
|
data/dotka.gemspec
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = 'dotka'
|
3
|
+
spec.version = '1.0.2'
|
4
|
+
spec.date = '2014-12-11'
|
5
|
+
spec.summary = 'Dota 2 WebAPI Wrapper'
|
6
|
+
spec.description = 'Makes interaction with Dota 2 WebAPI easy'
|
7
|
+
spec.authors = ['bound1ess']
|
8
|
+
spec.email = 'bound1ess.dev@gmail.com'
|
9
|
+
spec.files = `git ls-files`.split($/)
|
10
|
+
spec.license = 'MIT'
|
11
|
+
spec.homepage = 'https://github.com/bound1ess/dotka'
|
12
|
+
end
|
data/lib/dotka/hero.rb
ADDED
data/lib/dotka/item.rb
ADDED
data/lib/dotka/lobby.rb
ADDED
data/lib/dotka/match.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require_relative "raw"
|
2
|
+
require_relative "player"
|
3
|
+
require_relative "lobby"
|
4
|
+
require_relative "game_mode"
|
5
|
+
require_relative "region"
|
6
|
+
require_relative "storage"
|
7
|
+
|
8
|
+
module DotkaM
|
9
|
+
class Match < Raw
|
10
|
+
def id
|
11
|
+
@raw["match_id"].to_i
|
12
|
+
end
|
13
|
+
def players
|
14
|
+
players = Array.new
|
15
|
+
@raw["players"].each { |player|
|
16
|
+
players.push Player.new(player)
|
17
|
+
}
|
18
|
+
players
|
19
|
+
end
|
20
|
+
def winner
|
21
|
+
(!! @raw["radiant_win"]) ? "radiant" : "dire"
|
22
|
+
end
|
23
|
+
def duration
|
24
|
+
@raw["duration"].to_i
|
25
|
+
end
|
26
|
+
def start_time
|
27
|
+
@raw["start_time"].to_i
|
28
|
+
end
|
29
|
+
def lobby
|
30
|
+
Lobby.new Storage.new.get("lobbies", {"id" => @raw["lobby_type"]})
|
31
|
+
end
|
32
|
+
def game_mode
|
33
|
+
GameMode.new Storage.new.get("game_modes", {"id" => @raw["game_mode"]})
|
34
|
+
end
|
35
|
+
def region
|
36
|
+
Region.new Storage.new.get("regions", {"id" => @raw["cluster"]})
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/dotka/player.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
require_relative "raw"
|
2
|
+
require_relative "storage"
|
3
|
+
require_relative "hero"
|
4
|
+
require_relative "item"
|
5
|
+
|
6
|
+
module DotkaM
|
7
|
+
class Player < Raw
|
8
|
+
def account_id
|
9
|
+
@raw["account_id"].to_i
|
10
|
+
end
|
11
|
+
def hero
|
12
|
+
Hero.new Storage.new.get("heroes", {"id" => @raw["hero_id"]})
|
13
|
+
end
|
14
|
+
def items
|
15
|
+
storage = Storage.new
|
16
|
+
[
|
17
|
+
Item.new(storage.get "items", {"id" => @raw["item_0"]}),
|
18
|
+
Item.new(storage.get "items", {"id" => @raw["item_1"]}),
|
19
|
+
Item.new(storage.get "items", {"id" => @raw["item_2"]}),
|
20
|
+
Item.new(storage.get "items", {"id" => @raw["item_3"]}),
|
21
|
+
Item.new(storage.get "items", {"id" => @raw["item_4"]}),
|
22
|
+
Item.new(storage.get "items", {"id" => @raw["item_5"]})
|
23
|
+
]
|
24
|
+
end
|
25
|
+
def kills
|
26
|
+
@raw["kills"].to_i
|
27
|
+
end
|
28
|
+
def deaths
|
29
|
+
@raw["deaths"].to_i
|
30
|
+
end
|
31
|
+
def assists
|
32
|
+
@raw["assists"].to_i
|
33
|
+
end
|
34
|
+
def abandoned?
|
35
|
+
@raw["leaver_status"].to_i == 1
|
36
|
+
end
|
37
|
+
def team
|
38
|
+
@raw["player_slot"].to_i > 4 ? "dire" : "radiant"
|
39
|
+
end
|
40
|
+
def gold
|
41
|
+
@raw["gold"].to_i + @raw["gold_spent"].to_i
|
42
|
+
end
|
43
|
+
def last_hits
|
44
|
+
@raw["last_hits"].to_i
|
45
|
+
end
|
46
|
+
def denies
|
47
|
+
@raw["denies"].to_i
|
48
|
+
end
|
49
|
+
def gold_per_min
|
50
|
+
@raw["gold_per_min"].to_i
|
51
|
+
end
|
52
|
+
def xp_per_min
|
53
|
+
@raw["xp_per_min"].to_i
|
54
|
+
end
|
55
|
+
def hero_dmg
|
56
|
+
@raw["hero_damage"].to_i
|
57
|
+
end
|
58
|
+
def tower_dmg
|
59
|
+
@raw["tower_damage"].to_i
|
60
|
+
end
|
61
|
+
def hero_heal
|
62
|
+
@raw["hero_healing"].to_i
|
63
|
+
end
|
64
|
+
def level
|
65
|
+
@raw["level"].to_i
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|