Esempio n. 1
0
File: basic.py Progetto: 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)
Esempio n. 2
0
File: basic.py Progetto: 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)
Esempio 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, [])
Esempio 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']])
Esempio 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, [])
Esempio 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']])