dexter_plusplus 0.2.0
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.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +6 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +80 -0
- data/LICENSE.txt +21 -0
- data/NOTES.md +129 -0
- data/README.md +40 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/dexter-plusplus +9 -0
- data/bin/setup +8 -0
- data/dexter_plusplus.gemspec +29 -0
- data/lib/concerns/findable.rb +61 -0
- data/lib/dexter_plusplus/ability.rb +82 -0
- data/lib/dexter_plusplus/ability_menu.rb +101 -0
- data/lib/dexter_plusplus/api.rb +186 -0
- data/lib/dexter_plusplus/cli.rb +105 -0
- data/lib/dexter_plusplus/item.rb +75 -0
- data/lib/dexter_plusplus/item_menu.rb +83 -0
- data/lib/dexter_plusplus/move.rb +113 -0
- data/lib/dexter_plusplus/move_menu.rb +178 -0
- data/lib/dexter_plusplus/pokemon.rb +184 -0
- data/lib/dexter_plusplus/pokemon_menu.rb +182 -0
- data/lib/dexter_plusplus/type.rb +183 -0
- data/lib/dexter_plusplus/type_menu.rb +61 -0
- data/lib/dexter_plusplus/version.rb +3 -0
- data/lib/environment.rb +30 -0
- metadata +76 -0
@@ -0,0 +1,82 @@
|
|
1
|
+
class Ability
|
2
|
+
extend Findable
|
3
|
+
|
4
|
+
attr_accessor :name, :id, :effect, :pokemon_with_ability, :url, :data
|
5
|
+
@@all = []
|
6
|
+
@@tag = "ability"
|
7
|
+
@@limit = 293
|
8
|
+
|
9
|
+
def initialize(name, url)
|
10
|
+
self.name = name
|
11
|
+
self.url = url
|
12
|
+
self.data = JSON.parse(RestClient.get(url))
|
13
|
+
self.pokemon_with_ability = []
|
14
|
+
self.set_attributes
|
15
|
+
@@all << self
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.all
|
19
|
+
@@all
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.tag
|
23
|
+
@@tag
|
24
|
+
end
|
25
|
+
|
26
|
+
def tag
|
27
|
+
@@tag
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.limit
|
31
|
+
@@limit
|
32
|
+
end
|
33
|
+
|
34
|
+
def set_attributes
|
35
|
+
self.set_effect
|
36
|
+
self.set_id
|
37
|
+
end
|
38
|
+
|
39
|
+
def set_effect
|
40
|
+
effect_entries = self.data["effect_entries"]
|
41
|
+
effect_entries.each do |entry|
|
42
|
+
if entry["language"]["name"] == "en"
|
43
|
+
self.effect = entry["effect"]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def set_id
|
49
|
+
self.id = self.data["id"]
|
50
|
+
end
|
51
|
+
|
52
|
+
def add_pokemon(pokemon)
|
53
|
+
self.pokemon_with_ability << pokemon
|
54
|
+
end
|
55
|
+
|
56
|
+
def print_all
|
57
|
+
puts "---------------------------------------------------------"
|
58
|
+
puts " Dexter++ : Ability ".light_blue
|
59
|
+
puts "---------------------------------------------------------"
|
60
|
+
self.print_name
|
61
|
+
puts ""
|
62
|
+
self.print_effect
|
63
|
+
puts "---------------------------------------------------------"
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.print_all
|
67
|
+
@@all.each {|ability| ability.print_all}
|
68
|
+
end
|
69
|
+
|
70
|
+
def print_name
|
71
|
+
puts "Name: #{self.name.capitalize.light_blue}"
|
72
|
+
end
|
73
|
+
|
74
|
+
def get_colored_name
|
75
|
+
self.name.capitalize.light_blue
|
76
|
+
end
|
77
|
+
|
78
|
+
def print_effect
|
79
|
+
puts "Effect: #{self.effect}"
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
class AbilityMenu
|
2
|
+
|
3
|
+
attr_accessor :cli
|
4
|
+
|
5
|
+
def initialize(cli)
|
6
|
+
self.cli = cli
|
7
|
+
end
|
8
|
+
|
9
|
+
def main_menu
|
10
|
+
puts "\n\n"
|
11
|
+
input = self.cli.prompt.select("What Ability information would you like to get?", cycle: true) do |menu|
|
12
|
+
menu.choice 'Get a list of Abilities', 1
|
13
|
+
menu.choice 'Search for an Ability name', 2
|
14
|
+
menu.choice 'Get information from a random Ability', 3
|
15
|
+
menu.choice 'Return to the main menu'.light_green, 4
|
16
|
+
menu.choice 'Exit Dexter++'.light_red, 5
|
17
|
+
end
|
18
|
+
|
19
|
+
case input
|
20
|
+
when 1
|
21
|
+
self.list_abilities
|
22
|
+
when 2
|
23
|
+
self.search_by_name
|
24
|
+
when 3
|
25
|
+
self.get_random
|
26
|
+
when 4
|
27
|
+
self.cli.main_menu
|
28
|
+
when 5
|
29
|
+
self.cli.exit_program
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def list_abilities
|
34
|
+
puts "\n\nHow many Abililities would you like to list?"
|
35
|
+
input = gets.strip.to_i
|
36
|
+
until input.between?(1, Ability.limit)
|
37
|
+
if input <= 0
|
38
|
+
puts"That is not enough Abilities! Try a bigger number"
|
39
|
+
input = gets.strip.to_i
|
40
|
+
else
|
41
|
+
puts "Thats way too many Abilities! Try a smaller number."
|
42
|
+
input = gets.strip.to_i
|
43
|
+
end
|
44
|
+
end
|
45
|
+
puts "\n\nAwesome! Let me load that for you."
|
46
|
+
puts"\n\n"
|
47
|
+
options = Ability.find_with_offset_and_limit(rand(0...Ability.limit), input)
|
48
|
+
self.display_ability_options(options)
|
49
|
+
end
|
50
|
+
|
51
|
+
def search_by_name
|
52
|
+
puts "\n\nWhat Ability would you like to search for?"
|
53
|
+
input = gets.strip.downcase
|
54
|
+
puts "\n\nAwesome! Let me load that for you."
|
55
|
+
ability = API.get_ability_by_name(input)
|
56
|
+
ability.print_all
|
57
|
+
puts"\n\n"
|
58
|
+
self.display_more_options(ability)
|
59
|
+
end
|
60
|
+
|
61
|
+
def get_random
|
62
|
+
ability = API.get_random_ability
|
63
|
+
ability.print_all
|
64
|
+
puts"\n\n"
|
65
|
+
self.display_more_options(ability)
|
66
|
+
end
|
67
|
+
|
68
|
+
def display_ability_options(options)
|
69
|
+
options.unshift("Exit Dexter++".light_red)
|
70
|
+
options.unshift("Go back to main menu".light_green)
|
71
|
+
choice = self.cli.get_menu_from_array(options)
|
72
|
+
if choice == "Exit Dexter++".light_red
|
73
|
+
self.cli.exit_program
|
74
|
+
elsif choice == "Go back to main menu".light_green
|
75
|
+
self.cli.main_menu
|
76
|
+
else ability = API.get_ability_by_name(choice.downcase)
|
77
|
+
ability.print_all
|
78
|
+
puts "\n\n\n"
|
79
|
+
self.display_more_options(ability)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def display_more_options(ability)
|
84
|
+
puts "\n\n"
|
85
|
+
input = self.cli.prompt.select("What information about #{ability.name.capitalize} would you like to see?", cycle: true) do |menu|
|
86
|
+
menu.choice 'See list of Pokemon with this ability' , 1
|
87
|
+
menu.choice 'Go back to main menu'.light_green, 2
|
88
|
+
menu.choice 'Exit Dexter++'.light_red, 3
|
89
|
+
end
|
90
|
+
case input
|
91
|
+
when 1
|
92
|
+
menu = PokemonMenu.new(self.cli)
|
93
|
+
menu.search_by_ability(ability)
|
94
|
+
when 2
|
95
|
+
self.cli.main_menu
|
96
|
+
when 3
|
97
|
+
self.cli.exit_program
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
@@ -0,0 +1,186 @@
|
|
1
|
+
|
2
|
+
class API
|
3
|
+
|
4
|
+
#listing helpers
|
5
|
+
|
6
|
+
def self.get_pokemon_list_by_type(type)
|
7
|
+
output = []
|
8
|
+
begin
|
9
|
+
puts "\n\n"
|
10
|
+
puts "Getting list of #{type.capitalize} Pokemon..."
|
11
|
+
puts "\n\n"
|
12
|
+
data = JSON.parse(RestClient.get("https://pokeapi.co/api/v2/type/#{type}"))
|
13
|
+
index = 0
|
14
|
+
data["pokemon"].each{|pokemon| output << pokemon["pokemon"]["name"].capitalize}
|
15
|
+
rescue => e
|
16
|
+
puts "Error loading list of Pokemon with #{ability}"
|
17
|
+
puts e.message
|
18
|
+
end
|
19
|
+
output
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.get_pokemon_list_by_ability(ability)
|
23
|
+
output = []
|
24
|
+
begin
|
25
|
+
puts "\n\n"
|
26
|
+
puts "Getting list of Pokemon with #{ability}..."
|
27
|
+
puts "\n\n"
|
28
|
+
data = JSON.parse(RestClient.get("https://pokeapi.co/api/v2/ability/#{ability}"))
|
29
|
+
index = 0
|
30
|
+
data["pokemon"].each{|pokemon| output << pokemon["pokemon"]["name"].capitalize}
|
31
|
+
rescue => e
|
32
|
+
puts "Error loading list of Pokemon with #{ability}"
|
33
|
+
puts e.message
|
34
|
+
end
|
35
|
+
output
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.get_pokemon_list_by_generation(gen)
|
39
|
+
begin
|
40
|
+
puts "Getting list of Generation #{gen} Pokemon..."
|
41
|
+
puts "\n\n"
|
42
|
+
case gen
|
43
|
+
when 1
|
44
|
+
Pokemon.find_with_offset_and_limit(0, 151)
|
45
|
+
when 2
|
46
|
+
Pokemon.find_with_offset_and_limit(151, 100)
|
47
|
+
when 3
|
48
|
+
Pokemon.find_with_offset_and_limit(251, 135)
|
49
|
+
when 4
|
50
|
+
Pokemon.find_with_offset_and_limit(386, 107)
|
51
|
+
when 5
|
52
|
+
Pokemon.find_with_offset_and_limit(493, 156)
|
53
|
+
when 6
|
54
|
+
Pokemon.find_with_offset_and_limit(649, 72)
|
55
|
+
when 7
|
56
|
+
Pokemon.find_with_offset_and_limit(721, 86)
|
57
|
+
else
|
58
|
+
nil
|
59
|
+
end
|
60
|
+
rescue => e
|
61
|
+
puts "Error loading generation."
|
62
|
+
puts e.message
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
#Returning Pokemon objects
|
67
|
+
def self.get_pokemon_by_name(pokemon)
|
68
|
+
puts "\n\n"
|
69
|
+
puts "Searching for #{pokemon.capitalize}..."
|
70
|
+
puts "\n\n"
|
71
|
+
begin
|
72
|
+
Pokemon.find_or_create_by_name(pokemon)
|
73
|
+
rescue => e
|
74
|
+
puts "Error loading Pokemon by name."
|
75
|
+
puts e.message
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.get_random_pokemon
|
80
|
+
puts "\n\n"
|
81
|
+
puts "Searching for random Pokemon..."
|
82
|
+
puts "\n\n"
|
83
|
+
begin
|
84
|
+
Pokemon.find_random
|
85
|
+
rescue => e
|
86
|
+
puts "Error loading random Pokemon"
|
87
|
+
puts e.message
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
#Returning Type objects
|
92
|
+
|
93
|
+
def self.get_type_by_name(type)
|
94
|
+
puts "\n\n"
|
95
|
+
puts "Searching for #{type}..."
|
96
|
+
puts "\n\n"
|
97
|
+
begin
|
98
|
+
Type.find_or_create_by_name(type)
|
99
|
+
rescue => e
|
100
|
+
puts "Error loading type by name."
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def self.get_random_type
|
105
|
+
puts "\n\n"
|
106
|
+
puts "Searching for random Type..."
|
107
|
+
puts "\n\n"
|
108
|
+
begin
|
109
|
+
Type.find_random
|
110
|
+
rescue => e
|
111
|
+
puts "Error loading random Type"
|
112
|
+
puts e.message
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
#Returning move objects
|
117
|
+
|
118
|
+
def self.get_move_by_name(move)
|
119
|
+
puts "\n\n"
|
120
|
+
puts "Searching for #{move}..."
|
121
|
+
puts "\n\n"
|
122
|
+
begin
|
123
|
+
Move.find_or_create_by_name(move)
|
124
|
+
rescue => e
|
125
|
+
puts "Error loading move by name."
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def self.get_random_move
|
130
|
+
puts "\n\n"
|
131
|
+
puts "Searching for random Move..."
|
132
|
+
puts "\n\n"
|
133
|
+
begin
|
134
|
+
Move.find_random
|
135
|
+
rescue => e
|
136
|
+
puts "Error loading random Move"
|
137
|
+
puts e.message
|
138
|
+
end
|
139
|
+
end
|
140
|
+
#Returning Item objects
|
141
|
+
def self.get_item_by_name(item)
|
142
|
+
puts "\n\n"
|
143
|
+
puts "Searching for #{item}..."
|
144
|
+
begin
|
145
|
+
Item.find_or_create_by_name(item)
|
146
|
+
rescue => e
|
147
|
+
puts "Error loading item by name."
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
def self.get_random_item
|
152
|
+
puts "\n\n"
|
153
|
+
puts "Searching for random Item..."
|
154
|
+
puts "\n\n"
|
155
|
+
begin
|
156
|
+
Item.find_random
|
157
|
+
rescue => e
|
158
|
+
puts "Error loading random Item"
|
159
|
+
puts e.message
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
#Returning Ability objects
|
164
|
+
def self.get_ability_by_name(ability)
|
165
|
+
puts "\n\n"
|
166
|
+
puts "Searching for #{ability}..."
|
167
|
+
begin
|
168
|
+
Ability.find_or_create_by_name(ability)
|
169
|
+
rescue => e
|
170
|
+
puts "Error loading item by name."
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
def self.get_random_ability
|
175
|
+
puts "\n\n"
|
176
|
+
puts "Searching for random Ability..."
|
177
|
+
puts "\n\n"
|
178
|
+
begin
|
179
|
+
Ability.find_random
|
180
|
+
rescue => e
|
181
|
+
puts "Error loading random ability"
|
182
|
+
puts e.message
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
class CLI
|
2
|
+
|
3
|
+
@@prompt = TTY::Prompt.new
|
4
|
+
|
5
|
+
def greeting
|
6
|
+
puts " -⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
██████╗░███████╗██╗░░██╗████████╗███████╗██████╗░░░░░░░░░░░░░░░
|
11
|
+
██╔══██╗██╔════╝╚██╗██╔╝╚══██╔══╝██╔════╝██╔══██╗░░██╗░░░░██╗░░
|
12
|
+
██║░░██║█████╗░░░╚███╔╝░░░░██║░░░█████╗░░██████╔╝██████╗██████╗
|
13
|
+
██║░░██║██╔══╝░░░██╔██╗░░░░██║░░░██╔══╝░░██╔══██╗╚═██╔═╝╚═██╔═╝
|
14
|
+
██████╔╝███████╗██╔╝╚██╗░░░██║░░░███████╗██║░░██║░░╚═╝░░░░╚═╝░░
|
15
|
+
╚═════╝░╚══════╝╚═╝░░╚═╝░░░╚═╝░░░╚══════╝╚═╝░░╚═╝░░░░░░░░░░░░░░
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
🄰🄽 🄴🄽🄷🄰🄽🄲🄴🄳 🄿🄾🄺🄴🄳🄴🅇 🄱🅈 🅂🄴🄰🄽 🅃🄷🄾🄼🄿🅂🄾🄽
|
20
|
+
|
21
|
+
|
22
|
+
-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨-⃨"
|
23
|
+
puts"\n\n\n\n Welcome to Dexter++! Your personal tool for exploring the Pokemon universe!"
|
24
|
+
puts"\n\n"
|
25
|
+
end
|
26
|
+
|
27
|
+
def good_bye
|
28
|
+
puts "
|
29
|
+
|
30
|
+
██████╗ ██████╗ ██████╗ ██████╗ ██████╗ ██╗ ██╗███████╗██╗
|
31
|
+
██╔════╝ ██╔═══██╗██╔═══██╗██╔══██╗██╔══██╗╚██╗ ██╔╝██╔════╝██║
|
32
|
+
██║ ███╗██║ ██║██║ ██║██║ ██║██████╔╝ ╚████╔╝ █████╗ ██║
|
33
|
+
██║ ██║██║ ██║██║ ██║██║ ██║██╔══██╗ ╚██╔╝ ██╔══╝ ╚═╝
|
34
|
+
╚██████╔╝╚██████╔╝╚██████╔╝██████╔╝██████╔╝ ██║ ███████╗██╗
|
35
|
+
╚═════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚══════╝╚═╝
|
36
|
+
|
37
|
+
|
38
|
+
"
|
39
|
+
end
|
40
|
+
|
41
|
+
def main_menu
|
42
|
+
puts "\n\n\n\n"
|
43
|
+
puts "
|
44
|
+
█▀▄▀█ ▄▀█ █ █▄░█ █▀▄▀█ █▀▀ █▄░█ █░█
|
45
|
+
█░▀░█ █▀█ █ █░▀█ █░▀░█ ██▄ █░▀█ █▄█".light_yellow
|
46
|
+
puts"\n\n\n"
|
47
|
+
input = @@prompt.select("What would you like to do?", cycle: true) do |menu|
|
48
|
+
menu.choice "Get Pokemon information." , 1
|
49
|
+
menu.choice "Get Item information", 2
|
50
|
+
menu.choice "Get Move information", 3
|
51
|
+
menu.choice "Get Ability information", 4
|
52
|
+
menu.choice "Get Type information", 5
|
53
|
+
menu.choice "Exit Dexter++".light_red , 6
|
54
|
+
end
|
55
|
+
case input
|
56
|
+
when 1
|
57
|
+
menu = PokemonMenu.new(self)
|
58
|
+
menu.main_menu
|
59
|
+
when 2
|
60
|
+
menu = ItemMenu.new(self)
|
61
|
+
menu.main_menu
|
62
|
+
when 3
|
63
|
+
menu = MoveMenu.new(self)
|
64
|
+
menu.main_menu
|
65
|
+
when 4
|
66
|
+
menu = AbilityMenu.new(self)
|
67
|
+
menu.main_menu
|
68
|
+
when 5
|
69
|
+
menu = TypeMenu.new(self).main_menu
|
70
|
+
when 6
|
71
|
+
self.exit_program
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def run
|
76
|
+
self.greeting
|
77
|
+
self.main_menu
|
78
|
+
end
|
79
|
+
|
80
|
+
def prompt
|
81
|
+
@@prompt
|
82
|
+
end
|
83
|
+
|
84
|
+
def type_menu
|
85
|
+
@@prompt.select("Select a type to search for.", %w(Normal Flying Poison Ground Rock Bug Ghost Steel Fire Water Grass Electric Psychic Ice Dragon Dark Fairy Unknown Shadow Back ), cycle: true)
|
86
|
+
end
|
87
|
+
|
88
|
+
def get_menu_from_array(array)
|
89
|
+
@@prompt.select("\n\n\nSelect an option to see more information.\n", array, cycle: true)
|
90
|
+
end
|
91
|
+
|
92
|
+
def exit_program
|
93
|
+
puts"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
|
94
|
+
puts"\t\tHope you enjoyed using Dexter++! See you again soon!"
|
95
|
+
puts"\n\n\n"
|
96
|
+
self.good_bye
|
97
|
+
puts "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
|
98
|
+
begin
|
99
|
+
exit
|
100
|
+
rescue SystemExit
|
101
|
+
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|