Ejemplo n.º 1
0
Archivo: basic.py Proyecto: roblacy/pit
 def get_match(self, groups, quantity):
     """Returns cards to trade that match the given quantity"""
     match_with = []
     if config.BEAR in self.cards and config.BEAR not in self.locked_cards:
         match_with.append(config.BEAR)
     if config.BULL in self.cards and config.BULL not in self.locked_cards:
         match_with.append(config.BULL)
     matches = util.matching_groups_with(match_with, groups, quantity)
     vanilla_matches = util.matching_groups(groups, quantity)
     matches.extend(vanilla_matches)
     if matches:
         random.shuffle(matches)
         return matches[0]
     else:
         return self.get_match_with_break(groups, quantity)
Ejemplo n.º 2
0
Archivo: basic.py Proyecto: roblacy/pit
 def get_match(self, groups, quantity):
     """Returns cards to trade that match the given quantity"""
     match_with = []
     if config.BEAR in self.cards and config.BEAR not in self.locked_cards:
         match_with.append(config.BEAR)
     if config.BULL in self.cards and config.BULL not in self.locked_cards:
         match_with.append(config.BULL)
     matches = util.matching_groups_with(match_with, groups, quantity)
     vanilla_matches = util.matching_groups(groups, quantity)
     matches.extend(vanilla_matches)
     if matches:
         random.shuffle(matches)
         return matches[0]
     else:
         return self.get_match_with_break(groups, quantity)
Ejemplo n.º 3
0
 def test_no_match_found(self):
     """Matching groups are not found"""
     matches = util.matching_groups(self.card_groups, 4)
     self.assertEqual(matches, [])
Ejemplo n.º 4
0
 def test_match_found(self):
     """Matching groups are found"""
     matches = util.matching_groups(self.card_groups, 2)
     self.assertEqual(matches, [['b', 'b'], ['e', 'e'], ['f', 'f']])
Ejemplo n.º 5
0
 def test_no_match_found(self):
     """Matching groups are not found"""
     matches = util.matching_groups(self.card_groups, 4)
     self.assertEqual(matches, [])
Ejemplo n.º 6
0
 def test_match_found(self):
     """Matching groups are found"""
     matches = util.matching_groups(self.card_groups, 2)
     self.assertEqual(matches, [['b', 'b'], ['e', 'e'], ['f', 'f']])