示例#1
0
 def test_for_number_of_valid_instance_of_card_after_deal_card(self):
     set_of_decks = SetOfDecks()
     card = set_of_decks.deal_card()
     '''since there are 8 instances of each card after
     after popping one 7 instances will remain
     '''
     self.assertEqual(set_of_decks.get_decks_list().count(card), 7)
 def test_hit(self):
     set_of_decks = SetOfDecks()
     dealer = Dealer('DealWithMe')
     player = Player('IWill')
     set_of_decks.decks.clear()
     set_of_decks.decks.append(Card('Spade', 'A'))
     dealer.hit(set_of_decks, player)
     self.assertEqual(player.get_my_cards()[0].get_face_val(), 'A')
     self.assertNotEqual(player.get_my_cards()[0].get_face_val(), 'B')
 def test_distribute_card_first_time(self):
     current_players = []
     player1 = Player('Nikhil')
     player2 = Player('Nishant')
     current_players.append(player1)
     current_players.append(player2)
     set_of_decks = SetOfDecks()
     set_of_decks.get_decks_list().clear()
     set_of_decks.get_decks_list().append(Card('Spade', 'K'))
     set_of_decks.get_decks_list().append(Card('Spade', 'Q'))
     set_of_decks.get_decks_list().append(Card('Spade', '2'))
     set_of_decks.get_decks_list().append(Card('Spade', '3'))
     set_of_decks.get_decks_list().append(Card('Spade', '4'))
     set_of_decks.get_decks_list().append(Card('Spade', '5'))
     dealer = Dealer("IamDealer")
     dealer.distribute_card_first_time(current_players, set_of_decks)
     temp_list = []
     for card in player1.get_my_cards():
         temp_list.append(card.get_face_val())
     for card in player2.get_my_cards():
         temp_list.append(card.get_face_val())
     for card in dealer.get_my_cards():
         temp_list.append(card.get_face_val())
     self.assertEqual(temp_list, ['K', 'Q', '2', '3', '4', 0])
    def test_plays(self):
        set_of_decks = SetOfDecks()
        set_of_decks.decks.clear()
        card1 = Card('Spade', 'K')
        card2 = Card('Spade', 'Q')
        dealer = Dealer('DealWithMe')
        set_of_decks.decks.append(card1)
        set_of_decks.decks.append(card2)
        dealer.plays(set_of_decks)
        self.assertEqual(dealer.get_sum(), 20)
        self.assertNotEqual(dealer.get_sum(), 12)

        dealer.get_my_cards().clear()
        dealer.get_my_cards().append(Card('Diamond', 'K'))
        dealer.get_my_cards().append(Card('Diamond', '7'))
        dealer.plays(set_of_decks)
        self.assertEqual(dealer.get_sum(), 17)
        self.assertNotEqual(dealer.get_sum(), 18)
示例#5
0
 def __init__(self):
     self.set_of_decks = SetOfDecks()
     self.dealer = Dealer('Dealer')
     self.current_players = []
     self.standed_players = []
     self.busted_players = []
示例#6
0
 def test_number_of_cards_in_set_of_deck(self):
     set_of_decks = SetOfDecks()
     self.assertEqual(len(set_of_decks.get_decks_list()), 416)
示例#7
0
 def test_deal_card(self):
     set_of_decks = SetOfDecks()
     card = set_of_decks.deal_card()
     self.assertEqual(set_of_decks.decks.count(card), 7)
     self.assertNotEqual(set_of_decks.decks.count(card), 0)