-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayGame6
32 lines (29 loc) · 1.11 KB
/
playGame6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
def playGame(wordList):
"""
Allow the user to play an arbitrary number of hands.
1) Asks the user to input 'n' or 'r' or 'e'.
* If the user inputs 'n', let the user play a new (random) hand.
* If the user inputs 'r', let the user play the last hand again.
* If the user inputs 'e', exit the game.
* If the user inputs anything else, tell them their input was invalid.
2) When done playing the hand, repeat from step 1
"""
n = HAND_SIZE
gamesPlayed = 0
while True:
answer = raw_input("Enter n to deal a new hand, r to replay the last hand, or e to end game: ")
if gamesPlayed == 0 and answer == 'r':
print("You have not played a hand yet. Please play a new hand first!")
elif answer == 'n':
handRe = dealHand(n)
hand = handRe
playHand(hand, wordList, n)
gamesPlayed += 1
elif answer == 'r':
hand = handRe
playHand(hand, wordList, n)
gamesPlayed += 1
elif answer == 'e':
return
else:
print('Invalid command.')