def test_dealCardsToTable(): """ Test dealing of cards to the table """ # Create the player player = Player(money=100, name="John") player2 = Player(money=100, name="Sue") # Create the UI ui = UI() # Get our rule set houseRules = ui.selectHouseRules("Mystic Lake -- Shakopee, MN") # Set up the table table = Table() table.addPlayer(player) table.addPlayer(player2) # We want to hit all these cases cases = { "Insurance": False, "NotInsurance": False, "BlackJack": False, "NotBlackJack": False } # TODO: Maybe change how I check these paths? Technically this could run indefinitely long :-/ while True: # Set up the dealer each time to ensure we don't run out of cards... dealer = Dealer(houseRules=houseRules, ui=ui) table.setDealer(dealer) # Clear the table table.reset() # Do the dealing insurance, blackjack = dealer.dealHandsToTable(table) # Basic sanity checks assert len(player.getHands()) == 1 assert len(player2.getHands()) == 1 assert len(dealer.getHands()) == 1 assert len(player.getHand().getCards()) == 2 assert len(player2.getHand().getCards()) == 2 assert len(dealer.getHand().getCards()) == 2 # Update our cases to track what we've seen cases["Insurance"] |= insurance cases["NotInsurance"] |= not insurance cases["BlackJack"] |= blackjack cases["NotBlackJack"] |= not blackjack # See if we've exercized every case yet if set(cases.values()) == {True}: break
def test_dealCardsToTable(): """ Test dealing of cards to the table """ # Create the player player = Player(money=100,name="John") player2 = Player(money=100,name="Sue") # Create the UI ui = UI() # Get our rule set houseRules = ui.selectHouseRules("Mystic Lake -- Shakopee, MN") # Set up the table table = Table() table.addPlayer(player) table.addPlayer(player2) # We want to hit all these cases cases = {"Insurance":False,"NotInsurance":False,"BlackJack":False,"NotBlackJack":False} # TODO: Maybe change how I check these paths? Technically this could run indefinitely long :-/ while True: # Set up the dealer each time to ensure we don't run out of cards... dealer = Dealer(houseRules=houseRules,ui=ui) table.setDealer(dealer) # Clear the table table.reset() # Do the dealing insurance,blackjack = dealer.dealHandsToTable(table) # Basic sanity checks assert len(player.getHands()) == 1 assert len(player2.getHands()) == 1 assert len(dealer.getHands()) == 1 assert len(player.getHand().getCards()) == 2 assert len(player2.getHand().getCards()) == 2 assert len(dealer.getHand().getCards()) == 2 # Update our cases to track what we've seen cases["Insurance"] |= insurance cases["NotInsurance"] |= not insurance cases["BlackJack"] |= blackjack cases["NotBlackJack"] |= not blackjack # See if we've exercized every case yet if set(cases.values()) == {True}: break
def test_payoutTable(): """ Testing payoutTable method """ # Create the table table = Table() # Create the UI ui = UI(table) # Get our rule set houseRules = ui.selectHouseRules("Mystic Lake -- Shakopee, MN") # Set up the dealer (don't waste time between cards) dealer = Dealer(houseRules=houseRules, ui=ui, dealCardDelay=0) # Set up the player player = Player(money=100, name="Bill") player2 = Player(money=100, name="Dave") table.addPlayer(player) table.addPlayer(player2) table.setDealer(dealer) ######################################### # Dealer is busted / Player 2 is busted # ######################################### # Bet player.placeBet(5) player2.placeBet(10) hand = Hand(Card("K", "Spade"), Card("Q", "Spade")) hand.addCard(Card("5", "Club")) # He busted player2.addHand(hand) # Player 1 hasn't busted hand2 = Hand(Card("J", "Spade"), Card("2", "Club")) player.addHand(hand2) # Dealer has busted hand3 = Hand(Card("5", "Diamond"), Card("7", "Club")) hand3.addCard(Card("10", "Club")) dealer.addHand(hand3) # Play it dealer.payoutTable(table) # Test it assert player.getMoney() == 105 assert player2.getMoney() == 90 ########################################### # Dealer Beats Player 1 / Pushes Player 2 # ########################################### table.reset() # Bet player.placeBet(10) player2.placeBet(20) player.clearHands() hand = Hand(Card("K", "Spade"), Card("5", "Spade")) player.addHand(hand) player2.clearHands() hand2 = Hand(Card("J", "Spade"), Card("8", "Club")) player2.addHand(hand2) # Dealer has 18 dealer.clearHands() hand3 = Hand(Card("8", "Diamond"), Card("J", "Club")) dealer.addHand(hand3) # Play it dealer.payoutTable(table) # Test it assert player.getMoney() == 95 assert player2.getMoney() == 90
money = input("How much money to start with?: ") player = Player(money=money, name=name) # Add the player to the table table.addPlayer(player) # Init our dealer dealer = Dealer(houseRules=houseRules, ui=ui) # Add him to the table table.setDealer(dealer) while True: # Get the table ready table.reset() # Get the wager table.placeBets() # Deal to the table insurance, dealerBlackJack = dealer.dealHandsToTable(table) ui.drawTable() #drawAsciiTable(table,showDealerCard=False) if insurance: print("Insurance?") # If the dealer has blackjack if dealerBlackJack:
def test_payoutTable(): """ Testing payoutTable method """ # Create the table table = Table() # Create the UI ui = UI(table) # Get our rule set houseRules = ui.selectHouseRules("Mystic Lake -- Shakopee, MN") # Set up the dealer (don't waste time between cards) dealer = Dealer(houseRules=houseRules,ui=ui,dealCardDelay=0) # Set up the player player = Player(money=100,name="Bill") player2 = Player(money=100,name="Dave") table.addPlayer(player) table.addPlayer(player2) table.setDealer(dealer) ######################################### # Dealer is busted / Player 2 is busted # ######################################### # Bet player.placeBet(5) player2.placeBet(10) hand = Hand(Card("K","Spade"),Card("Q","Spade")) hand.addCard(Card("5","Club")) # He busted player2.addHand(hand) # Player 1 hasn't busted hand2 = Hand(Card("J","Spade"),Card("2","Club")) player.addHand(hand2) # Dealer has busted hand3 = Hand(Card("5","Diamond"),Card("7","Club")) hand3.addCard(Card("10","Club")) dealer.addHand(hand3) # Play it dealer.payoutTable(table) # Test it assert player.getMoney() == 105 assert player2.getMoney() == 90 ########################################### # Dealer Beats Player 1 / Pushes Player 2 # ########################################### table.reset() # Bet player.placeBet(10) player2.placeBet(20) player.clearHands() hand = Hand(Card("K","Spade"),Card("5","Spade")) player.addHand(hand) player2.clearHands() hand2 = Hand(Card("J","Spade"),Card("8","Club")) player2.addHand(hand2) # Dealer has 18 dealer.clearHands() hand3 = Hand(Card("8","Diamond"),Card("J","Club")) dealer.addHand(hand3) # Play it dealer.payoutTable(table) # Test it assert player.getMoney() == 95 assert player2.getMoney() == 90
money = input("How much money to start with?: ") player = Player(money=money,name=name) # Add the player to the table table.addPlayer(player) # Init our dealer dealer = Dealer(houseRules=houseRules,ui=ui) # Add him to the table table.setDealer(dealer) while True: # Get the table ready table.reset() # Get the wager table.placeBets() # Deal to the table insurance, dealerBlackJack = dealer.dealHandsToTable(table) ui.drawTable() #drawAsciiTable(table,showDealerCard=False) if insurance: print("Insurance?") # If the dealer has blackjack if dealerBlackJack: