battle_pet 0.1.7 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/battle_pet.rb +1 -7
- data/test/data/mechanical_squirrel_cn.json +1 -1
- data/test/data/mechanical_squirrel_us.json +1 -1
- data/test/test_battle_pet.rb +0 -7
- metadata +2 -3
- data/lib/battle_pet.yml +0 -1995
data/lib/battle_pet.rb
CHANGED
@@ -11,8 +11,6 @@ class BattlePet
|
|
11
11
|
tw: 'tw.battle.net',
|
12
12
|
cn: 'www.battlenet.com.cn'}
|
13
13
|
|
14
|
-
PET_NAMES = YAML.load File.read(File.join(File.dirname(__FILE__), 'battle_pet.yml'))
|
15
|
-
|
16
14
|
def initialize(id, locale = :us)
|
17
15
|
data = BattlePet.parse_data_from_api(id, locale)
|
18
16
|
set_attributes(data, locale)
|
@@ -31,7 +29,7 @@ class BattlePet
|
|
31
29
|
|
32
30
|
def set_attributes(data, locale)
|
33
31
|
@id = data["speciesId"]
|
34
|
-
@name =
|
32
|
+
@name = data["name"]
|
35
33
|
@description = data["description"]
|
36
34
|
@source = data["source"]
|
37
35
|
@can_battle = data["canBattle"]
|
@@ -45,10 +43,6 @@ class BattlePet
|
|
45
43
|
REGION_HOSTS[locale] || REGION_HOSTS[:us]
|
46
44
|
end
|
47
45
|
|
48
|
-
def self.find_name(id, locale)
|
49
|
-
PET_NAMES[id] && PET_NAMES[id]["name"][locale.to_s]
|
50
|
-
end
|
51
|
-
|
52
46
|
def acquire_abilities(abilities)
|
53
47
|
results = {}
|
54
48
|
abilities.each { |ability| results[ability['requiredLevel']] = Ability.new(ability) }
|
@@ -1 +1 @@
|
|
1
|
-
{"speciesId":39,"petTypeId":9,"creatureId":2671,"canBattle":true,"icon":"inv_pet_mechanicalsquirrel","description":"
|
1
|
+
{"speciesId":39,"petTypeId":9,"creatureId":2671,"name":"机械松鼠","canBattle":true,"icon":"inv_pet_mechanicalsquirrel","description":"机械松鼠体内的逻辑运算中心告诉它,要多多采集坚果和螺栓,以备冬季取用。","source":"专业技能:工程","abilities":[{"slot":2,"order":2,"requiredLevel":4,"id":459,"name":"旋紧发条","icon":"inv_gizmo_02","cooldown":0,"rounds":1,"petTypeId":9,"isPassive":false,"hideHints":false},{"slot":0,"order":3,"requiredLevel":10,"id":202,"name":"痛击","icon":"spell_druid_thrash","cooldown":0,"rounds":1,"petTypeId":7,"isPassive":false,"hideHints":false},{"slot":0,"order":0,"requiredLevel":1,"id":384,"name":"铁拳","icon":"inv_misc_desecrated_plategloves","cooldown":0,"rounds":1,"petTypeId":9,"isPassive":false,"hideHints":false},{"slot":1,"order":1,"requiredLevel":2,"id":389,"name":"超频","icon":"inv_gizmo_03","cooldown":0,"rounds":1,"petTypeId":9,"isPassive":false,"hideHints":false},{"slot":2,"order":5,"requiredLevel":20,"id":278,"name":"修复","icon":"ability_repair","cooldown":5,"rounds":3,"petTypeId":9,"isPassive":false,"hideHints":true},{"slot":1,"order":4,"requiredLevel":15,"id":392,"name":"强化护甲","icon":"inv_misc_wartornscrap_plate","cooldown":4,"rounds":1,"petTypeId":9,"isPassive":false,"hideHints":true}]}
|
@@ -1 +1 @@
|
|
1
|
-
{"speciesId":39,"petTypeId":9,"creatureId":2671,"canBattle":true,"icon":"inv_pet_mechanicalsquirrel","description":"A mechanical squirrel's logic center tells it to collect and store both nuts and bolts for the winter.","source":"Profession: Engineering","abilities":[{"slot":2,"order":2,"requiredLevel":4,"id":459,"name":"Wind-Up","icon":"inv_gizmo_02","cooldown":0,"rounds":1,"petTypeId":9,"isPassive":false,"hideHints":false},{"slot":0,"order":3,"requiredLevel":10,"id":202,"name":"Thrash","icon":"spell_druid_thrash","cooldown":0,"rounds":1,"petTypeId":7,"isPassive":false,"hideHints":false},{"slot":0,"order":0,"requiredLevel":1,"id":384,"name":"Metal Fist","icon":"inv_misc_desecrated_plategloves","cooldown":0,"rounds":1,"petTypeId":9,"isPassive":false,"hideHints":false},{"slot":1,"order":1,"requiredLevel":2,"id":389,"name":"Overtune","icon":"inv_gizmo_03","cooldown":0,"rounds":1,"petTypeId":9,"isPassive":false,"hideHints":false},{"slot":2,"order":5,"requiredLevel":20,"id":278,"name":"Repair","icon":"ability_repair","cooldown":5,"rounds":3,"petTypeId":9,"isPassive":false,"hideHints":true},{"slot":1,"order":4,"requiredLevel":15,"id":392,"name":"Extra Plating","icon":"inv_misc_wartornscrap_plate","cooldown":4,"rounds":1,"petTypeId":9,"isPassive":false,"hideHints":true}]}
|
1
|
+
{"speciesId":39,"petTypeId":9,"creatureId":2671,"name":"Mechanical Squirrel","canBattle":true,"icon":"inv_pet_mechanicalsquirrel","description":"A mechanical squirrel's logic center tells it to collect and store both nuts and bolts for the winter.","source":"Profession: Engineering","abilities":[{"slot":2,"order":2,"requiredLevel":4,"id":459,"name":"Wind-Up","icon":"inv_gizmo_02","cooldown":0,"rounds":1,"petTypeId":9,"isPassive":false,"hideHints":false},{"slot":0,"order":3,"requiredLevel":10,"id":202,"name":"Thrash","icon":"spell_druid_thrash","cooldown":0,"rounds":1,"petTypeId":7,"isPassive":false,"hideHints":false},{"slot":0,"order":0,"requiredLevel":1,"id":384,"name":"Metal Fist","icon":"inv_misc_desecrated_plategloves","cooldown":0,"rounds":1,"petTypeId":9,"isPassive":false,"hideHints":false},{"slot":1,"order":1,"requiredLevel":2,"id":389,"name":"Overtune","icon":"inv_gizmo_03","cooldown":0,"rounds":1,"petTypeId":9,"isPassive":false,"hideHints":false},{"slot":2,"order":5,"requiredLevel":20,"id":278,"name":"Repair","icon":"ability_repair","cooldown":5,"rounds":3,"petTypeId":9,"isPassive":false,"hideHints":true},{"slot":1,"order":4,"requiredLevel":15,"id":392,"name":"Extra Plating","icon":"inv_misc_wartornscrap_plate","cooldown":4,"rounds":1,"petTypeId":9,"isPassive":false,"hideHints":true}]}
|
data/test/test_battle_pet.rb
CHANGED
@@ -15,13 +15,6 @@ class BattlePetTest < Test::Unit::TestCase
|
|
15
15
|
assert_equal 'us.battle.net', BattlePet.host(:ca)
|
16
16
|
end
|
17
17
|
|
18
|
-
def test_find_name
|
19
|
-
assert_equal '机械松鼠', BattlePet.find_name(39, :cn)
|
20
|
-
assert_equal 'Adder', BattlePet.find_name(635, :us)
|
21
|
-
assert_equal nil, BattlePet.find_name(1, :cn)
|
22
|
-
assert_equal nil, BattlePet.find_name(39, :ca)
|
23
|
-
end
|
24
|
-
|
25
18
|
def test_check_patch
|
26
19
|
(1..864).to_a.sample(5) { |i| assert_equal '5.0', BattlePet.check_patch(i) }
|
27
20
|
(865..1013).to_a.sample(5) { |i| assert_equal '5.1', BattlePet.check_patch(i) }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: battle_pet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-31 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A simple gem to get data from WoW BattlePet API
|
15
15
|
email: zwt315@163.com
|
@@ -18,7 +18,6 @@ extensions: []
|
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
20
|
- lib/battle_pet.rb
|
21
|
-
- lib/battle_pet.yml
|
22
21
|
- lib/battle_pet/ability.rb
|
23
22
|
- lib/battle_pet/type.rb
|
24
23
|
- test/data/mechanical_squirrel_cn.json
|