Example #1
0
 def test_straight_flush_to_straight_flush_comparison(self):
     player = Player("player", ManualActionCollector())
     player2 = Player("Player2", ManualActionCollector())
     suit = Suit.DIAMONDS
     suit1 = Suit.CLUBS
     hand1 = [
         Card(Number.THREE, suit1),
         Card(Number.FOUR, suit1),
         Card(Number.FIVE, suit1),
         Card(Number.SIX, suit1),
         Card(Number.SEVEN, suit1)
     ]
     hand2 = [
         Card(Number.TWO, suit),
         Card(Number.THREE, suit),
         Card(Number.FOUR, suit),
         Card(Number.FIVE, suit),
         Card(Number.SIX, suit)
     ]
     round_result = RoundResult(
         [HandResult(hand1, player),
          HandResult(hand2, player2)])
     winning_hand_result = round_result.find_winning_hands()[0]
     winning_hand = winning_hand_result.cards
     self.assertTrue(set(hand1).issubset(winning_hand))
     self.assertEqual(player, winning_hand_result.player,
                      "Wrong Winning Player")
Example #2
0
 def test_flush_check(self):
     suit = Suit.DIAMONDS
     card = Card(Number.ACE, suit)
     card1 = Card(Number.TWO, suit)
     card2 = Card(Number.TEN, suit)
     card3 = Card(Number.KING, suit)
     card4 = Card(Number.JACK, suit)
     flush = [card, card1, card2, card3, card4]
     flush_result = HandResult(flush)
     self.assertTrue(flush_result.hand_type == HandType.FLUSH,
                     "Expected Flush")
Example #3
0
 def test_two_pair(self):
     suit = Suit.DIAMONDS
     suit1 = Suit.CLUBS
     card = Card(Number.QUEEN, suit)
     card1 = Card(Number.TEN, suit)
     card2 = Card(Number.QUEEN, suit1)
     card3 = Card(Number.TEN, suit1)
     card4 = Card(Number.JACK, suit1)
     two_pair = [card, card1, card2, card3, card4]
     two_pair_result = HandResult(two_pair)
     self.assertTrue(two_pair_result.hand_type == HandType.TWO_PAIR,
                     "Expected Two Pair")
Example #4
0
 def test_straight_flush(self):
     suit = Suit.DIAMONDS
     card = Card(Number.JACK, suit)
     card1 = Card(Number.TEN, suit)
     card2 = Card(Number.QUEEN, suit)
     card3 = Card(Number.ACE, suit)
     card4 = Card(Number.KING, suit)
     straight_flush = [card, card1, card2, card3, card4]
     straight_flush_result = HandResult(straight_flush)
     self.assertTrue(
         straight_flush_result.hand_type == HandType.STRAIGHT_FLUSH,
         "Expected Straight Flush")
Example #5
0
 def test_straight_check_ace_end(self):
     suit = Suit.DIAMONDS
     suit1 = Suit.CLUBS
     card = Card(Number.JACK, suit)
     card1 = Card(Number.TEN, suit1)
     card2 = Card(Number.QUEEN, suit)
     card3 = Card(Number.ACE, suit1)
     card4 = Card(Number.KING, suit)
     straight = [card, card1, card2, card3, card4]
     straight_result = HandResult(straight)
     self.assertTrue(straight_result.hand_type == HandType.STRAIGHT,
                     "Expected Straight")
Example #6
0
 def test_straight_check_ace_begin(self):
     suit = Suit.DIAMONDS
     suit1 = Suit.CLUBS
     card = Card(Number.FOUR, suit)
     card1 = Card(Number.TWO, suit1)
     card2 = Card(Number.THREE, suit)
     card3 = Card(Number.ACE, suit1)
     card4 = Card(Number.FIVE, suit)
     straight = [card, card1, card2, card3, card4]
     straight_result = HandResult(straight)
     self.assertTrue(straight_result.hand_type == HandType.STRAIGHT,
                     "Expected Straight")
Example #7
0
 def test_four_of_a_kind(self):
     suit = Suit.DIAMONDS
     suit1 = Suit.CLUBS
     card = Card(Number.TEN, Suit.SPADES)
     card1 = Card(Number.TEN, suit)
     card2 = Card(Number.TEN, suit1)
     card3 = Card(Number.THREE, suit1)
     card4 = Card(Number.TEN, Suit.HEARTS)
     four_of_a_kind = [card, card1, card2, card3, card4]
     four_of_a_kind_result = HandResult(four_of_a_kind)
     self.assertTrue(four_of_a_kind_result.hand_type == HandType.QUADS,
                     "Expected Quads")
