def test_addMoney(): """ Testing adding and removing money """ p = Player(money=100) p.addMoney(5) assert p.getMoney() == 105 p.addMoney(-6) assert p.getMoney() == 99
def test_getMoney(): """ Testing the getMoney call """ p = Player(money=167) assert p.getMoney() == 167
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
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