def test_creation_from_db(self): db = Database('sqlite:///:memory:') db.create_table('cards', OrderedDict( id = integer(primary_key=True), name = string(), atk = integer(), def_ = integer() )) Card = Item.from_table('Card', db.cards, exclude=['id']) self.assertEqual(Card.ATTRIBUTES, ('atk', 'def', 'name'))
def test_creation_from_db(): db = Database() db.create_table( 'cards', { 'id': integer(primary_key=True), 'name': text(), 'atk': integer(), 'def': integer()}) Card = Item.from_table('Card', db.cards, exclude=['id']) assert all(hasattr(Card, attr) for attr in ('atk', 'def', 'name'))
def test_creation_from_db(): db = Database() db.create_table( 'cards', { 'id': integer(primary_key=True), 'name': text(), 'atk': integer(), 'def': integer() }) Card = Item.from_table('Card', db.cards, exclude=['id']) assert all(hasattr(Card, attr) for attr in ('atk', 'def', 'name'))
def card(request): card = Item.new('Card', ('name', 'types'))() card.name = 'SomeCard' card.types = ('Land', ) return card
""" WTactics Plugin Prototype This module is an example of how to write a rules plugin for ViCE. Currently, it is contained within a single file. However, as plugins are really just python files, the different bits could be extracted into separate modules (actions, containers, items, etc) and packaged as a single python package. """ from vice.plugins import Item, Container, Action from vice.database import Database # opens a local db file db = Database('sqlite:///wtactics.db') # Items Item.from_table( 'Card', db.cards, exclude=('border_color', 'footer')) Item.new( # target is which card it is placed on 'Token', attributes=('owner', 'type_', 'target')) # Containers Zone = Container.new( 'Zone', lambda cls, item: [ item.NAME == 'Card']) for zone in 'Questing', 'Offensive', 'Defensive': Zone.new( '{0}Zone'.format(zone), lambda cls, item: Zone.constraints(cls, item) + [ zone.lower() in item.types])
def test_creation_from_new(): item = Item.new('Dice', ('sides', )) assert item.__name__ in Item.plugins()
""" WTactics Plugin Prototype This module is an example of how to write a rules plugin for ViCE. Currently, it is contained within a single file. However, as plugins are really just python files, the different bits could be extracted into separate modules (actions, containers, items, etc) and packaged as a single python package. """ from vice.plugins import Item, Container, Action from vice.database import Database # opens a local db file db = Database('sqlite:///wtactics.db') # Items Item.from_table('Card', db.cards, exclude=('border_color', 'footer')) Item.new( # target is which card it is placed on 'Token', attributes=('owner', 'type_', 'target')) # Containers Zone = Container.new('Zone', lambda cls, item: [item.NAME == 'Card']) for zone in 'Questing', 'Offensive', 'Defensive': Zone.new( '{0}Zone'.format(zone), lambda cls, item: Zone.constraints(cls, item) + [zone.lower() in item.types]) HeroZone = Zone.new(
def test_creation_from_new(self): item = Item.new('Dice', ('sides',)) self.assertEqual(item.__name__, 'Dice') self.assertEqual(item.NAME, 'Dice') self.assertTrue('Dice' in Item.plugins())