diff --git a/easter_eggs.py b/easter_eggs.py new file mode 100644 index 0000000..a701698 --- /dev/null +++ b/easter_eggs.py @@ -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, '______'), +] \ No newline at end of file diff --git a/mtgcardlookup.py b/mtgcardlookup.py index a123a68..b39b33f 100755 --- a/mtgcardlookup.py +++ b/mtgcardlookup.py @@ -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: