Example #1
0
    def get_heuristic_info(card):
        """
        hueristic category label (fetch-land, removal, creature)
        """
        heuristic_types = []
        heuristic_subtypes = []
        if ut.is_subset(['Basic', 'Land'], card.types):
            heuristic_types += ['basic']

        RuleHeuristics = mtgrules.RuleHeuristics

        for block in RuleHeuristics._iter_blocks(card):
            if RuleHeuristics.is_tapland(block, card):
                heuristic_types += ['tap']

            if RuleHeuristics.is_tangoland(block, card):
                heuristic_types += ['tango']

            if RuleHeuristics.is_triland(block, card):
                heuristic_types += ['tri']

            if RuleHeuristics.is_painland(block, card):
                heuristic_types += ['pain']

            if mtgrules.is_fetchland(block, card):
                heuristic_types += ['fetch']

        return heuristic_types, heuristic_subtypes
Example #2
0
    def mana_potential2(card, deck=None, recurse=True):
        r"""Returns a list of mana sets or mana producers

        CommandLine:
            python -m mtgmonte.mtgobjs --exec-mana_potential2:1

        Example:
            >>> # ENABLE_DOCTEST
            >>> from mtgmonte.mtgobjs import *  # NOQA
            >>> from mtgmonte import mtgobjs
            >>> deck = mtgobjs.Deck(mtgobjs.load_cards(['Tropical Island', 'Sunken Hollow', 'Island']))
            >>> cards = mtgobjs.load_cards(['Tundra', 'Ancient Tomb', 'Black Lotus'])
            >>> card = cards[-1]
            >>> result = ut.repr2([card.mana_potential2(deck) for card in cards])
            >>> print(str(result))

        Example:
            >>> # ENABLE_DOCTEST
            >>> from mtgmonte.mtgobjs import *  # NOQA
            >>> from mtgmonte import mtgobjs
            >>> deck = mtgobjs.Deck(mtgobjs.load_cards(['Tropical Island', 'Sunken Hollow', 'Island']))
            >>> cards = mtgobjs.load_cards(['Flooded Strand', 'Tundra', 'Island', 'Shivan Reef', 'Ancient Tomb'])
            >>> card = cards[-1]
            >>> result = ut.repr2([card.mana_potential2(deck, recurse=True)
            >>>                    for card in cards], nl=1, strvals=1, nobr=1)
            >>> print(result)
            [{G}, {U}, {B}],
            [{W}, {U}],
            [{U}],
            [{C}, {U}, {R}],
            [{CC}],

        Example:
            >>> # ENABLE_DOCTEST
            >>> from mtgmonte.mtgobjs import *  # NOQA
            >>> from mtgmonte import mtgobjs
            >>> deck = mtgobjs.Deck(mtgobjs.load_cards(['Tropical Island', 'Sunken Hollow', 'Island']))
            >>> cards = mtgobjs.load_cards(['Flooded Strand', 'Tundra', 'Island', 'Shivan Reef', 'Ancient Tomb'])
            >>> card = cards[-1]
            >>> result = ut.repr2([card.mana_potential2(deck, recurse=False)
            >>>                    for card in cards], nl=1, strvals=True, nobr=1)
            >>> print(result)
            [Tropical Island, Sunken Hollow, Island],
            [{W}, {U}],
            [{U}],
            [{C}, {U}, {R}],
            [{CC}],
        """
        from mtgmonte import mtgrules
        potential = ManaOption()
        #ManaOption()
        for block in card.ability_blocks:
            mana_generated = mtgrules.mana_generated(block, card)
            if mana_generated is not None:
                potential.extend(mana_generated)
            else:
                if mtgrules.is_fetchland(block, card):
                    fetch_targets = mtgrules.get_fetch_search_targets(block, card, deck)
                    if recurse:
                        mana_generated = [t.mana_potential2(deck) for t in fetch_targets]
                        mana_generated = ut.flatten(mana_generated)
                        mana_generated = ut.unique_ordered(mana_generated)
                        potential.extend(ManaOption(mana_generated))
                    else:
                        potential.extend(fetch_targets)
        return potential