honclient 0.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.
- data/lib/honclient/match_stats.rb +1 -1
- data/lib/honclient/player_hero_stats.rb +4 -7
- data/lib/honclient/player_stats.rb +32 -1
- data/lib/honclient/stats.rb +5 -1
- metadata +5 -21
- data/README +0 -21
|
@@ -10,7 +10,7 @@ module HoN
|
|
|
10
10
|
begin
|
|
11
11
|
url = "http://xml.heroesofnewerth.com/xml_requester.php?f=match_stats&opt=mid&mid[]=#{@match_id}"
|
|
12
12
|
xml_data = Net::HTTP.get_response(URI.parse(url)).body
|
|
13
|
-
data = Nokogiri::XML.
|
|
13
|
+
data = Nokogiri::XML.parse(xml_data)
|
|
14
14
|
data.xpath('//xmlRequest/stats/match/summ/stat').each do |stat|
|
|
15
15
|
@summary_stats[stat["name"]] = stat.content
|
|
16
16
|
end
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
module HoN
|
|
2
2
|
class PlayerHeroStats < Stats
|
|
3
|
+
attr_accessor :heroes, :nickname
|
|
3
4
|
def initialize(nickname)
|
|
4
5
|
@nickname = nickname
|
|
5
6
|
@heroes = {}
|
|
6
7
|
begin
|
|
7
8
|
url = "http://xml.heroesofnewerth.com/xml_requester.php?f=player_hero_stats&opt=nick&nick[]=#{@nickname}"
|
|
8
9
|
xml_data = Net::HTTP.get_response(URI.parse(url)).body
|
|
9
|
-
data = Nokogiri::XML.
|
|
10
|
+
data = Nokogiri::XML.parse(xml_data)
|
|
10
11
|
data.xpath("//xmlRequest/stats/player_hero_stats/hero").each do |hero|
|
|
11
12
|
temp = {}
|
|
12
13
|
hero.children.each do |stat|
|
|
@@ -19,12 +20,8 @@ module HoN
|
|
|
19
20
|
end
|
|
20
21
|
end
|
|
21
22
|
|
|
22
|
-
def
|
|
23
|
-
@
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def heroes
|
|
27
|
-
@heroes
|
|
23
|
+
def hero(name)
|
|
24
|
+
@heroes["Hero_#{name.capitalize}"]
|
|
28
25
|
end
|
|
29
26
|
|
|
30
27
|
def stats(hero,key)
|
|
@@ -24,7 +24,38 @@ module HoN
|
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
def kdr
|
|
27
|
-
|
|
27
|
+
(acc_herokills / acc_deaths).round(2)
|
|
28
|
+
rescue ZeroDivisionError
|
|
29
|
+
0
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def ranked_kdr
|
|
33
|
+
(rnk_herokills / rnk_deaths).round(2)
|
|
34
|
+
rescue ZeroDivisionError
|
|
35
|
+
0
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def mmr
|
|
39
|
+
rnk_amm_team_rating.to_f.round
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def tsr
|
|
43
|
+
puts (rnk_herokills / rnk_deaths / 1.1 / 1.15) * 0.65
|
|
44
|
+
tsr_value = ((rnk_herokills/rnk_deaths/1.1/1.15)*0.65)+
|
|
45
|
+
((rnk_heroassists/rnk_deaths/1.55)*1.20)+
|
|
46
|
+
(((rnk_wins/(rnk_wins+rnk_losses))/0.55)*0.9)+
|
|
47
|
+
(((rnk_gold/rnk_secs*60)/230) * (1-((230/195)*((rnk_em_played/rnk_games_played))))*0.35)+
|
|
48
|
+
((((rnk_exp/rnk_time_earning_exp*60)/380)*(1-((380/565)*(rnk_em_played/rnk_games_played))))*0.40)+
|
|
49
|
+
(( ((((rnk_denies/rnk_games_played)/12)*(1-((4.5/8.5)*(rnk_em_played/rnk_games_played))))*0.70)+
|
|
50
|
+
((((rnk_teamcreepkills/rnk_games_played)/93)*(1-((63/81)*(rnk_em_played/rnk_games_played))))*0.50)+
|
|
51
|
+
((rnk_wards/rnk_games_played)/1.45*0.30))*(37.5/(rnk_secs/rnk_games_played/60)))
|
|
52
|
+
if tsr_value > 10
|
|
53
|
+
10
|
|
54
|
+
elsif tsr_value < 0
|
|
55
|
+
0
|
|
56
|
+
else
|
|
57
|
+
tsr_value
|
|
58
|
+
end.round(2)
|
|
28
59
|
end
|
|
29
60
|
|
|
30
61
|
def assists_per_game
|
data/lib/honclient/stats.rb
CHANGED
metadata
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: honclient
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
prerelease:
|
|
5
|
-
|
|
6
|
-
- 0
|
|
7
|
-
- 1
|
|
8
|
-
version: "0.1"
|
|
4
|
+
prerelease:
|
|
5
|
+
version: "0.2"
|
|
9
6
|
platform: ruby
|
|
10
7
|
authors:
|
|
11
8
|
- Chris Gillis
|
|
@@ -14,7 +11,7 @@ autorequire:
|
|
|
14
11
|
bindir: bin
|
|
15
12
|
cert_chain: []
|
|
16
13
|
|
|
17
|
-
date:
|
|
14
|
+
date: 2011-03-30 00:00:00 -04:00
|
|
18
15
|
default_executable:
|
|
19
16
|
dependencies:
|
|
20
17
|
- !ruby/object:Gem::Dependency
|
|
@@ -25,10 +22,6 @@ dependencies:
|
|
|
25
22
|
requirements:
|
|
26
23
|
- - ">="
|
|
27
24
|
- !ruby/object:Gem::Version
|
|
28
|
-
segments:
|
|
29
|
-
- 1
|
|
30
|
-
- 4
|
|
31
|
-
- 3
|
|
32
25
|
version: 1.4.3
|
|
33
26
|
type: :runtime
|
|
34
27
|
version_requirements: *id001
|
|
@@ -42,9 +35,8 @@ extensions: []
|
|
|
42
35
|
extra_rdoc_files: []
|
|
43
36
|
|
|
44
37
|
files:
|
|
45
|
-
- README
|
|
46
|
-
- lib/honclient/player_hero_stats.rb
|
|
47
38
|
- lib/honclient/match_stats.rb
|
|
39
|
+
- lib/honclient/player_hero_stats.rb
|
|
48
40
|
- lib/honclient/player_stats.rb
|
|
49
41
|
- lib/honclient/stats.rb
|
|
50
42
|
- lib/honclient.rb
|
|
@@ -62,25 +54,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
62
54
|
requirements:
|
|
63
55
|
- - ">="
|
|
64
56
|
- !ruby/object:Gem::Version
|
|
65
|
-
segments:
|
|
66
|
-
- 1
|
|
67
|
-
- 8
|
|
68
|
-
- 7
|
|
69
57
|
version: 1.8.7
|
|
70
58
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
59
|
none: false
|
|
72
60
|
requirements:
|
|
73
61
|
- - ">="
|
|
74
62
|
- !ruby/object:Gem::Version
|
|
75
|
-
segments:
|
|
76
|
-
- 1
|
|
77
|
-
- 3
|
|
78
|
-
- 6
|
|
79
63
|
version: 1.3.6
|
|
80
64
|
requirements: []
|
|
81
65
|
|
|
82
66
|
rubyforge_project:
|
|
83
|
-
rubygems_version: 1.
|
|
67
|
+
rubygems_version: 1.5.2
|
|
84
68
|
signing_key:
|
|
85
69
|
specification_version: 3
|
|
86
70
|
summary: Heroes of Newerth api client
|
data/README
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# A wrapper for the Heroes of Newerth XML API
|
|
2
|
-
# -------------------------------------------
|
|
3
|
-
# Author: Chris Gillis
|
|
4
|
-
# -------------------------------------------
|
|
5
|
-
#
|
|
6
|
-
# A list of variables for stat() can be found on the xml.heroesofnewerth.com
|
|
7
|
-
# website by running the relevant example query
|
|
8
|
-
#
|
|
9
|
-
# DEPENDENCIES
|
|
10
|
-
# Requires rubygems
|
|
11
|
-
# rexml
|
|
12
|
-
#
|
|
13
|
-
# USAGE:
|
|
14
|
-
# require 'hon'
|
|
15
|
-
# @my_stats = HoN::PlayerStats.new("account_name")
|
|
16
|
-
# puts @my_stats.stat("acc_games_played")
|
|
17
|
-
# @match = HoN::MatchStats.new("match_id")
|
|
18
|
-
# puts @match.team_one
|
|
19
|
-
# puts @match.team_two
|
|
20
|
-
# puts @match.summary_stats("time_played")
|
|
21
|
-
# puts @match.team_one_stats("tm_losses")
|