コード例 #1
0
def start_wild(trainer: Trainer, species_id: int, level: int,
               database: Database) -> (bool, str):
    """
    Starts a new fight between a trainer and a new wild pokemon, that will be spawned. The bot send a new battle message
    to the trainer

    :param database: pokemon database
    :param bot: telegram bot, which send the message
    :param trainer: trainer in the fight
    :param species_id: species of the wild pokemon
    :param level: level of the wild pokemon
    """
    wild_pokemon = Pokemon.create_new(database,
                                      Data.all_species[species_id - 1], level)
    trainer_team = trainer.get_team(database, "id, currenthp")
    for p in trainer_team:
        if p.currenthp > 0:
            trainer_pokemon = p
            break
    else:
        return False, "Trainer in fight with no available pokemon!"
    trainer_pokemon.load_values(
        database,
        "hp_dv, attack_dv, defense_dv, special_dv, speed_dv, hp_exp, attack_exp, "
        "defense_exp, special_exp, speed_exp, species_id, currenthp, level, "
        "name")
    trainer.fight = Fight.create_new(database, wild_pokemon, trainer_pokemon)
    trainer.menu_id = int(MenuId.BATTLE)
    trainer.update_values(database, "fight, menu_id")

    return True, "Wild %s appeared!" % wild_pokemon.name
コード例 #2
0
 def reset_fight(bot: Bot, update: Update, trainer: Trainer, database: Database):
     trainer.menu_id = int(MenuId.MAIN_MENU)
     trainer.fight = None
     trainer.update_values(database, "fight, menu_id")