Exemple #1
0
def test_accents():
    cards = oracle.cards_from_query('Lim-Dûl the Necromancer')
    assert len(cards) == 1
    cards = oracle.cards_from_query('Séance')
    assert len(cards) == 1
    cards = oracle.cards_from_query('Lim-Dul the Necromancer')
    assert len(cards) == 1
    cards = oracle.cards_from_query('Seance')
    assert len(cards) == 1
Exemple #2
0
def test_legality_emoji():
    legal_cards = oracle.legal_cards()
    assert len(legal_cards) > 0
    legal_card = oracle.cards_from_query('island')[0]
    assert emoji.legal_emoji(legal_card) == ':white_check_mark:'
    illegal_card = oracle.cards_from_query('black lotus')[0]
    assert emoji.legal_emoji(illegal_card) == ':no_entry_sign:'
    assert emoji.legal_emoji(illegal_card,
                             True) == ':no_entry_sign: (not legal in PD)'
def test_legality():
    cards = oracle.cards_from_query('Swamp')
    assert len(cards) == 1
    assert cards[0].legalities['Standard'] == 'Legal'
    assert cards[0].legalities['Modern'] == 'Legal'
    assert cards[0].legalities['Legacy'] == 'Legal'
    assert cards[0].legalities['Vintage'] == 'Legal'
    assert cards[0].legalities['Penny Dreadful'] == 'Legal'
    cards = oracle.cards_from_query('Black Lotus')
    assert len(cards) == 1
    assert 'Standard' not in cards[0].legalities.keys()
    assert 'Modern' not in cards[0].legalities.keys()
    assert cards[0].legalities['Legacy'] == 'Banned'
    assert cards[0].legalities['Vintage'] == 'Restricted'
    assert 'Penny Dreadful' not in cards[0].legalities.keys()
Exemple #4
0
def cards_from_queries(queries):
    all_cards = []
    for query in queries:
        cards = oracle.cards_from_query(query)
        if len(cards) > 0:
            all_cards.extend(cards)
    return all_cards
    async def rhinos(self, bot, channel):
        """`!rhinos` Anything can be a rhino if you try hard enough"""
        rhinos = []
        rhino_name = "Siege Rhino"
        if random.random() < 0.1:
            rhino_name = "Abundant Maw"
        rhinos.extend(oracle.cards_from_query(rhino_name))

        def find_rhino(query):
            cards = complex_search('f:pd {0}'.format(query))
            if len(cards) == 0:
                cards = complex_search(query)
            return random.choice(cards)

        rhinos.append(find_rhino('o:"copy of target creature"'))
        rhinos.append(
            find_rhino(
                'o:"return target creature card from your graveyard to the battlefield"'
            ))
        rhinos.append(find_rhino('o:"search your library for a creature"'))
        msg = "\nSo of course we have {rhino}.".format(rhino=rhinos[0].name)
        msg += " And we have {copy}. It can become a rhino, so that's a rhino.".format(
            copy=rhinos[1].name)
        msg += " Then there's {reanimate}. It can get back one of our rhinos, so that's a rhino.".format(
            reanimate=rhinos[2].name)
        msg += " And then we have {search}. It's a bit of a stretch, but that's a rhino too.".format(
            search=rhinos[3].name)
        await bot.post_cards(rhinos, channel, additional_text=msg)
Exemple #6
0
def test_cards_from_query():
    cards = oracle.cards_from_query('Far/Away')
    assert len(cards) == 1
    assert cards[0].name == 'Far // Away'
    cards = oracle.cards_from_query('Jötun Grunt')
    assert len(cards) == 1
    assert cards[0].name == 'Jötun Grunt'
    cards = oracle.cards_from_query('Jotun Grunt')
    assert len(cards) == 1
    assert cards[0].name == 'Jötun Grunt'
    cards = oracle.cards_from_query('Ready / Willing')
    assert len(cards) == 1
    assert cards[0].name == 'Ready // Willing'
    cards = oracle.cards_from_query('Fire // Ice')
    assert len(cards) == 1
    assert cards[0].name == 'Fire // Ice'
Exemple #7
0
def test_imagedownload():
    filepath = '{dir}/{filename}'.format(dir=configuration.get('image_dir'),
                                         filename='island.jpg')
    if fetcher_internal.acceptable_file(filepath):
        os.remove(filepath)
    c = []
    c.extend(oracle.cards_from_query('Island'))
    assert image_fetcher.download_image(c) is not None
Exemple #8
0
def test_split_cards():
    cards = oracle.cards_from_query('Armed // Dangerous')
    assert len(cards) == 1
    assert image_fetcher.download_image(cards) is not None
    names = command.parse_queries('[Toil // Trouble]')
    assert len(names) == 1
    cards = command.cards_from_queries(names)
    assert len(cards) == 1
async def single_card_text(bot, channel, args, author, f):
    cards = list(oracle.cards_from_query(args))
    if len(cards) > 1:
        await bot.client.send_message(channel, '{author}: Ambiguous name.'.format(author=author.mention))
    elif len(cards) == 1:
        legal_emjoi = emoji.legal_emoji(cards[0])
        text = emoji.replace_emoji(f(cards[0]), bot.client)
        message = '**{name}** {legal_emjoi} {text}'.format(name=cards[0].name, legal_emjoi=legal_emjoi, text=text)
        await bot.client.send_message(channel, message)
    else:
        await bot.client.send_message(channel, '{author}: No matches.'.format(author=author.mention))
Exemple #10
0
    async def random(self, bot, channel, args):
        """`!random` Request a random PD legal card
`!random X` Request X random PD legal cards."""
        number = 1
        if len(args) > 0:
            try:
                number = int(args.strip())
            except ValueError:
                pass
        cards = [oracle.cards_from_query(name)[0] for name in random.sample(oracle.legal_cards(), number)]
        await bot.post_cards(cards, channel)
Exemple #11
0
def test_aether():
    cards = oracle.cards_from_query('aether Spellbomb')
    assert len(cards) == 1
 def __init__(self, exception):
     self.exception = str(exception)
     self.card = random.choice(oracle.cards_from_query('Lost'))
     self.cards = [self.card]