コード例 #1
0
 def test_go_down_auto_select(self):
     self.game.hand.add(self.threes_and_fours_hand)
     VictoryConditions.two_three_of_a_kind(self.game.hand.cards,
                                           self.game.victory_cards)
     self.game.go_down()
     self.assertEqual(Stack(), self.game.hand)
     self.assertEqual(self.threes_and_fours_hand, self.game.down_cards)
コード例 #2
0
 def test_go_down_manual_select2(self, mock_input):
     self.game.hand.add(three_of_a_kind(3))
     self.game.hand.add(three_of_a_kind(4))
     self.game.hand.add(three_of_a_kind(5))
     VictoryConditions.two_three_of_a_kind(self.game.hand.cards,
                                           self.game.victory_cards)
     self.game.go_down()
     self.assertEqual(three_of_a_kind(3), self.game.hand)
コード例 #3
0
 def test_go_down_manual_select_with_wild_cards(self, mock_input):
     self.game.hand.add(wild_three_of_a_kind(3))
     self.game.hand.add(wild_three_of_a_kind(4))
     self.game.hand.add(wild_three_of_a_kind(5))
     VictoryConditions.two_three_of_a_kind(self.game.hand.cards,
                                           self.game.victory_cards)
     self.game.go_down()
     self.assertEqual(
         Stack(cards=deque([
             Card(value='5', suit='Diamonds'),
             Card(value='5', suit='Hearts')
         ])), self.game.hand)
コード例 #4
0
 def test_two_three_of_a_kind_both_natural(self):
     """Test two natural three of a kinds."""
     self.game.hand.add(three_of_a_kind(3))
     self.game.hand.add(three_of_a_kind(4))
     self.assertTrue(
         VictoryConditions.two_three_of_a_kind(self.game.hand.cards,
                                               self.game.victory_cards))
コード例 #5
0
 def test_three_three_of_a_kinds_natural_on_two_three_hand(self):
     """Test three natural three of a kinds on the two three of a kind hand."""
     self.game.hand.add(three_of_a_kind(3))
     self.game.hand.add(three_of_a_kind(4))
     self.game.hand.add(three_of_a_kind(5))
     self.assertTrue(
         VictoryConditions.two_three_of_a_kind(self.game.hand.cards,
                                               self.game.victory_cards))
コード例 #6
0
 def test_two_three_of_a_kind_non_match(self):
     """Test hands that do not satisfy the victory condition of two three of a kinds."""
     mix = [
         Card('3', 'clubs'),
         Card('4', 'diamonds'),
         Card('5', 'hearts'),
         Card('6', 'spades')
     ]
     self.game.hand.add(mix)
     self.assertFalse(
         VictoryConditions.two_three_of_a_kind(self.game.hand.cards,
                                               self.game.victory_cards))
コード例 #7
0
    def test_auto_select_down_cards_two_threes(self):
        # Round 1: 2 x 3 of a kind
        threes = [
            Card('3', 'clubs'),
            Card('3', 'diamonds'),
            Card('3', 'hearts')
        ]
        self.game.hand.add(threes)
        fours = [
            Card('4', 'clubs'),
            Card('4', 'diamonds'),
            Card('4', 'hearts')
        ]
        self.game.hand.add(fours)

        self.assertEqual(Stack(), self.game.down_cards)
        self.assertEqual(self.threes_and_fours_hand, self.game.hand)
        VictoryConditions.two_three_of_a_kind(self.game.hand.cards,
                                              self.game.victory_cards)
        auto_select_down_cards(self.game.hand, self.game.victory_cards,
                               self.game.down_cards)

        self.assertEqual(self.threes_and_fours_hand, self.game.down_cards)
        self.assertEqual(Stack(), self.game.hand)
コード例 #8
0
 def test_two_three_of_a_kind_two_wild(self):
     """Test two wild three of a kinds with deuces."""
     self.game.hand.add(wild_three_of_a_kind(3))
     self.game.hand.add(wild_three_of_a_kind(4))
     self.assertTrue(
         VictoryConditions.two_three_of_a_kind(self.game.hand.cards,
                                               self.game.victory_cards))
     self.game.go_down()
     self.assertEqual(Stack(), self.game.hand)
     self.assertEqual(
         Stack(cards=deque([
             Card(value='2', suit='Clubs'),
             Card(value='3', suit='Diamonds'),
             Card(value='3', suit='Hearts'),
             Card(value='2', suit='Clubs'),
             Card(value='4', suit='Diamonds'),
             Card(value='4', suit='Hearts')
         ])), self.game.down_cards)
コード例 #9
0
 def test_two_and_three_of_a_kind_overlap(self):
     """Test interesting case - a hand that produced a bug while running the code.
     The bug had to do with overlapping sets of two/three of a kind."""
     overlap_cards = [
         Card('2', 'Spades'),
         Card('4', 'Diamonds'),
         Card('4', 'Hearts'),
         Card('4', 'Spades'),
         Card('6', 'Diamonds'),
         Card('7', 'Hearts'),
         Card('8', 'Spades'),
         Card('9', 'Clubs'),
         Card('10', 'Hearts'),
         Card('Jack', 'Hearts'),
         Card('Ace', 'Hearts'),
     ]
     self.game.hand.add(overlap_cards)
     self.assertFalse(
         VictoryConditions.two_three_of_a_kind(self.game.hand.cards,
                                               self.game.victory_cards))
コード例 #10
0
 def test_two_three_of_a_kind_empty(self):
     self.assertFalse(
         VictoryConditions.two_three_of_a_kind(self.game.hand.cards,
                                               self.game.victory_cards))