Ejemplo n.º 1
0
 def test_match_with_bull_and_bear(self):
     """Match found with bull and bear included"""
     self.card_groups['bull'] = 1
     matches = util.matching_groups_with(['bull', 'bear'], self.card_groups,
                                         3)
     self.assertEqual(matches,
                      [['a', 'bull', 'bear'], ['c', 'bull', 'bear']])
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
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.º 4
0
 def test_match_with_nothing(self):
     """Match found with nothing included"""
     matches = util.matching_groups_with([], self.card_groups, 3)
     self.assertEqual(matches, [['d', 'd', 'd']])
Ejemplo n.º 5
0
 def test_match_too_many_cards(self):
     """Match found when more cards requested than quantity"""
     self.card_groups['bull'] = 1
     matches = util.matching_groups_with(['bull', 'bear'], self.card_groups,
                                         1)
     self.assertEqual(matches, [['bull']])
Ejemplo n.º 6
0
 def test_match_with_bear(self):
     """Match found with bear included"""
     matches = util.matching_groups_with(['bear'], self.card_groups, 2)
     self.assertEqual(matches, [['a', 'bear'], ['c', 'bear']])
Ejemplo n.º 7
0
 def test_match_with_nothing(self):
     """Match found with nothing included"""
     matches = util.matching_groups_with([], self.card_groups, 3)
     self.assertEqual(matches, [['d', 'd', 'd']])
Ejemplo n.º 8
0
 def test_match_too_many_cards(self):
     """Match found when more cards requested than quantity"""
     self.card_groups['bull'] = 1
     matches = util.matching_groups_with(['bull', 'bear'], self.card_groups, 1)
     self.assertEqual(matches, [['bull']])
Ejemplo n.º 9
0
 def test_match_only_bull_and_bear(self):
     """Match found with only bull and bear included"""
     self.card_groups['bull'] = 1
     matches = util.matching_groups_with(['bull', 'bear'], self.card_groups, 2)
     self.assertEqual(matches, [['bull', 'bear']])
Ejemplo n.º 10
0
 def test_match_with_bear(self):
     """Match found with bear included"""
     matches = util.matching_groups_with(['bear'], self.card_groups, 2)
     self.assertEqual(matches, [['a', 'bear'], ['c', 'bear']])