Exemplo n.º 1
0
Arquivo: basic.py Projeto: 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)
Exemplo n.º 2
0
Arquivo: basic.py Projeto: 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)
Exemplo 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, [])
Exemplo 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']])
Exemplo 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, [])
Exemplo 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']])