コード例 #1
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()))
コード例 #2
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()))
コード例 #3
0
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()))
コード例 #4
0
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()))