From c7115b9f03d19fa59cc10145506cb16a2a9a375c Mon Sep 17 00:00:00 2001 From: qwewqa <198e559dbd446d973355f415bdfa34@gmail.com> Date: Mon, 18 Jan 2021 15:09:39 -0500 Subject: [PATCH] indicate unit and attribute via emoji in cards command --- miyu_bot/commands/cogs/card.py | 12 +++++++++--- miyu_bot/commands/common/fuzzy_matching.py | 2 +- miyu_bot/commands/common/name_aliases.py | 3 ++- miyu_bot/commands/common/reaction_message.py | 6 +++--- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/miyu_bot/commands/cogs/card.py b/miyu_bot/commands/cogs/card.py index aa436cd..013bde5 100644 --- a/miyu_bot/commands/cogs/card.py +++ b/miyu_bot/commands/cogs/card.py @@ -109,9 +109,9 @@ class Card(commands.Cog): display_prefix = display.get_formatted_from_card(card) if display_prefix: listing.append( - f'{display_prefix} : {self.format_card_name(card)}') + f'{display_prefix} {self.format_card_name_for_list(card)}') else: - listing.append(self.format_card_name(card)) + listing.append(self.format_card_name_for_list(card)) embed = discord.Embed(title=f'Card Search "{arg}"' if arg else 'Cards') asyncio.ensure_future(run_paged_message(ctx, embed, listing)) @@ -127,7 +127,8 @@ class Card(commands.Cog): units = {units_by_name[unit].id for unit in arguments.tags(names=units_by_name.keys(), aliases=unit_aliases)} rarities = {int(r[0]) for r in arguments.words(['4*', '3*', '2*', '1*', r'4\*', r'3\*', r'2\*', r'1\*'])} - attributes = {attributes_by_name[a].id for a in arguments.words(attributes_by_name.keys())} + attributes = {attributes_by_name[a].id + for a in arguments.words(attributes_by_name.keys()) | arguments.tags(attributes_by_name.keys())} event_bonus = bool(arguments.tags(['event', 'eventbonus', 'event_bonus'])) @@ -213,6 +214,11 @@ class Card(commands.Cog): def format_card_name(self, card): return f'{card.rarity_id}★ {card.name} {card.character.full_name_english}' + def format_card_name_for_list(self, card): + unit_emoji = self.bot.get_emoji(unit_emoji_ids_by_unit_id[card.character.unit_id]) + attribute_emoji = self.bot.get_emoji(attribute_emoji_ids_by_attribute_id[card.attribute_id]) + return f'`{unit_emoji}`+`{attribute_emoji}` {card.rarity_id}★ {card.name} {card.character.full_name_english}' + class CardAttribute(enum.Enum): Name = enum.auto() diff --git a/miyu_bot/commands/common/fuzzy_matching.py b/miyu_bot/commands/common/fuzzy_matching.py index 7f182af..0602033 100644 --- a/miyu_bot/commands/common/fuzzy_matching.py +++ b/miyu_bot/commands/common/fuzzy_matching.py @@ -118,7 +118,7 @@ class FuzzyMatchConfig: }) word_match_weight: float = -0.2 whole_match_weight: float = -0.25 - acronym_match_weight: float = -0.3 + acronym_match_weight: float = -0.25 class FuzzyMatcher: diff --git a/miyu_bot/commands/common/name_aliases.py b/miyu_bot/commands/common/name_aliases.py index 7a3dcfb..116fabb 100644 --- a/miyu_bot/commands/common/name_aliases.py +++ b/miyu_bot/commands/common/name_aliases.py @@ -12,7 +12,8 @@ units_by_name['rondo'] = units_by_name['燐舞曲'] units_by_name['special'] = units_by_name['スペシャル'] units_by_name['other'] = units_by_name['その他'] unit_aliases = { - 'happyaround': 'happy_around', + 'happyaround': 'happy_around!', + 'happy_around': 'happy_around!', 'hapiara': 'happy_around', 'ha': 'happy_around', 'peakyp-key': 'peaky_p-key', diff --git a/miyu_bot/commands/common/reaction_message.py b/miyu_bot/commands/common/reaction_message.py index 3c0c271..d738ae4 100644 --- a/miyu_bot/commands/common/reaction_message.py +++ b/miyu_bot/commands/common/reaction_message.py @@ -66,14 +66,14 @@ async def run_paged_message(ctx: Context, base_embed: discord.Embed, content: Li nonlocal item_number item_number += 1 if numbered: - return f'{item_number}.{" " * (max_item_number_length - len(str(item_number)))} {item}' + return f'`{item_number}.{" " * (max_item_number_length - len(str(item_number)))} {item}`' else: - return str(item) + return f'`{item}`' embeds = [ base_embed.from_dict({ **base_embed.to_dict(), - 'description': '```' + header + '\n'.join((format_item(i) for i in page)) + '```', + 'description': '' + header + '\n'.join((format_item(i) for i in page)) + '', }).set_footer(text=f'Page {i + 1}/{len(page_contents)}') for i, page in enumerate(page_contents)]