pokedex-terminal 0.1.2 → 0.1.4
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 +4 -4
- data/Gemfile +5 -3
- data/Gemfile.lock +1 -1
- data/README.md +53 -13
- data/Rakefile +5 -3
- data/bin/console +4 -3
- data/bin/pokedex-terminal +2 -1
- data/lib/classes/Delete.rb +16 -22
- data/lib/classes/List.rb +53 -52
- data/lib/classes/Main_menu.rb +77 -46
- data/lib/classes/New.rb +41 -42
- data/lib/classes/Print.rb +55 -41
- data/lib/classes/Search.rb +7 -11
- data/lib/classes/Update.rb +59 -57
- data/lib/classes/pokemon.csv +801 -0
- data/lib/pokemon-terminal.rb +5 -4
- data/lib/terminal/version.rb +3 -1
- data/pokedex-terminal.gemspec +16 -14
- metadata +30 -32
- data/data/pokemon.csv +0 -802
- data/lib/test.rb +0 -6
- data/lib/titlesequence.plaintext +0 -13
data/lib/classes/Print.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative './Main_menu'
|
2
4
|
require 'colorize'
|
3
5
|
|
4
6
|
class Print
|
5
|
-
|
6
7
|
def self.print_pokemon_expanded(hash)
|
7
|
-
|
8
|
-
puts
|
9
|
-
puts
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
print ", with a secondary type of #{hash[:type_2]} \n"
|
8
|
+
puts '-' * 40
|
9
|
+
puts (hash[:name]).to_s
|
10
|
+
puts '-' * 40
|
11
|
+
print "#{hash[:name]} belongs to the #{colorize_attribute(hash, :type_1, :type_1)} type"
|
12
|
+
if !hash[:type_2].nil?
|
13
|
+
print ", with a secondary type of #{colorize_attribute(hash, :type_2, :type_2)} \n"
|
14
14
|
else
|
15
15
|
print ".\n"
|
16
16
|
end
|
@@ -23,42 +23,56 @@ class Print
|
|
23
23
|
if hash[:legendary] == 'True'
|
24
24
|
puts "Most importantly, #{hash[:name]} is a legendary Pokemon!"
|
25
25
|
end
|
26
|
-
puts
|
26
|
+
puts '-' * 40
|
27
27
|
Main_menu.return?
|
28
28
|
end
|
29
29
|
|
30
30
|
def self.print_pokemon_condensed(hash)
|
31
|
-
|
32
|
-
name = "#{hash[:name]}"
|
33
|
-
case hash[:type_1]
|
34
|
-
when "Normal"
|
35
|
-
puts name
|
36
|
-
when "Fire"
|
37
|
-
puts name.colorize(:red)
|
38
|
-
when "Water"
|
39
|
-
puts name.colorize(:blue)
|
40
|
-
when "Grass"
|
41
|
-
puts name.colorize(:green)
|
42
|
-
when "Electric"
|
43
|
-
puts name.colorize(:light_blue)
|
44
|
-
when "Ice"
|
45
|
-
puts name.colorize(:grey)
|
46
|
-
when "Fighting"
|
47
|
-
puts name.colorize(:yellow)
|
48
|
-
when "Poison"
|
49
|
-
puts name.colorize(:purple)
|
50
|
-
when "Ground"
|
51
|
-
puts name.colorize(:brown)
|
52
|
-
when "Flying"
|
53
|
-
when "Psychic"
|
54
|
-
when "Bug"
|
55
|
-
when "Rock"
|
56
|
-
when "Ghost"
|
57
|
-
when "Dark"
|
58
|
-
when "Dragon"
|
59
|
-
when "Steel"
|
60
|
-
when "Fairy"
|
61
|
-
end
|
31
|
+
puts colorize_attribute(hash, :name, :type_1)
|
62
32
|
end
|
63
33
|
|
64
|
-
|
34
|
+
def self.colorize_attribute(hash, key, type)
|
35
|
+
attribute = ''
|
36
|
+
hash.each do |k, v|
|
37
|
+
attribute = v if k == key
|
38
|
+
end
|
39
|
+
case hash[type]
|
40
|
+
when 'Normal'
|
41
|
+
attribute
|
42
|
+
when 'Fire'
|
43
|
+
attribute.colorize(:red)
|
44
|
+
when 'Water'
|
45
|
+
attribute.colorize(:blue)
|
46
|
+
when 'Grass'
|
47
|
+
attribute.colorize(:green)
|
48
|
+
when 'Electric'
|
49
|
+
attribute.colorize(:light_blue)
|
50
|
+
when 'Ice'
|
51
|
+
attribute.colorize(:default)
|
52
|
+
when 'Fighting'
|
53
|
+
attribute.colorize(:light_red)
|
54
|
+
when 'Poison'
|
55
|
+
attribute.colorize(:cyan)
|
56
|
+
when 'Ground'
|
57
|
+
attribute.colorize(:default)
|
58
|
+
when 'Flying'
|
59
|
+
attribute.colorize(:light_white)
|
60
|
+
when 'Psychic'
|
61
|
+
attribute.colorize(:light_magenta)
|
62
|
+
when 'Bug'
|
63
|
+
attribute.colorize(:light_green)
|
64
|
+
when 'Rock'
|
65
|
+
attribute.colorize(:white)
|
66
|
+
when 'Ghost'
|
67
|
+
attribute.colorize(:light_black)
|
68
|
+
when 'Dark'
|
69
|
+
attribute.colorize(:black)
|
70
|
+
when 'Dragon'
|
71
|
+
attribute.colorize(:light_yellow)
|
72
|
+
when 'Steel'
|
73
|
+
attribute.colorize(:light_cyan)
|
74
|
+
when 'Fairy'
|
75
|
+
attribute.colorize(:magenta)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
data/lib/classes/Search.rb
CHANGED
@@ -1,27 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative './Print'
|
2
4
|
require_relative './Main_menu'
|
3
5
|
|
4
6
|
class Search
|
5
|
-
|
6
7
|
def self.by_name(data)
|
7
8
|
search_prompt = TTY::Prompt.new(active_color: :red)
|
8
9
|
poke_array = []
|
9
10
|
data.each do |hash|
|
10
|
-
hash.each do |k,v|
|
11
|
-
if k == :name
|
12
|
-
poke_array << v
|
13
|
-
end
|
11
|
+
hash.each do |k, v|
|
12
|
+
poke_array << v if k == :name
|
14
13
|
end
|
15
14
|
end
|
16
|
-
|
15
|
+
search_prompt.select('Please enter the name of the Pokemon you\'re looking for.', poke_array, filter: true)
|
17
16
|
end
|
18
17
|
|
19
18
|
def self.return_hash(data, name)
|
20
19
|
data.each do |hash|
|
21
|
-
if hash[:name] == name
|
22
|
-
return hash
|
23
|
-
end
|
20
|
+
return hash if hash[:name] == name
|
24
21
|
end
|
25
22
|
end
|
26
|
-
|
27
|
-
end
|
23
|
+
end
|
data/lib/classes/Update.rb
CHANGED
@@ -1,69 +1,71 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative './New'
|
2
4
|
require_relative './Search'
|
3
5
|
|
4
6
|
class Update
|
5
|
-
|
6
7
|
def self.update_pokemon_menu(data)
|
7
8
|
update_prompt = TTY::Prompt.new(active_color: :red)
|
8
9
|
name = Search.by_name(data)
|
9
10
|
data.each do |hash|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
case user_input
|
26
|
-
when 1
|
27
|
-
puts "What would you like #{hash[:name]}'s new name to be?"
|
28
|
-
name = New.add_name
|
29
|
-
hash[:name] = name
|
30
|
-
when 2
|
31
|
-
puts "What would you like #{hash[:name]}'s new type to be?"
|
32
|
-
type_1 = New.add_type
|
33
|
-
hash[:type_1] = type_1
|
34
|
-
when 3
|
35
|
-
puts "What would you like #{hash[:name]}'s new secondary type to be?"
|
36
|
-
type_2 = New.add_type
|
37
|
-
hash[:type_2] = type_2
|
38
|
-
when 4
|
39
|
-
hp = New.add_points('HP')
|
40
|
-
hash[:hp] = hp
|
41
|
-
when 5
|
42
|
-
attack = New.add_points('Attack')
|
43
|
-
hash[:attack] = attack
|
44
|
-
when 6
|
45
|
-
defense = New.add_points('Defense')
|
46
|
-
hash[:defense] = defense
|
47
|
-
when 7
|
48
|
-
sp_atk = New.add_points('Special Attack')
|
49
|
-
hash[:"sp._atk"] = sp_atk
|
50
|
-
when 8
|
51
|
-
sp_def = New.add_points('Special Defense')
|
52
|
-
hash[:"sp._def"] = sp_def
|
53
|
-
when 9
|
54
|
-
speed = New.add_points('Speed')
|
55
|
-
hash[:speed] = speed
|
56
|
-
when 10
|
57
|
-
generation = New.add_generation
|
58
|
-
hash[:generation] = generation
|
59
|
-
when 11
|
60
|
-
legendary = New.add_legendary
|
61
|
-
hash[:legendary] = legendary
|
62
|
-
when 12
|
63
|
-
Main_menu.run
|
64
|
-
end
|
11
|
+
next unless hash[:name] == name
|
12
|
+
|
13
|
+
user_input = update_prompt.select('Which attribute would you like to update?') do |menu|
|
14
|
+
menu.choice 'Name', 1
|
15
|
+
menu.choice 'Type', 2
|
16
|
+
menu.choice 'Secondary Type', 3
|
17
|
+
menu.choice 'HP', 4
|
18
|
+
menu.choice 'Attack', 5
|
19
|
+
menu.choice 'Defense', 6
|
20
|
+
menu.choice 'Special Attack', 7
|
21
|
+
menu.choice 'Special Defense', 8
|
22
|
+
menu.choice 'Speed', 9
|
23
|
+
menu.choice 'Generation', 10
|
24
|
+
menu.choice 'Legendary', 11
|
25
|
+
menu.choice 'Exit this menu', 12
|
65
26
|
end
|
27
|
+
case user_input
|
28
|
+
when 1
|
29
|
+
puts "What would you like #{hash[:name]}'s new name to be?"
|
30
|
+
name = New.add_name
|
31
|
+
hash[:name] = name
|
32
|
+
when 2
|
33
|
+
puts "What would you like #{hash[:name]}'s new type to be?"
|
34
|
+
type_1 = New.add_type
|
35
|
+
hash[:type_1] = type_1
|
36
|
+
when 3
|
37
|
+
puts "What would you like #{hash[:name]}'s new secondary type to be?"
|
38
|
+
type_2 = New.add_type
|
39
|
+
hash[:type_2] = type_2
|
40
|
+
when 4
|
41
|
+
hp = New.add_points('HP')
|
42
|
+
hash[:hp] = hp
|
43
|
+
when 5
|
44
|
+
attack = New.add_points('Attack')
|
45
|
+
hash[:attack] = attack
|
46
|
+
when 6
|
47
|
+
defense = New.add_points('Defense')
|
48
|
+
hash[:defense] = defense
|
49
|
+
when 7
|
50
|
+
sp_atk = New.add_points('Special Attack')
|
51
|
+
hash[:"sp._atk"] = sp_atk
|
52
|
+
when 8
|
53
|
+
sp_def = New.add_points('Special Defense')
|
54
|
+
hash[:"sp._def"] = sp_def
|
55
|
+
when 9
|
56
|
+
speed = New.add_points('Speed')
|
57
|
+
hash[:speed] = speed
|
58
|
+
when 10
|
59
|
+
generation = New.add_generation
|
60
|
+
hash[:generation] = generation
|
61
|
+
when 11
|
62
|
+
legendary = New.add_legendary
|
63
|
+
hash[:legendary] = legendary
|
64
|
+
when 12
|
65
|
+
Main_menu.run
|
66
|
+
end
|
67
|
+
hash[:total] = hash[:hp] + hash[:attack] + hash[:defense] + hash[:"sp._atk"] + hash[:"sp._def"] + hash[:speed]
|
68
|
+
Print.print_pokemon_expanded(hash)
|
66
69
|
end
|
67
70
|
end
|
68
|
-
|
69
71
|
end
|