Beispiel #1
0
    def test_convert_to_hands_should_return_array_of_hands_with_cards(self):
        card1 = Card(DeckSuite.HEARTS, DeckValue.EIGHT)
        card2 = Card(DeckSuite.TILES, DeckValue.TEN)
        card3 = Card(DeckSuite.PIKES, DeckValue.ACE)
        hand1 = Hand(card1, card2, card3)

        card4 = Card(DeckSuite.PIKES, DeckValue.JACK)
        card5 = Card(DeckSuite.HEARTS, DeckValue.QUEEN)
        card6 = Card(DeckSuite.CLOVERS, DeckValue.KING)
        hand2 = Hand(card4, card5, card6)

        actual = convert_to_hands("H8 T10 PA, PJ HQ CK")
        self.assertListEqual([hand1, hand2], actual)
Beispiel #2
0
    def test_select_strongest_hand_should_return_one_pair(self):
        card1 = Card(DeckSuite.CLOVERS, DeckValue.JACK)
        card2 = Card(DeckSuite.PIKES, DeckValue.JACK)
        card3 = Card(DeckSuite.HEARTS, DeckValue.QUEEN)
        card4 = Card(DeckSuite.TILES, DeckValue.THREE)
        card5 = Card(DeckSuite.PIKES, DeckValue.ACE)
        hand1 = Hand(card1, card2, card3, card4, card5)

        card6 = Card(DeckSuite.CLOVERS, DeckValue.JACK)
        card7 = Card(DeckSuite.PIKES, DeckValue.TWO)
        card8 = Card(DeckSuite.HEARTS, DeckValue.QUEEN)
        card9 = Card(DeckSuite.TILES, DeckValue.THREE)
        card10 = Card(DeckSuite.PIKES, DeckValue.ACE)
        hand2 = Hand(card6, card7, card8, card9, card10)

        self.assertEqual(hand1, select_strongest_hand(hand1, hand2))
Beispiel #3
0
    def test_convert_to_hand_should_convert_string_to_hand(self):
        card1 = Card(DeckSuite.HEARTS, DeckValue.EIGHT)
        card2 = Card(DeckSuite.TILES, DeckValue.TEN)
        card3 = Card(DeckSuite.PIKES, DeckValue.ACE)
        hand = Hand(card1, card2, card3)

        self.assertEqual(hand, convert_to_hand("H8 T10 PA"))
Beispiel #4
0
def convert_to_hand(seq: str) -> Hand:
    return Hand(*map(convert_to_card, seq.split()))