def test_placeAndClearBets(monkeypatch): """ Testing placing and clearing bets """ table = Table() player = Player(money=100,name="Steve") player2 = Player(money=100,name="Bob") table.addPlayer(player) table.addPlayer(player2) # Need to monkeypatch input #global count = 0 def placeBet(): global count if count == 0: count += 1 self.placeBet(10) else: self.placeBet(20) # Since we're basically changing the call variables # we need to copy the original method and call it separately player.placeBetOriginal = player.placeBet player2.placeBetOriginal = player2.placeBet monkeypatch.setattr(player,"placeBet",lambda : player.placeBetOriginal(10)) monkeypatch.setattr(player2,"placeBet",lambda : player2.placeBetOriginal(20)) # Place the bets table.placeBets() # Test that it worked assert len(player.getBets()) == 1 assert player.getBets()[0] == 10 assert len(player2.getBets()) == 1 assert player2.getBets()[0] == 20 # Now clear them table.clearBets() assert len(player.getBets()) == 0 assert len(player2.getBets()) == 0
# 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: print("Dealer Has BlackJack") table.getDealer().payoutTable(table) table.getDealer().dealerTurn = True
# 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: print("Dealer Has BlackJack") table.getDealer().payoutTable(table) table.getDealer().dealerTurn = True