Esempio n. 1
0
 def test_one_run_of_three(self):
     cribbage_hand = CribbageHand([
         Card(Rank('8'), Suite.DIAMONDS),
         Card(Rank('A'), Suite.DIAMONDS),
         Card(Rank('5'), Suite.CLUBS),
         Card(Rank('7'), Suite.DIAMONDS),
         Card(Rank('9'), Suite.SPADES),
     ])
     self.assertEqual(1, cribbage_hand.number_of_runs_of_three())
 def test_five_cards(self):
     cribbage_hand = CribbageHand([
         Card(Rank('5'), Suite.CLUBS),
         Card(Rank('3'), Suite.CLUBS),
         Card(Rank('2'), Suite.CLUBS),
         Card(Rank('3'), Suite.DIAMONDS),
         Card(Rank('2'), Suite.SPADES)
     ])
     self.assertEqual(1, cribbage_hand.number_of_fifteen_twos())
Esempio n. 3
0
 def test_two_runs_of_three(self):
     cribbage_hand = CribbageHand([
         Card(Rank('2'), Suite.DIAMONDS),
         Card(Rank('2'), Suite.HEARTS),
         Card(Rank('3'), Suite.CLUBS),
         Card(Rank('7'), Suite.DIAMONDS),
         Card(Rank('4'), Suite.SPADES),
     ])
     self.assertEqual(2, cribbage_hand.number_of_runs_of_three())
Esempio n. 4
0
 def test_count_one_pair(self):
     cribbage_hand = CribbageHand([
         Card(Rank('2'), Suite.DIAMONDS),
         Card(Rank('A'), Suite.DIAMONDS),
         Card(Rank('2'), Suite.CLUBS),
         Card(Rank('7'), Suite.DIAMONDS),
         Card(Rank('9'), Suite.DIAMONDS),
     ])
     self.assertEqual(1, cribbage_hand.number_of_pairs())
Esempio n. 5
0
 def test_not_run_of_five(self):
     cribbage_hand = CribbageHand([
         Card(Rank('3'), Suite.DIAMONDS),
         Card(Rank('4'), Suite.DIAMONDS),
         Card(Rank('J'), Suite.CLUBS),
         Card(Rank('K'), Suite.HEARTS),
         Card(Rank('A'), Suite.SPADES),
     ])
     self.assertFalse(cribbage_hand.is_run_of_five())
Esempio n. 6
0
 def test_count_four_pairs(self):
     cribbage_hand = CribbageHand([
         Card(Rank('0'), Suite.DIAMONDS),
         Card(Rank('A'), Suite.DIAMONDS),
         Card(Rank('0'), Suite.CLUBS),
         Card(Rank('0'), Suite.HEARTS),
         Card(Rank('0'), Suite.SPADES),
     ])
     self.assertEqual(6, cribbage_hand.number_of_pairs())
Esempio n. 7
0
 def test_run_of_five(self):
     cribbage_hand = CribbageHand([
         Card(Rank('3'), Suite.DIAMONDS),
         Card(Rank('4'), Suite.DIAMONDS),
         Card(Rank('5'), Suite.CLUBS),
         Card(Rank('6'), Suite.HEARTS),
         Card(Rank('7'), Suite.SPADES),
     ])
     self.assertTrue(cribbage_hand.is_run_of_five())
Esempio n. 8
0
 def test_not_run_of_four(self):
     cribbage_hand = CribbageHand([
         Card(Rank('6'), Suite.DIAMONDS),
         Card(Rank('A'), Suite.DIAMONDS),
         Card(Rank('6'), Suite.CLUBS),
         Card(Rank('7'), Suite.DIAMONDS),
         Card(Rank('6'), Suite.SPADES),
     ])
     self.assertFalse(cribbage_hand.is_run_of_four())
Esempio n. 9
0
 def test_count_three_pairs(self):
     cribbage_hand = CribbageHand([
         Card(Rank('6'), Suite.DIAMONDS),
         Card(Rank('A'), Suite.DIAMONDS),
         Card(Rank('6'), Suite.CLUBS),
         Card(Rank('7'), Suite.DIAMONDS),
         Card(Rank('6'), Suite.SPADES),
     ])
     self.assertEqual(3, cribbage_hand.number_of_pairs())
Esempio n. 10
0
 def test_one_point_for_the_J_of_the_same_suite_as_the_starter_card(self):
     cribbage_hand = CribbageHand([
         Card(Rank('3'), Suite.DIAMONDS),
         Card(Rank('J'), Suite.SPADES),
         Card(Rank('7'), Suite.DIAMONDS),
         Card(Rank('9'), Suite.DIAMONDS),
         Card(Rank('A'), Suite.SPADES),
     ])
     self.assertEqual(1, score(cribbage_hand))
Esempio n. 11
0
 def test_four_points_for_run_of_four(self):
     cribbage_hand = CribbageHand([
         Card(Rank('2'), Suite.DIAMONDS),
         Card(Rank('0'), Suite.SPADES),
         Card(Rank('J'), Suite.DIAMONDS),
         Card(Rank('Q'), Suite.DIAMONDS),
         Card(Rank('K'), Suite.SPADES),
     ])
     self.assertEqual(4, score(cribbage_hand))
Esempio n. 12
0
 def test_eight_points_for_double_run(self):
     cribbage_hand = CribbageHand([
         Card(Rank('5'), Suite.DIAMONDS),
         Card(Rank('5'), Suite.HEARTS),
         Card(Rank('6'), Suite.CLUBS),
         Card(Rank('A'), Suite.DIAMONDS),
         Card(Rank('7'), Suite.SPADES)
     ])
     self.assertEqual(8, score(cribbage_hand))
