Example #1
0
def test_cardCounts():
	"""
	Check correct card counts when creating a shoe
	"""
	
	# Up to eight decks
	for x in range(1,9):
		s = Shoe(x)
		assert len(s.getCards()) == 52*x
Example #2
0
def test_printShoe():
	"""
	Just testing that printShoe doesn't error out. Not sure how to test UI output.
	"""
	
	s = Shoe(6)
	s.shuffle()
	# Implicitly asserting that there is no exception
	s.printShoe()
Example #3
0
def test_cardDeal():
	"""
	Testing that our number of cards goes down by one when dealing a card
	"""
	
	s = Shoe(6)
	numCards = len(s.getCards())
	s.dealCard()
	numCardsAfter = len(s.getCards())
	assert numCardsAfter == numCards - 1
Example #4
0
def test_dealSpecificCardException():
	"""
	Ensure that we're raising an exception when we can't deal a specific card.
	"""
	
	s = Shoe(6)
	s.shuffle()
	
	for x in range(0,6):
		s.dealSpecificCard("9","Spade")
	
	# This should be an exception
	with pytest.raises(Exception):
		s.dealSpecificCard("9","Spade")
Example #5
0
def test_cardDistribution():
	"""
	Ensure we're getting the right number of card types (4 of each card) per deck
	"""
	
	# Up to eight decks
	for numDecks in range(1,9):
		# For each card name
		for name in Card.enumName.keys():
			# For each card suit
			for suit in Card.enumSuit:
				# Create the shoe
				s = Shoe(numDecks)
				s.shuffle()
				# count the number of times this specific card is found in the shoe
				c = len([myCard for myCard in s.getCards() if myCard.getName() == name and myCard.getSuit() == suit])
				# it should be equal to the number of decks in the shoe because there is only one of each card per deck
				assert c == numDecks
Example #6
0
def test_dealSpecificCard():
	"""
	Testing that dealing a specific card really only deals that specific card
	"""
	
	# Up to eight decks
	for numDecks in range(1,9):
		# For each card name
		for name in Card.enumName.keys():
			# For each card suit
			for suit in Card.enumSuit:
				# Create the shoe
				s = Shoe(numDecks)
				s.shuffle()
				# Remove this card from the shoe
				s.dealSpecificCard(name,suit)
				# count the number of times this specific card is found in the shoe
				c = len([myCard for myCard in s.getCards() if myCard.getName() == name and myCard.getSuit() == suit])
				# it should be equal to the number of decks in the shoe minus the one we just dealt
				assert c == numDecks - 1
Example #7
0
    def __init__(self, houseRules, ui, dealCardDelay=1):
        """
		Input:
			houseRules = object of rules as returned by "selectHouseRules"
			UI = Active UI instantiation
			(optional) dealCardDelay = number of seconds to sleep between dealer dealing a card
		"""

        self.numDecksPerShoe = int(houseRules["number_of_decks"], 10)

        self.hitSoft17 = asciiToBool(houseRules["hit_soft_17"])

        self.doubleAfterSplit = asciiToBool(houseRules["double_after_split"])

        # TODO: Not sure how to deal with this one. Probably need an enum.
        self.doubleOn = houseRules["double_on"]

        self.totalHandsAllowed = int(houseRules["total_hands"], 10)

        self.resplitAces = asciiToBool(houseRules["resplit_ace"])

        self.blackJackPays = self.blackJackPaysToInt(
            houseRules["blackjack_pays"])

        self.penetration = float(houseRules["penetration"])

        # Init a new Shoe while we're at it
        self.shoe = Shoe(self.numDecksPerShoe)
        self.shoe.shuffle()

        # Give ourself a hands list
        self.hands = []

        # Have we played our hand yet?
        self.dealerTurn = False

        # Set the UI
        self.ui = ui

        # Set our between card sleep timer
        self.dealCardDelay = dealCardDelay