本文整理汇总了Python中Deck.deal_card方法的典型用法代码示例。如果您正苦于以下问题:Python Deck.deal_card方法的具体用法?Python Deck.deal_card怎么用?Python Deck.deal_card使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Deck
的用法示例。
在下文中一共展示了Deck.deal_card方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: deal
# 需要导入模块: import Deck [as 别名]
# 或者: from Deck import deal_card [as 别名]
def deal():
"""Generates a new round. Deals a hand to the dealer and player.
Checks if either hand is a BlackJack"""
global outcome, in_play, dealer, player, deck, score, total_games
if total_games != 0:
outcome = ""
if in_play:
outcome = "Player dealed again, lost a point. "
score -= 1
in_play = False
dealer = Hand()
player = Hand()
deck = Deck()
deck.shuffle()
dealer.add_card(deck.deal_card())
dealer.add_card(deck.deal_card())
player.add_card(deck.deal_card())
player.add_card(deck.deal_card())
in_play = True
outcome += "New Game! Hit or Stand?"
if in_play and player.get_value() == 21:
stand()
if in_play and dealer.get_value() == 21:
stand()