예제 #1
0
    def test_hit_or_stand_player_stands(self):
        test_deck = game.Deck()
        test_hand = game.Hand()
        test_selection = 's'

        game.hit_or_stand(test_deck, test_hand, test_selection)

        self.assertEqual(game.playing, False)
 def test_twoPairs(self):
     hand = game.Hand()
     hand.addCard(cards.Card(10, 'S'))
     hand.addCard(cards.Card(9, 'H'))
     hand.addCard(cards.Card(9, 'S'))
     hand.addCard(cards.Card(8, 'C'))
     hand.addCard(cards.Card(8, 'S'))
     self.assertEqual(evaluateHand(hand), {3: [9, 8, 10]})
예제 #3
0
    def test_hit_or_stand_player_hit(self):
        test_deck = game.Deck()
        test_hand = game.Hand()
        test_selection = 'h'

        game.hit_or_stand(test_deck, test_hand, test_selection)

        self.assertEqual(len(test_hand.cards), 1)
 def test_pair(self):
     hand = game.Hand()
     hand.addCard(cards.Card(10, 'S'))
     hand.addCard(cards.Card(9, 'H'))
     hand.addCard(cards.Card(7, 'S'))
     hand.addCard(cards.Card(4, 'C'))
     hand.addCard(cards.Card(4, 'S'))
     self.assertEqual(evaluateHand(hand), {2: [4, 10, 9, 7]})
 def test_straight(self):
     hand = game.Hand()
     hand.addCard(cards.Card(14, 'S'))
     hand.addCard(cards.Card(5, 'S'))
     hand.addCard(cards.Card(4, 'S'))
     hand.addCard(cards.Card(3, 'C'))
     hand.addCard(cards.Card(2, 'S'))
     self.assertEqual(evaluateHand(hand), {5: [5]})
 def test_threeOfAKind(self):
     hand = game.Hand()
     hand.addCard(cards.Card(14, 'S'))
     hand.addCard(cards.Card(5, 'H'))
     hand.addCard(cards.Card(5, 'S'))
     hand.addCard(cards.Card(5, 'C'))
     hand.addCard(cards.Card(2, 'S'))
     self.assertEqual(evaluateHand(hand), {4: [5, 14, 2]})
 def test_fullHouse(self):
     hand = game.Hand()
     hand.addCard(cards.Card(11, 'S'))
     hand.addCard(cards.Card(11, 'D'))
     hand.addCard(cards.Card(11, 'H'))
     hand.addCard(cards.Card(5, 'C'))
     hand.addCard(cards.Card(5, 'S'))
     self.assertEqual(evaluateHand(hand), {7: [11, 5]})
 def test_flush(self):
     hand = game.Hand()
     hand.addCard(cards.Card(13, 'S'))
     hand.addCard(cards.Card(11, 'S'))
     hand.addCard(cards.Card(10, 'S'))
     hand.addCard(cards.Card(7, 'S'))
     hand.addCard(cards.Card(4, 'S'))
     self.assertEqual(evaluateHand(hand), {6: [13, 11, 10, 7, 4]})
 def test_fourOfAKind(self):
     hand = game.Hand()
     hand.addCard(cards.Card(12, 'S'))
     hand.addCard(cards.Card(12, 'D'))
     hand.addCard(cards.Card(12, 'H'))
     hand.addCard(cards.Card(12, 'C'))
     hand.addCard(cards.Card(9, 'S'))
     self.assertEqual(evaluateHand(hand), {8: [12, 9]})
 def test_straightFlush(self):
     hand = game.Hand()
     hand.addCard(cards.Card(13, 'S'))
     hand.addCard(cards.Card(12, 'S'))
     hand.addCard(cards.Card(11, 'S'))
     hand.addCard(cards.Card(10, 'S'))
     hand.addCard(cards.Card(9, 'S'))
     self.assertEqual(evaluateHand(hand), {9: [13]})
 def test_highCard(self):
     hand = game.Hand()
     hand.addCard(cards.Card(12, 'S'))
     hand.addCard(cards.Card(9, 'H'))
     hand.addCard(cards.Card(7, 'S'))
     hand.addCard(cards.Card(5, 'C'))
     hand.addCard(cards.Card(4, 'S'))
     self.assertEqual(evaluateHand(hand), {1: [12, 9, 7, 5, 4]})
 def test_royalFlush(self):
     hand = game.Hand()
     hand.addCard(cards.Card(14, 'S'))
     hand.addCard(cards.Card(13, 'S'))
     hand.addCard(cards.Card(12, 'S'))
     hand.addCard(cards.Card(11, 'S'))
     hand.addCard(cards.Card(10, 'S'))
     self.assertEqual(evaluateHand(hand), {10: []})
예제 #13
0
    def test_deal_to_player(self):
        test_deck = game.Deck()
        test_deck.shuffle()

        test_player = game.Hand()
        pulled_card = test_deck.deal()
        test_player.add_card(pulled_card)

        self.assertIsNotNone(test_player.value)
        self.assertEqual(test_player.cards[0].suit, pulled_card.suit)
예제 #14
0
    def test_hit_card(self):
        test_deck = game.Deck()
        test_hand = game.Hand()
        game.hit(test_deck, test_hand)

        self.assertEqual(len(test_hand.cards), 1)
예제 #15
0
def push(player, dealer):
    print("It's a tie. PUSH!!!")


if __name__ == "__main__":

    while True:
        print("...Simple BlackJack...")

        ## Setup Deck & Shuffle
        deck = game.deck.Deck()
        deck.shuffle()

        ## Setup Dealer & Player
        player = game.Hand()
        player.pick_card(deck.deal())
        player.pick_card(deck.deal())

        dealer = game.Hand()
        dealer.pick_card(deck.deal())
        dealer.pick_card(deck.deal())

        ## Set up player chips
        player_chips = game.Chip(250)

        make_bet(player_chips)

        ## Show short summary...
        short_sum(player, dealer)