示例#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
示例#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
示例#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
示例#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
示例#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
示例#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
示例#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"
示例#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"
示例#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"
示例#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"
示例#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"
示例#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
示例#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"
示例#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
示例#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
示例#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"
示例#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
示例#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
示例#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
示例#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
示例#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"
示例#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"
示例#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
示例#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
示例#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
示例#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
示例#27
0
 def __init__(self):
     self.deck = Deck()
     self.dealer_hand = Hand()
     self.player_hand = Hand()
示例#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