Example #1
0
 def emptyFilter(self):
     """ Test that if the filter returns no cards, the condition returns false """
     event = CardsEvent([], None, BuildPlayerContext())
     result = HasCards(EVENT, filter=DummyFilter()).evaluate(event.context)
     self.assertFalse(
         result,
         "The Condition should be false, if the filter returns no cards")
Example #2
0
 def __init__(self, zoneType, thenEffects, number=None):
     """ Initialize the Effect with the zone to look at """
     self.zoneType = zoneType
     if number is None:
         number = 1
     self.number = number
     ConditionalEffect.__init__(self, HasCards(self.zoneType), thenEffects)
Example #3
0
 def noCards(self):
     """ Test that if the source has no cards, the condition returns false """
     event = CardsEvent([], None, BuildPlayerContext())
     result = HasCards(EVENT).evaluate(event.context)
     self.assertFalse(
         result,
         "The Condition should be false, if the source has no cards")
Example #4
0
    def __init__(self,
                 zoneTypes,
                 numberOfCards,
                 toDescription,
                 thenEffects,
                 criteria=None,
                 leftoverCardEffects=[]):
        """ Initialize the options """
        self.zoneTypes = zoneTypes
        self.numberOfCards = numberOfCards
        self.toDescription = toDescription
        self.leftoverCardEffects = leftoverCardEffects

        self.filters = None
        if criteria is not None:
            self.filters = []
            for zoneType in zoneTypes:
                self.filters.append(
                    IntersectionFilter(
                        [ComparisonFilter(zoneType, c) for c in criteria]))

        conditions = []
        for zoneType in zoneTypes:
            filter = None
            if self.filters is not None:
                filter = self.filters[zoneTypes.index(zoneType)]
            conditions.append(HasCards(zoneType, filter=filter))
        condition = OrCondition(conditions)

        ConditionalEffect.__init__(self, condition, thenEffects)
Example #5
0
 def filterHasCards(self):
     """ Test that if the filter returns cards, the condition returns true """
     event = CardsEvent([1, 2, 3], None, BuildPlayerContext())
     result = HasCards(EVENT,
                       filter=DummyFilter(results=[1, 2, 3])).evaluate(
                           event.context)
     self.assertTrue(
         result,
         "The Condition should be true, if the filter returns cards")
Example #6
0
 def hasCards(self):
     """ Test that if the source has cards, the condition returns true """
     event = CardsEvent([1, 2, 3], None, BuildPlayerContext())
     result = HasCards(EVENT).evaluate(event.context)
     self.assertTrue(
         result, "The Condition should be true, if the source has cards")
Example #7
0
 def __init__(self, game):
     """ Initialize the Game """
     self.game = game
     self.condition = OrCondition(
         [NotCondition(FullLineUp()),
          NotCondition(HasCards(SUPERVILLAIN))])