示例#1
0
    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 trainercard(self, bot: Bot, update: Update, trainer: Trainer,
                    database: Database):
        delete_message(bot, update)
        trainer.load_values(
            database=database,
            values="name, draws, wins, badges, looses, pokedollar")
        trainer.load_values(database=database, values="registeredsince")
        bot.send_message(trainer.id,
                         """
```Ⓣ Ⓡ Ⓐ Ⓘ Ⓝ Ⓔ Ⓡ - Ⓒ Ⓐ Ⓡ Ⓓ
═══════════════
  Name: {0}
  TrainerID:{1}
  Pokédollar:
  {2}₱
═══════════════
  Registered Since:
  {3}
═══════════════
  Badges: {4}
═══════════════
  Wins: {5}
  Looses: {6}
  Draws: {7}
═══════════════```""".format(trainer.name, trainer.id, trainer.pokedollar,
                             trainer.registeredsince.strftime('%Y-%m-%d'),
                             trainer.badges, trainer.wins, trainer.looses,
                             trainer.draws),
                         parse_mode=ParseMode.MARKDOWN,
                         reply_markup=InlineKeyboardMarkup([[
                             InlineKeyboardButton("⏪ Profile",
                                                  callback_data=str(
                                                      ButtonId.MENU_PROFILE))
                         ]]))
示例#3
0
    def switch_to_starter(self, bot: Bot, update: Update, trainer: Trainer,
                          database: Database):
        """Switch Pokemon Buttons"""
        data = update.callback_query.data

        species = int(data.replace(str(ButtonId.SWITCH_TO_STARTER), ""))
        bot.sendSticker(trainer.id,
                        Stickerpacks.get_starter(species),
                        reply_markup=self.return_starter_buttons()[species])

        delete_message(bot, update)
示例#4
0
 def yes_name(self, bot: Bot, update: Update, trainer: Trainer,
              database: Database):
     """Rename Message"""
     delete_message(bot, update)
     bot.send_message(
         trainer.id,
         text="Okay nice! How do you want to call your little friend?"
         " (Please only use normal character [A-Z, a-z], maximal 16 chars)")
     trainer.load_values(database=database, values="menu_id")
     trainer.menu_id = int(MenuId.ENTER_NAME)
     trainer.update_values(database, "menu_id")
示例#5
0
    def search(self, bot: Bot, update: Update, trainer: Trainer, database: Database):
        """sets earch MenuID and sends instructions"""
        delete_message(bot, update)

        dex_but = [[InlineKeyboardButton("⏪ Exit Search", callback_data = str(ButtonId.POKEDEX_EXIT_SEARCH))]]
        dex_keys = InlineKeyboardMarkup(dex_but)

        bot.send_message(trainer.id,
                         "Here you can search for a Pokemon-Species-ID or a Pokemon-Species-Name."
                         " So please send me a name or number from 1 to 151 now! Write "
                         " \"exit\"  to leave or click here: ", reply_markup = dex_keys)

        trainer.menu_id = int(MenuId.POKEDEX_SEARCH)
        trainer.update_values(database, "menu_id")
示例#6
0
    def no_name(self, bot: Bot, update: Update, trainer: Trainer,
                database: Database):
        """Dont want to Rename"""
        delete_message(bot, update)
        bot.send_message(
            trainer.id,
            text="Nice! Have fun with your new friend! You two seem very strong!"
            " Click on the button bellow to show the Mainmenu.",
            reply_markup=InlineKeyboardMarkup([[
                InlineKeyboardButton("Menu",
                                     callback_data=str(ButtonId.MAINMENU))
            ]]))

        trainer.menu_id = int(MenuId.MAIN_MENU)
        trainer.lastcatched = None
        trainer.update_values(database, "menu_id, lastcatched")
