Example #1
0
    def test_add_cards_to_hand_no_pile(self):
        game = Egrt(0.5)
        card_1 = Card(Rank.FOUR, Suit.HEART)
        card_2 = Card(Rank.JACK, Suit.CLUB)

        game.prev_card = card_1
        game.top_card = card_2

        actual_hand = deque()
        game.add_cards_to_hand(actual_hand)
        self.assertEqual(list(actual_hand), [card_1, card_2])
        self.assertEqual(len(game.pile), 0)
        self.assertIsNone(game.prev_card)
        self.assertIsNone(game.top_card)
        self.assertIsNone(game.chances_remaining)
Example #2
0
    def test_add_cards_to_hand_single_card_in_pile(self):
        game = Egrt(0.5)
        card_1 = Card(Rank.FOUR, Suit.HEART)
        card_2 = Card(Rank.SIX, Suit.SPADE)
        card_3 = Card(Rank.QUEEN, Suit.CLUB)

        game.pile.append(card_1)
        game.prev_card = card_2
        game.top_card = card_3

        actual_hand = deque()
        game.add_cards_to_hand(actual_hand)
        self.assertEqual(list(actual_hand), [card_1, card_2, card_3])
        self.assertEqual(len(game.pile), 0)
        self.assertIsNone(game.prev_card)
        self.assertIsNone(game.top_card)
        self.assertIsNone(game.chances_remaining)
Example #3
0
    def test_add_cards_to_hand_multiple_cards_in_pile(self):
        game = Egrt(0.5)
        card_1 = Card(Rank.FOUR, Suit.HEART)
        card_2 = Card(Rank.SIX, Suit.SPADE)
        card_3 = Card(Rank.QUEEN, Suit.CLUB)
        card_4 = Card(Rank.TEN, Suit.DIAMOND)
        card_5 = Card(Rank.EIGHT, Suit.CLUB)
        card_6 = Card(Rank.TWO, Suit.CLUB)
        card_7 = Card(Rank.NINE, Suit.SPADE)

        game.pile.extend([card_1, card_2, card_3, card_4, card_5])
        game.prev_card = card_6
        game.top_card = card_7

        actual_hand = deque()
        game.add_cards_to_hand(actual_hand)
        self.assertEqual(
            list(actual_hand),
            [card_1, card_2, card_3, card_4, card_5, card_6, card_7])
        self.assertEqual(len(game.pile), 0)
        self.assertIsNone(game.prev_card)
        self.assertIsNone(game.top_card)
        self.assertIsNone(game.chances_remaining)
Example #4
0
 def test_is_slap_sandwich_slap(self):
     game = Egrt(0.5)
     game.prev_card = Card(Rank.SEVEN, Suit.CLUB)
     game.top_card = Card(Rank.SIX, Suit.DIAMOND)
     self.assertTrue(game.is_slap(Card(Rank.SIX, Suit.HEART)))
Example #5
0
 def test_is_slap_yes_is_slap(self):
     game = Egrt(0.5)
     game.prev_card = Card(Rank.ACE, Suit.CLUB)
     game.top_card = Card(Rank.QUEEN, Suit.DIAMOND)
     self.assertTrue(game.is_slap(Card(Rank.ACE, Suit.HEART)))
Example #6
0
 def test_is_slap_not_a_slap(self):
     game = Egrt(0.5)
     game.prev_card = Card(Rank.SEVEN, Suit.CLUB)
     game.top_card = Card(Rank.SIX, Suit.DIAMOND)
     self.assertFalse(game.is_slap(Card(Rank.FIVE, Suit.HEART)))
Example #7
0
 def test_is_slap_single_card_in_pile(self):
     game = Egrt(0.5)
     game.top_card = Card(Rank.JACK, Suit.DIAMOND)
     self.assertTrue(game.is_slap(Card(Rank.JACK, Suit.HEART)))
Example #8
0
 def test_set_chances_remaining_ace(self):
     game = Egrt(0.5)
     game.top_card = Card(Rank.JACK, Suit.SPADE)
     game.set_chances_remaining()
     self.assertEqual(game.chances_remaining, 1)
Example #9
0
 def test_set_chances_remaining_ace(self):
     game = Egrt(0.5)
     game.top_card = Card(Rank.QUEEN, Suit.DIAMOND)
     game.set_chances_remaining()
     self.assertEqual(game.chances_remaining, 2)
Example #10
0
 def test_set_chances_remaining_ace(self):
     game = Egrt(0.5)
     game.top_card = Card(Rank.KING, Suit.CLUB)
     game.set_chances_remaining()
     self.assertEqual(game.chances_remaining, 3)
Example #11
0
 def test_set_chances_remaining_ace(self):
     game = Egrt(0.5)
     game.top_card = Card(Rank.ACE, Suit.HEART)
     game.set_chances_remaining()
     self.assertEqual(game.chances_remaining, 4)
Example #12
0
 def test_set_chances_remaining_non_face_card(self):
     game = Egrt(0.5)
     game.top_card = Card(Rank.TEN, Suit.HEART)
     with self.assertRaises(ValueError):
         game.set_chances_remaining()
Example #13
0
 def test_add_cards_to_hand_no_prev_card(self):
     game = Egrt(0.5)
     game.top_card = Card(Rank.THREE, Suit.CLUB)
     with self.assertRaises(ValueError):
         game.add_cards_to_hand(deque())
Example #14
0
 def test_is_slap_king_queen_sandwich(self):
     game = Egrt(0.5)
     game.prev_card = Card(Rank.QUEEN, Suit.DIAMOND)
     game.top_card = Card(Rank.SIX, Suit.DIAMOND)
     self.assertFalse(game.is_slap(Card(Rank.KING, Suit.SPADE)))