コード例 #1
0
def test_add_cards1():
    """Adding cards to hand gives correct hand value"""
    test_hand = cards.Hand()

    test_hand.add_cards(cards.Card("Diamonds", "King"))
    assert test_hand.value == 10
    assert test_hand.aces == 0
コード例 #2
0
def test_clear_hand():
    test_hand = cards.Hand()
    test_hand.add_cards(cards.Card("Diamonds", "King"))
    test_hand.add_cards(cards.Card("Hearts", "Ace"))
    print(test_hand.cards)
    test_hand.clear_hand()
    print(test_hand.cards)
    assert test_hand.cards == []
コード例 #3
0
def test_add_cards2():
    """Next 5 tests are checking aces are handled correctly"""
    test_hand = cards.Hand()
    test_hand.add_cards(cards.Card("Diamonds", "King"))
    test_hand.adjust_for_ace()
    test_hand.add_cards(cards.Card("Hearts", "Ace"))
    test_hand.adjust_for_ace()

    assert test_hand.value == 21
    assert test_hand.aces == 1
コード例 #4
0
def test_add_cards5():
    test_hand = cards.Hand()

    test_hand.add_cards(cards.Card("Hearts", "Ace"))
    test_hand.adjust_for_ace()

    test_hand.add_cards(cards.Card("Clubs", "Ace"))
    test_hand.adjust_for_ace()

    assert test_hand.value == 12
    assert test_hand.aces == 1
コード例 #5
0
def test_add_cards3():
    test_hand = cards.Hand()
    test_hand.add_cards(cards.Card("Diamonds", "King"))
    test_hand.adjust_for_ace()
    test_hand.add_cards(cards.Card("Hearts", "Ace"))
    test_hand.adjust_for_ace()
    test_hand.add_cards(cards.Card("Spades", "Eight"))
    test_hand.adjust_for_ace()

    assert test_hand.value == 19
    assert test_hand.aces == 0
コード例 #6
0
def test_card_string():
    test_hand = cards.Hand()
    test_hand.add_cards(cards.Card("Diamonds", "King"))
    test_hand.adjust_for_ace()
    assert test_hand.hand_held() == "King of Diamonds"
    test_hand.add_cards(cards.Card("Hearts", "Ace"))
    test_hand.adjust_for_ace()
    assert test_hand.hand_held() == "King of Diamonds, and the Ace of Hearts"
    test_hand.add_cards(cards.Card("Spades", "Eight"))
    test_hand.adjust_for_ace()
    assert (
        test_hand.hand_held()
        == "King of Diamonds, Ace of Hearts, and the Eight of Spades"
    )
コード例 #7
0
def test_holding():
    test_hand = cards.Hand()
    test_hand.add_cards(cards.Card("Diamonds", "King"))
    test_hand.adjust_for_ace()
    test_hand.add_cards(cards.Card("Hearts", "Ace"))
    test_hand.adjust_for_ace()
    test_hand.add_cards(cards.Card("Spades", "Eight"))
    test_hand.adjust_for_ace()
    assert test_hand.holding() == [
        ("Diamonds", "King"),
        ("Hearts", "Ace"),
        ("Spades", "Eight"),
    ]
    assert test_hand.cards[0].rank == "King"
コード例 #8
0
def test_hand(fake_card, capsys):
    """test that hand displays correctly"""
    test_hand = cards.Hand()
    test_hand.add_cards(fake_card)
    assert test_hand.hand_held() == "King of Diamonds"
コード例 #9
0
def test_converting_list_to_object():
    test_hand = cards.Hand()
    test_alexa_session_attr = ["King of Diamonds", "Ace of Hearts", "Eight of Spades"]
    pass
コード例 #10
0
ファイル: game_set_up.py プロジェクト: Pektech/alexa21
from lambda2.code.alexa import cards

player_hand, alexa_hand, deck = cards.Hand().create_initial_hand()

game_state = cards.GameState()

player_chips = cards.Chips()