def estimate_colors(self, mana_cost_text, color_indicator=None): if color_indicator is None: color_indicator = self.color_indicator # the argument could be made that this is "wrong" for the case of # mismatched mana cost and color indicator. But the only example I can # think of "Ghostfire" would probably be Red anyway return estimate_colors(mana_cost_text) | set(color_indicator or [])
def get(cls, card): """ Cards that have activated abilities of different colors than their normal mana color (if it has a color) often have designers placing them in multicolored sections """ merged = merge_mana_costs(*(card.activated_ability_mana_costs or [])) activated_colors = estimate_colors(merged) # don't handle phyrexian, that comes later if (not any('/P' in sym for sym in merged) and activated_colors and # there's color reqs in activation costs activated_colors != card.colors): # and they're new return { cls.key: dict(colors=activated_colors | card.colors) }
def get(cls, card): """ Some designers, when laying out the curves, place suspends out as if their CMC was the suspend cost """ # \u2014 is the specific em-dash returned by tutor has_suspend = re.search(u"Suspend \d+\u2014(\{.+\}) \(", card.text) if not has_suspend: return mana_cost = has_suspend.group(1) suspend_heuristic = dict( mana_cost=mana_cost, converted_mana_cost=estimate_cmc(mana_cost) ) suspend_colors = estimate_colors(mana_cost) if suspend_colors != card.colors: suspend_heuristic['colors'] = card.colors | suspend_colors return {cls.key: suspend_heuristic}
def get(cls, card): """ but for cards that have phyrexian in their activated abilities, the re-occurring cost is a bit much to assume that you can avoid the color requirement for """ phyrexian_result = _handle_phyrexian.get(card) all_costs = merge_mana_costs(card.activated_ability_mana_costs or []) phyrexian_symbols = [sym for sym in all_costs if '/P' in sym] # if not, there was no phyrexian anywhere if phyrexian_result or phyrexian_symbols: # copy whatever they had so far ability_result = deepcopy( (phyrexian_result or {}).get(_handle_phyrexian.key, {}) ) if all_costs and phyrexian_symbols: ability_result['colors'] = ( ability_result.get('colors', set()) | estimate_colors(all_costs) ) return { cls.key: ability_result }