Exemplo n.º 1
0
 def test_play(self):
     # two pair
     poker = Poker()
     poker.new_game(('S2', 'D2', 'H3', 'C3', 'C5'))
     poker.calculate()
     assert poker.hold_cards_index == [0, 1, 2, 3]
     # 3 kind
     poker.new_game(('S2', 'D2', 'H2', 'D4', 'C5'))
     poker.calculate()
     assert poker.hold_cards_index == [0, 1, 2]
     poker.new_game(('S2', 'D2', 'JOKER', 'D4', 'C5'))
     poker.calculate()
     assert poker.hold_cards_index == [0, 1, 2]
     poker.new_game(('SJ', 'D7', 'S8', 'JOKER', 'HJ'))
     poker.calculate()
     assert poker.hold_cards_index == [0, 3, 4]
     # straight
     poker.new_game(('S2', 'D3', 'H6', 'D4', 'C5'))
     poker.calculate()
     assert poker.hold_cards_index == list(range(5))
     poker.new_game(('S2', 'D3', 'HA', 'D4', 'C5'))
     poker.calculate()
     assert poker.hold_cards_index == list(range(5))
     poker.new_game(('ST', 'DQ', 'HA', 'DK', 'CJ'))
     poker.calculate()
     assert poker.hold_cards_index == list(range(5))
     poker.new_game(['S6', 'D2', 'JOKER', 'C4', 'C5'])
     poker.calculate()
     assert poker.hold_cards_index == list(range(5))
     poker.new_game(['SA', 'H3', 'JOKER', 'C4', 'C5'])
     poker.calculate()
     assert poker.hold_cards_index == list(range(5))
     poker.new_game(['SA', 'DJ', 'JOKER', 'CK', 'CT'])
     poker.calculate()
     assert poker.hold_cards_index == list(range(5))
     # flush
     poker.new_game(['S2', 'H2', 'S3', 'H3', 'C3'])
     poker.calculate()
     assert poker.hold_cards_index == list(range(5))
     poker.new_game(['S6', 'S2', 'JOKER', 'S4', 'S5'])
     poker.calculate()
     assert poker.hold_cards_index == list(range(5))
     # full house
     poker.new_game(['S2', 'H2', 'JOKER', 'S3', 'H3'])
     poker.calculate()
     assert poker.hold_cards_index == list(range(5))
     poker.new_game(['D3', 'H2', 'JOKER', 'S3', 'D2'])
     poker.calculate()
     assert poker.hold_cards_index == list(range(5))
     # 4 kind
     poker.new_game(['S5', 'D5', 'H5', 'JOKER', 'C3'])
     poker.calculate()
     assert poker.hold_cards_index == [0, 1, 2, 3]
     poker.new_game(['S2', 'H2', 'JOKER', 'S3', 'D2'])
     poker.calculate()
     assert poker.hold_cards_index == [0, 1, 2, 4]
     # straight flush
     poker.new_game(['SA', 'S2', 'JOKER', 'S3', 'S4'])
     poker.calculate()
     assert poker.hold_cards_index == list(range(5))
     # 5 kind
     poker.new_game(['S5', 'D5', 'H5', 'C5', 'JOKER'])
     poker.calculate()
     assert poker.hold_cards_index == list(range(5))
     # joker
     poker.new_game(['S5', 'D6', 'HA', 'C8', 'JOKER'])
     poker.calculate()
     assert poker.hold_cards_index == [4]
     # one pair
     poker.new_game(['S5', 'D6', 'HA', 'C8', 'D5'])
     poker.calculate()
     assert poker.hold_cards_index == [0, 4]
     poker.new_game(('H5', 'D6', 'C7', 'C5', 'S3'))
     poker.calculate()
     assert poker.hold_cards_index == [0, 3]
     # 4 kind suits
     poker.new_game(['S5', 'S6', 'SA', 'S8', 'D9'])
     poker.calculate()
     assert poker.hold_cards_index == [0, 1, 2, 3]
     # no pair
     poker.new_game(['S5', 'D6', 'HA', 'C8', 'CK'])
     poker.calculate()
     n = len(poker.hold_cards_index)
     assert n == 1 or n == 0
