Exemple #1
0
 def setUp(self):
     print("Set_up")
     self.c1 = Card(1, "Diamond")
     self.c2 = Card(2, "Diamond")
     self.c3 = Card(3, "Diamond")
     self.c4 = Card(4, "Diamond")
     self.p_1 = Player("p_1", 5000, 5)
     self.list = [self.c1, self.c2, self.c3, self.c4]
     self.dc = DeckOfCards()
    def __init__(self, number_of_cards=5):
        if number_of_cards > 13:
            raise ValueError(
                "the number of cards need to be lost of 13 and big of 5")
        if number_of_cards < 5:
            raise ValueError(
                "the number of cards need to be lost of 13 and big of 5")

        self.number_of_cards = number_of_cards
        self.deckOfCards = DeckOfCards()
        self.players = []
Exemple #3
0
 def __init__(self, name1="player-1", name2="player-2", num_cards=10):
     """מקבלת כמה קלפים לחלק לכל שחקן, מגדירה 2 שחקנים, יוצרת חפיסה ומתחילה משחק חדש"""
     if type(num_cards) == int:  # נכנסת רק כאשר המספר הוא שלם ותקין
         if 1 <= num_cards:  # בודקת שכמות הקלפים היא תיקנית ולא פחות מ1
             if num_cards > 26:  # אם כמות הקלפים לחלוקה גדול מ26 היא תחלק רק 26 קלפים ותעדכן את המשתמש
                 print("only 26 cards dealt")
                 num_cards = 26
             self.num_cards = num_cards
             self.player_1 = Player(name1, self.num_cards)
             self.player_2 = Player(name2, self.num_cards)
             self.deck_cards = DeckOfCards()
             self.new_game()
         else:
             exit("ERROR!")  # אם הכמות היא פחות מ1 תדפיס שגיאה
     else:
         exit("ERROR!")  # אם המספר אינו תיקני
 def setUp(self):
     self.tester = DeckOfCards()
 def test_shuffle(self):
     """בודקת האם החפיסה לפני הערבוב שווה לחפיסה חדשה, ובודקת האם החפיסה אחרי הערבוב לא שווה לחפיסה חדשה לפני ערבוב"""
     deck1 = DeckOfCards()
     self.assertEqual(deck1.cards, self.tester.show())
     self.tester.shuffle()
     self.assertNotEqual(deck1.cards, self.tester.show())
 def test_sum_cards(self):
     """בודקת האם בחפיסה חדשה שנוצרת יש 52 קלפים"""
     deck1 = DeckOfCards()
     self.assertEqual(len(deck1.cards), 52)
Exemple #7
0
 def test_set_hand_all_cards_set(self):
     """checks the game will played for 10 rounds"""
     deck = DeckOfCards()
     player = Player('Ohad')
     player.set_hand(deck)
     self.assertEqual(len(player.player_hand), player.cards_number)
Exemple #8
0
 def test_set_hand1(self, mock_deal_one):
     """checks the player really get cards from the deck"""
     deck = DeckOfCards()
     player = Player('Ohad')
     player.set_hand(deck)
     self.assertEqual(player.player_hand.count(Card(11, 2)), 10)
Exemple #9
0
 def setUp(self):
     print("Set_up")
     self.d_card = DeckOfCards()
     self.c1 = Card(1, "Diamond")
 def test_shuffle(self, mock_shuffle):
     """checking the list is shuffling the deck"""
     deck = DeckOfCards()
     deck.shuffle()
     mock_shuffle.assert_called_once_with(deck.list_cards)
 def test_show(self):
     """checks the method are really shows the full deck"""
     deck = DeckOfCards()
     self.assertEqual(deck.show(), deck.list_cards)
 def test_deal_one(self):
     """copy the deck of cards to 'a' and remove if the card we removed appears on the copied list"""
     deck = DeckOfCards()
     a = deck.list_cards.copy()
     self.assertIn(deck.deal_one(), a)
Exemple #13
0
 def __init__(self, name1, name2, num_cards=10):
     self.player1 = Player(name1)
     self.player2 = Player(name2)
     self.num_cards = num_cards
     self.deck = DeckOfCards()
     self.new_game()
Exemple #14
0
 def setUp(self):
     self.player_1 = Player("dima", 2)
     self.player_2 = Player("shahar", 27)
     self.deck_cards = DeckOfCards()
     self.card_1 = Card(1, 3)
     self.card_2 = Card(2, 1)
Exemple #15
0
 def test_set_hand_3(self):
     """בודקת אם נכנס לחפיסה משהו שהוא לא אובייקט Card"""
     deck_cards = DeckOfCards()
     deck_cards.cards.append(1)  # מכניסים סתם מספר במקום אובייקט
     with self.assertRaises(SystemExit):
         self.player_1.set_hand(deck_cards)