Example #1
0
    def test_drawn_cards_multiple_hands_no_cards(self):
        actor = bj.Actor()
        actor.add_card(bj.create_card(3))
        actor.add_card(bj.create_card(5))

        actor.hands.append(bj.Hand())
        actor.add_card(bj.create_card(6), 1)
        actor.add_card(bj.create_card(5), 1)

        actor.hands.append(bj.Hand())
        actor.add_card(bj.create_card(3), 2)
        actor.add_card(bj.create_card(8), 2)

        self.assertEqual(actor.drawn_cards(), 0)
Example #2
0
    def test_reset(self):
        hand = bj.Hand()
        hand.add_card(bj.create_card(8))
        hand.add_card(bj.create_card(8))
        hand.reset()

        self.assertEqual(len(hand.cards), 0)
Example #3
0
    def test_string_multiple_hands(self):
        actor = bj.Actor()
        actor.add_card(bj.create_card(3))
        actor.add_card(bj.create_card(5))

        actor.hands.append(bj.Hand())
        actor.add_card(bj.create_card(6), 1)
        actor.add_card(bj.create_card(5), 1)

        self.assertEqual(str(actor), '(0) 3 5 - 8\n(1) 6 5 - 11\n')
Example #4
0
    def test_basic_hand(self):
        hand = bj.Hand()
        hand.add_card(bj.create_card(10))
        hand.add_card(bj.create_card(8))

        self.assertEqual(hand.count(), 18)
        self.assertFalse(hand.is_blackjack())
        self.assertTrue(hand.can_double_down())
        self.assertFalse(hand.can_split())
        self.assertFalse(hand.is_soft_hand())
Example #5
0
    def test_is_blackjack(self):
        hand = bj.Hand()
        hand.add_card(bj.create_card(10))
        hand.add_card(bj.create_ace())

        self.assertTrue(hand.is_blackjack())

        hand.add_card(bj.create_card(10))
        self.assertEqual(hand.count(), 21)
        self.assertFalse(hand.is_blackjack())
Example #6
0
    def test_count_multiple_hands(self):
        actor = bj.Actor()
        actor.add_card(bj.create_card(10))
        actor.add_card(bj.create_card(8))

        # Add a new hand.
        actor.hands.append(bj.Hand())
        actor.add_card(bj.create_card(6), 1)
        actor.add_card(bj.create_card(5), 1)

        self.assertEqual(actor.count(), 18)
        self.assertEqual(actor.count(1), 11)
Example #7
0
    def test_aces(self):
        hand = bj.Hand()
        hand.add_card(bj.create_ace())
        hand.add_card(bj.create_card(8))

        self.assertTrue(hand.is_soft_hand())

        hand.add_card(bj.create_ace())
        self.assertEqual(hand.count(), 20)

        hand.add_card(bj.create_card(10))
        self.assertEqual(hand.count(), 20)
Example #8
0
    def test_count_append(self):
        hand = bj.Hand()
        hand.add_card(bj.create_ace())
        hand.add_card(bj.create_card(5))
        self.assertEqual(hand.count(), 16)

        hand.add_card(bj.create_card(4))
        self.assertEqual(hand.count(), 20)

        hand.add_card(bj.create_card(8))
        self.assertEqual(hand.count(), 18)

        hand.add_card(bj.create_card(5))
        self.assertEqual(hand.count(), 23)
Example #9
0
    def test_split_multiple_hands(self):
        actor = bj.Actor()
        actor.add_card(bj.create_card(5))
        actor.add_card(bj.create_card(5))

        actor.hands.append(bj.Hand())
        actor.add_card(bj.create_card(8), 1)
        actor.add_card(bj.create_card(7), 1)

        actor.split_hand()

        self.assertEqual(len(actor.hands), 3)
        self.assertEqual(actor.count(), 5)
        self.assertEqual(actor.hands[0].cards[0].min_val, 5)
        self.assertTrue(actor.hands[0].is_split)

        self.assertEqual(actor.count(1), 5)
        self.assertEqual(actor.hands[1].cards[0].min_val, 5)
        self.assertTrue(actor.hands[1].is_split)

        self.assertEqual(actor.hands[2].cards[0].min_val, 8)
Example #10
0
    def test_split(self):
        hand = bj.Hand()
        hand.add_card(bj.create_card(8))
        hand.add_card(bj.create_card(8))

        self.assertTrue(hand.can_split())