Example #1
0
 def test_empty_locked(self):
     """Available cards found when no cards locked
     """
     self.locked_cards = []
     self.expected.update({'b': 2, 'd': 1})
     available = util.available_card_groups(self.cards, self.locked_cards)
     self.assertEqual(available, self.expected)
Example #2
0
 def test_empty_locked(self):
     """Available cards found when no cards locked
     """
     self.locked_cards = []
     self.expected.update({'b': 2, 'd': 1})
     available = util.available_card_groups(self.cards, self.locked_cards)
     self.assertEqual(available, self.expected)
Example #3
0
File: basic.py Project: roblacy/pit
 def make_offers(self):
     """Makes open offers.
     """
     groups = util.available_card_groups(self.cards, self.locked_cards)
     for count in [4,3,2,1]:
         if count in groups.values():
             self.notify(gameengine.Message.OFFER, count=count)
Example #4
0
File: basic.py Project: roblacy/pit
 def make_offers(self):
     """Makes open offers.
     """
     groups = util.available_card_groups(self.cards, self.locked_cards)
     for count in [4, 3, 2, 1]:
         if count in groups.values():
             self.notify(gameengine.Message.OFFER, count=count)
Example #5
0
File: basic.py Project: roblacy/pit
 def attempt_response(self, offer):
     """If cards are available, issues a binding offer to match the offer.
     """
     # because I haven't syncronized access to self.cards and self.locked_cards
     # this will sometimes get a KeyError accessing data that has been deleted
     # by the other thread - ok to just ignore & move on
     try:
         groups = util.available_card_groups(self.cards, self.locked_cards)
         cards = self.get_match(groups, offer.count)
     except KeyError:
         return None
     if cards:
         self.notify(gameengine.Message.BINDING_OFFER, cards=cards, target_uid=offer.uid)
         self.locked_cards.extend(cards)
         self.outgoing_offers.append((time.time(), cards, offer.uid))
         return True
Example #6
0
File: basic.py Project: roblacy/pit
 def attempt_response(self, offer):
     """If cards are available, issues a binding offer to match the offer.
     """
     # because I haven't syncronized access to self.cards and self.locked_cards
     # this will sometimes get a KeyError accessing data that has been deleted
     # by the other thread - ok to just ignore & move on
     try:
         groups = util.available_card_groups(self.cards, self.locked_cards)
         cards = self.get_match(groups, offer.count)
     except KeyError:
         return None
     if cards:
         self.notify(gameengine.Message.BINDING_OFFER,
                     cards=cards,
                     target_uid=offer.uid)
         self.locked_cards.extend(cards)
         self.outgoing_offers.append((time.time(), cards, offer.uid))
         return True
Example #7
0
 def test_mixed_locked(self):
     """Available cards found when not locked in complete sets"""
     self.locked_cards.append('a')
     self.expected.update({'a': 2})
     available = util.available_card_groups(self.cards, self.locked_cards)
     self.assertEqual(available, self.expected)
Example #8
0
 def test_available(self):
     """Available cards are found & counted correctly
     """
     available = util.available_card_groups(self.cards, self.locked_cards)
     self.assertEqual(available, self.expected)
Example #9
0
 def test_mixed_locked(self):
     """Available cards found when not locked in complete sets"""
     self.locked_cards.append('a')
     self.expected.update({'a': 2})
     available = util.available_card_groups(self.cards, self.locked_cards)
     self.assertEqual(available, self.expected)
Example #10
0
 def test_available(self):
     """Available cards are found & counted correctly
     """
     available = util.available_card_groups(self.cards, self.locked_cards)
     self.assertEqual(available, self.expected)