Refactor easter eggs into a separate file

This commit is contained in:
Holly 2021-12-17 20:44:58 +00:00
parent ec8ffed27b
commit 6443f7b849
2 changed files with 21 additions and 4 deletions

14
easter_eggs.py Normal file
View File

@ -0,0 +1,14 @@
# List of easter eggs
# If the function retuns True on the supplied name, operate on the card name here instead of the supplied one
longest_card_elemental = '''
Our Market Research Shows That
Players Like Really Long Card
Names So We Made this Card to Have
the Absolute Longest Card Name Ever
Elemental'''.strip().replace('\n', ' ')
eggs = [
(lambda s: len(s) > 141, longest_card_elemental),
(lambda s: not s, '______'),
]

View File

@ -21,6 +21,7 @@ nest_asyncio.apply() # It has something to do with Scrython using asyncio, which
# I'm sorry, it's completely beyond me. Look it up.
import face
from easter_eggs import eggs
from debug import *
@ -121,12 +122,14 @@ async def get_cards(card_names):
set_code = ''
try:
if len(name) > 141:
c = scrython.cards.Named(fuzzy='Our Market Research Shows That Players Like Really Long Card Names So We Made this Card to Have the Absolute Longest Card Name Ever Elemental')
elif len(name) == 0:
c = scrython.cards.Named(fuzzy='_____')
# Check if any of the easter eggs should happen
for func, replacement in eggs:
if func(name):
c = scrython.cards.Named(fuzzy=replacement)
break
else:
c = scrython.cards.Named(fuzzy=name, set=set_code)
cards.append(c)
responses.append(f'{c.name()} - {c.scryfall_uri()}')
except scrython.foundation.ScryfallError: