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


Python Deck.shuffle方法代码示例

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


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

示例1: test_05_shuffle

# 需要导入模块: import Deck [as 别名]
# 或者: from Deck import shuffle [as 别名]
 def test_05_shuffle(self):
     d1 = Deck()
     d2 = Deck()
     d1.shuffle()
     self.assertFalse(same_cards(d1,d2), "deck wasn't shuffled")
     d1.sort()
     self.assertTrue(same_cards(d1,d2), "deck wasn't sorted")
开发者ID:ian-garrett,项目名称:CIS_211,代码行数:9,代码来源:test_Decks.py

示例2: dealSomeHands

# 需要导入模块: import Deck [as 别名]
# 或者: from Deck import shuffle [as 别名]
def dealSomeHands():
    # Generate the initial deck and shuffle it.
    d = Deck()
    d.shuffle()

    # Find out from the user how many hands to generate.
    while True:
        # Run this while loop until we get a legal (positive
        # integer) answer from the user.
        nStr = input("How many hands should I deal? ")
        if not nStr.isdigit():
            print (" Positive number required. Try again!")
        else:
            n = int( nStr ); break
            
        # Generate n hands.
    for i in range( n ):
        # If there are not enough cards left in the deck
        # to deal a hand, generate and shuffle a new deck.
        if ( len(d) < 5 ):
            print("\nDealing a new deck.")
            d = Deck()
            d.shuffle()
            
        # Generate a new hand, print it, and evaluate it.
        h = Hand(d)
        print("\n\tHand drawn (", i + 1, "): ", sep="")
        print(h)
        print( "\t   -", h.evaluateHand())
开发者ID:Taylor4484,项目名称:CS-313E---Elements-of-Software-Design,代码行数:31,代码来源:Poker.py

示例3: __init__

# 需要导入模块: import Deck [as 别名]
# 或者: from Deck import shuffle [as 别名]
class Dealer:
    def __init__(self):
        self.deck = Deck(False)

    def shuffleDeck(self):
        self.deck = Deck(False)
        self.deck.shuffle()
        self.deck.shuffle()
        self.deck.shuffle()
        self.deck.shuffle()
开发者ID:DpinkyandDbrain,项目名称:PokerJunctionServer,代码行数:12,代码来源:Dealer.py

示例4: main

# 需要导入模块: import Deck [as 别名]
# 或者: from Deck import shuffle [as 别名]
def main():
	size = int(sys.argv[1])
	me = Deck(range(1,size+1))
	print("initial state:")
	me.debugprint()
	for i in range(15):
		me.shuffle()
		print("---")
		print(" below is the", i,"th iteration:")
		me.debugprint()
开发者ID:DalikarFT,项目名称:CFVOP,代码行数:12,代码来源:deckTest.py

示例5: test_shuffle

# 需要导入模块: import Deck [as 别名]
# 或者: from Deck import shuffle [as 别名]
def test_shuffle():
	newdeck = Deck()
	beforeshuffle = []
	for card in newdeck:
		beforeshuffle.append(card)
	newdeck.shuffle()

	sameplace = 0
	index = 0
	for card in newdeck:
		if card.card_value == beforeshuffle[index].card_value:
			sameplace += 1
		index += 1
	assert sameplace < newdeck.size/3
开发者ID:caseymacphee,项目名称:deck_of_cards,代码行数:16,代码来源:test_deck.py

示例6: test_deal

# 需要导入模块: import Deck [as 别名]
# 或者: from Deck import shuffle [as 别名]
def test_deal():
	newdeck = Deck()
	newdeck.shuffle()
	first_player = []
	second_player = []
	third_player = []
	card_per_hand = 7
	for card in range(card_per_hand):
		first_player.append(newdeck.deal())
		second_player.append(newdeck.deal())
		third_player.append(newdeck.deal())
	assert len(first_player) == 7
	assert len(second_player) == 7
	assert len(third_player) == 7
开发者ID:caseymacphee,项目名称:deck_of_cards,代码行数:16,代码来源:test_deck.py

示例7: deal

