本文整理汇总了Python中hand.Hand.set_players方法的典型用法代码示例。如果您正苦于以下问题:Python Hand.set_players方法的具体用法?Python Hand.set_players怎么用?Python Hand.set_players使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hand.Hand
的用法示例。
在下文中一共展示了Hand.set_players方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from hand import Hand [as 别名]
# 或者: from hand.Hand import set_players [as 别名]
#.........这里部分代码省略.........
player.player_hand.current_cards.append(the_card)
def split_hand(self, player):
print("\n\t{0} SPLITS THEIR CARDS!\n".format(player.get_name()))
split_hand = player.player_hand.get_current_cards()
second_hand = Player(str(player.get_name() + '- Split Hand'), player.get_bet())
player.player_hand.set_current_cards(split_hand.pop(0))
player.player_hand.current_cards.append(self.deck.draw_card())
second_hand.player_hand.set_current_cards(split_hand.pop())
second_hand.player_hand.current_cards.append(self.deck.draw_card())
return self.evaluate_cards(player)
def double_down(self, player):
player_bet = player.get_bet()
new_bet = player_bet * 2
print("\n{0} DOUBLES DOWN! ... Bet doubled to {1}\n".format(
player.get_name(),
player_bet
))
player.set_bet(player_bet)
player.player_hand.current_cards.append(self.deck.draw_card())
if self.calculate_hand_value(player) > 21:
self.bust(player)
else:
print("Current Hand {0}, Total: {1}".format(
player.player_hand.display_current_hand(),
self.calculate_hand_value(player),
))
self.stay(player)
def bust(self, player):
print("\n\t{0} BUSTS! ... {1}\n".format(
player.get_name(),
self.calculate_hand_value(player)
))
current_players = self.hand.get_players()
current_players.remove(player)
self.hand.set_players(current_players)
return 0
def get_choices(self, player):
cards = player.player_hand.get_current_cards()
count = player.player_hand.times_evaluated
choices = ['(S)tay.','(H)it!']
valid_input = ["s", "h"]
if cards[0].get_face() == cards[1].get_face():
choices.append('(Spl)it')
valid_input.append('spl')
elif int((cards[0].get_value() + cards[1].get_value())) in range(9,12) and count <= 1:
if player.get_current_money() > (player.get_bet() * 2):
choices.append('(D)ouble Down')
valid_input.append('d')
return self.set_choice(player, choices, valid_input)
def set_choice(self, player, choices, valid_input):
player_choice = str(input("Dealer Hand:\n\nCurrent Hand {0}, Total: {1}, What will you do? \n {2} \n > "
.format(
player.player_hand.display_current_hand(),
self.calculate_hand_value(player),
choices
)
)).lower()
choice_made = False
while choice_made == False:
try:
if player_choice == "s" and player_choice in valid_input:
choice_made = True
self.stay(player)
elif player_choice == "h" and player_choice in valid_input:
choice_made = True
self.hit(player)
self.evaluate_cards(player)
elif player_choice == "spl" and player_choice in valid_input:
choice_made = True
self.split_hand(player)
elif player_choice == "d" and player_choice in valid_input:
choice_made = True
self.double_down(player)
else:
print("I Don't Recognize That Input...")
return self.set_choice(player, choices, valid_input)
except ValueError:
print("I Don't Recognize That Input...")
return self.set_choice(player, choices, valid_input)