def test_dealStright(self): player = SimpleFelix() cards = self.__createCards(1,13 ,1,21 ,2,6 ,3,21 ,3,13 ,1,22 ,3,3 ,3,9 ,3,6 ,1,12 ,4,8 ,1,10 ,4,11 ) player.deal(cards) #self.logger.debug(player.dumpTestAssert()) #self.logger.debug(player) #self.fiveCardHands: self.assertEquals(len(player.fiveCardHands), 1 ) self.assertTrue(self.__checkCards(player.fiveCardHands[0].cards, self.__createCards(3,9, 1,10, 4,11, 1,12, 1,13))) #self.threeKinds: self.assertEquals(len(player.threeKinds), 0 ) #self.pairs: self.assertEquals(len(player.pairs), 2 ) self.assertTrue(self.__checkCards(player.pairs[0].cards, self.__createCards(2,6, 3,6))) self.assertTrue(self.__checkCards(player.pairs[1].cards, self.__createCards(1,21, 3,21))) #self.highs: self.assertEquals(len(player.highs), 3 ) self.assertTrue(self.__checkCards(player.highs[0].cards, self.__createCards(3,3))) self.assertTrue(self.__checkCards(player.highs[1].cards, self.__createCards(4,8))) self.assertTrue(self.__checkCards(player.highs[2].cards, self.__createCards(3,13))) #self.big2Highs: self.assertEquals(len(player.big2Highs), 1 ) self.assertTrue(self.__checkCards(player.big2Highs[0].cards, self.__createCards(1,22)))
def test_dealFlushSkipForStright(self): player = SimpleFelix() cards = self.__createCards(4,10 ,3,7 ,1,12 ,4,9 ,4,21 ,1,8 ,2,10 ,4,3 ,3,12 ,2,11 ,4,5 ,3,22 ,4,6) player.deal(cards) #self.logger.debug(player.dumpTestAssert()) #self.logger.debug(player) #self.fiveCardHands: self.assertEquals(len(player.fiveCardHands), 2 ) self.assertTrue(self.__checkCards(player.fiveCardHands[0].cards, self.__createCards(1,8, 4,9, 2,10, 2,11, 1,12))) self.assertTrue(self.__checkCards(player.fiveCardHands[1].cards, self.__createCards(4,3, 4,5, 4,6, 4,10, 4,21))) #self.threeKinds: self.assertEquals(len(player.threeKinds), 0 ) #self.pairs: self.assertEquals(len(player.pairs), 0 ) #self.highs: self.assertEquals(len(player.highs), 2 ) self.assertTrue(self.__checkCards(player.highs[0].cards, self.__createCards(3,7))) self.assertTrue(self.__checkCards(player.highs[1].cards, self.__createCards(3,12))) #self.big2Highs: self.assertEquals(len(player.big2Highs), 1 ) self.assertTrue(self.__checkCards(player.big2Highs[0].cards, self.__createCards(3,22)))
def test_dealFullHouse(self): player = SimpleFelix() cards = self.__createCards(3,22, 2,3, 3,3, 1,4, 4,4, 1,7, 3,7, 2,6, 4,6, 4,21, 2,5, 2,21, 1,21) player.deal(cards) #self.logger.debug(player.dumpTestAssert()) #self.logger.debug(player) #self.fiveCardHands: self.assertEquals(len(player.fiveCardHands), 1 ) self.assertTrue(self.__checkCards(player.fiveCardHands[0].cards, self.__createCards(4,21, 2,21, 1,21, 2,3, 3,3))) #self.threeKinds: self.assertEquals(len(player.threeKinds), 0 ) #self.pairs: self.assertEquals(len(player.pairs), 3 ) self.assertTrue(self.__checkCards(player.pairs[0].cards, self.__createCards(1,4, 4,4))) self.assertTrue(self.__checkCards(player.pairs[1].cards, self.__createCards(2,6, 4,6))) self.assertTrue(self.__checkCards(player.pairs[2].cards, self.__createCards(1,7, 3,7))) #self.highs: self.assertEquals(len(player.highs), 1 ) self.assertTrue(self.__checkCards(player.highs[0].cards, self.__createCards(2,5))) #self.big2Highs: self.assertEquals(len(player.big2Highs), 1 ) self.assertTrue(self.__checkCards(player.big2Highs[0].cards, self.__createCards(3,22)))
def test_dealTwoFlushSameSuit(self): player = SimpleFelix() cards = self.__createCards(4,21 ,4,8 ,4,11 ,4,10 ,4,5 ,1,3 ,4,9 ,2,3 ,4,6 ,2,22 ,4,13 ,4,4 ,4,8) player.deal(cards) #self.logger.debug(player.dumpTestAssert()) #self.logger.debug(player) #self.fiveCardHands: self.assertEquals(len(player.fiveCardHands), 2 ) self.assertTrue(self.__checkCards(player.fiveCardHands[0].cards, self.__createCards(4,4, 4,5, 4,6, 4,8, 4,13))) self.assertTrue(self.__checkCards(player.fiveCardHands[1].cards, self.__createCards(4,8, 4,9, 4,10, 4,11, 4,21))) #self.threeKinds: self.assertEquals(len(player.threeKinds), 0 ) #self.pairs: self.assertEquals(len(player.pairs), 1 ) self.assertTrue(self.__checkCards(player.pairs[0].cards, self.__createCards(1,3, 2,3))) #self.highs: self.assertEquals(len(player.highs), 0 ) #self.big2Highs: self.assertEquals(len(player.big2Highs), 1 ) self.assertTrue(self.__checkCards(player.big2Highs[0].cards, self.__createCards(2,22)))
def test_dealFourKind(self): player = SimpleFelix() cards = self.__createCards(3,21, 2,4, 3,4, 1,4, 4,4, 2,6, 3,7, 1,8, 2,9, 3,10, 3,11, 3,12, 3,13) player.deal(cards) #self.logger.debug(player.dumpTestAssert()) #self.logger.debug(player) #self.fiveCardHands: self.assertEquals(len(player.fiveCardHands), 2 ) self.assertTrue(self.__checkCards(player.fiveCardHands[0].cards, self.__createCards(2,4, 3,4, 1,4, 4,4, 2,6))) self.assertTrue(self.__checkCards(player.fiveCardHands[1].cards, self.__createCards(3,10, 3,11, 3,12, 3,13, 3,21))) #self.threeKinds: self.assertEquals(len(player.threeKinds), 0 ) #self.pairs: self.assertEquals(len(player.pairs), 0 ) #self.highs: self.assertEquals(len(player.highs), 3 ) self.assertTrue(self.__checkCards(player.highs[0].cards, self.__createCards(3,7))) self.assertTrue(self.__checkCards(player.highs[1].cards, self.__createCards(1,8))) self.assertTrue(self.__checkCards(player.highs[2].cards, self.__createCards(2,9)))
def test_dealRFlushThirdLargest(self): player = SimpleFelix() cards = self.__createCards(3,21, 4,7, 3,3, 3,4, 3,5, 3,6, 3,7, 3,8, 3,9, 3,10, 3,11, 3,12, 3,13) player.deal(cards) self.assertEqual(len(player.fiveCardHands), 2) self.assertTrue(self.__checkCards(player.fiveCardHands[0].cards, self.__createCards(3,5, 3,6, 3,7, 3,8, 3,9))) self.assertTrue(self.__checkCards(player.fiveCardHands[1].cards, self.__createCards(3,21, 3,10, 3,11, 3,12, 3,13))) self.assertTrue(self.__checkCards(player.highs[0].cards, self.__createCards(3,3))) self.assertTrue(self.__checkCards(player.highs[1].cards, self.__createCards(3,4))) self.assertTrue(self.__checkCards(player.highs[2].cards, self.__createCards(4,7)))
def test_dealRFlushTwoDifferentSuit(self): player = SimpleFelix() cards = self.__createCards(3,21, 4,7, 3,3, 3,4, 2,5, 2,6, 2,7, 2,8, 2,9, 3,10, 3,11, 3,12, 3,13) player.deal(cards) self.assertEqual(len(player.fiveCardHands), 2) self.assertTrue(self.__checkCards(player.fiveCardHands[0].cards, self.__createCards(2,5, 2,6, 2,7, 2,8, 2,9))) self.assertTrue(self.__checkCards(player.fiveCardHands[1].cards, self.__createCards(3,21, 3,10, 3,11, 3,12, 3,13))) self.assertTrue(self.__checkCards(player.highs[0].cards, self.__createCards(3,3))) self.assertTrue(self.__checkCards(player.highs[1].cards, self.__createCards(3,4))) self.assertTrue(self.__checkCards(player.highs[2].cards, self.__createCards(4,7)))
def test_dealRFlushLargest(self): player = SimpleFelix() cards = self.__createCards(2,21, 2,22, 2,3, 2,4, 2,5, 2,6, 2,7, 2,8, 2,9, 2,10, 2,11, 2,12, 2,13) player.deal(cards) self.assertEqual(len(player.fiveCardHands), 2) self.assertTrue(self.__checkCards(player.fiveCardHands[0].cards, self.__createCards(2,9, 2,10, 2,11, 2,12, 2,13))) self.assertTrue(self.__checkCards(player.fiveCardHands[1].cards, self.__createCards(2,21, 2,22, 2,3, 2,4, 2,5))) #self.logger.debug(player) self.assertTrue(self.__checkCards(player.highs[0].cards, self.__createCards(2,6))) self.assertTrue(self.__checkCards(player.highs[1].cards, self.__createCards(2,7))) self.assertTrue(self.__checkCards(player.highs[2].cards, self.__createCards(2,8)))
def test_dealRFlushSingleFlush(self): player = SimpleFelix() cards = self.__createCards(3,21, 4,7, 3,3, 1,4, 4,4, 2,6, 2,7, 2,8, 2,9, 3,10, 3,11, 3,12, 3,13) player.deal(cards) self.assertEqual(len(player.fiveCardHands), 1) self.assertTrue(self.__checkCards(player.fiveCardHands[0].cards, self.__createCards(3,21, 3,10, 3,11, 3,12, 3,13))) self.assertTrue(self.__checkCards(player.highs[0].cards, self.__createCards(3,3))) self.assertTrue(self.__checkCards(player.highs[1].cards, self.__createCards(2,6))) self.assertTrue(self.__checkCards(player.highs[2].cards, self.__createCards(2,8))) self.assertTrue(self.__checkCards(player.highs[3].cards, self.__createCards(2,9))) self.assertTrue(self.__checkCards(player.pairs[0].cards, self.__createCards(1,4, 4,4))) self.assertTrue(self.__checkCards(player.pairs[1].cards, self.__createCards(2,7, 4,7)))
def test_dealThreeKindx3(self): player = SimpleFelix() cards = self.__createCards(1,8, 2,8, 3,8, 1,4, 4,4, 1,7, 3,7, 2,6, 4,6, 4,21, 3,6, 2,21, 1,21) player.deal(cards) #self.logger.debug(player.dumpTestAssert()) #self.logger.debug(player) #self.fiveCardHands: self.assertEquals(len(player.fiveCardHands), 2 ) self.assertTrue(self.__checkCards(player.fiveCardHands[0].cards, self.__createCards(1,8, 2,8, 3,8, 1,7, 3,7))) self.assertTrue(self.__checkCards(player.fiveCardHands[1].cards, self.__createCards(4,21, 2,21, 1,21, 1,4, 4,4))) #self.threeKinds: self.assertEquals(len(player.threeKinds), 1 ) self.assertTrue(self.__checkCards(player.threeKinds[0].cards, self.__createCards(2,6, 4,6, 3,6))) #self.pairs: self.assertEquals(len(player.pairs), 0 ) #self.highs: self.assertEquals(len(player.highs), 0 )
allCards = [] for suit in suits: for num in nums: allCards.append(Card(suit, num)) #printCardStr(cards) i = 0 while 1: i += 1 os.system('clear') print i cards = random.sample(allCards, 13) print cards felix = SimpleFelix() try: felix.deal(cards) print (felix) if i == 999: raise Exception('fucn') except Exception, e: print e print (felix) raw_input('press enter to continue')
cardStr = ','.join(cardStrs) print 'cards = self.__createCards(%s)' % cardStr def dumpCreateCard(i, player): template = ' self.players[%s].deal(self.__createCards(%s))\n' print template % (i, player.createCardDump(player.holdingCards)) nums = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 21, 22] suits = [1, 2, 3, 4] allCards = [] for suit in suits: for num in nums: allCards.append(Card(suit, num)) players = [] for i in range(4): player = SimpleFelix() cards = random.sample(allCards, 13) player.deal(cards) for card in cards: allCards.remove(card) players.append(player) for i in range(4): dumpCreateCard(i, players[i])