Example #8
0
 def test_full_house(self):
     suit = Suit.DIAMONDS
     suit1 = Suit.CLUBS
     card = Card(Number.THREE, suit)
     card1 = Card(Number.TEN, suit)
     card2 = Card(Number.TEN, suit1)
     card3 = Card(Number.THREE, suit1)
     card4 = Card(Number.TEN, Suit.HEARTS)
     full_house = [card, card1, card2, card3, card4]
     full_house_result = HandResult(full_house)
     self.assertTrue(full_house_result.hand_type == HandType.FULL_HOUSE,
                     "Expected Full House")
Example #9
0
 def test_high_card(self):
     suit = Suit.DIAMONDS
     suit1 = Suit.CLUBS
     card = Card(Number.QUEEN, suit)
     card1 = Card(Number.TEN, suit)
     card2 = Card(Number.FIVE, suit1)
     card3 = Card(Number.THREE, suit1)
     card4 = Card(Number.JACK, suit1)
     high_card = [card, card1, card2, card3, card4]
     high_card_result = HandResult(high_card)
     self.assertTrue(high_card_result.hand_type == HandType.HIGH_CARD,
                     "Expected High Card")
Example #10
0
 def test_three_of_a_kind(self):
     suit = Suit.DIAMONDS
     suit1 = Suit.CLUBS
     three_of_a_kind = [
         Card(Number.ACE, suit),
         Card(Number.ACE, suit1),
         Card(Number.ACE, Suit.SPADES),
         Card(Number.THREE, suit),
         Card(Number.TWO, suit1)
     ]
     three_of_a_kind_result = HandResult(three_of_a_kind)
     self.assertTrue(three_of_a_kind_result.hand_type == HandType.TRIPS,
                     "Expected Trips")
Example #11
0
 def test_pair_two_pair_comparison(self):
     player = Player("player", ManualActionCollector())
     player2 = Player("Player2", ManualActionCollector())
     suit = Suit.DIAMONDS
     suit1 = Suit.CLUBS
     hand1 = [
         Card(Number.TWO, suit),
         Card(Number.TWO, suit1),
         Card(Number.THREE, suit),
         Card(Number.THREE, suit1),
         Card(Number.FOUR, suit1)
     ]
     hand2 = [
         Card(Number.ACE, suit),
         Card(Number.ACE, suit1),
         Card(Number.KING, Suit.CLUBS),
         Card(Number.QUEEN, suit),
         Card(Number.JACK, suit1)
     ]
     round_result = RoundResult(
         [HandResult(hand1, player),
          HandResult(hand2, player2)])
     winning_hand = round_result.find_winning_hands()[0].cards
     self.assertTrue(set(hand1).issubset(winning_hand))
Example #12
0
 def test_quads_to_quads_comparison(self):
     player = Player("player", ManualActionCollector())
     player2 = Player("Player2", ManualActionCollector())
     suit = Suit.DIAMONDS
     suit1 = Suit.CLUBS
     hand1 = [
         Card(Number.THREE, suit1),
         Card(Number.THREE, Suit.HEARTS),
         Card(Number.THREE, suit),
         Card(Number.THREE, Suit.SPADES),
         Card(Number.KING, suit1)
     ]
     hand2 = [
         Card(Number.TWO, suit1),
         Card(Number.TWO, Suit.HEARTS),
         Card(Number.TWO, suit),
         Card(Number.TWO, Suit.SPADES),
         Card(Number.KING, suit)
     ]
     round_result = RoundResult(
         [HandResult(hand1, player),
          HandResult(hand2, player2)])
     winning_hand = round_result.find_winning_hands()[0].cards
     self.assertTrue(set(hand1).issubset(winning_hand))
Example #13
0
 def test_straight_to_flush_comparison(self):
     player = Player("player", ManualActionCollector())
     player2 = Player("Player2", ManualActionCollector())
     suit = Suit.DIAMONDS
     suit1 = Suit.CLUBS
     hand1 = [
         Card(Number.TWO, suit),
         Card(Number.NINE, suit),
         Card(Number.FOUR, suit),
         Card(Number.FIVE, suit),
         Card(Number.SIX, suit)
     ]
     hand2 = [
         Card(Number.ACE, Suit.SPADES),
         Card(Number.KING, suit1),
         Card(Number.QUEEN, Suit.SPADES),
         Card(Number.JACK, Suit.HEARTS),
         Card(Number.TEN, suit1)
     ]
     round_result = RoundResult(
         [HandResult(hand1, player),
          HandResult(hand2, player2)])
     winning_hand = round_result.find_winning_hands()[0].cards
     self.assertTrue(set(hand1).issubset(winning_hand))
Example #14
0
    def declare_winner(self):
        hands = []
        for seat in self.table.seats:
            if not seat.is_free:
                hands.append(HandResult(seat.player.hand, seat.player))
        round_result = RoundResult(hands)
        winning_hands = round_result.find_winning_hands()

        for seat in self.table.seats:
            if not seat.is_free:
                seat.player.tell_result(round_result)

        print("Round Winner(s)!: ")
        for winning_hand in winning_hands:
            print(winning_hand.player.name + " " + str(winning_hand.hand_type))