def setup_dealer_tie_scenario(self):
        player = Player()
        player.bet = Decimal(1.00)
        player.money = Decimal(1.00)
        
        card1 = Card('Hearts', 'Jack')
        card2 = Card('Hearts', 'King')
        dealer_hand = Hand()
        player_hand = Hand()
        dealer_hand.add_card(card1)
        player_hand.add_card(card2)

        return player, player_hand, dealer_hand
    def setup_dealer_blackjack(self):
        player = Player()
        player.bet = Decimal(1.00)
        player.money = Decimal(1.00)
        
        card1 = Card('Hearts', 'Jack')
        card2 = Card('Hearts', 'Ace')
        dealer_hand = Hand()
        player_hand = Hand()
        dealer_hand.add_card(card1)
        dealer_hand.add_card(card2)

        return player, player_hand, dealer_hand
示例#3
0
def start_game(request):
    context = {}
    if request.POST:
        return HttpResponseBadRequest("Please do not post")
    else:
        context = get_dealer(request, context)
        hand = Hand()
        hand.add_card(C.generate_card())
        hand.add_card(C.generate_card())
        hand.save()
        context['player'].hand = hand
        context['player'].save()
        dealhand = Hand()
        dealhand.add_card(C.generate_card())
        dealhand.save()
        context['dealer'].hand = dealhand
        context['dealer'].save()
        print context['dealer'].hand
        return HttpResponseRedirect('/game/playing')
示例#4
0
def start_game(request):
    context = {}
    if request.POST:
        return HttpResponseBadRequest("Please do not post")
    else:
        context = get_dealer(request, context)
        hand = Hand()
        hand.add_card(C.generate_card())
        hand.add_card(C.generate_card())
        hand.save()
        context['player'].hand = hand
        context['player'].save()
        dealhand = Hand()
        dealhand.add_card(C.generate_card())
        dealhand.save()
        context['dealer'].hand = dealhand
        context['dealer'].save()
        print context['dealer'].hand
        return HttpResponseRedirect('/game/playing')
示例#5
0
                                                                            round(player.money, 2), player.name, round(player.start_money, 2)))
    print("{} Hands played. {} Hands won. Win percentage: {}%".format(
        player.games_played, player.wins, player.win_percentage))
    if player.money < 1:
        break
    else:
        # player.bet() = int(input("{}, make your wager:
        # $".format(player.name)))
        bet = get_bet(player)
        if player.bet > player.money:
            print("You don't have that much, so you promise your partner a payment.")
            print("Luckily (maybe) for you, the dealer accepts.")

        # initial deal
        for i in range(2):
            player_hand.add_card(deck.deal())
            x = deck.deal()
            dealer_hand.add_card(x)
            if i == 1:
                print(
                    "There are {} cards left in the deck.".format(
                        deck.cards_left()))
                print("The dealer's face-up card is a {}".format(x))
                print("")

                print(
                    "Your hand consists of:{}".format(
                        player_hand.show_cards()))
    print("Your score is: {}".format(player_hand.score()))

    # handling being dealt a blackjack
示例#6
0
 def test_show_cards_returns_string(self):
     hand = Hand()
     hand.add_card(Card('Heart','4'))
     hand.add_card(Card('Diamond','Ace'))
     self.assertTrue(hand.show_cards, 'a string, any string')
示例#7
0
 def test_hand_scoring_with_multiple_aces(self):
     hand = Hand()
     hand.add_card(Card('Heart','Ace'))
     hand.add_card(Card('Diamond','Ace'))
     self.assertTrue(hand.score, '12')
示例#8
0
 def test_hand_scoring(self):
     hand = Hand()
     hand.add_card(Card('Heart','4'))
     hand.add_card(Card('Diamond','7'))
     self.assertTrue(hand.score, '11')