def test_playActiveHands(monkeypatch): """ Testing playing active hands """ # 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 players player = Player(money=100,name="Ted") player2 = Player(money=100,name="James") # Add to table table.addPlayer(player) table.addPlayer(player2) table.setDealer(dealer) # Add hands hand = Hand(Card("5","Club"),Card("5","Spade")) hand2 = Hand(Card("6","Club"),Card("7","Diamond")) player.addHand(hand) player.addHand(hand2) hand3 = Hand(Card("A","Spade"),Card("7","Club")) player2.addHand(hand3) hand4 = Hand(Card("5","Diamond"),Card("7","Spade")) dealer.addHand(hand4) # Interaction here can get ugly. We're only going to test # How many times we get our hands run def countHands(x,y): global count count += 1 global count count = 0 # Add the monkeypatch monkeypatch.setattr(dealer,"facilitatePlayerHand",countHands) monkeypatch.setattr(dealer,"playDealersHand",lambda _: None) # Try it out table.playActiveHands() # Make sure we did all hands assert count == 3
# 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: print("Dealer Has BlackJack") table.getDealer().payoutTable(table) table.getDealer().dealerTurn = True ui.drawTable() continue #validActions = dealer.allowedHandActions(player.getHand(),player) #player.selectHandAction(0,validActions) table.playActiveHands() ui.drawTable() table.getDealer().payoutTable(table)
# 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: print("Dealer Has BlackJack") table.getDealer().payoutTable(table) table.getDealer().dealerTurn = True ui.drawTable() continue #validActions = dealer.allowedHandActions(player.getHand(),player) #player.selectHandAction(0,validActions) table.playActiveHands() ui.drawTable() table.getDealer().payoutTable(table)