本文整理汇总了Python中card.Card.new方法的典型用法代码示例。如果您正苦于以下问题:Python Card.new方法的具体用法?Python Card.new怎么用?Python Card.new使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类card.Card
的用法示例。
在下文中一共展示了Card.new方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _initiate_opening_hands
# 需要导入模块: from card import Card [as 别名]
# 或者: from card.Card import new [as 别名]
def _initiate_opening_hands(self):
for rank in Card.STR_RANKS:
for suit,val in Card.CHAR_SUIT_TO_INT_SUIT.items():
John._FULL_DECK.append(Card.new(rank + suit))
for combo in itertools.combinations(John._FULL_DECK, 2):
John._ALL_HOLE_CARDS.append(combo)
cards = Card.int_to_str(combo[0]) + Card.int_to_str(combo[1])
c1_rank, c1_suit, c2_rank, c2_suit = cards
# Check for pairs
if c1_rank == c2_rank:
for rank in Card.STR_RANKS:
if c1_rank == rank:
if rank not in John._PAIRS:
John._PAIRS[rank] = set()
John._PAIRS[rank].add(combo)
else:
for rank_pair in itertools.combinations(Card.STR_RANKS[::-1], 2):
ranks = rank_pair[0] + rank_pair[1]
if rank_pair == (c2_rank, c1_rank) or rank_pair == (c1_rank, c2_rank):
if c1_suit == c2_suit: # Suited!
if ranks not in John._SUITED:
John._SUITED[ranks] = set()
John._SUITED[ranks].add(combo)
if Card.STR_RANKS.index(rank_pair[0]) == 1 + Card.STR_RANKS.index(rank_pair[1]):
if ranks not in John._SUITED_CONNECTORS:
John._SUITED_CONNECTORS[ranks] = set()
John._SUITED_CONNECTORS[ranks].add(combo)
# DEBUGGING
# print(ranks, Card.int_to_str(combo[0]), Card.int_to_str(combo[1]))
else:
if ranks not in John._UNSUITED:
John._UNSUITED[ranks] = set()
John._UNSUITED[ranks].add(combo)
示例2: GetFullDeck
# 需要导入模块: from card import Card [as 别名]
# 或者: from card.Card import new [as 别名]
def GetFullDeck():
if Deck._FULL_DECK:
return list(Deck._FULL_DECK)
# create the standard 52 card deck
for rank in Card.STR_RANKS:
for suit,val in Card.CHAR_SUIT_TO_INT_SUIT.iteritems():
Deck._FULL_DECK.append(Card.new(rank + suit))
return list(Deck._FULL_DECK)
示例3: draw_specified
# 需要导入模块: from card import Card [as 别名]
# 或者: from card.Card import new [as 别名]
def draw_specified(self, string):
card = Card.new(string)
for i, card_num in enumerate(self.cards):
if card_num == card.real:
return self.cards.pop(i)