标签:code end enumerate init and div port index random
见代码
1 import random 2 3 4 class Card: 5 def __init__(self, color, style, value): 6 self.color = color 7 self.style = style 8 self.value = value 9 10 11 class Cards: 12 13 def __init__(self): 14 self.card_list = [] 15 self.card_style = [‘2‘, ‘3‘, ‘4‘, ‘5‘, ‘6‘, ‘7‘, ‘8‘, ‘9‘, ‘10‘, ‘J‘, ‘Q‘, ‘K‘, ‘A‘] 16 self.card_3 = [] 17 18 def group(self): 19 for i in "????": 20 for index, j in enumerate(self.card_style): 21 self.card_list.append(Card(i, j, index)) 22 23 def send(self): 24 for t in range(3): 25 index_3 = (random.randint(0, len(self.card_list))-1) 26 self.card_3.append(self.card_list[index_3]) 27 del self.card_list[index_3] 28 self.card_3.sort(key=lambda v: v.value) 29 for u in self.card_3: 30 print(u.color+u.style, end=‘ ‘) 31 32 if self.card_3[0].value == self.card_3[1].value and self.card_3[1].value == self.card_3[2].value: 33 print("-三条") 34 elif self.card_3[0].value == self.card_3[1].value or self.card_3[1].value == self.card_3[2].value or self.card_3[0].value == self.card_3[2].value: 35 print("-二条") 36 elif self.card_3[0].value+1 == self.card_3[1].value == self.card_3[2].value-1 and self.card_3[0].color == self.card_3[1].color == self.card_3[2].color: 37 print("-同花顺") 38 elif self.card_3[0].color == self.card_3[1].color == self.card_3[2].color: 39 print("-同花") 40 elif self.card_3[0].value+1 == self.card_3[1].value == self.card_3[2].value-1: 41 print("-顺子") 42 else: 43 print("-杂牌") 44 45 46 c = Cards() 47 c.group() 48 c.send()
标签:code end enumerate init and div port index random
原文地址:https://www.cnblogs.com/tttzqf/p/9346450.html