Esempio n. 1
0
def equipment_up():
    eq_id = int(request.values.get('eq_id'))
    poke_id = int(request.args.get('poke_id'))

    id = int(poke_id)
    rid = user.user_info['role_id_list'][0]
    role.load(rid)
    pokemon = Pokemon()
    pokemon.load(id)

    print("up_id", id)
    print("up_poke_id", pokemon.pokemon_id)

    bp_id = role.role_info['backpack_id']
    pokemon.equip(bp_id, eq_id)
    pokemon.load(id)

    hd = handbook()
    equipments = []
    for eq in pokemon.pokemon_info['equipment']:
        hd.load_equipment(eq)
        one_equipment = {}
        one_equipment['name'] = hd.equipment['name']
        one_equipment['id'] = eq
        equipments.append(one_equipment)

    empty_equipments = []

    # 添加装备
    from gameflask.code.backpack import Backpack
    bp = Backpack()
    bp_id = role.role_info['backpack_id']
    bp.load(bp_id)
    equipment_ids = bp.backpack['equipment_lst']
    for i, eq in enumerate(equipment_ids):
        hd = handbook()
        if eq[1] == -1:
            one_empty_equipment = {}
            one_empty_equipment['id'] = eq[0]
            hd.load_equipment(eq[0])
            one_empty_equipment['name'] = hd.equipment['name']
            empty_equipments.append(one_empty_equipment)

    url = "https://img.pokemondb.net/artwork/large/" + pokemon.pokemon_info[
        'name'].lower() + ".jpg"

    return render_template("mainpage/repertory/repertory_detail.html",
                           poke_id=id,
                           url=url,
                           moves=pokemon.pokemon_info['moves'],
                           equipments=equipments,
                           empty_equipments=empty_equipments,
                           one_pokemon=pokemon.pokemon_info)
Esempio n. 2
0
def showhandbook():
    hd = handbook()
    pokemon_keys = hd.get_all_pokemon()

    # 无条件查找
    pokemons = []
    for pokemon_index in pokemon_keys:
        hd = handbook()
        hd.load_pokemon(pokemon_index)
        one_pokemon = hd.pokemon
        one_pokemon['key'] = pokemon_index
        pokemons.append(hd.pokemon)

    return render_template('mainpage/handbook/handbook.html',
                           pokemons=pokemons)
Esempio n. 3
0
def showequipment():
    rid = user.user_info['role_id_list'][0]
    role.load(rid)
    bp_id = role.role_info['backpack_id']
    from gameflask.code.backpack import Backpack
    bp = Backpack()

    bp.load(bp_id)

    equipment_ids = bp.backpack['equipment_lst']
    _equipments = [None for i in range(len(equipment_ids))]
    print('isa', equipment_ids)
    from gameflask.code.pokemon import Pokemon
    for i, eq in enumerate(equipment_ids):
        hd = handbook()

        hd.load_equipment(eq[0])
        pok = Pokemon()
        pok.load(eq[1])
        hd.equipment['owner'] = pok.pokemon_info['name']

        _equipments[i] = hd.equipment
        print(_equipments)

    return render_template('mainpage/equipment/equipment.html',
                           equipments=_equipments)
Esempio n. 4
0
def handbook_detail(id=None):
    hd = handbook()
    hd.load_pokemon(id)

    url = "https://img.pokemondb.net/artwork/large/" + hd.pokemon[
        'name'].lower() + ".jpg"

    return render_template("mainpage/handbook/handbook_detail.html",
                           url=url,
                           moves=hd.pokemon['moves'],
                           one_pokemon=hd.pokemon)
Esempio n. 5
0
def search_by_type():
    if request.method == 'POST':
        pokemon_type = request.form.getlist('type')
        print(pokemon_type[0])

        hd = handbook()
        if (pokemon_type[0] == 'all'):
            pokemon_keys = hd.get_all_pokemon()
            print("is all")
        else:
            print("not all")
            pokemon_keys = hd.get_all_pokemon_by_type_name(pokemon_type[0])

        # 无条件查找
        pokemons = []
        for pokemon_index in pokemon_keys:
            hd = handbook()
            hd.load_pokemon(pokemon_index)
            one_pokemon = hd.pokemon
            one_pokemon['key'] = pokemon_index
            pokemons.append(hd.pokemon)

        return render_template('mainpage/handbook/handbook.html',
                               pokemons=pokemons)
Esempio n. 6
0
def search_by_name():
    if request.method == 'POST':
        pokemon_name = request.form['pokemon_name']

        hd = handbook()
        pokemon_index = hd.get_pokemon_id_by_name(pokemon_name)

        pokemons = []

        hd.load_pokemon(pokemon_index)
        one_pokemon = hd.pokemon
        one_pokemon['key'] = pokemon_index
        pokemons.append(hd.pokemon)

        return render_template('mainpage/handbook/handbook.html',
                               pokemons=pokemons)
Esempio n. 7
0
def main():
    uid = user.uid
    role_id_list = user.user_info["role_id_list"][0]
    role.load(role_id_list)

    rolename = role.role_info["name"]
    # 图鉴宝可梦数量待写
    hd = handbook()
    tot = len(hd.get_all_pokemon())

    money = role.role_info["money"]
    job = role.role_info["job"]
    lv = role.role_info["lv"]

    power = role.role_info["power"]

    return render_template('main.html',
                           rolename=rolename,
                           tot=tot,
                           money=money,
                           job=job,
                           lv=lv,
                           power=power)