Example #1
0
	def test_flush(self):
		print "test_flush"
		openCards = []
		openCards.append(self.deck.getSpecificCard(3,3))
		openCards.append(self.deck.getSpecificCard(7,3))
		openCards.append(self.deck.getSpecificCard(10,2)) 
		openCards.append(self.deck.getSpecificCard(8,3)) 
		openCards.append(self.deck.getSpecificCard(13,3))
		self.hand.append(self.deck.getSpecificCard(4,2))
		self.hand.append(self.deck.getSpecificCard(10,3))
		self.opponentsHand.append(self.deck.getSpecificCard(3,2))
		self.opponentsHand.append(self.deck.getSpecificCard(7,0))
		self.assertEqual(evaluator.determineWinningHand(self.hand,self.opponentsHand,openCards),1)
		self.assertTrue(evaluator.isFlush(openCards+self.hand))
Example #2
0
	def test_straight(self):
		print "test_straight"
		openCards = []
		openCards.append(self.deck.getSpecificCard(3,1))
		openCards.append(self.deck.getSpecificCard(4,1))
		openCards.append(self.deck.getSpecificCard(5,2)) 
		openCards.append(self.deck.getSpecificCard(10,0)) 
		openCards.append(self.deck.getSpecificCard(13,3))
		self.hand.append(self.deck.getSpecificCard(6,2))
		self.hand.append(self.deck.getSpecificCard(7,3))
		self.opponentsHand.append(self.deck.getSpecificCard(7,2))
		self.opponentsHand.append(self.deck.getSpecificCard(8,0))
		self.assertEqual(evaluator.determineWinningHand(self.hand,self.opponentsHand,openCards),1)
		self.assertTrue(evaluator.isStraight(openCards+self.hand))
Example #3
0
	def test_fullHouse(self):
		print "test_fullHouse"
		openCards = []
		openCards.append(self.deck.getSpecificCard(9,0))
		openCards.append(self.deck.getSpecificCard(9,1))
		openCards.append(self.deck.getSpecificCard(10,1)) 
		openCards.append(self.deck.getSpecificCard(4,2)) # irrelevant card
		openCards.append(self.deck.getSpecificCard(3,2)) # irrelevant card
		self.hand.append(self.deck.getSpecificCard(9,2))
		self.hand.append(self.deck.getSpecificCard(10,3))
		self.opponentsHand.append(self.deck.getSpecificCard(2,2))
		self.opponentsHand.append(self.deck.getSpecificCard(2,0))
		self.assertEqual(evaluator.determineWinningHand(self.hand,self.opponentsHand,openCards),1)
		self.assertTrue(evaluator.isFullHouse(openCards+self.hand))
Example #4
0
	def test_triple(self):
		print "test_triple"
		openCards = []
		openCards.append(self.deck.getSpecificCard(3,1))
		openCards.append(self.deck.getSpecificCard(4,1))
		openCards.append(self.deck.getSpecificCard(5,2)) 
		openCards.append(self.deck.getSpecificCard(10,0)) 
		openCards.append(self.deck.getSpecificCard(13,3))
		self.hand.append(self.deck.getSpecificCard(3,2))
		self.hand.append(self.deck.getSpecificCard(5,3))
		self.opponentsHand.append(self.deck.getSpecificCard(4,2))
		self.opponentsHand.append(self.deck.getSpecificCard(4,0))
		self.assertEqual(evaluator.determineWinningHand(self.hand,self.opponentsHand,openCards),-1)
		self.assertTrue(evaluator.isTriple(openCards+self.opponentsHand))
Example #5
0
	def endHand(self):
		winningPlayer = self.currentPlayers[0]
		while len(self.currentPlayers) > 1:
			# print self.currentPlayers
			winner = evaluator.determineWinningHand(winningPlayer.hand,self.currentPlayers[1].hand,self.openCards)
			if winner == 1:
				del self.currentPlayers[1] # remove losing player
			else:
				winningPlayer = self.currentPlayers[1]
				del self.currentPlayers[0] # remove losing player
		winningPlayer.stack += self.pot
		self.winningPlayer = winningPlayer.name
		self.winningHand = winningPlayer.hand
		self.actionPosition = 0
		self.dealerPosition = 0
Example #6
0
	def test_straightFlush(self):
		print "test_straightFlush"
		# straight flush vs. straight flush
		openCards = []
		openCards.append(self.deck.getSpecificCard(11,1))
		openCards.append(self.deck.getSpecificCard(12,1))
		openCards.append(self.deck.getSpecificCard(10,1))
		openCards.append(self.deck.getSpecificCard(4,2)) # irrelevant card
		openCards.append(self.deck.getSpecificCard(3,2)) # irrelevant card
		self.hand.append(self.deck.getSpecificCard(14,1))
		self.hand.append(self.deck.getSpecificCard(13,1))
		self.opponentsHand.append(self.deck.getSpecificCard(9,2))
		self.opponentsHand.append(self.deck.getSpecificCard(8,2))
		self.assertTrue(evaluator.isFlush(openCards+self.hand))
		self.assertTrue(evaluator.isStraightFlush(openCards+self.hand))
		self.assertEqual(evaluator.determineWinningHand(self.hand,self.opponentsHand,openCards),1)
Example #7
0
	def test_misc(self):
		print "test_misc"
		openCards = []
		openCards.append(self.deck.getSpecificCard(8,1))
		openCards.append(self.deck.getSpecificCard(10,3))
		openCards.append(self.deck.getSpecificCard(9,2)) 
		openCards.append(self.deck.getSpecificCard(9,3)) 
		openCards.append(self.deck.getSpecificCard(3,3))
		self.hand.append(self.deck.getSpecificCard(14,2))
		self.hand.append(self.deck.getSpecificCard(11,3))
		self.opponentsHand.append(self.deck.getSpecificCard(6,3))
		self.opponentsHand.append(self.deck.getSpecificCard(6,2))
		# print self.hand
		# print self.opponentsHand
		# print openCards
		self.assertEqual(evaluator.determineWinningHand(self.hand,self.opponentsHand,openCards),-1)