# 需要导入模块: import Deck [as 别名]
# 或者: from Deck import shuffle [as 别名]
def deal():
	'''
	resets game, deals 4 cards face down, flips 3 to begin (1 dealer, 2 player)
	'''
	global dealer_hand_display
	global player_hand_display

	global dealer_hand
	global player_hand
	global global_deck

	# resets global variables and shuffles deck, creating new game
	dealer_hand = []
	player_hand = []
	global_deck = Deck()
	global_deck.shuffle()

	current_bet.config(state=NORMAL)
	
	for i in range(2):
		dealer_hand.append(global_deck.nextcard())
		player_hand.append(global_deck.nextcard())
	for i in range(2,6):
		dealer_hand_display[i].display('blank')
		player_hand_display[i].display('blank')
	player_hand_display[0].display('front', player_hand[0].ID)
	player_hand_display[1].display('front', player_hand[1].ID)
	dealer_hand_display[0].display('back')
	dealer_hand_display[1].display('front', dealer_hand[1].ID)

	# extra credit, checks for "Blackjack"
	if (check_blackjack(dealer_hand)) or (check_blackjack(player_hand)):
		dealer_hand_display[0].display('front', dealer_hand[0].ID)
		if (check_blackjack(dealer_hand)):
			win_process('dealer')
		elif (check_blackjack(player_hand)):
			win_process('player')
开发者ID:ian-garrett,项目名称:CIS_211,代码行数:39,代码来源:blackjack.py

示例8: deal

# 需要导入模块: import Deck [as 别名]
# 或者: from Deck import shuffle [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

示例9: main

# 需要导入模块: import Deck [as 别名]
# 或者: from Deck import shuffle [as 别名]
def main():
    '''Main program for the blackjack game'''

    #Creates the GUI and the deck object
    setupGUI()
    deck = Deck()

    #List of the card objects
    listUser = []
    listDealer = []

    #List the the card values
    userTotal = []
    dealerTotal = []

    counter = 0

    pt = win.getMouse()

    while not quitt.clicked(pt):

        if start.clicked(pt):

            #Shuffles the deck
            deck.shuffle()

            #Gets the users first 2 cards and draws them to the window
            uCard1 = deck.dealCard()
            uCard1.draw(win,userCard1.getAnchor())

            uCard2 = deck.dealCard()
            uCard2.draw(win,userCard2.getAnchor())

            #Adds the 2 cards to the users list of cards
            listUser.append(uCard1)
            listUser.append(uCard2)

            #Gets the dealers 2 cards and draws one of them to the window
            dCard1 = deck.dealCard()
            
            dCard2 = deck.dealCard()
            dCard2.draw(win,dealerCard2.getAnchor())

            #Adds the 2 cards to the dealers list of cards
            listDealer.append(dCard1)
            listDealer.append(dCard2)

            #Gets the values of the users cards and appends them to the list
            num = addTotal(uCard1)
            userTotal.append(num)

            num = addTotal(uCard2)
            userTotal.append(num)

            message.setText("Press Hit Me or Stand")

            start.deactivate()
            stand.activate()
            hitMe.activate()

            #Checks the users total to see if they have 21
            userTotal = winLose(userTotal)

        if hitMe.clicked(pt):

            #Deals a card to the user and adds it to the list
            listUser.append(deck.dealCard())

            #Draws the new card to the window
            x = userCard2.getAnchor().getX()
            y = userCard2.getAnchor().getY()
            listUser[counter+2].draw(win,Point(x+20*(counter+1),y))

            #Adds the value of the card to the list and checks to see if the
            #user has got 21 or over 21
            num = addTotal(listUser[counter+2])
            userTotal.append(num)

            userTotal = winLose(userTotal)
            
            counter = counter + 1

        if stand.clicked(pt):
            
            stand.deactivate()
            hitMe.deactivate()
            playAgain.activate()

            #Reveals the dealers cards
            dCard2.undraw()
            dCard1.draw(win,dealerCard1.getAnchor())
            dCard2.draw(win,dealerCard2.getAnchor())

            #Gets the value of the dealers cards and adds them to the list
            num2 = addTotal(dCard1)
            dealerTotal.append(num2)

            num2 = addTotal(dCard2)
            dealerTotal.append(num2)
            
