当前位置: 首页>>代码示例>>Python>>正文


Python Deck.cardNamesList方法代码示例

本文整理汇总了Python中Deck.Deck.cardNamesList方法的典型用法代码示例。如果您正苦于以下问题:Python Deck.cardNamesList方法的具体用法?Python Deck.cardNamesList怎么用?Python Deck.cardNamesList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Deck.Deck的用法示例。


在下文中一共展示了Deck.cardNamesList方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from Deck import Deck [as 别名]
# 或者: from Deck.Deck import cardNamesList [as 别名]

#.........这里部分代码省略.........
					playerActionList.extend(finalPlayerAction)
						
					if len(playerActionList) < 1:
						playerActionList = [noaction]
						
					playersActions.append(playerActionList)
							
				i = i+1
				j = j+1
				
				if (i >= len(self.players)):
					cont = False
					
			### Make dealer draw or stay
			keepDrawing = True
			while (keepDrawing):
				if verbose:
					print BlackJack.displayDealerCards(self, dealerCards, True) # Show Dealer cards
					
				## Dealer stands on soft 17
				if(BlackJack.sumCards(self, dealerCards) <= 16):
					if verbose:
						print "Dealer draws"
					dealerCards.append(self.deck.drawCard())
				else:
					if verbose:
						print "Dealer stands"
					keepDrawing = False
			
			### Display win or lose and addMoney
			BlackJack.results(self, dealerCards, playerCards, bets, insurancesList)
			
			self.logDF['dealerCards'][self.currentRoundNumber] = str(dealerCards).strip('[]')
			self.logDF['dealerCardsNames'][self.currentRoundNumber] = str(self.deck.cardNamesList(dealerCards)).strip('[]')
			dealerScore = BlackJack.sumCards(self, dealerCards)
			dealerBlackJack = BlackJack.hasBlackJack(self, dealerCards)
			if dealerBlackJack:
				dealerScore = "BJ"
			self.logDF['dealerScore'][self.currentRoundNumber] = dealerScore
			
			## Compute correct amount of money for players who splitted
			k = 0 ## k = index with splitted hands
			for i in range(len(playersBackup)): ## i = index of true number of players
				cardsPlayer = playerCards[i]
				scorePlayer = [BlackJack.sumCards(self, playerCards[i])]
				playerBlackJack = BlackJack.hasBlackJack(self, playerCards[i])
				if playerBlackJack:
					scorePlayer = ["BJ"]
				## When players are given cards that don't call for action
				## (e.g. Black Jack), actionsPlayer can be non existent
				try:
					actionsPlayer = playersActions[i]
				except:
					actionsPlayer = ""
					
				if playersSplit[i]:
					moneyWithSplitResult = self.players[k].money + self.players[k+1].money - playersBackup[i].money
					#~ print "with split result : ", moneyWithSplitResult
					playersBackup[i].money = moneyWithSplitResult
					k = k+1
					cardsPlayer.extend(playerCards[k])
					actionsPlayer.extend(playersActions[k])
					scorePlayer.extend([BlackJack.sumCards(self, playerCards[k])]) ## BJ are not valid on splits
				else:
					playersBackup[i].money = self.players[k].money
					
开发者ID:haroine,项目名称:BlackJack,代码行数:69,代码来源:BlackJack.py


注:本文中的Deck.Deck.cardNamesList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。