Texas Hold'em
Four kinds of color cards from each suit AK
Functions are as follows:
1. shuffle: the 52 cards upset
2. Licensing: After the reshuffle, five cards issued to players
3. Verify player's cards type
Brand type the following points
A. Flush
B. Flush
Junko C.
D. four (7777x)
E. three (777xx)
F. one pair (77xxx)
G. two pairs (7788x)
H. full house (77,788) three with a pair
I. normal licensing (24567)
. 1 Import Random 2 Import Time . 3 . 4 # Create a card . 5 card_list = [] . 6 for I in [ ' A ' , 2,. 3,. 4,. 5,. 6,. 7,. 8,. 9, 10, ' J ' , ' Q ' , ' K ' ]: 7 for J in [ ' spades ' , ' hearts ' , ' block ' , ' plum' ]: . 8 Card = J + STR (I) . 9 card_list.append (Card) 10 . 11 # loading progress animation 12 is FMT = ' {: 3D} [{: <20 is}] ' .format 13 is 14 15 DEF ProgressBar () : 16 for n- in Range (21 is ): . 17 the time.sleep (0.1 ) 18 is Print ( ' \ R & lt ' , FMT (n-*. 5, ' = ' * n-), End = '' ) . 19 20 is 21 is # Shuffle 22 is DEF shuffle (): 23 is random.shuffle (card_list) 24 ProgressBar () 25 Print ( ' \ n- ' + ' shuffled complete ' ) 26 is Print (card_list) 27 28 29 # licensing 30 DEF Deal () : 31 is Print ( ' sent you cards is: ' ) 32 the time.sleep (. 1 ) 33 is Print (card_list [0:. 5 ]) 34 is the time.sleep (. 1) 35 36 37 [ # Analyzing card 38 is DEF Showdown (): 39 Color = [] 40 size = [] 41 is # extracted five card suit 42 is for K in Range (. 1,. 6 ): 43 is color.append (STR (card_list [K -. 1] [0: 2 ])) 44 is # extracted five cards size 45 for H in Range (. 1,. 6 ): 46 is size5 = STR (card_list [H -. 1] [2: len (card_list [H -. 1 ])]) 47 IF size5 == " J": 48 size5 = 11 49 elif size5 == "Q": 50 size5 = 12 51 elif size5 == "K": 52 size5 = 13 53 elif size5 == "A": 54 size5 = 1 55 size.append(int(size5)) 56 57 size_set = list(set(size)) 58 59 # 判断牌 60 while color[0] == color[1] == color[2] == color[3] == color[4]: 61 if max(size) - min(size) == 4: 62 print("同花顺") 63 break 64 print('同花') 65 break 66 else: 67 if size == list(set(size)) and max(size) - min(size) == 4: 68 print('顺子') 69 elif len(size) - 1 == len(size_set): 70 print('一对') 71 elif len(size) - 2 == len(size_set): 72 for a in range(0, 5): 73 for b in range(0, 3): 74 if size[a] == size_set[b]: 75 size[a] = 0 76 size_set[b] = 0 77 last = [x for x in size if x != 0] 78 if last[0] == last[1]: 79 print('三条') 80 else: 81 print('两对') 82 elif len(size) - 3 == len(size_set): 83 for a in range(0, 5): 84 for b in range(0, 2): 85 if size[a] == size_set[b]: 86 size[a] = 0 87 size_set[b] = 0 88 Last = [X for X in size IF ! X = 0] 89 IF Last [0] == Last [. 1] == Last [2 ]: 90 Print ( ' four ' ) 91 is the else : 92 Print ( ' full house ' ) 93 the else : 94 Print ( ' normal license ' ) 95 96 97 IF the __name__ == " __main__ " : 98 # Preparation 99 Print ( ' here have a card: ' ) 100 the time.sleep (. 1 ) 101 Print (card_list) 102 the time.sleep (. 1 ) 103 Print ( ' start shuffling ' ) 104 105 # shuffling 106 shuffle () 107 108 # licensing 109 Deal () 110 111 # light card 112 Showdown ()