def main(): parser = argparse.ArgumentParser( description="generate pokemon ascii art and avatars") parser.add_argument("--avatar", dest='avatar', help="generate a pokemon avatar.", type=str, default=None) parser.add_argument("--pokemon", dest='pokemon', help="generate ascii for a particular pokemon (by name)", type=str, default=None) parser.add_argument("--message", dest='message', help="add a custom message to your ascii!", type=str, default=None) parser.add_argument('--catch', help="catch a random pokemon!", dest='catch', default=False, action='store_true') parser.add_argument('--list', help="list pokemon available", dest='list', default=False, action='store_true') try: args = parser.parse_args() except: parser.print_help() sys.exit(0) if args.list is True: names = catch_em_all(return_names=True) print("\n".join(names)) elif args.pokemon is not None: get_ascii(name=args.pokemon, message=args.message) # If the user wants to create an avatar elif args.avatar != None: get_avatar(args.avatar) elif args.catch == True: catch = get_pokemon() pid = list(catch.keys())[0] get_ascii(pid=pid, message=args.message) else: parser.print_help()
def main(): parser = argparse.ArgumentParser( description="generate pokemon ascii art and avatars") parser.add_argument("--avatar", dest='avatar', help="generate a pokemon avatar.", type=str, default=None) parser.add_argument( "--pokemon", dest='pokemon', help="generate ascii for a particular pokemon (by name)", type=str, default=None) parser.add_argument("--message", dest='message', help="add a custom message to your ascii!", type=str, default=None) parser.add_argument('--catch', help="catch a random pokemon!", dest='catch', default=False, action='store_true') parser.add_argument('--list', help="list pokemon available", dest='list', default=False, action='store_true') try: args = parser.parse_args() except: parser.print_help() sys.exit(0) if args.list is True: names = catch_em_all(return_names=True) print("\n".join(names)) elif args.pokemon is not None: get_ascii(name=args.pokemon, message=args.message) # If the user wants to create an avatar elif args.avatar != None: get_avatar(args.avatar) elif args.catch == True: catch = get_pokemon() pid = list(catch.keys())[0] get_ascii(pid=pid, message=args.message) else: parser.print_help()
def list_pokemon(do_sort=False): '''print list of all names of pokemon in database Parameters ========== do_sort: return list of sorted pokemon (ABC) ''' names = catch_em_all(return_names=True) if do_sort: names.sort() for name in names: try: print(name) except: pass
def get_avatar(name, pokemons=None, print_screen=True, include_name=True): """get_avatar will return a unique pokemon for a specific avatar based on the hash :param name: the name to look up :param print_screen: if True, will print ascii to the screen (default True) and not return :param include_name: if True, will add name (minus end of address after @) to avatar """ if pokemons is None: pokemons = catch_em_all() # The IDs are numbers between 1 and the max number_pokemons = len(pokemons) trainer = get_trainer(name) pid = str(trainer % number_pokemons) pokemon = get_pokemon(pid=pid, pokemons=pokemons) avatar = pokemon[pid]["ascii"] if include_name is True: avatar = "%s\n\n%s" % (avatar, name.split("@")[0]) if print_screen is True: print(avatar) return avatar
def get_avatar(name, pokemons=None, print_screen=True, include_name=True): '''get_avatar will return a unique pokemon for a specific avatar based on the hash :param name: the name to look up :param print_screen: if True, will print ascii to the screen (default True) and not return :param include_name: if True, will add name (minus end of address after @) to avatar ''' if pokemons is None: pokemons = catch_em_all() # The IDs are numbers between 1 and the max number_pokemons = len(pokemons) trainer = get_trainer(name) pid = str(trainer % number_pokemons) pokemon = get_pokemon(pid=pid,pokemons=pokemons) avatar = pokemon[pid]["ascii"] if include_name is True: avatar = "%s\n\n%s" %(avatar,name.split("@")[0]) if print_screen is True: print(avatar) return avatar
def test_get_pokemon(tmp_path): from pokemon.master import catch_em_all catch = catch_em_all() assert len(catch) == 890
import math import random from copy import deepcopy from io import BytesIO from typing import Tuple import nextcord from PIL import Image, ImageEnhance from nextcord.ext import commands # noinspection PyUnresolvedReferences from pokemon.master import catch_em_all, get_pokemon from .embed import Embed from ..helpers.constants import ICONS pokemons = catch_em_all() class Pokemon: def __init__(self, ctx: commands.Context): self.bot = ctx.bot self.channel = ctx.channel self.status = 0 self.scoreboard = dict() self.timed_out = False async def start(self) -> None: channel = self.channel name, original_img, black_img = await self.get()
def get_pokemon_id(): """Return a random pokemon id""" return random.choice(list(catch_em_all()))