Pokemon-Terminal/printer.py

91 lines
2.4 KiB
Python
Raw Normal View History

# Module for printing various information.
import extractor
# Print the instructions of usage.
def print_usage():
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
''')
# 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)
# 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
for index in range(i, j):
name = items[index][:-1]
# For formatting.
if len(name) < 10:
name += " "
if len(rows) < items_per_column:
rows.append(name)
else:
rows[(index - i) % items_per_column] += "\t\t" + name
print_list(rows)
# Helper method for printing all the Pokemon in a particular region.
def print_region(i, j):
print_columns(extractor.load_names(), i, j)
# 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():
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))