示例#1
0
文件: basic.py 项目: 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)
示例#2
0
文件: basic.py 项目: 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)
示例#3
0
 def test_no_match_found(self):
     """Matching groups are not found"""
     matches = util.matching_groups(self.card_groups, 4)
     self.assertEqual(matches, [])
示例#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']])
示例#5
0
文件: test_util.py 项目: roblacy/pit
 def test_no_match_found(self):
     """Matching groups are not found"""
     matches = util.matching_groups(self.card_groups, 4)
     self.assertEqual(matches, [])
示例#6
0
文件: test_util.py 项目: roblacy/pit
 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']])