Esempio n. 1
0
 def test_four_of_a_kind(self):
     result = Poker.get_winning_combination(
         ['01S', '01C', '01H', '01D', '05S'])
     self.assertEqual(result, "Four of a kind!")
     result = Poker.get_winning_combination(
         ['01S', '05C', '05H', '05D', '05S'])
     self.assertEqual(result, "Four of a kind!")
Esempio n. 2
0
 def test_full_house(self):
     result = Poker.get_winning_combination(
         ['01S', '01C', '01H', '03D', '03S'])
     self.assertEqual(result, "Full House!")
     result = Poker.get_winning_combination(
         ['01S', '01C', '03H', '03D', '03S'])
     self.assertEqual(result, "Full House!")
Esempio n. 3
0
 def test_two_pair(self):
     result = Poker.get_winning_combination(['01D', '01H', '02C', '02S', '03S'])
     self.assertEqual(result, "Two pair!")
     result = Poker.get_winning_combination(['01D', '02H', '02C', '03S', '03H'])
     self.assertEqual(result, "Two pair!")
     result = Poker.get_winning_combination(['01D', '01H', '02C', '03S', '03H'])
     self.assertEqual(result, "Two pair!")
Esempio n. 4
0
 def test_high_card(self):
     result = Poker.get_winning_combination(
         ['01D', '03H', '05C', '07S', '09H'])
     self.assertEqual(result, "High card!")
     result = Poker.get_winning_combination(
         ['02D', '04H', '06C', '08S', '10H'])
     self.assertEqual(result, "High card!")
Esempio n. 5
0
 def test_three_of_a_kind(self):
     result = Poker.get_winning_combination(['01D', '01H', '01C', '04S', '05S'])
     self.assertEqual(result, "Three of a kind!")
     result = Poker.get_winning_combination(['01D', '02H', '02C', '02S', '03S'])
     self.assertEqual(result, "Three of a kind!")
     result = Poker.get_winning_combination(['01D', '02H', '03C', '03S', '03H'])
     self.assertEqual(result, "Three of a kind!")
Esempio n. 6
0
 def test_one_pair(self):
     result = Poker.get_winning_combination(['01D', '01H', '02C', '03S', '04H'])
     self.assertEqual(result, "One pair!")
     result = Poker.get_winning_combination(['01D', '02H', '02C', '03S', '04H'])
     self.assertEqual(result, "One pair!")
     result = Poker.get_winning_combination(['01D', '02H', '03C', '03S', '04H'])
     self.assertEqual(result, "One pair!")
     result = Poker.get_winning_combination(['01D', '02H', '03C', '04S', '04H'])
     self.assertEqual(result, "One pair!")
Esempio n. 7
0
 def test_straight(self):
     result = Poker.get_winning_combination(['01D', '02H', '03C', '04S', '05S'])
     self.assertEqual(result, "Straight!")
     result = Poker.get_winning_combination(['09D', '10H', '11C', '12S', '13S'])
     self.assertEqual(result, "Straight!")
     result = Poker.get_winning_combination(['04D', '05H', '06C', '07S', '08S'])
     self.assertEqual(result, "Straight!")
     result = Poker.get_winning_combination(['01D', '10H', '11C', '12S', '13S'])
     self.assertEqual(result, "Straight!")
Esempio n. 8
0
 def test_flush(self):
     result = Poker.get_winning_combination(['01S', '03S', '05S', '07S', '09S'])
     self.assertEqual(result, "Flush!")
     result = Poker.get_winning_combination(['01C', '03C', '05C', '07C', '09C'])
     self.assertEqual(result, "Flush!")
     result = Poker.get_winning_combination(['01H', '03H', '05H', '07H', '09H'])
     self.assertEqual(result, "Flush!")
     result = Poker.get_winning_combination(['01D', '03D', '05D', '07D', '09D'])
     self.assertEqual(result, "Flush!")
Esempio n. 9
0
 def test_straight_flush_card(self):
     result = Poker.get_winning_combination(['01S', '02S', '03S', '04S', '05S'])
     self.assertEqual(result, "Straight Flush!")
     result = Poker.get_winning_combination(['06C', '07C', '08C', '09C', '10C'])
     self.assertEqual(result, "Straight Flush!")
     result = Poker.get_winning_combination(['09H', '10H', '11H', '12H', '13H'])
     self.assertEqual(result, "Straight Flush!")
     result = Poker.get_winning_combination(['07D', '08D', '09D', '10D', '11D'])
     self.assertEqual(result, "Straight Flush!")
     result = Poker.get_winning_combination(['01H', '10H', '11H', '12H', '13H'])
     self.assertEqual(result, "Straight Flush!")
Esempio n. 10
0
def poker_game():
    print("Welcome to Poker Game!!!\n")
    print("Press 'S' and Enter keys to shuffle card...")
    while True:
        userinput = input()
        if userinput == "S" or userinput == "s":
            b = Poker.shuffle_cards()
            deckID = b
            break
        else:
            print("Invalid input")

    drawnumber = 0
    print("Press 'D' to draw cards\nPress 'X' to exit")
    while True:
        userinput = input()
        if userinput == "D" or userinput == "d":
            draw_and_lay(deckID)
            drawnumber = drawnumber + 1
        elif userinput == "X" or userinput == "x":
            print("Thank you! Goodbye!")
            exit()
        else:
            print("Invalid input!")

        if drawnumber == 10:
            print(
                "Maximum number of draw cards for a deck has been reached...exiting..."
            )
            break
        else:
            print("Press 'D' to draw cards\nPress 'X' to exit")
Esempio n. 11
0
def draw_and_lay(deckID):
    c = Poker.draw_cards(deckID)
    code = Poker.json_extract(c, "code")
    value = Poker.json_extract(c, "value")
    suit = Poker.json_extract(c, "suit")

    Poker.show_card_on_hand(value, suit)
    remapped = Poker.sort_cards(code)

    result = Poker.get_winning_combination(remapped)
    print("Highest-scoring hand is: {result}\n")