def heal_yes(self, bot: Bot, update: Update, trainer: Trainer, database: Database): delete_message(bot, update) pokeraw = trainer.get_team( database, "id, species_id, level, name, teamnr, currenthp, hp_dv, hp_exp" ) # blocktimer row_count = database.dict_cursor.rowcount healtime = row_count * 5 # "UPDATE trainer SET blocktimer = NOW() + INTERVAL %s MINUTE WHERE id = % s;", (healtime, cid,)) # trainer.set_attribute("blocktimer", "NOW() + INTERVAL {0} MINUTE".format(healtime)) trainer.blocktimer = dt.datetime.now() + dt.timedelta(minutes=healtime) # d.cmd("UPDATE pokemon SET currenthp = %s WHERE id = %s", (temppoke.calculate_max_hp(), temppoke.id,)) for poke in pokeraw: poke.currenthp = poke.calculate_max_hp() poke.update_values(database, "currenthp") # poke.set_attribute("currenthp", "{0}".format(poke.calculate_max_hp())) center_buttons = [[ InlineKeyboardButton("Pick up!", callback_data='pickuppkmn') ]] center_keys = InlineKeyboardMarkup(center_buttons) bot.send_message( Trainer.id, "Ok. We'll need your Pokémon. Come back in {0} minutes and pick up your Pokémon. You can't do anything while we are healing your Pokémon. Please take a seat in our waiting room..." .format(healtime), reply_markup=center_keys) trainer.menu_id = MenuId.CENTER_HEAL_BLOCKER trainer.update_values(database, "blocktimer") trainer.update_values(database, "menu_id")
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
def menu_pokemon(cls, bot: Bot, update: Update, trainer: Trainer, database: Database): team = trainer.get_team(database, "id, name, level") buttons = [] for i, t in enumerate(team): buttons.append([InlineKeyboardButton( t.name + " - lvl. " + str(t.level), callback_data=ButtonId.BATTLE_MENU_NEW_POKEMON + str(i))]) buttons.append([cls.button_back]) battle_message.edit_menu(bot, update.callback_query.message, InlineKeyboardMarkup(buttons))
def tinfo(bot, update): """ :param bot: :param update: :return: """ d = get_database() try: data = update.message.text id = update.message.from_user.id trainer = Trainer(id) trainer.load_values(d, "menu_id") if trainer.menu_id == 3: pokes = trainer.get_team( d, "id, name, level, currenthp, gender, hp_exp, hp_dv, species_id, current_status" ) show_poke_info(bot, id, data, pokes) finally: free_database(d)
def pokemon_team(self, bot: Bot, update: Update, trainer: Trainer, database: Database): delete_message(bot, update) team = trainer.get_team(database, "id, name, level, teamnr, currenthp, gender") msg = "" for p in team: poke = Pokemon(p.id) poke.load_values(database, "teamnr, name, level, currenthp") poke.load_values( database, "gender, hp_exp, hp_dv, species_id, current_status") msg += """ ({0}) {1} [{5}] Lv. {2} \n HP: {3}/{4}\n""".format( poke.teamnr, poke.name, poke.level, poke.currenthp, poke.calculate_max_hp(), poke.gender) bot.send_message(trainer.id, "Your Pokémon-Team:\n" + msg, reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton("⏪ Profile", callback_data=str( ButtonId.MENU_PROFILE)) ]]))
def heal(self, bot: Bot, update: Update, trainer: Trainer, database: Database): """ if menu_id==3: Ask the player if the trainer wants to heal his Pokemonteam and prints the time the pokemon need to heal. Gets id and teamnr from database. Yes = menu_id -> MenuId.POKEMON_CENTER """ pokemon = trainer.get_team(database, "id, teamnr") row_count = database.dict_cursor.rowcount healtime = row_count * minutes_to_heal center_buttons = [[ InlineKeyboardButton("Heal, please!", callback_data='heal_y'), InlineKeyboardButton("Nope.", callback_data='heal_n') ]] center_keys = InlineKeyboardMarkup(center_buttons) bot.send_message( id, "Welcome to our Pokémon Center! We heal your Pokémon back to perfect health! Shall we heal your Pokémon? We will need {0} minutes to heal every Pokémon in your team." .format(healtime), reply_markup=center_keys) trainer.menu_id = MenuId.POKEMON_CENTER trainer.update_values(database, "menu_id")