botemon 0.2.4 → 0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/bin/botemon +7 -2
- data/lib/botemon/movedex.rb +47 -18
- data/lib/botemon/moveset.rb +2 -1
- data/lib/botemon/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MTQ0ZGE1YzRlMjNlMTY1ZTRiMDA3ZTUzY2FhMmZmOGE2N2I0N2MxMQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZDk0ODJiNWJlOGNkNWZjZTk0YjU3NjFlZmQxMDkwMGNkNTM1OTA1Mg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MWY4NTY4NmJmNWE5NzU0NGVjODY0YmNhNzAzNDAxNWEzYmE1MzAzODRjNjI3
|
10
|
+
YTljZmRlY2I0MGZlMTQ1MzEzZTRlOThjZTAwM2U1MmI1OGU5NTFlNjcxYzMw
|
11
|
+
OWNjOTc0OTQwYWEzZGI2ZGQ5OWY2NjA0NGRkZjVlZDgwYjU2YTE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YjNjNjEwZTM5ODYzNzU3Y2E2M2QwNTU3MDdlODhmMDQ1ZDUzMTU4ODg1MTE4
|
14
|
+
ZDdkNGY2NTQ1ZmE0OTRjYWRmMWFjZTQ3YjE0NmFlMmViMjVmYjU0ZTc3NTQ0
|
15
|
+
ZThlM2M3ZGMwZjlmYThmZTA0YTEyMjE3OWNhYmIxNzQ0YWZmMzA=
|
data/bin/botemon
CHANGED
@@ -61,8 +61,13 @@ Cinch::Bot.new {
|
|
61
61
|
if name == nil
|
62
62
|
m.reply Format(:red, 'Pokémon not found.')
|
63
63
|
else
|
64
|
-
|
65
|
-
|
64
|
+
movesets = Movedex.get name, tier
|
65
|
+
if movesets != nil || movesets.any?
|
66
|
+
m.reply Format(:red, "--- #{movesets.first.pokemon} (#{movesets.first.tier}) ---")
|
67
|
+
movesets.each { |moveset| m.reply Format(:red, " -- #{moveset.name} --\n#{moveset.to_s.split("\n").map { |l| Format(:red, l) }.join("\n")}\n") }
|
68
|
+
else
|
69
|
+
m.reply Format(:red, 'Moveset not found.')
|
70
|
+
end
|
66
71
|
end
|
67
72
|
end
|
68
73
|
|
data/lib/botemon/movedex.rb
CHANGED
@@ -25,36 +25,65 @@ class Movedex
|
|
25
25
|
return nil
|
26
26
|
end
|
27
27
|
end
|
28
|
-
|
29
|
-
def self.tiers
|
30
|
-
['uber', 'ou', 'bl', 'uu', 'bl2', 'ru', 'nu', 'lc', 'limbo', 'nfe']
|
31
|
-
end
|
32
28
|
|
33
29
|
def self.get(name, tier)
|
34
|
-
return nil if name == nil || tier == nil
|
30
|
+
return nil if name == nil || tier == nil
|
35
31
|
|
36
32
|
begin
|
37
33
|
url = URI::encode "http://www.smogon.com/bw/pokemon/#{name}/#{tier}"
|
38
34
|
|
39
|
-
moveset = Moveset.new
|
40
35
|
smogon = Nokogiri::HTML(open(url))
|
41
36
|
rescue
|
42
37
|
return nil
|
43
38
|
end
|
44
39
|
|
45
|
-
|
46
|
-
moveset.name = smogon.xpath('//td[@class="name"]/h2').first.text
|
47
|
-
moveset.tier = smogon.xpath('//table[@class="info"]/tr/td/a').last.text
|
48
|
-
|
49
|
-
section = smogon.xpath('//table[@class="info strategyheader"]/tr')[1].children
|
50
|
-
moveset.item = section[2].text.gsub(/\n/m, '').gsub(/\t/m, '').strip
|
51
|
-
moveset.ability = section[4].text.gsub(/\n/m, '').gsub(/\t/m, '').strip
|
52
|
-
moveset.nature = section[6].text.gsub(/\n/m, '').gsub(/\t/m, '').strip
|
40
|
+
movesets = []
|
53
41
|
|
54
|
-
|
55
|
-
|
56
|
-
|
42
|
+
smogon.xpath('//table[@class="info strategyheader"]').each { |s|
|
43
|
+
moveset = Moveset.new
|
44
|
+
|
45
|
+
moveset.pokemon = smogon.xpath('//tr/td[@class="header"]/h1').last.text
|
46
|
+
moveset.name = s.xpath('tr')[1].xpath('td[@class="name"]/h2').first.text
|
47
|
+
moveset.tier = smogon.xpath('//div[@id="content_wrapper"]/ul/li/strong').last.text
|
48
|
+
|
49
|
+
s.xpath('.//a').each { |a|
|
50
|
+
(moveset.item ||= []) << a.text if a['href'].include? '/items/'
|
51
|
+
(moveset.ability ||= []) << a.text if a['href'].include? '/abilities/'
|
52
|
+
(moveset.nature ||= []) << a.text if a['href'].include? '/natures/'
|
53
|
+
}
|
54
|
+
|
55
|
+
movesets << moveset
|
56
|
+
}
|
57
57
|
|
58
|
-
|
58
|
+
i = 0
|
59
|
+
smogon.xpath('//table[@class="info moveset"]').each { |s|
|
60
|
+
moveset = movesets[i]
|
61
|
+
|
62
|
+
continue = false
|
63
|
+
s.xpath('.//td')[0].text.each_line { |a|
|
64
|
+
a = a.gsub(/\n?/, '').strip
|
65
|
+
if a == ?~
|
66
|
+
continue = false
|
67
|
+
elsif a == ?/
|
68
|
+
continue = true
|
69
|
+
elsif a.empty?
|
70
|
+
next
|
71
|
+
elsif a != ?~ && a != ?/
|
72
|
+
if continue
|
73
|
+
moveset.moves.last << a
|
74
|
+
else
|
75
|
+
(moveset.moves ||= []) << [a]
|
76
|
+
end
|
77
|
+
continue = false
|
78
|
+
end
|
79
|
+
}
|
80
|
+
|
81
|
+
moveset.evs = s.xpath('.//td').last.text.strip
|
82
|
+
|
83
|
+
movesets[i] = moveset
|
84
|
+
i += 1
|
85
|
+
}
|
86
|
+
|
87
|
+
return movesets
|
59
88
|
end
|
60
89
|
end
|
data/lib/botemon/moveset.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
#encoding: utf-8
|
1
2
|
#--
|
2
3
|
# Copyright(C) 2013 Giovanni Capuano <webmaster@giovannicapuano.net>
|
3
4
|
#
|
@@ -21,7 +22,7 @@ class Moveset
|
|
21
22
|
attr_accessor :pokemon, :name, :tier, :item, :ability, :nature, :moves, :evs
|
22
23
|
|
23
24
|
def to_s
|
24
|
-
"
|
25
|
+
"Item: #{item.join(' / ')}\nAbility: #{ability.join(' / ')}\nNature: #{nature.join(' / ')}\nMoves: #{''.tap { |s| moves.each { |move| s << move.join(' / ') + ', '}}[0..-3]}\nEVs: #{evs}"
|
25
26
|
end
|
26
27
|
|
27
28
|
end
|
data/lib/botemon/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: botemon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.3'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Giovanni Capuano
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cinch
|