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


Python Deck.deck方法代码示例

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


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

示例1: start

# 需要导入模块: import Deck [as 别名]
# 或者: from Deck import deck [as 别名]
def start():

    new_deck1 = copy.deepcopy(Deck.deck())

    new_dealer1 = 0
    new_hand1 = 0
    ace_dealer1 = 0
    ace_hand1 = 0

    print()
    card_d = int(input("What card should the dealer start with? "))
    print()

    card_d = new_deck1[card_d-1]
    print(card_d[0])

    new_dealer1 += card_d[1]

    if card_d[1] == 11:
        ace_dealer1 += 1

    print()
    cards_h = input("What cards should the player start with? ").split(" ")
    card_h = []
    for card in cards_h:
        card_h.append(int(card))
    print()

    card_h0 = new_deck1[card_h[0]-1]
    card_h1 = new_deck1[card_h[1]-1]

    new_deck1.remove(card_d)
    new_deck1.remove(card_h0)
    new_deck1.remove(card_h1)

    new_hand1 += card_h0[1]
    new_hand1 += card_h1[1]

    if card_h0[1] == 11:
        ace_hand1 += 1

    if card_h1[1] == 11:
        ace_hand1 += 1

    print(card_h0[0])
    print(card_h1[0])
    print()
    print("The dealer has", new_dealer1)
    print("You have", new_hand1)
    print()

    return new_deck1, new_dealer1, new_hand1, ace_dealer1, ace_hand1
开发者ID:JesperVines,项目名称:Gy-arbete,代码行数:54,代码来源:Start.py


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