示例#7
0
    def printtext(self, bot: Bot, update: Update, trainer: Trainer,
                  database: Database):
        delete_message(bot, update)
        buttons = [[
            InlineKeyboardButton("⏪ Info",
                                 callback_data=str(ButtonId.MENU_INFO))
        ]]
        markup = InlineKeyboardMarkup(buttons)
        bot.send_message(trainer.id,
                         """
*Privacy policy*
With using this Bot you agreed to follow terms:

_General_
`This bot` (@PokemonAdventureBot) `uses reasonable precautions to keep the personal information disclosed to us secure 
and to disclose such information only to responsible third parties after permission from the user.
This bot is not responsible for the content or the privacy policies of websites to which we may provide links or the 
websites of our affiliates or advertisers.`

_Information collected by this bot_
`This bot collects information about users during their registration for this game and during their participation in 
certain activities on our bot, including contests. When users request a message from our server, 
our Web server automatically collects some information about the users, 
including their Telegram-IDs and the first name or their nickname. 
These IDs are used by Telegram on the network to send the requested messages and media to users.`

*Copyrights*

_General disclaimer_
`Pokémon (c) 2002-2017 Pokémon. 
(c) 1995-2017 Nintendo/Creatures Inc./GAME FREAK inc. TM, (c) and Pokémon character names are trademarks of Nintendo. 
This bot is not licensed from Nintendo or GameFreak and a non-comercial fan-project. 
It is only for users to have fun and was developed by Divirad for and with fun. ;)

If you like this bot please buy the original games! They are great! ;)`
(Or donate us with this command /donate to keep the server up. 
Save the home of every single pokemon with just a little donation)

*Used sources for gamedata:*
[Bulbapedia](bulbapedia.bulbagarden.net)
[PokemonDB](pokemondb.net)

*Contact*
[email protected]
@kurodevs""",
                         ParseMode.MARKDOWN,
                         reply_markup=markup)
    def send_actual_position(self, bot: Bot, update: Update, trainer: Trainer,
                             database: Database):
        """sends the loaded rpg piece"""
        trainer.load_values(database,
                            "game_pos_x, game_pos_y, game_location_id")

        interact = False

        actual_location = get_map().get_location_by_id(
            trainer.game_location_id)
        actual_tile = actual_location.get_tile(trainer.game_pos_x,
                                               trainer.game_pos_y)

        sticker = None
        if actual_tile == WAYTYPE.NONE:
            # TODO log Error
            pass

        left = actual_location.can_walk(trainer.game_pos_x - 1,
                                        trainer.game_pos_y)
        right = actual_location.can_walk(trainer.game_pos_x + 1,
                                         trainer.game_pos_y)
        up = actual_location.can_walk(trainer.game_pos_x,
                                      trainer.game_pos_y - 1)
        down = actual_location.can_walk(trainer.game_pos_x,
                                        trainer.game_pos_y + 1)

        if actual_tile is None:
            # TODO Raise Error!
            trainer.load_values(database, "name")
            bot.send_message(trainer.id, "Hello "+ trainer.name+ "! Sadly there occured an error in this bot" + \
                ":( Please go to your trainercard write down your trainer-ID and inform @kurodevs that you "+ \
                             " have an \"invalid position in the map\". We will fix it soon! "+\
                             "Thank you for using our bot! <3")
            raise PokemonBotError("Trainer: " + str(trainer.id) +
                                  " has no valid position in the map!")

        if actual_tile.type == WAYTYPE.FOREST:
            sticker = Stickerpacks.get_forrestpath(left, right, up, down)
        elif actual_tile.type == WAYTYPE.CAVE:
            sticker = Stickerpacks.get_cavepath(left, right, up, down)

        markup = self.create_markup(left, right, up, down, interact)

        delete_message(bot, update)
        bot.sendSticker(trainer.id, sticker=sticker, reply_markup=markup)
 def donate(self, bot: Bot, update: Update, trainer: Trainer,
            database: Database):
     delete_message(bot, update)
     buttons = [[
         InlineKeyboardButton(
             "Donate!",
             url="http://www.divirad.com/pokemonadventurebot/donate.html")
     ],
                [
                    InlineKeyboardButton("⏪ Info",
                                         callback_data=str(
                                             ButtonId.MENU_INFO))
                ]]
     markup = InlineKeyboardMarkup(buttons)
     bot.send_message(trainer.id,
                      donate_message,
                      ParseMode.MARKDOWN,
                      reply_markup=markup)
示例#10
0
    def potions(self, bot: Bot, update: Update, trainer: Trainer,
                database: Database):

        trainer.load_values(database, "pokedollar")

        data = update.callback_query.data.replace(str(ButtonId.SHOP_POTIONS),
                                                  "")
        delete_message(bot, update)

        num = self.num_calc(4, data)

        item = self.ShopItem()
        item.LoadPotionFromD(num, database)
        bot.sendSticker(trainer.id,
                        Stickerpacks.get_potions(num),
                        reply_markup=self.create_buttons(
                            item, str(ButtonId.SHOP_POTIONS_MIN),
                            str(ButtonId.SHOP_POTIONS_PLS),
                            str(ButtonId.SHOP_POTIONS_BUY), num,
                            trainer.pokedollar))