#.........这里部分代码省略.........
开发者ID:Frank-K,项目名称:Blackjack_Game,代码行数:103,代码来源:Blackjack.py

示例10: Engine

# 需要导入模块: import Deck [as 别名]
# 或者: from Deck import shuffle [as 别名]
class Engine(object):
    
    #Creates a dictionary to map each type of hand to a corresponding score
	hand_values = {
	    'Pair' : 1, 'Two Pair' : 2, 'Three of a Kind' : 3,
            'Straight' : 4, 'Flush' : 5, 'Full House' : 6,
            'Four of a Kind' : 7, 'Straight Flush' : 8,
            'Royal Flush' : 9, 'High Card' : 0 }
	
    #Builds the deck and adds each player's hand to a list
	def __init__(self, comp_players):
		

		self.comp_players = comp_players

        #Create a list of Hand objects, one for each player
		self.hands = []

		print "Computer Players: ", self.comp_players
		
        #Build and shuffle the deck
		self.poker_deck = Deck()
		self.poker_deck.shuffle()
		
        #Add the player's Hand to self.hands
		self.hands.append(Hand(self.poker_deck.dealHand()))
		
        #Add one Hand to self.hands for each computer player
		for i in range(comp_players):
			self.hands.append(Hand(self.poker_deck.dealHand()))
	
    #Plays the game by comparing the scores of each player's type of hand
	def play(self):
		    
        #Remove the player's hand from self.hands and determines its score
		player_hand = self.hands.pop(0)
		player_score = Engine.hand_values[player_hand.determineScore()]
		
        #Print out the user's hand and its type
		print "*" * 20
		print "     YOUR HAND     "
		print "*" * 20
		player_hand.__str__()		
		print "*" * 20
		print "HAND: ", player_hand.determineScore()
		print "*" * 20
		
		comp_scores = []
		
        #Add each computer player's score to a list
		for i in range(self.comp_players):
			comp_scores.append(Engine.hand_values[self.hands.pop().determineScore()])
		
        #If any computer player has a better hand, the user loses
        #If the player ties for the best hand, the player ties
        #If the player has the highest scoring hand, the user wins
		canWin = True
		for score in comp_scores:
			if player_score < score:
				return 'You lose!'
			elif player_score == score:
				canWin = False
		
		if canWin:
			return 'You win!'
		else:
			return 'You tied!'
开发者ID:briangillespie,项目名称:poker,代码行数:69,代码来源:Engine.py

示例11: BlackjackFrame

