def _validate(self, string, expected, scale=10, split="", raises=None):
     if raises:
         with self.assertRaises(raises):
             self._validate(string, expected, scale=scale, split=split, raises=None)
     else:
         actual = parsers.cmc(unicode(string), scale=scale, split=split)
         assert actual == int(expected * scale)
Exemple #2
0
 def _validate(self, string, expected, scale=10, split='', raises=None):
     if raises:
         with self.assertRaises(raises):
             self._validate(string, expected, scale=scale, split=split, raises=None)
     else:
         actual = parsers.cmc(unicode(string), scale=scale, split=split)
         assert actual == int(expected * scale)
Exemple #3
0
def process_card(card, scale=10, split=''):
    '''
    Pass 'left' or 'right' when processing a split card.
    Processes and updates all additional fields (cmc, loyalty, tilde rules) on a card
    that is already populated with basic data like mana cost, name, oracle rules, etc.
    '''
    card.processed_ascii_name = parsers.ascii_card_name(card.name)
    card.processed_cmc = parsers.cmc(card.cost, scale=scale, split=split)
    card.processed_colors = parsers.colors(card.color, card.cost)
    card.processed_power = parsers.power_toughness(card.type,
                                                   card.power,
                                                   scale=scale)
    card.processed_toughness = parsers.power_toughness(card.type,
                                                       card.toughness,
                                                       scale=scale)
    card.processed_loyalty = parsers.loyalty(card.type,
                                             card.toughness,
                                             scale=scale)

    type, subtype = parsers.types(card.type, split=split)
    card.processed_types = type
    card.processed_subtypes = subtype
    card.processed_tilde_rules = parsers.tilde_rules(card.name,
                                                     card.oracle_rules)

    card.processed_scale = scale

    # Catch Ghostfire's colorless oddity
    if card.name == u'Ghostfire':
        card.processed_colors = u''
Exemple #4
0
def process_card(card, scale=10, split=''):
    '''
    Pass 'left' or 'right' when processing a split card.
    Processes and updates all additional fields (cmc, loyalty, tilde rules) on a card
    that is already populated with basic data like mana cost, name, oracle rules, etc.
    '''
    card.processed_ascii_name = parsers.ascii_card_name(card.name)
    card.processed_cmc = parsers.cmc(card.cost, scale=scale, split=split)
    card.processed_colors = parsers.colors(card.color, card.cost)
    card.processed_power = parsers.power_toughness(card.type, card.power, scale=scale)
    card.processed_toughness = parsers.power_toughness(card.type, card.toughness, scale=scale)
    card.processed_loyalty = parsers.loyalty(card.type, card.toughness, scale=scale)

    type, subtype = parsers.types(card.type, split=split)
    card.processed_types = type
    card.processed_subtypes = subtype
    card.processed_tilde_rules = parsers.tilde_rules(card.name, card.oracle_rules)

    card.processed_scale = scale

    # Catch Ghostfire's colorless oddity
    if card.name == u'Ghostfire':
        card.processed_colors = u''