def end_hand(self): if len(self.cards) == 0: return self.hand_hidden = False message = "" #case for player bust: if Rulebook.check_bust( Rulebook.check_hand_value(self.player.get_cards())): message = "Player busts! Dealer wins." #case for dealer bust: elif Rulebook.check_bust(Rulebook.check_hand_value(self.cards)): message = "Dealer busts! Player wins." #case for player beating dealer: elif Rulebook.check_player_win( Rulebook.check_hand_value(self.cards), Rulebook.check_hand_value(self.player.get_cards())): message = "Player wins!" #case for dealer beating player: elif Rulebook.check_dealer_win( Rulebook.check_hand_value(self.cards), Rulebook.check_hand_value(self.player.get_cards())): message = "Dealer wins!" #case for tie else: message = "Tie!" self.update_view(message) #Reset cards self.cards = [] self.player.collect_cards()
def test_cpw_player_win_ace(self): self.assertTrue(Rulebook.check_player_win("20", "11 or 21"))
def test_cpw_player_not_win(self): #can be tie or loss. self.assertFalse(Rulebook.check_player_win("21", "10"))
def test_cpw_player_tie(self): self.assertFalse(Rulebook.check_player_win("21", "21"))
def test_cpw_player_win(self): self.assertTrue(Rulebook.check_player_win("5", "21"))