bnet 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -4
- data/TODO.md +2 -2
- data/bnet.gemspec +1 -1
- data/lib/bnet.rb +1 -0
- data/lib/bnet/diablo3/hero.rb +84 -20
- data/lib/bnet/diablo3/item.rb +3 -0
- data/lib/bnet/version.rb +1 -1
- data/spec/bnet/diablo3/hero_spec.rb +56 -4
- data/spec/bnet/diablo3/item_spec.rb +4 -0
- metadata +9 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6579c6af8e90cabd36c994dada112e6ea966ea3e
|
4
|
+
data.tar.gz: 4cb4347e3015db6adfa60214fb6ab0d3fcf01257
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a472e1e583b1719d1016b2be5b73f9b0720ecda1073fbdd3afbad37a65a4839ab9f752ae08dc59a66237a3bd99d0216d94676e3ef8b8c986ed2d04044037b2c4
|
7
|
+
data.tar.gz: 69767dabae0858fac67bcda254f9482af8f873dfa8352b55a25ab1b9489a58808ed5d34d12ccb5778d344dada87738ec1b81bac9f39dc669a8a0f6898087a6d7
|
data/README.md
CHANGED
@@ -14,7 +14,7 @@ This is a work in progress : [TODO-LIST](https://github.com/keikun17/bnet-masher
|
|
14
14
|
|
15
15
|
## Configuration
|
16
16
|
|
17
|
-
# initializer file (
|
17
|
+
# initializer file (config/initializer/bnet_initializer.rb)
|
18
18
|
Bnet.configuration.api_key = 'your_api_key'
|
19
19
|
|
20
20
|
## Diablo
|
@@ -60,9 +60,20 @@ This is a work in progress : [TODO-LIST](https://github.com/keikun17/bnet-masher
|
|
60
60
|
#
|
61
61
|
# Returns a Hero object with the following attributes
|
62
62
|
#
|
63
|
-
#
|
64
|
-
#
|
65
|
-
#
|
63
|
+
# :life, :damage, :attack_speed, :armor, :strength, :dexterity, :vitality,
|
64
|
+
# :intelligence, :physical_resist, :fire_resist, :cold_resist,
|
65
|
+
# :lightning_resist, :poison_resist, :arcane_resist, :crit_damage,
|
66
|
+
# :block_chance, :block_amount_min, :block_amount_max, :damage_increase,
|
67
|
+
# :crit_chance, :damage_reduction, :thorns, :life_steal, :life_per_kill,
|
68
|
+
# :gold_find, :magic_find, :life_on_Hit, :primary_resource,
|
69
|
+
# :secondary_resource
|
70
|
+
#
|
71
|
+
# and the following misc attributes
|
72
|
+
#
|
73
|
+
# :paragon_level, :seasonal, :name, :hero_id,
|
74
|
+
# :level, :hardcore, :gender, :dead, :hero_class, :last_update,
|
75
|
+
# :active_skills, :passive_skills, :region, :battle_tag, :career,
|
76
|
+
# :items
|
66
77
|
|
67
78
|
Bnet::Diablo3::Hero.find(battle_tag: 'PlayerOne-1309', region: 'us', hero_id: 1304986)
|
68
79
|
|
data/TODO.md
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
- [ ] Bnet::Community [ ] doc
|
6
6
|
- [ ] Bnet::Diablo3 [ ] doc
|
7
7
|
- [ ] Bnet::Starcraft2 [ ] doc
|
8
|
-
- [ ] Bnet::
|
8
|
+
- [ ] Bnet::WOW [ ] doc
|
9
9
|
- [ ] Bnet::Rails [ ] doc
|
10
10
|
|
11
11
|
### Diablo
|
@@ -13,7 +13,7 @@
|
|
13
13
|
- [x] Bnet::Diabo3::Career [x] doc
|
14
14
|
- [x] Heroes (as `Hero`) [x] doc
|
15
15
|
- [x] Bnet::Diabo3::Hero [x] doc
|
16
|
-
- [x] Bnet::Diablo3::Skill
|
16
|
+
- [x] Bnet::Diablo3::Skill
|
17
17
|
- [ ] Bnet::Diablo3::Data [ ] doc
|
18
18
|
- [ ] Items [ ] doc
|
19
19
|
- [ ] Followers [ ] doc
|
data/bnet.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.6"
|
22
22
|
spec.add_development_dependency "rake", "~> 10.0"
|
23
23
|
|
24
|
-
spec.add_development_dependency "rspec"
|
24
|
+
spec.add_development_dependency "rspec", "~> 3.1"
|
25
25
|
spec.add_development_dependency "rspec-nc"
|
26
26
|
spec.add_development_dependency "guard"
|
27
27
|
spec.add_development_dependency "guard-rspec"
|
data/lib/bnet.rb
CHANGED
data/lib/bnet/diablo3/hero.rb
CHANGED
@@ -2,7 +2,17 @@ class Bnet::Diablo3::Hero < Bnet::BnetResource
|
|
2
2
|
|
3
3
|
attr_accessor :paragon_level, :seasonal, :name, :hero_id,
|
4
4
|
:level, :hardcore, :gender, :dead, :hero_class, :last_update,
|
5
|
-
:active_skills, :passive_skills, :region, :battle_tag, :career
|
5
|
+
:active_skills, :passive_skills, :region, :battle_tag, :career,
|
6
|
+
:items,
|
7
|
+
|
8
|
+
# stats
|
9
|
+
:life, :damage, :attack_speed, :armor, :strength, :dexterity, :vitality,
|
10
|
+
:intelligence, :physical_resist, :fire_resist, :cold_resist,
|
11
|
+
:lightning_resist, :poison_resist, :arcane_resist, :crit_damage,
|
12
|
+
:block_chance, :block_amount_min, :block_amount_max, :damage_increase,
|
13
|
+
:crit_chance, :damage_reduction, :thorns, :life_steal, :life_per_kill,
|
14
|
+
:gold_find, :magic_find, :life_on_Hit, :primary_resource,
|
15
|
+
:secondary_resource
|
6
16
|
|
7
17
|
PARAMS_MAPPING = {
|
8
18
|
"paragonLevel" => :paragon_level,
|
@@ -14,7 +24,7 @@ class Bnet::Diablo3::Hero < Bnet::BnetResource
|
|
14
24
|
"gender" => :gender,
|
15
25
|
"dead" => :dead,
|
16
26
|
"class" => :hero_class,
|
17
|
-
"last-updated" => :last_updated
|
27
|
+
"last-updated" => :last_updated,
|
18
28
|
}
|
19
29
|
|
20
30
|
|
@@ -99,33 +109,87 @@ class Bnet::Diablo3::Hero < Bnet::BnetResource
|
|
99
109
|
|
100
110
|
# Create an instance by passing in the args from the response
|
101
111
|
def self.from_api(response)
|
102
|
-
|
112
|
+
hero = super(response)
|
103
113
|
|
104
|
-
if
|
105
|
-
|
114
|
+
if hero
|
115
|
+
assign_skills_from_raw_skills(hero, response["skills"]) if response["skills"]
|
116
|
+
assign_stats_from_raw_stats(hero, response["stats"]) if response["stats"]
|
117
|
+
assign_items_from_raw_items(hero, response["items"]) if response["items"]
|
118
|
+
end
|
119
|
+
|
120
|
+
return hero
|
121
|
+
end
|
106
122
|
|
107
|
-
|
108
|
-
if active["skill"]
|
109
|
-
skill.name = active["skill"]["name"]
|
110
|
-
end
|
111
|
-
if active["rune"]
|
112
|
-
skill.rune = active["rune"]["name"]
|
113
|
-
end
|
123
|
+
private
|
114
124
|
|
115
|
-
|
125
|
+
def self.assign_items_from_raw_items(hero, raw_items)
|
126
|
+
hero.items = raw_items.collect do |location, item_props|
|
127
|
+
item = Bnet::Diablo3::Item.new
|
128
|
+
item.location = location
|
129
|
+
item.item_id = item_props["id"]
|
130
|
+
item.name = item_props["name"]
|
131
|
+
item
|
132
|
+
end
|
133
|
+
|
134
|
+
return hero
|
135
|
+
end
|
116
136
|
|
137
|
+
def self.assign_skills_from_raw_skills(hero, raw_skills)
|
138
|
+
hero.active_skills = raw_skills["active"].collect do |active|
|
139
|
+
skill = Bnet::Diablo3::Skill.new
|
140
|
+
if active["skill"]
|
141
|
+
skill.name = active["skill"]["name"]
|
117
142
|
end
|
143
|
+
if active["rune"]
|
144
|
+
skill.rune = active["rune"]["name"]
|
145
|
+
end
|
146
|
+
|
147
|
+
skill
|
148
|
+
end
|
118
149
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
end
|
124
|
-
skill
|
150
|
+
hero.passive_skills = raw_skills["passive"].collect do |passive|
|
151
|
+
skill = Bnet::Diablo3::Skill.new
|
152
|
+
if passive["skill"]
|
153
|
+
skill.name = passive["skill"]["name"]
|
125
154
|
end
|
155
|
+
skill
|
126
156
|
end
|
127
157
|
|
128
|
-
|
158
|
+
return hero
|
159
|
+
end
|
160
|
+
|
161
|
+
def self.assign_stats_from_raw_stats(hero, raw_stats)
|
162
|
+
hero.life = raw_stats["life"]
|
163
|
+
hero.damage = raw_stats["damage"]
|
164
|
+
hero.attack_speed = raw_stats["attackSpeed"]
|
165
|
+
hero.armor = raw_stats["armor"]
|
166
|
+
hero.strength = raw_stats["strength"]
|
167
|
+
hero.dexterity = raw_stats["dexterity"]
|
168
|
+
hero.vitality = raw_stats["vitality"]
|
169
|
+
hero.intelligence = raw_stats["intelligence"]
|
170
|
+
hero.physical_resist = raw_stats["physicalResist"]
|
171
|
+
hero.fire_resist = raw_stats["fireResist"]
|
172
|
+
hero.cold_resist = raw_stats["coldResist"]
|
173
|
+
hero.lightning_resist = raw_stats["lightningResist"]
|
174
|
+
hero.poison_resist = raw_stats["poisonResist"]
|
175
|
+
hero.arcane_resist = raw_stats["arcaneResist"]
|
176
|
+
hero.crit_damage = raw_stats["critDamage"]
|
177
|
+
hero.block_chance = raw_stats["blockChance"]
|
178
|
+
hero.block_amount_min = raw_stats["blockAmountMin"]
|
179
|
+
hero.block_amount_max = raw_stats["blockAmountMax"]
|
180
|
+
hero.damage_increase = raw_stats["damageIncrease"]
|
181
|
+
hero.crit_chance = raw_stats["critChance"]
|
182
|
+
hero.damage_reduction = raw_stats["damageReduction"]
|
183
|
+
hero.thorns = raw_stats["thorns"]
|
184
|
+
hero.life_steal = raw_stats["lifeSteal"]
|
185
|
+
hero.life_per_kill = raw_stats["lifePerKill"]
|
186
|
+
hero.gold_find = raw_stats["goldFind"]
|
187
|
+
hero.magic_find = raw_stats["magicFind"]
|
188
|
+
hero.life_on_Hit = raw_stats["lifeOnHit"]
|
189
|
+
hero.primary_resource = raw_stats["primaryResource"]
|
190
|
+
hero.secondary_resource = raw_stats["secondaryResource"]
|
191
|
+
|
192
|
+
return hero
|
129
193
|
end
|
130
194
|
|
131
195
|
end
|
data/lib/bnet/version.rb
CHANGED
@@ -20,17 +20,69 @@ describe Bnet::Diablo3::Hero do
|
|
20
20
|
expect(subject.hero_class).to eq('wizard')
|
21
21
|
end
|
22
22
|
|
23
|
+
it "assigns items" do
|
24
|
+
expect(subject.items).to match([
|
25
|
+
an_object_having_attributes(location: "head", name: "Leoric's Crown", item_id: "Unique_Helm_002_x1" ),
|
26
|
+
an_object_having_attributes(location: "torso"),
|
27
|
+
an_object_having_attributes(location: "feet"),
|
28
|
+
an_object_having_attributes(location: "hands"),
|
29
|
+
an_object_having_attributes(location: "shoulders"),
|
30
|
+
an_object_having_attributes(location: "legs"),
|
31
|
+
an_object_having_attributes(location: "bracers"),
|
32
|
+
an_object_having_attributes(location: "mainHand"),
|
33
|
+
an_object_having_attributes(location: "offHand"),
|
34
|
+
an_object_having_attributes(location: "waist"),
|
35
|
+
an_object_having_attributes(location: "rightFinger"),
|
36
|
+
an_object_having_attributes(location: "leftFinger"),
|
37
|
+
an_object_having_attributes(location: "neck")
|
38
|
+
])
|
39
|
+
end
|
40
|
+
|
41
|
+
it "assigns stats" do
|
42
|
+
expect(subject).to have_attributes({
|
43
|
+
life: 266712,
|
44
|
+
damage: 412878.0,
|
45
|
+
attack_speed: 1.284000051021576,
|
46
|
+
armor: 5327,
|
47
|
+
strength: 77,
|
48
|
+
dexterity: 77,
|
49
|
+
vitality: 3089,
|
50
|
+
intelligence: 7189,
|
51
|
+
physical_resist: 1021,
|
52
|
+
fire_resist: 1152,
|
53
|
+
cold_resist: 897,
|
54
|
+
lightning_resist: 1190,
|
55
|
+
poison_resist: 897,
|
56
|
+
arcane_resist: 1040,
|
57
|
+
crit_damage: 3.18,
|
58
|
+
block_chance: 0.0,
|
59
|
+
block_amount_min: 0,
|
60
|
+
block_amount_max: 0,
|
61
|
+
damage_increase: 0.0,
|
62
|
+
crit_chance: 0.38500000075,
|
63
|
+
damage_reduction: 0.0,
|
64
|
+
thorns: 0.0,
|
65
|
+
life_steal: 0.0,
|
66
|
+
life_per_kill: 6701.0,
|
67
|
+
gold_find: 2.03,
|
68
|
+
magic_find: 0.0,
|
69
|
+
life_on_Hit: 6542.0,
|
70
|
+
primary_resource: 133,
|
71
|
+
secondary_resource: 0
|
72
|
+
})
|
73
|
+
end
|
74
|
+
|
23
75
|
it "assigns skills" do
|
24
76
|
expect(subject.active_skills.map(&:name)).
|
25
77
|
to match_array([ "Magic Missile", "Arcane Orb",
|
26
78
|
"Hydra", "Familiar", "Magic Weapon",
|
27
79
|
"Teleport" ])
|
28
80
|
|
29
|
-
|
30
|
-
|
31
|
-
|
81
|
+
expect(subject.active_skills.map(&:rune)).
|
82
|
+
to match_array([ "Seeker", "Frozen Orb", "Frost Hydra", "Sparkflint",
|
83
|
+
"Force Weapon", "Fracture"])
|
32
84
|
|
33
|
-
|
85
|
+
expect(subject.passive_skills.map(&:name)).
|
34
86
|
to match_array([ "Elemental Exposure", "Prodigy", "Astral Presence",
|
35
87
|
"Cold Blooded" ])
|
36
88
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bnet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Buddy Magsipoc
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -42,16 +42,16 @@ dependencies:
|
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '3.1'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '3.1'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec-nc
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -216,6 +216,7 @@ files:
|
|
216
216
|
- lib/bnet/diablo3.rb
|
217
217
|
- lib/bnet/diablo3/career.rb
|
218
218
|
- lib/bnet/diablo3/hero.rb
|
219
|
+
- lib/bnet/diablo3/item.rb
|
219
220
|
- lib/bnet/diablo3/skill.rb
|
220
221
|
- lib/bnet/starcraft2.rb
|
221
222
|
- lib/bnet/starcraft2/profile.rb
|
@@ -230,6 +231,7 @@ files:
|
|
230
231
|
- spec/bnet/api_spec.rb
|
231
232
|
- spec/bnet/diablo3/career_spec.rb
|
232
233
|
- spec/bnet/diablo3/hero_spec.rb
|
234
|
+
- spec/bnet/diablo3/item_spec.rb
|
233
235
|
- spec/bnet/diablo3/skill_spec.rb
|
234
236
|
- spec/bnet/diablo3_spec.rb
|
235
237
|
- spec/bnet/starcraft2/profile_spec.rb
|
@@ -271,6 +273,7 @@ test_files:
|
|
271
273
|
- spec/bnet/api_spec.rb
|
272
274
|
- spec/bnet/diablo3/career_spec.rb
|
273
275
|
- spec/bnet/diablo3/hero_spec.rb
|
276
|
+
- spec/bnet/diablo3/item_spec.rb
|
274
277
|
- spec/bnet/diablo3/skill_spec.rb
|
275
278
|
- spec/bnet/diablo3_spec.rb
|
276
279
|
- spec/bnet/starcraft2/profile_spec.rb
|