Skip to content

Instantly share code, notes, and snippets.

@art-solopov
Created January 29, 2017 20:50
Show Gist options
  • Save art-solopov/b46b9b041198fe06f6c3c0bda00bbcde to your computer and use it in GitHub Desktop.
Save art-solopov/b46b9b041198fe06f6c3c0bda00bbcde to your computer and use it in GitHub Desktop.
Create your own Pokemon team!
#!/usr/bin/env python3
HTML = True
NAME = 'Artemiy'
POKEMON = [
{
'species': 'Quilava',
'type': 'fire',
'moves': [
'flamethrower',
'flame charge',
'swift',
'hidden power'
]
},
{
'species': 'Raichu (Alolan)',
'type': 'Electric/Psychic',
'moves': [
'thunderbolt',
'thunder wave',
'psychic',
'quick attack'
]
},
{
'species': 'Dragonair',
'type': 'Dragon',
'moves': [
'surf',
'dragon rush',
'blizzard',
'aqua tail'
]
},
{
'species': 'Ivysaur',
'type': 'Grass/Poison',
'moves': [
'razor leaf',
'toxic',
'sleep powder',
'hidden power'
]
},
{
'species': 'Pidgeotto',
'type': 'Normal/Flying',
'moves': [
'fly',
'aerial ace',
'facade',
'quick attack'
]
},
{
'species': 'Sylveon',
'type': 'Fairy',
'moves': [
'moonblast',
'swift',
'giga impact',
'psyshock'
]
}
]
def pokemon_lines(pokemon):
yield pokemon['species'].upper()
yield ''
yield 'TYPE: ' + '/'.join([x.capitalize()
for x in pokemon['type'].split('/')])
yield ''
for move in pokemon['moves']:
yield '• ' + move.capitalize()
SINGLE_LINE_FORMAT = '║ {0:^75} ║'
DOUBLE_LINE_FORMAT = '║ {0:<36} │ {1:<36} ║'
TOP_LINE = '╔' + ('═' * 77) + '╗'
MID_LINE = '╟' + ('─' * 38) + '┼' + ('─' * 38) + '╢'
BOTTOM_LINE = '╚' + ('═' * 38) + '╧' + ('═' * 38) + '╝'
HTML_TOP = '''
<html>
<head>
<meta charset="UTF-8" />
</head>
<body>
<pre>
'''
HTML_BOTTOM = '''
</pre>
</body>
</html>
'''
if __name__ == '__main__':
if HTML:
print(HTML_TOP)
print(TOP_LINE)
print(SINGLE_LINE_FORMAT.format(NAME + "'s Pokémon team"))
for pokemon_l, pokemon_r in zip(POKEMON[:3], POKEMON[3:]):
print(MID_LINE)
zip_lines = zip(pokemon_lines(pokemon_l), pokemon_lines(pokemon_r))
for line_l, line_r in zip_lines:
print(DOUBLE_LINE_FORMAT.format(line_l, line_r))
print(BOTTOM_LINE)
if HTML:
print(HTML_BOTTOM)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment