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
""" 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)
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