Skip to content

Commit c61a499

Browse files
committed
Merge pull request nashby#9 from edchiou/master
*Finally fixed
2 parents 13bae43 + ce5a57b commit c61a499

File tree

3 files changed

+84
-2
lines changed

3 files changed

+84
-2
lines changed

lib/dota/match.rb

+21
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,27 @@ def gpm
233233
def items
234234
(0..5).map { |i| Constants::Items[raw_player["item_#{i}"]] }
235235
end
236+
237+
# List of items on secondary unit (e.g. Syllabear's bear)
238+
#
239+
# @return [Array<String>] an array of item names
240+
def additional_unit_items
241+
(0..5).map { |i| Items[raw_player['additional_units'][0]["item_#{i}"]] }
242+
end
243+
244+
# Names of secondary units
245+
#
246+
# @return [Array<String>] an array of secondary unit names
247+
def additional_unit_names
248+
raw_player['additional_units'][0]['unitname']
249+
end
250+
251+
# List of ability upgrades, their timings, and level taken at
252+
#
253+
# @return [Array<Hash>] an array of ability upgrades
254+
def upgrades
255+
(0..raw_player['ability_upgrades'].length).map { |i| raw_player['ability_upgrades'][i] }
256+
end
236257
end
237258
end
238259
end

spec/fixtures/match_player.json

+50-1
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,54 @@
2121
"hero_damage": 8270,
2222
"tower_damage": 597,
2323
"hero_healing": 39,
24-
"level": 13
24+
"level": 13,
25+
"ability_upgrades": [
26+
{
27+
"ability": 5412,
28+
"time": 97,
29+
"level": 1
30+
},
31+
{
32+
"ability": 5414,
33+
"time": 277,
34+
"level": 2
35+
},
36+
{
37+
"ability": 5412,
38+
"time": 329,
39+
"level": 3
40+
},
41+
{
42+
"ability": 5414,
43+
"time": 460,
44+
"level": 4
45+
},
46+
{
47+
"ability": 5412,
48+
"time": 580,
49+
"level": 5
50+
},
51+
{
52+
"ability": 5415,
53+
"time": 794,
54+
"level": 6
55+
},
56+
{
57+
"ability": 5412,
58+
"time": 1075,
59+
"level": 7
60+
}
61+
]
62+
,
63+
"additional_units": [
64+
{
65+
"unitname": "spirit_bear",
66+
"item_0": 181,
67+
"item_1": 182,
68+
"item_2": 0,
69+
"item_3": 0,
70+
"item_4": 0,
71+
"item_5": 0
72+
}
73+
]
2574
}

spec/match_player_spec.rb

+13-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def player.raw_player; { 'leaver_status' => 2 }; end
4141
player.last_hits.must_equal 98
4242
end
4343

44-
it 'returns the number of times a player denied a creep' do
44+
it 'returns denies' do
4545
player.denies.must_equal 2
4646
end
4747

@@ -76,4 +76,16 @@ def player.raw_player; { 'leaver_status' => 2 }; end
7676
it 'returns xpm' do
7777
player.xpm.must_equal 304
7878
end
79+
80+
it 'returns additional unit names' do
81+
player.additional_unit_names.must_equal 'spirit_bear'
82+
end
83+
84+
it 'returns additional unit items' do
85+
player.additional_unit_items.must_equal ['orb_of_venom', 'stout_shield', 'emptyitembg', 'emptyitembg', 'emptyitembg', 'emptyitembg']
86+
end
87+
88+
it 'returns ability upgrades' do
89+
player.upgrades[0].must_equal ({"ability" => 5412, "time" => 97, "level" => 1})
90+
end
7991
end

0 commit comments

Comments
 (0)