indicate unit and attribute via emoji in cards command

pull/1/head
qwewqa 4 years ago
parent a4df77aae5
commit c7115b9f03
  1. 12
      miyu_bot/commands/cogs/card.py
  2. 2
      miyu_bot/commands/common/fuzzy_matching.py
  3. 3
      miyu_bot/commands/common/name_aliases.py
  4. 6
      miyu_bot/commands/common/reaction_message.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()

@ -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:

@ -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',

@ -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)]

Loading…
Cancel
Save