async def idolize(self, ctx, *args: str): """ Description: | Idolizes a card in your album. You must have two copies of the card. For example, !idolize 1200. Arguments: | Card ID (This is the left number of a card in your album) """ user = ctx.message.author card_id = 0 # Parse args for card id and idolized. for arg in args: if _is_number(arg): card_id = int(arg) image = None card = await self.bot.db.users.get_card_from_album(user.id, card_id) if card and card['unidolized_count'] >= 2: card['_id'] = card['id'] await self.bot.db.users.remove_from_user_album(user.id, card_id, count=2) await self.bot.db.users.add_to_user_album(user.id, [card], idolized=True) card_info = await self.bot.db.cards.get_card(card_id) img_url = 'http:' + card_info['card_idolized_image'] fname = basename(urlsplit(img_url).path) image_path = idol_img_path.joinpath(fname) image = await get_one_img(img_url, image_path, self.bot.session_manager) await self.__handle_idolize_result(ctx, image)
async def _handle_solo_scout(self): """ Handles a solo scout :return: Path of scout image """ card = await self._scout_cards() # Send error message if no card was returned if not card: self.results = [] return None card = card[0] if card["card_image"] is None: url = "http:" + card["card_idolized_image"] else: url = "http:" + card["card_image"] fname = basename(urlsplit(url).path) image_path = idol_img_path.joinpath(fname) bytes_ = await get_one_img( url, image_path, self._bot.session_manager) return ScoutImage(bytes_, fname)
async def view(self, ctx, *args: str): """ Description: | View a card from your album. For example, !view 1200 or !view 1200 idolized. Optional Arguments: | Card ID (This is the left number of a card in your album) Idolized (Shows the idolized copy if it exist in your album) """ user = ctx.message.author idolized = False card_id = 0 # Parse args for card id and idolized. for arg in args: if _is_number(arg): card_id = int(arg) if arg in ['idolized', 'i']: idolized = True image = None card = await self.bot.db.users.get_card_from_album(user.id, card_id) valid = False if card: unidolized_count = card['unidolized_count'] idolized_count = card['idolized_count'] if idolized: valid = (idolized_count > 0) else: valid = (idolized_count > 0 or unidolized_count > 0) if card['card_image'] == None: idolized = True if valid: img_url = '' if idolized: img_url = 'http:' + card['card_idolized_image'] elif card: img_url = 'http:' + card['card_image'] fname = basename(urlsplit(img_url).path) image_path = idol_img_path.joinpath(fname) image = await get_one_img( img_url, image_path, self.bot.session_manager) await self.__handle_view_result(ctx, image)
async def idolize(self, ctx, *args: str): """ Description: | Idolizes a card in your album. You must have two copies of the card. For example, !idolize 1200. Arguments: | Card ID (This is the left number of a card in your album) """ user = ctx.message.author card_id = 0 # Parse args for card id and idolized. for arg in args: if _is_number(arg): card_id = int(arg) image = None card = await self.bot.db.users.get_card_from_album(user.id, card_id) if not card: await self.__send_error_msg( ctx, 'This card does not exist in your album.') return # Check to make sure the card can actually be idolized. round_img = card['round_card_image'] round_card_i_img = card['round_card_idolized_image'] if card['card_idolized_image'] == None or round_img == round_card_i_img: await self.__send_error_msg(ctx, 'This card cannot be idolized.') return if card and card['unidolized_count'] >= 2: card['_id'] = card['id'] await self.bot.db.users.remove_from_user_album( user.id, card_id, count=2) await self.bot.db.users.add_to_user_album( user.id, [card], idolized=True) img_url = 'http:' + card['card_idolized_image'] fname = basename(urlsplit(img_url).path) image_path = idol_img_path.joinpath(fname) image = await get_one_img( img_url, image_path, self.bot.session_manager) await self.__handle_idolize_result(ctx, image)