本文整理汇总了Python中hand.Hand.sort_rank方法的典型用法代码示例。如果您正苦于以下问题:Python Hand.sort_rank方法的具体用法?Python Hand.sort_rank怎么用?Python Hand.sort_rank使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hand.Hand
的用法示例。
在下文中一共展示了Hand.sort_rank方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from hand import Hand [as 别名]
# 或者: from hand.Hand import sort_rank [as 别名]
#.........这里部分代码省略.........
return (self.pokerHand, self.two_pair(pairs))
elif self.pokerHand == 3:
return (self.pokerHand, self.three_of_kind(most_common))
elif self.pokerHand == 4:
return (self.pokerHand,self.straight(highCardStraight))
elif self.pokerHand == 5:
return (self.pokerHand,self.flush(flush_color))
elif self.pokerHand == 6:
return (self.pokerHand, self.full_haouse(three, pairs))
elif self.pokerHand == 7:
return (self.pokerHand,self.four_kind(most_common))
elif self.pokerHand == 8:
return (self.pokerHand,self.straight_flush(highCardStraight,flush_color))
elif self.pokerHand == 9:
return (self.pokerHand,self.royal_flush(highCardStraight,flush_color))
elif self.pokerHand == -1:
print ("BLAAAAAAAD!!!!!!!")
return (-1,[])
## zwraca kolor karty
def get_card_suit(self,card_rank):
for card in self.cards:
if card.rank == card_rank:
return card.suit
## szuka karty o podanej figurze i kolorze
def search_card_suit(self,card_rank,card_suit):
for card in self.cards:
if card.rank == card_rank and card.suit==card_suit:
return card.suit
## zwraca reke o wysokiej karcie
def high_card(self):
self.hand.sort_rank()
return self.hand.cards[:5]
## zwraca reke o jednej parze
def one_pair(self,pair):
onepair = []
temp=[]
self.hand.sort_rank()
i=0
for card in self.hand.cards:
if card.rank==pair:
onepair.append(card)
elif i<3:
temp.append(card)
i+=1
onepair.extend(temp)
return onepair
## zwraca reke z dwiema parami
def two_pair(self,pairs):
pairs.sort(reverse=True)
pairs = pairs[:2]
twopair= []
temp=[]
self.hand.sort_rank()
i=0
for card in self.hand.cards:
if card.rank in pairs:
twopair.append(card)
elif i<1:
temp.append(card)
i+=1