Example #1
0
    def test_sighCardWithoutAce(self):
        ranks = [3, 7, 11, 4, 5]
        suits = ['d', 'c', 'h', 's']
        hand = Hand(
            [Card(suits[random.randint(0, 3)], ranks[i]) for i in range(5)])

        assert hand.highCard() == 11
Example #2
0
    def test_notTwoPair(self):
        ranks = [1, 2, 3, 4, 5]
        suits = ['d', 'c', 'h', 's']
        hand = Hand(
            [Card(suits[random.randint(0, 3)], ranks[i]) for i in range(5)])

        assert hand.isTwoPair() == False
Example #3
0
    def test_threeOfAKind(self):
        ranks = [7, 7, 7, 4, 5]
        suits = ['d', 'c', 'h', 's']
        hand = Hand(
            [Card(suits[random.randint(0, 3)], ranks[i]) for i in range(5)])

        assert hand.isThreeOfAKind() == True
Example #4
0
    def test_straightEdgeCase(self):
        ranks = [10, 11, 12, 13, 1]
        suits = ['d', 'c', 'h', 's']
        hand = Hand(
            [Card(suits[random.randint(0, 3)], ranks[i]) for i in range(5)])

        assert hand.isStraight() == True
Example #5
0
    def test_straight(self):
        ranks = [1, 2, 3, 4, 5]
        suits = ['d', 'c', 'h', 's']
        hand = Hand(
            [Card(suits[random.randint(0, 3)], ranks[i]) for i in range(5)])

        assert hand.isStraight() == True
Example #6
0
class Game:
    def __init__(self):
        self.deck = Deck()
        self.dealer_hand = Hand()
        self.player_hand = Hand()

    def start(self):
        self.deck.shuffle()
        self.player_hand.add_card(self.deck.deal())
        self.dealer_hand.add_card(self.deck.deal())
        self.player_hand.add_card(self.deck.deal())
        self.dealer_hand.add_card(self.deck.deal())

    def put_cards_back(self):
        for card in self.dealer_hand.cards:
            self.deck.add_card_on_bottom(card)
        for card in self.player_hand.cards:
            self.deck.add_card_on_bottom(card)
        self.dealer_hand.cards = []
        self.player_hand.cards = []
        self.dealer_hand.value = self.player_hand.value = 0
        self.dealer_hand.aces = self.player_hand.aces = 0
Example #7
0
    def test_royalFlush(self):
        ranks = [1, 10, 11, 12, 13]
        suits = ['d', 'd', 'd', 'd', 'd']
        hand = Hand([Card(suits[i], ranks[i]) for i in range(5)])

        assert hand.valueAsText == "Royal flush"
Example #8
0
    def test_fourOfAKind(self):
        ranks = [4, 4, 4, 4, 13]
        suits = ['d', 'c', 'h', 's', 'd']
        hand = Hand([Card(suits[i], ranks[i]) for i in range(5)])

        assert hand.valueAsText == "Four of a kind"
Example #9
0
    def test_straightFlush(self):
        ranks = [1, 2, 3, 4, 5]
        suits = ['d', 'd', 'd', 'd', 'd']
        hand = Hand([Card(suits[i], ranks[i]) for i in range(5)])

        assert hand.valueAsText == "Straight flush"
Example #10
0
    def test_flush(self):
        ranks = [1, 2, 7, 11, 5]
        suits = ['d', 'd', 'd', 'd', 'd']
        hand = Hand([Card(suits[i], ranks[i]) for i in range(5)])

        assert hand.valueAsText == "Flush"
Example #11
0
    def test_fullHouse(self):
        ranks = [1, 1, 1, 5, 5]
        suits = ['d', 'c', 'h', 's', 'd']
        hand = Hand([Card(suits[i], ranks[i]) for i in range(5)])

        assert hand.valueAsText == "Full House"
Example #12
0
    def test_fourOfAkindBug(self):
        ranks = [2, 2, 3, 4, 5]
        suit = ['d', 'c', 'd', 's', 'd']
        hand = Hand([Card(suit[i], ranks[i]) for i in range(5)])

        assert hand.isFourOfAKind() == False