示例#11
0
    def choosed(self, bot: Bot, update: Update, trainer: Trainer,
                database: Database):
        """Choose Pokemon"""
        data = update.callback_query.data
        species = int(data.replace(str(ButtonId.CHOOSE_STARTER), ""))

        poke = Pokemon.create_new(database, all_species[species], 5, trainer)
        delete_message(bot, update)
        bot.sendSticker(trainer.id, Stickerpacks.get_item(0))
        bot.send_message(trainer.id,
                         text="Nice, " + poke.name +
                         " is your first Pokémon!\n" +
                         poke.species.pokedextext +
                         "\nDo you want to give your Pokémon a nickname?",
                         reply_markup=self.return_rename_buttons())
        trainer.menu_id = int(MenuId.CHOOSE_IF_RENAME)
        trainer.lastcatched = poke.id
        trainer.update_values(database, "menu_id, lastcatched")
        dexter = Pokedex(poke.id, trainer.id)
        dexter.create_new(database, poke.species.id, trainer)
示例#12
0
    def balls(self, bot: Bot, update: Update, trainer: Trainer,
              database: Database):

        trainer.load_values(database, "pokedollar")

        data = update.callback_query.data.replace(str(ButtonId.SHOP_BALLS), "")
        delete_message(bot, update)

        num = self.num_calc(3, data)

        item = self.ShopItem()
        item.LoadBallsFromD(num, database)

        bot.sendSticker(
            trainer.id,
            Stickerpacks.get_balls(num),
            reply_markup=self.create_buttons(
                item,
                str(ButtonId.SHOP_BALLS_MIN), str(ButtonId.SHOP_BALLS_PLS),
                str(ButtonId.SHOP_BALLS_BUY), num,
                trainer.pokedollar))  #num, userinfo['pokedollar'], "balls"))
示例#13
0
 def shopmenu(self, bot: Bot, update: Update, trainer: Trainer,
              database: Database):
     delete_message(bot, update)
     shop_but = [
         [
             InlineKeyboardButton("Pokéball",
                                  callback_data=str(ButtonId.SHOP_BALLS))
         ],
         [
             InlineKeyboardButton("Potions",
                                  callback_data=str(ButtonId.SHOP_POTIONS))
         ],
         [
             InlineKeyboardButton("⏪ Go Out",
                                  callback_data=str(ButtonId.MENU_GOOUT))
         ]
     ]
     shop_keys = InlineKeyboardMarkup(shop_but)
     bot.send_message(trainer.id,
                      text="Hi there! May I help you?",
                      reply_markup=shop_keys)
示例#14
0
    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))
                         ]]))
示例#15
0
    def switch_pages(self, bot: Bot, update: Update, trainer: Trainer, database: Database):
        # ButtonId.POKEDEX_PAGES
        # delete_message(bot, update)
        temp = update.callback_query.data
        data = temp.replace(str(ButtonId.SWITCH_TO_STARTER), "")

        # if data.find('pls') != -1:
        if data.find('pls') != -1:
            #dexnum = int(data[8:])
            dexnum = int(temp.replace(str(ButtonId.POKEDEX_PLS), ""))
            total = dexnum + 1
            if total >= 152:
                total = 1
            delete_message(bot, update)
            self.dexentry(database, bot, update, trainer.id, total)

        elif data.find('min') != -1:
            dexnum = int(temp.replace(str(ButtonId.POKEDEX_MIN), ""))
            total = dexnum - 1
            if total <= 0:
                total = 151
            delete_message(bot, update)
            self.dexentry(database, bot, update, trainer.id, total)
示例#16
0
 def flip_charts(self, bot: Bot, update: Update, trainer: Trainer, database: Database):
     delete_message(bot, update)
     self.dexentry(database,bot, update,trainer.id, 1)
示例#17
0
 def pokedex(self, bot: Bot, update: Update, trainer: Trainer, database: Database):
     delete_message(bot, update)
     self.send_menu(bot, trainer)
示例#18
0
 def print_sub_menu(bot, update, trainer, menu: str, buttons):
     """Prints a Sub-Menu"""
     delete_message(bot, update)
     markup = InlineKeyboardMarkup(buttons)
     bot.send_message(trainer.id, menu, reply_markup=markup)
示例#19
0
 def mainmenu(self, bot: Bot, update: Update, trainer: Trainer,
              database: Database):
     """MainMenu"""
     delete_message(bot, update)
     self.send_main_menu(bot, trainer)