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''
def _validate(self, types, toughness, expected_loyalty, scale=10): actual_loyalty = parsers.loyalty(unicode(types), unicode(toughness), scale=scale) if expected_loyalty is None: assert actual_loyalty is None else: assert actual_loyalty == int(expected_loyalty * scale)