Exemplo n.º 1
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''
Exemplo n.º 2
0
 def _validate(self, string, type, expected_power, expected_toughness, scale=10):
     pow_str, tough_str = string.split(u"/")
     actual_power = parsers.power_toughness(unicode(type), unicode(pow_str), scale=scale)
     actual_toughness = parsers.power_toughness(unicode(type), unicode(tough_str), scale=scale)
     if expected_power is None:
         assert actual_power is None
     else:
         assert actual_power == int(expected_power * scale)
     if expected_toughness is None:
         assert actual_toughness is None
     else:
         assert actual_toughness == int(expected_toughness * scale)
Exemplo n.º 3
0
 def _validate(self, string, type, expected_power, expected_toughness, scale=10):
     pow_str, tough_str = string.split(u'/')
     actual_power = parsers.power_toughness(unicode(type), unicode(pow_str), scale=scale)
     actual_toughness = parsers.power_toughness(unicode(type), unicode(tough_str), scale=scale)
     if expected_power is None:
         assert actual_power is None
     else:
         assert actual_power == int(expected_power * scale)
     if expected_toughness is None:
         assert actual_toughness is None
     else:
         assert actual_toughness == int(expected_toughness * scale)
Exemplo n.º 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''