def get(cls, card): """ the idea is that for each land you play of the appropriate type you have a mana, and it gets cheaper. This is most common in pauper cubes and it often gets laid out on curve as the player has all basics of the appropriate type. """ affinity_for_basic_land_match = re.search( "Affinity for (Island|Plains|Mountains|Forests|Swamps)", card.text ) if affinity_for_basic_land_match: land_cared_about = affinity_for_basic_land_match.group(1) land_color = estimate_colors_from_lands([land_cared_about]) heuristic = dict( converted_mana_cost=int( ceil(float(card.converted_mana_cost) / 2) ) ) if land_color != card.colors: heuristic['colors'] = land_color | card.colors return { cls.key: heuristic }
def get_colors_from_found_lands(cls, search_string, text): """ return the colors associated with lands found in the text :param search_string: the regex match that you expect has one or more instances of a basic land types :param text: the text to search from :return: the associated colors :rtype: set """ match = re.search(search_string, text, re.I | re.DOTALL) if not match: return set() return estimate_colors_from_lands( cls.find_all(cls.all_land_names, match.group()) )