2017-04-21 04:04:47 +00:00
|
|
|
# Module for printing various information.
|
|
|
|
|
|
|
|
import extractor
|
|
|
|
|
2017-04-21 03:24:04 +00:00
|
|
|
|
|
|
|
# Print the instructions of usage.
|
|
|
|
def print_usage():
|
2017-04-21 04:04:47 +00:00
|
|
|
print(
|
|
|
|
'''
|
|
|
|
Usage:
|
|
|
|
python3.5 main.py [Pokemon name]
|
|
|
|
python3.5 main.py [Pokemon index]
|
|
|
|
python3.5 main.py [region]
|
|
|
|
python3.5 main.py [one letter]
|
|
|
|
|
|
|
|
Parameter Explanations:
|
|
|
|
[Pokemon name] - Changes the terminal background to the specified Pokemon.
|
|
|
|
[Pokemon index] - Changes the terminal background to a Pokemon by its index.
|
|
|
|
[region] - Print all the Pokemon of the specified region.
|
|
|
|
[one letter] - Print all Pokemon who's names begin with a particular letter.
|
|
|
|
|
|
|
|
Examples:
|
|
|
|
[Pokemon name] - python3.5 main.py pikachu
|
|
|
|
[Pokemon index] - python3.5 main.py 25
|
|
|
|
[region] - python3.5 main.py johto
|
|
|
|
python3.5 main.py all
|
|
|
|
[one letter] - python3.5 main.py k
|
|
|
|
''')
|
2017-04-21 03:24:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Print all the items in a list. Used for printing each Pokemon from a particular region.
|
|
|
|
def print_list(list_of_items):
|
|
|
|
for item in list_of_items:
|
|
|
|
print(item)
|
|
|
|
|
|
|
|
|
2017-04-21 04:04:47 +00:00
|
|
|
# Print a list as multiple columns instead of just one.
|
|
|
|
def print_columns(items, i, j):
|
|
|
|
rows = []
|
|
|
|
items_per_column = int((j - i) / 3) + 1
|
2017-04-21 03:24:04 +00:00
|
|
|
|
|
|
|
for index in range(i, j):
|
2017-04-21 04:04:47 +00:00
|
|
|
name = items[index][:-1]
|
2017-04-21 03:24:04 +00:00
|
|
|
|
2017-04-21 04:27:01 +00:00
|
|
|
# For formatting: this helps line up columns correctly where a short name would otherwise ruin it.
|
2017-04-21 03:24:04 +00:00
|
|
|
if len(name) < 10:
|
2017-04-21 04:27:01 +00:00
|
|
|
name += " "
|
|
|
|
|
|
|
|
# More formatting: this lines up the columns by adding zeros.
|
|
|
|
# Example: "2 Ivysaur" -> "002 Ivysaur"
|
|
|
|
zeroes = ""
|
|
|
|
if int(name.split(' ')[0]) < 10:
|
|
|
|
zeroes = "00"
|
|
|
|
elif int(name.split(' ')[0]) < 100:
|
|
|
|
zeroes = "0"
|
2017-04-21 03:24:04 +00:00
|
|
|
|
2017-04-21 04:04:47 +00:00
|
|
|
if len(rows) < items_per_column:
|
2017-04-21 04:27:01 +00:00
|
|
|
rows.append(zeroes + name)
|
2017-04-21 03:24:04 +00:00
|
|
|
else:
|
2017-04-21 04:27:01 +00:00
|
|
|
rows[(index - i) % items_per_column] += "\t\t" + zeroes + name
|
2017-04-21 04:04:47 +00:00
|
|
|
|
|
|
|
print_list(rows)
|
|
|
|
|
2017-04-21 03:24:04 +00:00
|
|
|
|
2017-04-21 04:04:47 +00:00
|
|
|
# Helper method for printing all the Pokemon in a particular region.
|
|
|
|
def print_region(i, j):
|
|
|
|
print_columns(extractor.load_names(), i, j)
|
2017-04-21 03:24:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Print each Kanto region Pokemon and its corresponding number.
|
|
|
|
def print_kanto():
|
|
|
|
print_region(0, 151)
|
|
|
|
|
|
|
|
|
|
|
|
# Print each Johto region Pokemon and its corresponding number.
|
|
|
|
def print_johto():
|
|
|
|
print_region(151, 251)
|
|
|
|
|
|
|
|
|
|
|
|
# Print each Hoenn region Pokemon and its corresponding number.
|
|
|
|
def print_hoenn():
|
|
|
|
print_region(251, 386)
|
|
|
|
|
|
|
|
|
|
|
|
# Print each Sinnoh region Pokemon and its corresponding number.
|
|
|
|
def print_sinnoh():
|
2017-04-21 04:04:47 +00:00
|
|
|
print_region(386, 493)
|
|
|
|
|
|
|
|
|
|
|
|
# Print all the Pokemon for all the regions supported.
|
|
|
|
def print_all():
|
|
|
|
print_region(0, 493)
|
|
|
|
|
|
|
|
|
|
|
|
# Print all the Pokemon who's names begin with a particular letter.
|
|
|
|
def print_pokemon_starting_with(char):
|
|
|
|
pokemon = extractor.pokemon_starting_with(char)
|
|
|
|
print_columns(pokemon, 0, len(pokemon))
|