示例#1
0
    def test_populate(self):
        d = {}
        p = u.populate(d)

        @p("Foo")
        def foo():
            pass

        self.assertIs(d["Foo"], foo)

        p = u.populate(d, allow_overwrite=False)

        with self.assertRaises(ValueError):
            @p("Foo")
            def foo():
                pass
示例#2
0
文件: core.py 项目: Julian/cardboard
"""
Contains functionality to map a card name to functions implementing behavior.

"""

from cardboard.util import populate


__all__ = ["cards", "card"]

cards = {}
card = populate(cards, allow_overwrite=False)
示例#3
0
"""
Contains functionality to map a card name to functions implementing behavior.

"""

from cardboard.util import populate

__all__ = ["cards", "card"]

cards = {}
card = populate(cards, allow_overwrite=False)
示例#4
0
from cardboard.ability import AbilityNotImplemented
from cardboard.util import populate

abilities = {}
ability = populate(abilities)


@ability(name="Deathtouch")
def deathtouch(card):
    return AbilityNotImplemented


@ability(name="Defender")
def defender(card):
    card.can_attack = False


@ability(name="Double Strike")
def double_strike(card):
    return AbilityNotImplemented


@ability(name="Enchant")
def enchant(card):
    return AbilityNotImplemented


@ability(name="Equip")
def equip(card):
    return AbilityNotImplemented