def test_creation_from_new(self):
        action = Action.new('shuffle', lambda cls, item:
            random.shuffle(item)
        )

        self.assertEqual(action.__name__, 'Shuffle')
        self.assertEqual(action.NAME, 'shuffle')
        self.assertIn('shuffle', Action.plugins())
    def test_plugins(self):
        actions = Action.plugins()

        self.assertIsInstance(actions.move, self.Move)

        actions.move(1, self.source, self.destination)
        self.assertSequenceEqual(self.source, [1, 3])
        self.assertSequenceEqual(self.destination, [7, 8, 9, 2])
Exemple #3
0
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(
    'HeroZone', lambda cls, item:
        Zone.constraints(cls, item) + [
            len(cls) == 1])

# register the plugins
actions = Action.plugins()
containers = Container.plugins()
items = Item.plugins()
Exemple #4
0
def actions():
    Echo = Action.new('Echo', lambda x: x)

    assert Echo.NAME == 'echo'
    return Action.plugins()
Exemple #5
0
def actions():
    Echo = Action.new('Echo', lambda x: x)

    assert Echo.NAME == 'echo'
    return Action.plugins()
Exemple #6
0
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(
    'HeroZone',
    lambda cls, item: Zone.constraints(cls, item) + [len(cls) == 1])

# register the plugins
actions = Action.plugins()
containers = Container.plugins()
items = Item.plugins()