コード例 #1
0
def db(request):
    db = Database('wtactics.db')

    def fin():
        os.remove(db.location)

    request.addfinalizer(fin)

    return db
コード例 #2
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'))
コード例 #3
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(