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


Python Deck.deal_card方法代码示例

本文整理汇总了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()
开发者ID:melorca,项目名称:blackjack,代码行数:26,代码来源:blackjack.py


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