示例#1
0
 def test_parse_with_gaps(self):
     md = VugraphMD.parse('3SQH269D347QKC34QK,S68KAH37QD2JAC27A,S2357H8JAD568C69J,')
     self.assertEqual(md.dealer, 3)
     self.assertEqual(len(md.hands), 4)
     self.assertEqual(md.hands[0], Hand.parse('SQH269D347QKC34QK'))
     self.assertEqual(md.hands[1], Hand.parse('S68KAH37QD2JAC27A'))
     self.assertEqual(md.hands[2], Hand.parse('S2357H8JAD568C69J'))
     self.assertEqual(md.hands[3], Hand.parse('s49tjh45tkd9tc58t'))
示例#2
0
 def test_parse_none_missing(self):
     md = VugraphMD.parse('3SQJHQT9632D82CK98,S8743HK854DK76CQ2,SAT2HAJ7DAJ543CJ5,SK965HDQT9CAT7643')
     self.assertEqual(md.dealer, 3)
     self.assertEqual(len(md.hands), 4)
     self.assertEqual(md.hands[0], Hand.parse('SQJHQT9632D82CK98'))
     self.assertEqual(md.hands[1], Hand.parse('S8743HK854DK76CQ2'))
     self.assertEqual(md.hands[2], Hand.parse('SAT2HAJ7DAJ543CJ5'))
     self.assertEqual(md.hands[3], Hand.parse('SK965HDQT9CAT7643'))
示例#3
0
 def test_init(self):
     hands = [
         Hand.parse('SQJHQT9632D82CK98'),
         Hand.parse('S8743HK854DK76CQ2'),
         Hand.parse('SAT2HAJ7DAJ543CJ5'),
         Hand.parse('SK965HDQT9CAT7643')
     ]
     md = VugraphMD(3, hands)
     self.assertEqual(md.dealer, 3)
     self.assertEqual(md.hands, hands)
示例#4
0
 def test_parse_valid(self):
     self.assertEqual(str(Hand.parse('sakqjt98765432')), 's23456789tjqka')
     self.assertEqual(str(Hand.parse('s23456789tjqka')), 's23456789tjqka')
     self.assertEqual(str(Hand.parse('sqh269d347qkc34qk')),
                      'c34qkd347qkh269sq')
     self.assertEqual(str(Hand.parse('SAKQJT98765432')), 's23456789tjqka')
     self.assertEqual(str(Hand.parse('SQH269D347QKC34QK')),
                      'c34qkd347qkh269sq')
     self.assertEqual(str(Hand.parse('saskhqhjdtd9d8c7c6c5s4s3h2')),
                      'c567d89th2jqs34ka')
示例#5
0
 def parse(md):
     dealer = int(md[0:1])
     if dealer < 1 or dealer > 4:
         raise Exception('Unexpected dealer: ' + md)
     hands = []
     remaining_cards = Deck.cards()
     for hand_str in md[1:].split(','):
         if '' == hand_str:
             hands.append(Hand(remaining_cards))
         else:
             hand = Hand.parse(hand_str)
             hands.append(hand)
             for card in hand.cards:
                 remaining_cards.remove(card)
     if len(hands) != 4:
         raise Exception('Unexpected number of hands: ' + md)
     return VugraphMD(dealer, hands)