コード例 #1
0
ファイル: test_plugins_packge.py プロジェクト: Gallaecio/ViCE
    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'))
コード例 #2
0
ファイル: test_item.py プロジェクト: aspidites/ViCE
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'))
コード例 #3
0
ファイル: test_item.py プロジェクト: kleopatra999/ViCE
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'))
コード例 #4
0
def card(request):
    card = Item.new('Card', ('name', 'types'))()
    card.name = 'SomeCard'
    card.types = ('Land', )

    return card
コード例 #5
0
ファイル: test_container.py プロジェクト: aspidites/ViCE
def card(request):
    card = Item.new('Card', ('name', 'types'))()
    card.name = 'SomeCard'
    card.types = ('Land', )

    return card
コード例 #6
0
ファイル: __init__.py プロジェクト: aspidites/ViCE
""" 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])
コード例 #7
0
ファイル: test_item.py プロジェクト: aspidites/ViCE
def test_creation_from_new():
    item = Item.new('Dice', ('sides', ))

    assert item.__name__ in Item.plugins()
コード例 #8
0
ファイル: __init__.py プロジェクト: cnelsonsic/ViCE
""" 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(
コード例 #9
0
ファイル: test_item.py プロジェクト: kleopatra999/ViCE
def test_creation_from_new():
    item = Item.new('Dice', ('sides', ))

    assert item.__name__ in Item.plugins()
コード例 #10
0
ファイル: test_plugins_packge.py プロジェクト: Gallaecio/ViCE
    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())