def valid(self):
     """ Test that the comparison returns valid """
     criteria = FixedCriteria("name", self.cardName, "==")
     isValid = criteria.compare(self.card, None)
     self.assertTrue(
         isValid,
         "The Comparison should be valid when the field value is set properly"
     )
 def invalid(self):
     """ Test that the comparison returns invalid """
     criteria = FixedCriteria("name", self.cardName + "Gibberish", "==")
     isValid = criteria.compare(self.card, None)
     self.assertFalse(
         isValid,
         "The Comparison should not be valid when the field value is set differently"
     )
Esempio n. 3
0
 def __init__(self, attackCard, context):
     """ Initialize the Request with the attack """
     self.attackCard = attackCard
     self.context = context
     self.defenseFilters = [ComparisonFilter(zoneType, FixedCriteria("defendFrom", zoneType, "==")) for zoneType in self.ZONES]
     self.cardsForZone = {}
     Request.__init__(self, [context.player])
Esempio n. 4
0
 def criteriaUsed(self):
     """ Test that the condition is false, if the criteria limits the matches below the required number """
     name = "Test Name"
     cards = [BuildCard(name=name) for i in range(10)]
     event = CardsEvent(cards, None, BuildPlayerContext())
     result = Matching(EVENT, criteria=FixedCriteria("name", name, "!=")).evaluate(event.context)
     self.assertFalse(result, "The Condition should be false, if the criteria limits the matching cards")
Esempio n. 5
0
 def notMatchingCriteria(self):
     """ Test that the condition is false when the card does not match the criteria """
     result = NthPlayed(1, FixedCriteria("name", self.name,
                                         "!=")).evaluate(self.event.context)
     self.assertFalse(
         result,
         "When the Event card does not match the criteria and is the nth card, the condition should be false"
     )
Esempio n. 6
0
 def notNthPlayed(self):
     """ Test that the condition is false when the card is not the nth one played """
     result = NthPlayed(2, FixedCriteria("name", self.name,
                                         "==")).evaluate(self.event.context)
     self.assertFalse(
         result,
         "When the Event card matches the criteria and is not the nth card, the condition should be false"
     )
Esempio n. 7
0
    def isNthPlayed(self):
        """ Test that the condition is true when the card is the nth one played """
        n = 3
        playedSource = self.event.context.loadSource(PLAYED)
        [playedSource.add(BuildCard(self.name)) for i in range(n - 1)]

        result = NthPlayed(n, FixedCriteria("name", self.name,
                                            "==")).evaluate(self.event.context)
        self.assertTrue(
            result,
            "When the Event card matches the criteria and is the nth card, the condition should be true"
        )
Esempio n. 8
0
 def __init__(self,
              zoneTypes,
              cost,
              toDescription,
              thenEffects,
              leftoverCardEffects=[]):
     """ Initialize the options """
     self.cost = cost
     PickCards.__init__(self,
                        zoneTypes,
                        1,
                        toDescription,
                        thenEffects,
                        criteria=[FixedCriteria("cost", self.cost, "<=")],
                        leftoverCardEffects=[])
Esempio n. 9
0
 def buildOptions(self, context):
     """ Build the Options for the card types """
     options = []
     for cardType in self.findPossibleTypes(context):
         cardFilter = IntersectionFilter([
             self.filter,
             ComparisonFilter(self.zoneType,
                              FixedCriteria("cardType", cardType, "=="))
         ])
         options.append(
             Option(
                 "Pick " + cardType,
                 [PerMatch(self.zoneType, self.effects, filter=cardFilter)
                  ]))
     return options
Esempio n. 10
0
    def notMatchingCriteria(self):
        """ Test that the condition is false when the card is not the nth unique card played """
        n = 3
        type = self.cardType + "Gibberish"
        playedSource = self.event.context.loadSource(PLAYED)
        [
            playedSource.add(BuildCard(self.name + str(i), cardType=type))
            for i in range(n - 1)
        ]

        result = NthUnique(n,
                           [FixedCriteria("cardType", type, "==")]).evaluate(
                               self.event.context)
        self.assertFalse(
            result,
            "When the Event card does not match the criteria and is the nth uniquely named card, the condition should be false"
        )
Esempio n. 11
0
 def invalid(self):
     """ Test that the comparison returns invalid """
     criteria = FixedCriteria("name", self.cardName + "Gibberish", "==")
     isValid = criteria.compare(self.card, None)
     self.assertFalse(isValid, "The Comparison should not be valid when the field value is set differently")
Esempio n. 12
0
 def valid(self):
     """ Test that the comparison returns valid """
     criteria = FixedCriteria("name", self.cardName, "==")
     isValid = criteria.compare(self.card, None)
     self.assertTrue(isValid, "The Comparison should be valid when the field value is set properly")