當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。