Esempio n. 13
0
 def test_fifteen_two(self):
     cribbage_hand = CribbageHand([
         Card(Rank('0'), Suite.DIAMONDS),
         Card(Rank('5'), Suite.HEARTS),
         Card(Rank('3'), Suite.CLUBS),
         Card(Rank('A'), Suite.DIAMONDS),
         Card(Rank('8'), Suite.SPADES),
     ])
     self.assertEqual(2, score(cribbage_hand))
Esempio n. 14
0
 def test_four_points_for_a_flush(self):
     cribbage_hand = CribbageHand([
         Card(Rank('3'), Suite.DIAMONDS),
         Card(Rank('A'), Suite.DIAMONDS),
         Card(Rank('7'), Suite.DIAMONDS),
         Card(Rank('9'), Suite.DIAMONDS),
         Card(Rank('J'), Suite.SPADES),
     ])
     self.assertEqual(4, score(cribbage_hand))
Esempio n. 15
0
 def test_twelve_points_for_four_cards_of_a_kind(self):
     cribbage_hand = CribbageHand([
         Card(Rank('0'), Suite.DIAMONDS),
         Card(Rank('A'), Suite.DIAMONDS),
         Card(Rank('0'), Suite.CLUBS),
         Card(Rank('0'), Suite.HEARTS),
         Card(Rank('0'), Suite.SPADES),
     ])
     self.assertEqual(12, score(cribbage_hand))
Esempio n. 16
0
 def test_six_points_for_three_cards_of_a_kind(self):
     cribbage_hand = CribbageHand([
         Card(Rank('6'), Suite.DIAMONDS),
         Card(Rank('A'), Suite.DIAMONDS),
         Card(Rank('6'), Suite.CLUBS),
         Card(Rank('7'), Suite.DIAMONDS),
         Card(Rank('6'), Suite.SPADES),
     ])
     self.assertEqual(6, score(cribbage_hand))
Esempio n. 17
0
 def test_four_points_for_two_pairs_of_cards_of_a_kind(self):
     cribbage_hand = CribbageHand([
         Card(Rank('3'), Suite.DIAMONDS),
         Card(Rank('A'), Suite.DIAMONDS),
         Card(Rank('3'), Suite.CLUBS),
         Card(Rank('6'), Suite.DIAMONDS),
         Card(Rank('A'), Suite.HEARTS),
     ])
     self.assertEqual(4, score(cribbage_hand))
Esempio n. 18
0
 def test_highest_possible_score(self):
     cribbage_hand = CribbageHand([
         Card(Rank('5'), Suite.DIAMONDS),
         Card(Rank('5'), Suite.HEARTS),
         Card(Rank('5'), Suite.CLUBS),
         Card(Rank('J'), Suite.SPADES),
         Card(Rank('5'), Suite.SPADES),
     ])
     self.assertEqual(29, score(cribbage_hand))
Esempio n. 19
0
 def test_fifteen_sixteen_and_six_pairs(self):
     cribbage_hand = CribbageHand([
         Card(Rank('5'), Suite.DIAMONDS),
         Card(Rank('5'), Suite.HEARTS),
         Card(Rank('5'), Suite.CLUBS),
         Card(Rank('0'), Suite.SPADES),
         Card(Rank('5'), Suite.SPADES),
     ])
     self.assertEqual(28, score(cribbage_hand))
Esempio n. 20
0
 def test_five_points_for_a_flush_and_starter_card_of_same_suite(self):
     cribbage_hand = CribbageHand([
         Card(Rank('3'), Suite.DIAMONDS),
         Card(Rank('A'), Suite.DIAMONDS),
         Card(Rank('7'), Suite.DIAMONDS),
         Card(Rank('9'), Suite.DIAMONDS),
         Card(Rank('J'), Suite.DIAMONDS),
     ])
     self.assertEqual(5, score(cribbage_hand))
Esempio n. 21
0
 def test_sixteen_points_for_double_double_run(self):
     cribbage_hand = CribbageHand([
         Card(Rank('4'), Suite.DIAMONDS),
         Card(Rank('2'), Suite.HEARTS),
         Card(Rank('3'), Suite.CLUBS),
         Card(Rank('4'), Suite.DIAMONDS),
         Card(Rank('3'), Suite.SPADES),
     ])
     self.assertEqual(16, score(cribbage_hand))
Esempio n. 22
0
 def test_two_points_for_a_pair_of_cards_of_a_kind(self):
     cribbage_hand = CribbageHand([
         Card(Rank('2'), Suite.DIAMONDS),
         Card(Rank('A'), Suite.DIAMONDS),
         Card(Rank('2'), Suite.CLUBS),
         Card(Rank('7'), Suite.DIAMONDS),
         Card(Rank('9'), Suite.DIAMONDS),
     ])
     self.assertEqual(2, score(cribbage_hand))
Esempio n. 23
0
 def test_three_points_for_a_run_of_three(self):
     cribbage_hand = CribbageHand([
         Card(Rank('0'), Suite.DIAMONDS),
         Card(Rank('A'), Suite.DIAMONDS),
         Card(Rank('2'), Suite.CLUBS),
         Card(Rank('8'), Suite.DIAMONDS),
         Card(Rank('9'), Suite.SPADES),
     ])
     self.assertEqual(3, score(cribbage_hand))
 def test_parse_five_cards(self):
     expected = CribbageHand([
         Card(Rank('6'), Suite.SPADES),
         Card(Rank('8'), Suite.DIAMONDS),
         Card(Rank('A'), Suite.DIAMONDS),
         Card(Rank('3'), Suite.SPADES),
         Card(Rank('J'), Suite.SPADES)
     ])
     cribbage_hand = parse_hand('6♠8♦A♦3♠J♠')
     self.assertEqual(expected, cribbage_hand)