def test_hand_bet_doubling():
    h = Hand()
    bet = 10
    h.bet = bet
    h.double_bet()

    assert_equal(h.bet, bet*2)
Exemple #2
0
def test_hand_bet_doubling():
    h = Hand()
    bet = 10
    h.bet = bet
    h.double_bet()

    assert_equal(h.bet, bet * 2)
Exemple #3
0
def test_hand():
    h = Hand()
    card1, card2, card3 = create_some_cards()

    # Set a bet for a hand.
    h.bet = 10

    assert_equal(h.bet, 10)

    h.put_card(card1)
    h.put_card(card2)
    h.put_card(card3)

    card_value_sum = 0
    for i in xrange(len(h)):
        if h.card_stack[i].number > 10:
            card_value_sum += 10
        else:
            card_value_sum += h.card_stack[i].number

    assert_equal(value(h), card_value_sum)

    # Hand not busted yet, 1+k+1 = 12
    assert_false(busted(h, Rules()))

    h.put_card(card2)

    # hands get busted after one more King( 12 + 10 = 22)
    assert_true(busted(h, Rules()))
def test_hand():
    h = Hand()
    card1, card2, card3 = create_some_cards()

    # Set a bet for a hand.
    h.bet = 10

    assert_equal(h.bet, 10)

    h.put_card(card1)
    h.put_card(card2)
    h.put_card(card3)

    card_value_sum = 0 
    for i in xrange(len(h)):
        if h.card_stack[i].number > 10:
            card_value_sum += 10
        else:
            card_value_sum += h.card_stack[i].number

    assert_equal(value(h), card_value_sum)

    # Hand not busted yet, 1+k+1 = 12
    assert_false(busted(h, Rules()))

    h.put_card(card2)

    # hands get busted after one more King( 12 + 10 = 22)
    assert_true(busted(h, Rules()))
def test_player_standing():
    p = Player('Fooman')
    p.hand_list.append(Hand())

    p.stand(p.hand_list[0])

    assert_true(p.hand_list[0].final_hand)
def create_stuff(): 
    o = Player('Barman')
    o.balance = 200
    o.hand_list.append(Hand())
    o.hand_list[o.current_hand].put_card(Card(2,'heart'))

    p = Player('Fooman')
    p.balance = 150
    p.hand_list.append(Hand())
    p.hand_list[p.current_hand].put_card(Card(1,'spade'))

#   Stats not yet implemented.
#   q = Game()

    r = Rules()

    return o, p, r
def test_player_betting():
    p = Player('Fooman')
    h = Hand()

    p.hand_list.append(h)

    p.bet(10)

    # balance should now be -10 and bet of the hand 10.

    assert_true(p.balance == -10 and h.bet == 10)
def test_player_hitting():
    p = Player('Fooman')
    h = Hand()
    pack = Pack()
    #    length = len(pack)

    init_pack(pack)
    p.hand_list.append(h)

    p.hit(pack)

    assert_true(len(p.hand_list[0]) == 1 and len(pack) == 51)

    hit_20_cards(p, pack)

    # Should bust from hitting 20 cards.
    assert_true(busted(p.hand_list[0], Rules()))
Exemple #9
0
def test_hand_negative_bet():
    h = Hand()
    # This should fail at the moment since nothing is done to ensure positive bets.
    assert_raises(Exception, set_negative_bet, h)