def test_bet_approved(self): player = Player() view = View() player.create_bank(2500) bet = player.bet(100) self.assertEqual(bet,100) del player
def test_has_ace(self): player = Player() player.bank.amount = 2500 hand = Hand() card = Card(suit='Clubs', value=(1, 11), face='Ace') hand.cards.append(card) self.assertEqual(hand.has_ace(), True) del hand del card
def test_hand_black_jack(self): game = Game() game.turn = 'Player' player = Player() dealer = Dealer() view = View() card1 = Card(suit='Clubs', value=(1, 11), face='Ace') card2 = Card(suit='Clubs', value=(10), face='10') card3 = Card(suit='Clubs', value=(5), face='5') player.hand.cards.append(card1) player.hand.cards.append(card2) dealer.hand.cards.append(card1) dealer.hand.cards.append(card3) self.assertEqual(game.game_over(view, player, dealer), True)
def test_hand_busted(self): game = Game() game.turn = 'Player' player = Player() dealer = Dealer() view = View() card1 = Card(suit='Clubs', value=(10), face='10') card2 = Card(suit='Clubs', value=(8), face='8') card3 = Card(suit='Clubs', value=(2), face='2') player.hand.cards.append(card1) player.hand.cards.append(card2) player.hand.cards.append(card3) # dealer.hand.cards.append(card1) # dealer.hand.cards.append(card3) self.assertEqual(player.hand.busted(), False)
# Logic: # 0. Player places bets # 1. Dealer deals # 2. Player hits or stays (while loop) # - Check for blackjack or bust # 3. Once Player stays, it's the Dealer's turn # 4. Dealer hits until they beat the Player or the Dealer busts (while loop) # - Check conditions for game end in every round (over Players sum, blackjack or bust) # 5. Players credit modified based on bet # 6. Replay? from black_jack import Card, Player, deal, Deck, show_cards, place_bet, check_game_end import time deck = Deck() player = Player('Player', 100) dealer = Player('Dealer', 300) players = [dealer, player] game_on = True while (game_on == True): deck.full_new() deck.shuffle() bet = place_bet(player) deal(players, deck) players_turn = True player_busted = False while players_turn: choice = input('Hit or Stay? Press H or S and then Enter.\n') if choice.lower() == 'h': player.hit(deck)
def test_bet_refused(self): player = Player() view = View() player.create_bank(50) self.assertEqual(player.bet(1000),False) del player
def test_create_player(self): player = Player() player_test = black_jack.Player() self.assertEqual(type(player_test),type(player)) del player, player_test