Exemplo n.º 2
0
 def test_play(self):
     # two pair
     poker = Poker()
     poker.new_game(("S2", "D2", "H3", "C3", "C5"))
     poker.calculate()
     assert poker.hold_cards_index == [0, 1, 2, 3]
     # 3 kind
     poker.new_game(("S2", "D2", "H2", "D4", "C5"))
     poker.calculate()
     assert poker.hold_cards_index == [0, 1, 2]
     poker.new_game(("S2", "D2", "JOKER", "D4", "C5"))
     poker.calculate()
     assert poker.hold_cards_index == [0, 1, 2]
     poker.new_game(("SJ", "D7", "S8", "JOKER", "HJ"))
     poker.calculate()
     assert poker.hold_cards_index == [0, 3, 4]
     # straight
     poker.new_game(("S2", "D3", "H6", "D4", "C5"))
     poker.calculate()
     assert poker.hold_cards_index == list(range(5))
     poker.new_game(("S2", "D3", "HA", "D4", "C5"))
     poker.calculate()
     assert poker.hold_cards_index == list(range(5))
     poker.new_game(("ST", "DQ", "HA", "DK", "CJ"))
     poker.calculate()
     assert poker.hold_cards_index == list(range(5))
     poker.new_game(["S6", "D2", "JOKER", "C4", "C5"])
     poker.calculate()
     assert poker.hold_cards_index == list(range(5))
     poker.new_game(["SA", "H3", "JOKER", "C4", "C5"])
     poker.calculate()
     assert poker.hold_cards_index == list(range(5))
     poker.new_game(["SA", "DJ", "JOKER", "CK", "CT"])
     poker.calculate()
     assert poker.hold_cards_index == list(range(5))
     # flush
     poker.new_game(["S6", "S2", "S8", "S4", "S5"])
     poker.calculate()
     assert poker.hold_cards_index == list(range(5))
     poker.new_game(["S6", "S2", "JOKER", "S4", "S5"])
     poker.calculate()
     assert poker.hold_cards_index == list(range(5))
     # full house
     poker.new_game(["S2", "H2", "JOKER", "S3", "H3"])
     poker.calculate()
     assert poker.hold_cards_index == list(range(5))
     poker.new_game(["D3", "H2", "JOKER", "S3", "D2"])
     poker.calculate()
     assert poker.hold_cards_index == list(range(5))
     poker.new_game(["S2", "H2", "S2", "H3", "C3"])
     poker.calculate()
     assert poker.hold_cards_index == list(range(5))
     # 4 kind
     poker.new_game(["S5", "D5", "H5", "JOKER", "C3"])
     poker.calculate()
     assert poker.hold_cards_index == [0, 1, 2, 3]
     poker.new_game(["S2", "H2", "JOKER", "S3", "D2"])
     poker.calculate()
     assert poker.hold_cards_index == [0, 1, 2, 4]
     # straight flush
     poker.new_game(["SA", "S2", "JOKER", "S3", "S4"])
     poker.calculate()
     assert poker.hold_cards_index == list(range(5))
     # 5 kind
     poker.new_game(["S5", "D5", "H5", "C5", "JOKER"])
     poker.calculate()
     assert poker.hold_cards_index == list(range(5))
     # joker
     poker.new_game(["S5", "D6", "HA", "C8", "JOKER"])
     poker.calculate()
     assert poker.hold_cards_index == [4]
     # one pair
     poker.new_game(["S5", "D6", "HA", "C8", "D5"])
     poker.calculate()
     assert poker.hold_cards_index == [0, 4]
     poker.new_game(("H5", "D6", "C7", "C5", "S3"))
     poker.calculate()
     assert poker.hold_cards_index == [0, 3]
     # 4 kind suits
     poker.new_game(["S5", "S6", "SA", "S8", "D9"])
     poker.calculate()
     assert poker.hold_cards_index == [0, 1, 2, 3]
     # no pair
     poker.new_game(["S5", "D6", "HA", "C8", "CK"])
     poker.calculate()
     n = len(poker.hold_cards_index)
     assert n == 1 or n == 0