Example #13
0
    def test_threeOfAKind(self):
        ranks = [1, 3, 3, 3, 5]
        suits = ['d', 'c', 'h', 's', 'd']
        hand = Hand([Card(suits[i], ranks[i]) for i in range(5)])

        assert hand.valueAsText == "Three of a kind"
Example #14
0
    def test_fourOfAKind(self):
        ranks = [2, 2, 2, 2, 5]
        suits = ['d', 's', 'c', 'h', 'd']
        hand = Hand([Card(suits[i], ranks[i]) for i in range(5)])

        assert hand.isFourOfAKind() == True
Example #15
0
def test_straightFlush():
    ranks = [1, 2, 3, 4, 5]
    suit = 'c'
    hand = Hand([Card(suit, ranks[i]) for i in range(5)])

    assert hand.isStraightFlush() == True
Example #16
0
    def test_onePair(self):
        ranks = [1, 2, 2, 4, 5]
        suits = ['d', 'c', 'h', 's', 'd']
        hand = Hand([Card(suits[i], ranks[i]) for i in range(5)])

        assert hand.valueAsText == "One pair"
Example #17
0
    def test_twoPairNotThreeOfAKind(self):
        ranks = [7, 7, 4, 4, 5]
        suits = ['d', 'c', 'h', 's', 'd']
        hand = Hand([Card(suits[i], ranks[i]) for i in range(5)])

        assert hand.isThreeOfAKind() != True
Example #18
0
    def test_fullHouseRecognizedAsHighCard(self):
        ranks = [6, 6, 11, 11, 11]
        suits = ['h', 'd', 's', 'd', 'h']
        hand = Hand([Card(suits[i], ranks[i]) for i in range(5)])

        assert hand.isFullHouse() == True
Example #19
0
    def test_twoPairNotFullHouse(self):
        ranks = [3, 3, 3, 7, 2]
        suits = ['d', 's', 'c', 'h', 'd']
        hand = Hand([Card(suits[i], ranks[i]) for i in range(5)])

        assert hand.isFullHouse() == False
Example #20
0
    def test_fullHouse(self):
        ranks = [3, 3, 3, 7, 7]
        suits = ['d', 's', 'c', 'h', 'd']
        hand = Hand([Card(suits[i], ranks[i]) for i in range(5)])

        assert hand.isFullHouse() == True
Example #21
0
    def test_highCard(self):
        ranks = [1, 2, 8, 4, 5]
        suits = ['d', 'c', 'h', 's', 'd']
        hand = Hand([Card(suits[i], ranks[i]) for i in range(5)])

        assert hand.valueAsText == "Highcard of A"
Example #22
0
    def test_twoPair(self):
        ranks = [1, 2, 2, 4, 4]
        suits = ['d', 'c', 'h', 's', 'd']
        hand = Hand([Card(suits[i], ranks[i]) for i in range(5)])

        assert hand.valueAsText == "Two pairs"
Example #23
0
    def test_RoyalFlush(self):
        ranks = [10, 11, 12, 13, 1]
        suit = 's'
        hand = Hand([Card(suit, ranks[i]) for i in range(5)])

        assert hand.isRoyalFlush() == True
Example #24
0
    def test_fullHouseNotFourOfAKind(self):
        ranks = [3, 3, 3, 7, 7]
        suits = ['d', 's', 'c', 'h', 'd']
        hand = Hand([Card(suits[i], ranks[i]) for i in range(5)])

        assert hand.isFourOfAKind() == False
Example #25
0
    def test_twoPair(self):
        ranks = [7, 7, 4, 4, 5]
        suits = ['d', 'c', 'h', 's', 'd']
        hand = Hand([Card(suits[i], ranks[i]) for i in range(5)])

        assert hand.isTwoPair() == True
Example #26
0
    def test_royalFlushShouldFail(self):
        ranks = [1, 2, 3, 4, 5]
        suit = 'c'
        hand = Hand([Card(suit, ranks[i]) for i in range(5)])

        assert hand.isRoyalFlush() == False
Example #27
0
 def __init__(self):
     self.deck = Deck()
     self.dealer_hand = Hand()
     self.player_hand = Hand()
Example #28
0
def test_Flush():
    ranks = [1, 7, 11, 4, 5]
    suit = 'd'
    hand = Hand([Card(suit, ranks[i]) for i in range(5)])

    assert hand.isFlush() == True