# 需要导入模块: import Deck [as 别名]
# 或者: from Deck import shuffle [as 别名]
class BlackjackFrame(Frame):
    """
    Subclass of Frame, creates a blackjack game.
    """
    
    _player_hand = []
    _dealer_hand = []
    
    _player_move = 0
    _dealer_move = 0
    
    _player_wins = 0
    _dealer_wins = 0
    
    def __init__(self, parent):
        """
        Buttons and card labels initialized.
        """
        
        Frame.__init__(self, parent)
        self.configure(background = 'white')
        
        self._cards = Deck(BlackjackCard)
        self._cards.shuffle()
        self.pack()
        
        CardLabel.load_images()
        
        self._dc1 = CardLabel(self)
        self._dc1.grid(row = 0, column = 0)
        self._dc2 = CardLabel(self)
        self._dc2.grid(row = 0, column = 1)
        self._dc3 = CardLabel(self)
        self._dc3.grid(row = 0, column = 2)
        self._dc4 = CardLabel(self)
        self._dc4.grid(row = 0, column = 3)
        self._dc5 = CardLabel(self)
        self._dc5.grid(row = 0, column = 4)
        self._dc6 = CardLabel(self)
        self._dc6.grid(row = 0, column = 5)
        
        self._pc1 = CardLabel(self)
        self._pc1.grid(row = 1, column = 0)
        self._pc2 = CardLabel(self)
        self._pc2.grid(row = 1, column = 1)
        self._pc3 = CardLabel(self)
        self._pc3.grid(row = 1, column = 2)
        self._pc4 = CardLabel(self)
        self._pc4.grid(row = 1, column = 3)
        self._pc5 = CardLabel(self)
        self._pc5.grid(row = 1, column = 4)
        self._pc6 = CardLabel(self)
        self._pc6.grid(row = 1, column = 5)
        
        self._deal = Button(self, text = 'Deal', command = self.dealcb)
        self._deal.grid(row = 2, column = 0, padx = 10, pady = 10)
        self._hit = Button(self, text = 'Hit', command = self.hitcb)
        self._hit.grid(row = 2, column = 2, padx = 10, pady = 10)
        self._stand = Button(self, text = 'Stand', command = self.standcb)
        self._stand.grid(row = 2, column = 4, padx = 10, pady = 10)

        self.dealcb()
        
    def dealcb(self):
        """
        Resets player and dealer hands with 2 cards each from top of deck and sets up starting layout for each hand.
        """
        self._hit.configure(state = ACTIVE)
        self._stand.configure(state = ACTIVE)
        old = self._dealer_hand + self._player_hand
        self._cards.restore(old)

        self._player_hand = self._cards.deal(2)
        self._dealer_hand = self._cards.deal(2)
        self._player_move = 0
        self._dealer_move = 0
        
        self._dc1.display('back')
        self._dc2.display('front', self._dealer_hand[1]._id)
        self._dc3.display('blank')
        self._dc4.display('blank')
        self._dc5.display('blank')
        self._dc6.display('blank')
        
        self._pc1.display('front', self._player_hand[0]._id)
        self._pc2.display('front', self._player_hand[1]._id)
        self._pc3.display('blank')
        self._pc4.display('blank')
        self._pc5.display('blank')
        self._pc6.display('blank')
        
        Label(self, text = 'Dealer Wins: ').grid(row = 3, column = 2, padx = 10, pady = 10)
        self.dcount = Label(self, text = self._dealer_wins)
        self.dcount.update_idletasks()
        self.dcount.grid(row = 3, column = 3, padx = 10, pady = 10)
        Label(self, text = 'Player Wins: ').grid(row = 4, column = 2, padx = 10, pady = 10)
        self.pcounts = Label(self, text = self._player_wins)
        self.pcounts.grid(row = 4, column = 3, padx = 10, pady = 10)
        self.pcounts.update_idletasks()
    
#.........这里部分代码省略.........
开发者ID:hrmyd,项目名称:CIS-211,代码行数:103,代码来源:BlackjackFrame.py

示例12: __init__

# 需要导入模块: import Deck [as 别名]
# 或者: from Deck import shuffle [as 别名]
class Pondukapall:
	def __init__(self):
		self.board = [] #cards on the board(hand)
		self.on = True
		self.deck = Deck() #the deck
		self.deck.shuffle()
		for i in range(0,4):
			self.board.append(self.deck.draw())
		self.beginDisplay()
		self.redisplay()
	def checkSuit(self):
		if len(self.board) < 4:
				print "not enough cards"
				return
		if self.board[-1][-1] == self.board[-4][-1]: #if last character in last and fourth last is same
			self.board.pop(len(self.board)-2)
			self.board.pop(len(self.board)-2)
		else: 
			print "the last and fouth last cards are not the same suit\n"
		self.checkWinCondition()
		self.redisplay()
	def checkRank(self):
		if len(self.board) < 4:
			print "not enough cards"
			return
		if self.board[-4][0] == self.board[-1][0]:
			if len(self.board[-4]) == 3 or self.board[-4][1] == self.board[-1][1]:
				for i in range(0,4):
					self.board.pop()
		else: 
			print "\n the last and fourth last cards are not the same rank\n"
		self.checkWinCondition()
		self.redisplay()
	def draw(self):
		if len(self.deck.deck) > 0:
			if len(self.board) > 3:
				if self.board[-4][0] == self.board[-1][0] or self.board[-1][-1] == self.board[-4][-1]:
					print "you missed one LOSER, now live with it"
			self.board.append(self.deck.deck.pop())
		else:
			print "deck over"
		self.checkWinCondition()
		self.redisplay()
	def checkWinCondition(self):
		if len(self.deck.deck) <= 0:
			self.on = False
			if len(self.board) >= 4:
				if (self.board[-4][0] == self.board[-1][0] or self.board[-1][-1] == self.board[-4][-1]):
					return
			if len(self.board) <= 2:
				print "Game Over: YOU WIN!!\n"
				print "type restart to start over or exit to quit"
			else: 
				print "Game Over: You Lose"
				print "type restart to start over or exit to quit"
		return self.on
	def redisplay(self):
		print "\n"
		print map(str, self.board)
		print "\n"
	def beginDisplay(self):
		print "Welcome to Panda Solitaire\n"
		print "Type help for controlls"
	def helpDisplay(self):
		print "insert commands to play the game\n"
		print "d or draw: will draw a card\n"
		print "s or suit: will check the last and fourth last cards for same suit\n"
		print "r or rank: will check the lst and fourth last cards for the same rank\n"
		print "exit or quit: will end the game\n"
		print "help: will bring up this help text, but you know that allready"
		print "restart: will restart your game"
		self.redisplay()
