Esempio n. 1
0
 def patch(self, pokemon_name):
     pokemon = get_pokemon_by_name(pokemon_name)
     if pokemon is None:
         raise PokemonNotFoundError(pokemon_name)
     # if pokemon is None:
     #     return {'msg': 'Not found'}, 404
     data = request.json
     edit_pokemon(pokemon, data)
     pokemon = get_pokemon_by_name(pokemon_name)
     return pokemon.get_small_data()
Esempio n. 2
0
def apply_potion_to_collection(collection):
    get_potion = PotionCollection.get_or_none(amount=10)
    if get_potion is None:
        print("No potion for collections of amount 10")
    pokemon_collections = PokemonCollection.select().where(
        PokemonCollection.collection == collection)
    for pokemon in pokemon_collections:
        real_pokemon = get_pokemon_by_name(pokemon.name)
        pokemon.heal(get_potion.amount, real_pokemon.hp)
Esempio n. 3
0
 def get(self, pokemon_name):
     pokemon = get_pokemon_by_name(pokemon_name)
     if pokemon is None:
         raise PokemonNotFoundError(pokemon_name)
     forms = bool(request.args["forms"])
     if forms == True:
         return {
             "stats": pokemon.get_small_data(),
             "forms": get_pokemon_form(pokemon)
         }
     return pokemon.get_small_data()
Esempio n. 4
0
 def put(self, collection_name):
     collection = get_collection_by_name(collection_name)
     # if collection is None:
     #     return {'msg': 'Collection not found'}, 404
     pokemon_name = request.args['pokemon']
     pokemon = get_pokemon_by_name(pokemon_name)
     if pokemon is None:
         raise PokemonNotFoundError(pokemon_name)
     # if pokemon is None:
     #     return {'msg': 'Pokemon Not found'}, 404
     else:
         add_pokemon_to_collection(pokemon, collection)
         return "%s added to %s" % (pokemon.name, collection.name)
Esempio n. 5
0
    def get(self, pokemon_name):
        pokemon = get_pokemon_by_name(pokemon_name)
        forms = request.args.get('forms', 'false') == 'true'
        abilities = request.args.get('abilities',None)
        if pokemon is None:
            # return {'msg': 'Not found'}, 404
            raise PokemonNotFoundError(pokemon_name)
        pokemon = pokemon.get_small_data()

        if forms:
            pokemon['forms'] = []
            forms_of_this_pokemon = get_forms_of_pokemons(pokemon['id'])
            for forms in forms_of_this_pokemon:
                pokemon['forms'].append(forms.name)
        return pokemon.get_small_data()
Esempio n. 6
0
 def get(self, pokemon_name):
     ask_shape = request.args.get('shape', 'false') == 'true'
     pokemon = get_pokemon_by_name(pokemon_name)
     # if pokemon is None:
     #     raise PokemonNotFoundError(pokemon_name)
     return pokemon.get_small_data(ask_shape)
Esempio n. 7
0
def apply_potion_to_pokemon_collection(pokemon_collection):
    get_potion = Potion.get_or_none(amount=10)
    if get_potion is None:
        print("No potion of amount 10")
    real_pokemon = get_pokemon_by_name(pokemon_collection.name)
    pokemon_collection.heal(get_potion.amount, real_pokemon.hp)
Esempio n. 8
0
    def get(self, pokemon_name):
        pokemon = get_pokemon_by_name(pokemon_name)
        if pokemon is None:
            return {'msg': 'Not found'}, 404

        return pokemon.get_small_data()
Esempio n. 9
0
 def get(self, pokemon_name):
     pokemon = get_pokemon_by_name(pokemon_name)
     return pokemon.get_small_data()
Esempio n. 10
0
 def put(self, collection_name):
     collection = get_collection_by_name(collection_name)
     pokemon_name = request.arg.get['pokemon']
     pokemon = get_pokemon_by_name(pokemon_name)
     add_new_pokemon_to_collection(pokemon, collection)
Esempio n. 11
0
    def get(self, pokemon_name):
        pokemon = get_pokemon_by_name(pokemon_name)
        if pokemon is None:
            raise PokemonNotFoundError(pokemon_name)

        return pokemon.get_small_data()
Esempio n. 12
0
def user_add_pokemon(user, pokemonname):
    pokemon = get_pokemon_by_name(pokemonname)
    stats = pokemon.stats
    pok = Pokemons.create(user_id=user.id, **stats)
    return pok