开发者ID:Eiiki,项目名称:University-of-Iceland,代码行数:74,代码来源:Pondukapall.py

示例13: Deck

# 需要导入模块: import Deck [as 别名]
# 或者: from Deck import shuffle [as 别名]
from Card import *
from Deck import *
from Debug import *

if __name__ == '__main__':
    deck = Deck()

    deck.shuffle()

    hand = Hand('new hand')

    card = deck.pop_card()
    hand.add_card(card)

    deck.move_cards(hand, 4)

    print hand
    print find_defining_class(hand, 'shuffle')

    hands = deck.deal_hands(3, 5)
    for hand in hands:
        print hand 
开发者ID:petemulholland,项目名称:learning,代码行数:24,代码来源:Chapter18.py

示例14: __init__

# 需要导入模块: import Deck [as 别名]
# 或者: from Deck import shuffle [as 别名]
class Blackjack: #create new class

    def __init__(self,dHand=[],pHand=[]):
        self.dHand=dHand
        self.pHand=pHand
        self.deck=Deck() #create new deck
        self.deck.shuffle() #shuffle deck

    def makeCard(self,card,xpos,ypos): #additonal method that pairs the card dealt with the picture of that card
        card=card
        card=card.split()
        rank=card[0]
        suit=card[2]

        if suit=="Spades":
            suit="s"
        elif suit=="Hearts":
            suit="h"
        elif suit=="Clubs":
            suit="c"
        else:
            suit="d"

        if rank=="Jack":
            rank="11"
        if rank=="Queen":
            rank="12"
        if rank=="King":
            rank=13
        if rank=="Ace":
            rank=1
        rank=str(rank)

        self.cardPic=Image(Point(xpos,ypos),suit+rank+".gif")
        return self.cardPic #returns the picture of the card in the correct spot 
        

    def initDeal(self,gwin,xposD,yposD,xposP,yposP):
        #Start with the player's hand first
        card1p=self.deck.dealCard()
        self.pHand.append(card1p)
        card1p=self.makeCard(card1p,xposP,yposP)
        card1p.draw(gwin)
        
        card2p=self.deck.dealCard()
        self.pHand.append(card2p)
        card2p=self.makeCard(card2p,xposP+100,yposP)
        card2p.draw(gwin)

        #Now the dealer's hand
        card1d=self.deck.dealCard()
        self.dHand.append(card1d)
        card1d=self.makeCard(card1d,xposD+100,yposD)
        card1d.draw(gwin)

        card2d=self.deck.dealCard()
        self.dHand.append(card2d)
        self.hiddenCard=self.makeCard(card2d,xposD,yposD)
        #one card needs to be face down, but counted
        card2d=Image(Point(xposD,yposD),"b2fv.gif")
        card2d.draw(gwin)
        


    def hit(self,gwin,xpos,ypos,hand):
        newCard=self.deck.dealCard() #deal a new card
        hand.append(newCard) #add it to the list
        newCard=self.makeCard(newCard,xpos,ypos)
        newCard.draw(gwin)

    
        
    def evaluateHand(self,hand):
        handTotal=0 #accumulator to know which person got higher total
        j=0
        for i in hand:#go through the hand list one by one
            c=hand[j]
            j=j+1
            c=c.split()
            #give appropriate cards the correct values
            if c[0]=="Jack" or c[0]=="Queen" or c[0]=="King":
                c[0]=10
                value=c[0]
            elif c[0]=="Ace" and handTotal+11<21:
                c[0]=11
                value=c[0]
            elif c[0]=="Ace" and handTotal+11>21:
                c[0]=1
                value=c[0]
            else:
                value=eval(c[0])
            handTotal=handTotal+value #accumulate values
            self.handTotal=handTotal
        return self.handTotal #return hand total

    def dealerPlays(self,gwin,xpos,ypos):
        self.evaluateHand(self.dHand) #call this method to have a total returned to you
        while self.handTotal<17: #while the total is less than 17, keep hitting
            self.hit(gwin,xpos,ypos,self.dHand)
            xpos=xpos+100
#.........这里部分代码省略.........
开发者ID:janester,项目名称:blackjack,代码行数:103,代码来源:Backjack.py

示例15: BlackJack

# 需要导入模块: import Deck [as 别名]
# 或者: from Deck import shuffle [as 别名]
class BlackJack(object):
    '''
    classdocs
    '''

    def __init__(self, playerName):
        '''
        Initializes the game by
        - shuffling the deck
        - initializing a player1 (with given playerName) and dealer object (both are Player objects)
        '''
        self.gamedeck = Deck()
        self.gamedeck.reset()
        self.gamedeck.shuffle()
        self.playerName = playerName

        self.user = Player(self.playerName)
        self.dealer = Player("Dealer")


    def getWinner(self):
        '''
        returns the player object (either the class's player1 or dealer object) that is the winner
        based on their hands (closest to 21 without going over)

        return - Player object
        '''
        print ""
        print "WINNER:"

        #if the you got 21
        if self.user.getBJScore() == 21 and self.dealer.getBJScore() != 21:
            return self.user

        #if the dealer got 21
        if self.dealer.getBJScore() == 21 and self.user.getBJScore() != 21:
            return self.dealer

        #if both players got the same score
        if self.user.getBJScore() == self.dealer.getBJScore():
            return "No one Won. Both players got the same score!"

        #if dealer busted
        if self.dealer.getBJScore() > 21 and self.user.getBJScore() < 21:
            return self.user

        #if you busted
        elif self.dealer.getBJScore() < 21 and self.user.getBJScore() > 21:
            return self.dealer

        #if both players were under 21
        if self.user.getBJScore() < 21 and self.dealer.getBJScore() < 21:
            if self.user.getBJScore() > self.dealer.getBJScore():
                return self.user
            else:
                return self.dealer

        #if both player busted
        if self.user.getBJScore() > 21 and self.dealer.getBJScore() > 21:
            return "No one won. Both players busted!"

    def play(self):

        '''
        play the game using the class's deck, player1, and dealer objects
        '''

        '''
        initialize player1 and dealer hands (2 cards each)
        show player 1 hand
        player1 decision (hit or stand)
        dealer complete hand
        present game outcome - player1 win or lose
        '''


        """player logic"""
        #draw 2 cards for the dealer and the user
        for i in range(2):
            self.user.addToHand(self.gamedeck.takeCard())
        for i in range(2):
            self.dealer.addToHand(self.gamedeck.takeCard())

        print "{0}".format(self.user.nameStr)
        print "-"*30

        #print the user's hand
        for i in range(len(self.user.hand)):
            print self.user.hand[i]


        print "Your current score is {0}".format(self.user.getBJScore())

        #ask the user if they want to hit or stand
        hit_or_stand = raw_input("Would you like to hit or stand? ")
        hit_or_stand = hit_or_stand.lower()

        #error handling - make sure they actually put in "hit" or "stand"
        while hit_or_stand != "hit" and hit_or_stand != "stand":
            hit_or_stand = raw_input("Would you like to hit or stand? ")
#.........这里部分代码省略.........
开发者ID:James-Harris14,项目名称:Blackjack-Game,代码行数:103,代码来源:BlackJack.py


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